14 #include "msdevstudio/MSconfig.h"
25 #if QT_VERSION < 0x040000
28 #include <QtGui/QMouseEvent>
29 #include <QtGui/QPaintEvent>
37 using namespace hippodraw;
42 QWidget ( parent, name, wflags )
65 plotter -> addObserver (
this );
114 if ( display == 0 )
return;
122 double diff = ratio - w / h;
123 if ( diff > 0.00001 ) {
125 int new_w = static_cast <
int > ( w * ratio );
143 int ix = static_cast <
int > (
x );
144 int iy = static_cast <
int > (
y );
145 int iw = static_cast <
int > ( w );
146 int ih = static_cast <
int > ( h );
192 std::vector < double > & picked )
const
197 m_plotter -> fillPickedPointFrom ( xx, yy, picked );
202 return static_cast <
int > ( dx );
207 return static_cast <
int > ( dy );
212 #if QT_VERSION < 0x040000
215 transformAndFill ( QPolygon & array,
217 const std::vector< double > & x,
218 const std::vector< double > & y,
223 unsigned int size = x.size();
224 assert ( size == y.size() );
226 for (
unsigned int i = 0;
i <
size;
i++ ) {
227 int ix = (this->*xfunc) ( x[
i] );
228 int iy = (this->*yfunc) ( y[i] );
229 array.setPoint ( i , ix, iy );
239 const std::vector< double > & y,
243 unsigned int size = x.size();
244 assert ( size == y.size() );
246 #if QT_VERSION < 0x040000
249 QPolygon array ( size );
262 const std::vector < double > & y,
267 unsigned int size = x.size();
268 assert ( size == y.size() );
270 #if QT_VERSION < 0x040000
273 QPolygon array ( size );
292 if ( e -> state () == Qt::ControlButton ) {
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
void drawMethod(const std::vector< double > &x, const std::vector< double > &y, int opt1, int opt2)
Draws in the view using the specified method.
The class of derived from ViewBase for drawing as a Qt Widget.
virtual ~QtViewWidget()
The required virtual destructor.
virtual void drawSelf()
Draws itself.
drawPolyline(const QPointArray &a, int index=0, int npoints=-1)
Paint buffer for Qwt widgets.
QPainter * m_painter
The current Qt QPainter object.
void prepareMarginRect()
Prepares the margin rectangle.
virtual double getAspectRatio() const
Get the aspect ratio.
virtual void update(const Observable *display)
Responds to update message from Observable.
virtual float userToMarginX(double x) const
Converts the user X coordinate into the margin X coordinate.
virtual void resizeEvent(QResizeEvent *event)
Overloads the inherit member function to set the margin rectangle.
DrawBorder class interface.
virtual QSize sizeHint() const
Re-implements inherited member to return a reasonable size.
void setPlotter(PlotterBase *)
Re-implements inherited member to test something for SIP.
void transformAndFill(QPointArray &array, const std::vector< double > &x, const std::vector< double > &y, int(QtViewWidget::*xfunc)(double) const, int(QtViewWidget::*yfunc)(double) const )
Fills the array with QPoint objects whose coordinates are in the QPaintDevice space from the vectors ...
The class of derived from ViewBase for drawing to the screen and PostScript generation using Qt toolk...
The base class for the PlotterBase hierarchy.
hippodraw::QtViewWidget class interface
PlotterBase * m_plotter
The plotter object used by this view.
void drawViewMethod(const std::vector< double > &x, const std::vector< double > &y, int opt1, int opt2)
Draws in the view using the specified method.
int toCanvasX(double dx) const
Converts coordinate from view space to canvas space.
intp size(numeric::array arr)
virtual void fillPickedPoint(double x, double y, std::vector< double > &picked) const
Fills the picked point vector.
Class representing a rectangle.
drawLineSegments(const QPointArray &a, int index=0, int nlines=-1)
int toViewX(double datX) const
Converts the data space coordinate X to the view space coordinate X.
virtual void mousePressEvent(QMouseEvent *e)
overrides the inherited virtual function.
virtual void paintEvent(QPaintEvent *)
Overrides virtual function of QWidget to do drawing.
virtual float userToInvertedMarginY(double y) const
Converts the user Y coordinate into the top-left based margin Y coordinate.
virtual void setPlotter(PlotterBase *plotter)
Sets the PlotterBase object to plotter.
virtual Rect getDrawRect() const
Returns the drawing Rectangle in the devices coordinate system.
int toCanvasY(double dy) const
Converts coordinate from view space to canvas space.
virtual void draw(QPainter &)
Re-implements the inherited function.
virtual void setDoubleBuffering(unsigned dblbuf)
virtual double marginToUserX(double x) const
Converts from view coordinate to data coordinate, without taking into account transforms or scaling...
virtual double marginToInvertedUserY(double y) const
Converts from inverted view coordinate to data coordinate, without taking into account transforms or ...
QtViewWidget(const QtViewWidget &)
The copy constructor.
int toViewY(double datY) const
Converts the data space coordinate Y to the view space coordinate Y.
void setDrawRect(const QRect &rect)
Sets the drawing rectangle in the paint device space.
hippodraw::PlotterBase class interface.
virtual void setGeometry(int x, int y, int w, int h)
Overloads the inherit member function in order to prepare the margin rectangle.