27 #ifndef QPCANVAS_QO_H_
28 #define QPCANVAS_QO_H_
42 #include <qwt_plot_picker.h>
56 class QPCanvas :
public QFrame,
public QPExportCanvas {
59 friend class QPAxesCache;
60 friend class QPDrawThread;
61 friend class QPLayeredCanvas;
62 friend class QPPlotItem;
63 friend class QPPlotter;
85 QPCanvas(QPPlotter* parent = NULL);
112 std::pair<int, int>
size()
const;
113 virtual void setMinimumSize(
int width,
int height ){
114 QFrame::setMinimumSize( width, height );
122 QFrame::setVisible(
false );
135 void setTitleFont(
const PlotFont& font);
142 void setBackground(
const PlotAreaFill& areaFill);
153 void refresh(
int drawLayersFlag);
157 bool isQWidget()
const {
return true; }
176 std::pair<bool,SortDirection> axisScaleSortDirection(
PlotAxis axis)
const;
183 bool axisReferenceValueSet(
PlotAxis axis)
const;
186 double axisReferenceValue(
PlotAxis axis)
const;
189 void setAxisReferenceValue(
PlotAxis axis,
bool on,
double value = 0);
192 bool cartesianAxisShown(
PlotAxis axis)
const;
196 bool show =
true,
bool hideNormalAxis =
true);
208 void setAxisFont(
PlotAxis axis,
const PlotFont& font);
221 void setAxisRange(
PlotAxis axis,
double from,
double to);
227 void setAxesRanges(
PlotAxis xAxis,
double xFrom,
double xTo,
228 PlotAxis yAxis,
double yFrom,
double yTo);
231 bool axesAutoRescale()
const;
234 void setAxesAutoRescale(
bool autoRescale =
true);
240 bool axesRatioLocked()
const;
243 void setAxesRatioLocked(
bool locked =
true);
247 int cachedAxesStackSizeLimit()
const;
250 void setCachedAxesStackSizeLimit(
int sizeInKilobytes);
253 std::pair<int, int> cachedAxesStackImageSize()
const;
256 void setCachedAxesStackImageSize(
int width,
int height);
266 std::vector<PlotItemPtr> allPlotItems()
const;
272 unsigned int numPlotItems()
const;
278 void removePlotItems(
const std::vector<PlotItemPtr>& items);
281 void clearPlotItems();
294 void releaseDrawing();
297 bool drawingIsHeld()
const;
301 void setSelectLineShown(
bool shown =
true);
311 bool gridShown(
bool* xMajor = NULL,
bool* xMinor = NULL,
312 bool* yMajor = NULL,
bool* yMinor = NULL)
const;
315 void showGrid(
bool xMajor,
bool xMinor,
bool yMajor,
bool yMinor);
321 void setGridMajorLine(
const PlotLine& line);
327 void setGridMinorLine(
const PlotLine& line);
331 bool legendShown()
const;
334 void showLegend(
bool on =
true, LegendPosition position = EXT_BOTTOM);
337 LegendPosition legendPosition()
const;
340 void setLegendPosition(LegendPosition position);
346 void setLegendLine(
const PlotLine& line);
352 void setLegendFill(
const PlotAreaFill& area);
358 void setLegendFont(
const PlotFont& font);
362 bool autoIncrementColors()
const;
365 void setAutoIncrementColors(
bool autoInc =
true);
368 bool exportToFile(
const PlotExportFormat& format);
387 PlotCoordinate convertCoordinate(
const PlotCoordinate& coord,
388 PlotCoordinate::System newSystem = PlotCoordinate::WORLD)
const;
398 PlotFactory* implementationFactory()
const;
405 QPLayeredCanvas& asQwtPlot();
406 const QPLayeredCanvas& asQwtPlot()
const;
410 QwtPlotPicker& getSelecter();
414 void reinstallTrackerFilter();
417 QSize sizeHint()
const;
420 QSize minimumSizeHint()
const;
426 virtual void setMinimumSizeHint(
int width,
int height );
428 virtual void setCommonAxes(
bool commonX,
bool commonY );
429 void addAxisListener( AxisListener* listener );
430 void clearAxisListeners();
432 virtual bool isDrawing();
437 void setQPPlotter(QPPlotter* parent);
444 void logObject(
const casacore::String& className,
void* address,
bool creation,
454 QPAxesCache& axesCache();
455 const QPAxesCache& axesCache()
const;
459 void mousePressEvent(QMouseEvent* event);
462 void mouseReleaseEvent(QMouseEvent* event);
465 void mouseDoubleClickEvent(QMouseEvent* event);
468 void keyReleaseEvent(QKeyEvent* event);
471 void wheelEvent(QWheelEvent* event);
474 void resizeEvent(QResizeEvent* event);
476 bool isThreading()
const;
484 std::vector<PlotLogObject> m_queuedLogs;
487 QPLayeredCanvas m_canvas;
490 std::vector<std::pair<PlotItemPtr, QPPlotItem*> > m_plotItems;
493 std::vector<std::pair<PlotItemPtr, QPPlotItem*> > m_layeredItems;
496 QPScaleDraw* m_scaleDraws[QwtPlot::axisCnt];
499 bool m_axesRatioLocked;
501 bool isCommonAxis(
PlotAxis axis )
const;
506 std::vector<double> m_axesRatios;
509 QPAxesCache m_stackCache;
512 bool m_autoIncColors;
515 std::vector<int> m_usedColors;
518 QwtPlotPicker m_picker;
522 QPMouseFilter m_mouseFilter;
526 QPLegendHolder* m_legend;
528 bool m_legendFontSet;
534 QList<AxisListener*> axisListeners;
554 PlotCoordinate globalPosToPixelCoord(
int x,
int y);
555 PlotCoordinate globalPosToPixelCoord(QMouseEvent* event) {
556 return globalPosToPixelCoord(event->globalX(),
event->globalY()); }
557 PlotCoordinate globalPosToPixelCoord(QWheelEvent* event) {
558 return globalPosToPixelCoord(event->globalX(),
event->globalY()); }
562 virtual bool print( QPrinter& printer );
563 virtual bool print( QPainter* painter,
PlotAreaFillPtr paf,
double widthWidth,
564 double widgetHeight,
int externalAxisWidth,
int externalAxisHeight,
565 int rowIndex,
int colIndex, QRect imageRect );
566 virtual bool printRect( QPainter* painter, QRect rect);
568 virtual int canvasWidth()
const{
571 virtual int canvasHeight()
const {
574 virtual const QPalette& palette()
const {
575 return asQwtPlot().palette();
577 virtual QPalette::ColorRole backgroundRole()
const{
578 return asQwtPlot().backgroundRole();
582 QImage grabImageFromCanvas(
const PlotExportFormat& format );
588 static unsigned int axisIndex(
PlotAxis a);
589 static PlotAxis axisIndex(
unsigned int i);
592 const QwtScaleDiv* getAxisScaleDiv(
int axisId)
const;
594 void setTimeScaleDiv(
PlotAxis axis,
double from,
double to);
606 void regionSelected(
const QwtDoubleRect&);
607 void regionSelected2(
const QRectF&);
613 void trackerMouseEvent(QMouseEvent* event);
615 void enableAxis( QwtPlot::Axis axis,
bool enable );
casacore::CountedPtr< PlotAreaFill > PlotAreaFillPtr
bool m_inDraggingMode
Whether we're in dragging mode or not.
virtual void showGrid(bool xMajor, bool xMinor, bool yMajor, bool yMinor)=0
Sets whether the grid is shown, for each of the given line groups.
casacore::CountedPtr< PlotLine > PlotLinePtr
virtual void setTitleFont(const PlotFont &font)=0
Set the font of the canvas title to the given.
unsigned int PlotAxisBitset
Set of bit flags to indicate combinations of sides, used (as of this writing) for indicating which ax...
virtual void setAxisRange(PlotAxis axis, double from, double to)=0
Sets the displayed range of the given axis, in world coordinates.
virtual void setGridMinorLine(const PlotLine &line)=0
Sets the line used to draw the minor grid lines.
void show(const variant &v)
virtual void setSelectLine(const PlotLine &line)=0
set the line for the selection tool
virtual void setAxisFont(PlotAxis axis, const PlotFont &font)=0
Set the font of the axis title to the given.
virtual void setLegendFill(const PlotAreaFill &area)=0
Sets the area fill used for the legend background.
virtual void setSelectLine(PlotLinePtr line)
Sets the selection line to the given.
PlotCursor
Enum for cursors.
PlotAxis
Enum for the four plot axes.
virtual void setAxesRanges(PlotAxis xAxis, double xFrom, double xTo, PlotAxis yAxis, double yFrom, double yTo)
Sets the displayed ranges of the given axes, in world coordinates.
virtual void setLegendFont(const PlotFont &font)=0
Sets the font used for the legend text.
casacore::CountedPtr< PlotFont > PlotFontPtr
casacore::CountedPtr< PlotLogger > PlotLoggerPtr
std::pair< double, double > prange_t
Typedef for range, which is two doubles (min and max).
casacore::CountedPtr< PlotItem > PlotItemPtr
virtual void setGridMajorLine(const PlotLine &line)=0
Sets the line used to draw the major grid lines.
virtual void setBackground(const PlotAreaFill &areaFill)=0
Sets the background of the canvas to the given.
AngleFormat
Enum for angle formats.
virtual void showCartesianAxis(PlotAxis mirrorAxis, PlotAxis secondaryAxis, bool show=true, bool hideNormalAxis=true)=0
Show or hide the given Cartesian axis.
String: the storage and methods of handling collections of characters.
virtual void setLegendLine(const PlotLine &line)=0
Sets the line used to outline the legend.
PlotAxisScale
Enum for possible axis scales.
virtual void showAxes(PlotAxisBitset axes)=0
Shows/Hides axes based on the given bitset, which should be a bitwise-or of PlotAxis values...
PlotCanvasLayer
The canvas is composed of multiple layers, where changing/adding items from one layer will not affect...
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.