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