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