Skip to content

Commit c1fdcbc

Browse files
author
Koen Deforche
committed
Several changes:
* implemented a WAxisSliderWidget * WCartesianChart: interactivity features * WPaintedWidget: interactivity API
1 parent 6c3f7d9 commit c1fdcbc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+4709
-476
lines changed

examples/charts/ChartsExample.C

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,15 @@ CategoryExample::CategoryExample(Wt::WContainerWidget *parent):
163163
chart->setModel(model); // set the model
164164
chart->setXSeriesColumn(0); // set the column that holds the categories
165165
chart->setLegendEnabled(true); // enable the legend
166+
chart->setZoomEnabled(true);
167+
chart->setPanEnabled(true);
168+
chart->setCrosshairEnabled(true);
166169

167170
// Automatically layout chart (space for axes, legend, ...)
168171
chart->setAutoLayoutEnabled(true);
169172

173+
chart->setBackground(WColor(200,200,200));
174+
170175
/*
171176
* Add all (but first) column as bar series
172177
*/
@@ -251,14 +256,18 @@ TimeSeriesExample::TimeSeriesExample(Wt::WContainerWidget *parent):
251256
chart->setModel(model); // set the model
252257
chart->setXSeriesColumn(0); // set the column that holds the X data
253258
chart->setLegendEnabled(true); // enable the legend
259+
chart->setZoomEnabled(true);
260+
chart->setPanEnabled(true);
261+
chart->setCrosshairEnabled(true);
254262

255263
chart->setType(ScatterPlot); // set type to ScatterPlot
256264
chart->axis(XAxis).setScale(DateScale); // set scale of X axis to DateScale
257265

258266
// Automatically layout chart (space for axes, legend, ...)
259267
chart->setAutoLayoutEnabled();
260268

261-
/*
269+
chart->setBackground(WColor(200,200,200));
270+
/*
262271
* Add first two columns as line series
263272
*/
264273
for (int i = 1; i < 3; ++i) {
@@ -299,6 +308,9 @@ ScatterPlotExample::ScatterPlotExample(WContainerWidget *parent):
299308
chart->setModel(model); // set the model
300309
chart->setXSeriesColumn(0); // set the column that holds the X data
301310
chart->setLegendEnabled(true); // enable the legend
311+
chart->setZoomEnabled(true);
312+
chart->setPanEnabled(true);
313+
chart->setCrosshairEnabled(true);
302314

303315
chart->setType(ScatterPlot); // set type to ScatterPlot
304316

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ Wt/WIdentityProxyModel.C
138138
Wt/WItemDelegate.C
139139
Wt/WItemSelectionModel.C
140140
Wt/WJavaScript.C
141+
Wt/WJavaScriptExposableObject.C
142+
Wt/WJavaScriptHandle.C
143+
Wt/WJavaScriptObjectStorage.C
141144
Wt/WJavaScriptPreamble.C
142145
Wt/WJavaScriptSlot.C
143146
Wt/WLabel.C
@@ -277,6 +280,7 @@ Wt/Auth/AuthUtils.C
277280
Wt/Auth/MailUtils.C
278281
Wt/Chart/WAbstractChart.C
279282
Wt/Chart/WAxis.C
283+
Wt/Chart/WAxisSliderWidget.C
280284
Wt/Chart/WDataSeries.C
281285
Wt/Chart/WPieChart.C
282286
Wt/Chart/WCartesianChart.C

src/Wt/Auth/Login

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ public:
118118

119119
/*! \brief %Signal that indicates login changes.
120120
*
121-
* This signal is emitted as a result of login() or logout().
121+
* This signal is emitted as a result of login() or logout(). If no
122+
* user was logged in, then a changed() signal does not necessarily
123+
* mean that user is loggedIn() as the user may have been identified
124+
* correctly but have a DisabledLogin state() for example.
122125
*/
123126
Signal<>& changed() { return changed_; }
124127

src/Wt/Chart/WAxis

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
#define CHART_WAXIS_H_
99

1010
#include <Wt/Chart/WChartGlobal>
11+
#include <Wt/WDateTime>
1112
#include <Wt/WFont>
1213
#include <Wt/WPen>
1314
#include <Wt/WString>
14-
#include <Wt/WDateTime>
15+
#include <Wt/WTransform>
16+
1517
#include <boost/any.hpp>
1618
#include <cfloat>
1719

@@ -491,6 +493,12 @@ public:
491493
*/
492494
void setPen(const WPen& pen);
493495

496+
/*! \brief Returns the pen used for rendering the axis and ticks.
497+
*
498+
* \sa setPen()
499+
*/
500+
const WPen& pen() const { return pen_; }
501+
494502
/*! \brief Changes the pen used for rendering labels for this axis
495503
*
496504
* The default value is a black pen of 0 width.
@@ -501,11 +509,11 @@ public:
501509
*/
502510
void setTextPen(const WPen& pen);
503511

504-
/*! \brief Returns the pen used for rendering the axis and ticks.
512+
/*! \brief Returns the pen used for rendering labels for this axis
505513
*
506-
* \sa setPen()
514+
* \sa setTextPen()
507515
*/
508-
const WPen& pen() const { return pen_; }
516+
const WPen& textPen() const { return textPen_; }
509517

510518
/*! \brief Changes the pen used for rendering the grid lines.
511519
*
@@ -596,11 +604,56 @@ public:
596604
*/
597605
virtual WString label(double u) const;
598606

599-
/*! \brief Returns the chart to which this axis belongs.
607+
/*! \brief Sets the initial zoom level for this axis.
608+
*
609+
* Only applies to a WCartesianChart in interactive mode.
610+
* The zoom level should be >= 1 and smaller than maxZoom()
611+
*
612+
* \note This is only implemented for the X and first Y axis. It has no effect on the second Y axis.
613+
*/
614+
void setInitialZoom(double initialZoom);
615+
616+
/*! \brief Get the initial zoom level for this axis.
617+
*
618+
* \see setInitialZoom()
619+
*/
620+
double initialZoom() const;
621+
622+
/*! \brief Sets the maximum zoom level for this axis.
623+
*
624+
* Only applies to a WCartesianChart in interactive mode.
625+
* The zoom level should be >= 1 (no zoom).
600626
*
601-
* \sa WCartesianChart::axis()
627+
* \note This is only implemented for the X and first Y axis. It has no effect on the second Y axis.
602628
*/
603-
// WCartesianChart *chart() const { return chart_; }
629+
void setMaxZoom(double maxZoom);
630+
631+
/*! \brief Get the maximum zoom level for this axis.
632+
*
633+
* \see setMaxZoom()
634+
*/
635+
double maxZoom() const;
636+
637+
/*! \brief Sets the initial value to pan to for this axis.
638+
*
639+
* This sets the leftmost (horizontal axis)
640+
* or bottom (vertical axis) value to be displayed on the chart.
641+
*
642+
* Note that if this would cause the chart to go out of bounds,
643+
* the panning of the chart will be automatically adjusted.
644+
*
645+
* Only applies to a WCartesianChart in interactive mode.
646+
* The zoom level should be >= 1 and smaller than maxZoom()
647+
*
648+
* \note This is only implemented for the X and first Y axis. It has no effect on the second Y axis.
649+
*/
650+
void setInitialPan(double initialPan);
651+
652+
/*! \brief Get the initial value to pan to for this axis, when pan is enabled on the chart.
653+
*
654+
* \see setInitialPan()
655+
*/
656+
double initialPan() const;
604657

605658
int segmentCount() const { return (int)segments_.size(); }
606659

@@ -613,7 +666,22 @@ public:
613666
const WPointF& axisStart,
614667
const WPointF& axisEnd,
615668
double tickStart, double tickEnd, double labelPos,
616-
WFlags<AlignmentFlag> labelFlags) const;
669+
WFlags<AlignmentFlag> labelFlags,
670+
const WTransform &transform = WTransform()) const {
671+
std::vector<WPen> pens;
672+
std::vector<WPen> textPens;
673+
render(painter, properties, axisStart, axisEnd, tickStart, tickEnd, labelPos, labelFlags, transform, pens, textPens);
674+
}
675+
676+
void render(WPainter& painter,
677+
WFlags<AxisProperty> properties,
678+
const WPointF& axisStart,
679+
const WPointF& axisEnd,
680+
double tickStart, double tickEnd, double labelPos,
681+
WFlags<AlignmentFlag> labelFlags,
682+
const WTransform &transform,
683+
std::vector<WPen> pens,
684+
std::vector<WPen> textPens) const;
617685

618686
/*! \brief Returns the positions for grid lines on this axis.
619687
*
@@ -625,7 +693,8 @@ public:
625693
void renderLabel(WPainter& painter,
626694
const WString& text, const WPointF& p,
627695
WFlags<AlignmentFlag> flags,
628-
double angle, int margin) const;
696+
double angle, int margin, WTransform transform,
697+
const WPen& pen) const;
629698

630699
void setRenderMirror(bool enable) { renderingMirror_ = enable; }
631700
double calcTitleSize(WPaintDevice *device, Orientation orientation) const;
@@ -659,7 +728,7 @@ protected:
659728

660729
/*! \brief Returns the label (and ticks) information for this axis.
661730
*/
662-
virtual void getLabelTicks(std::vector<TickLabel>& ticks, int segment) const;
731+
virtual void getLabelTicks(std::vector<TickLabel>& ticks, int segment, int zoomLevel) const;
663732

664733
/*! \brief Returns the Date format
665734
*/
@@ -688,6 +757,9 @@ private:
688757
double titleOffset_;
689758
WPen textPen_;
690759
Orientation titleOrientation_;
760+
double maxZoom_;
761+
double initialZoom_;
762+
double initialPan_;
691763

692764
// for 3D charts, don't call update when the labelangle is tempor. changed
693765
bool renderingMirror_;

0 commit comments

Comments
 (0)