14 #include "msdevstudio/MSconfig.h"
25 #if QT_VERSION < 0x040000
28 #include <QtGui/QMouseEvent>
29 #include <QtGui/QPaintEvent>
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 ) {
The base class for the PlotterBase hierarchy.
QtViewWidget(const QtViewWidget &)
The copy constructor.
virtual void mousePressEvent(QMouseEvent *e)
overrides the inherited virtual function.
PlotterBase * m_plotter
The plotter object used by this view.
drawPolyline(const QPointArray &a, int index=0, int npoints=-1)
int toCanvasX(double dx) const
Converts coordinate from view space to canvas space.
The class of derived from ViewBase for drawing as a Qt Widget.
void drawViewMethod(const std::vector< double > &x, const std::vector< double > &y, int opt1, int opt2)
Draws in the view using the specified method.
virtual void update(const Observable *display)
Responds to update message from Observable.
virtual void setGeometry(int x, int y, int w, int h)
Overloads the inherit member function in order to prepare the margin rectangle.
virtual void resizeEvent(QResizeEvent *event)
Overloads the inherit member function to set the margin rectangle.
virtual float userToMarginX(double x) const
Converts the user X coordinate into the margin X coordinate.
int toViewY(double datY) const
Converts the data space coordinate Y to the view space coordinate Y.
hippodraw::PlotterBase class interface.
virtual double getAspectRatio() const
Get the aspect ratio.
intp size(numeric::array arr)
QPainter * m_painter
The current Qt QPainter object.
int toViewX(double datX) const
Converts the data space coordinate X to the view space coordinate X.
virtual void paintEvent(QPaintEvent *)
Overrides virtual function of QWidget to do drawing.
virtual void setDoubleBuffering(unsigned dblbuf)
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.
void drawMethod(const std::vector< double > &x, const std::vector< double > &y, int opt1, int opt2)
Draws in the view using the specified method.
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
virtual void setPlotter(PlotterBase *plotter)
Sets the PlotterBase object to plotter.
virtual QSize sizeHint() const
Re-implements inherited member to return a reasonable size.
virtual void drawSelf()
Draws itself.
void setDrawRect(const QRect &rect)
Sets the drawing rectangle in the paint device space.
drawLineSegments(const QPointArray &a, int index=0, int nlines=-1)
virtual void draw(QPainter &)
Re-implements the inherited function.
The class of derived from ViewBase for drawing to the screen and PostScript generation using Qt toolk...
Class representing a rectangle.
virtual double marginToUserX(double x) const
Converts from view coordinate to data coordinate, without taking into account transforms or scaling...
Paint buffer for Qwt widgets.
virtual double marginToInvertedUserY(double y) const
Converts from inverted view coordinate to data coordinate, without taking into account transforms or ...
virtual ~QtViewWidget()
The required virtual destructor.
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 ...
void setPlotter(PlotterBase *)
Re-implements inherited member to test something for SIP.
virtual float userToInvertedMarginY(double y) const
Converts the user Y coordinate into the top-left based margin Y coordinate.
DrawBorder class interface.
void prepareMarginRect()
Prepares the margin rectangle.
virtual void fillPickedPoint(double x, double y, std::vector< double > &picked) const
Fills the picked point vector.
hippodraw::QtViewWidget class interface