ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QCPSelectableCursor Class Reference

QCustomPlot: selectable cursor interface. More...

#include <ecvQCustomPlot.h>

Inheritance diagram for QCPSelectableCursor:
[legend]
Collaboration diagram for QCPSelectableCursor:
[legend]

Public Member Functions

 QCPSelectableCursor (QCPAxis *keyAxis, QCPAxis *valueAxis)
 Default constructor. More...
 
virtual bool isSelectable (QPoint click) const
 
double currentVal () const
 
double minVal () const
 
double maxVal () const
 
void range (double &minVal, double &maxVal) const
 
void setCurrentVal (double val)
 
void setRange (double minVal, double maxVal)
 
double pixelToKey (int pixX) const
 Converts a pixel value (X) to the equivalent key. More...
 
double pixelToValue (int pixY) const
 Converts a pixel value (Y) to the equivalent value. More...
 
virtual void clearData ()
 
double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const override
 
- Public Member Functions inherited from QCPAbstractPlottable
 QCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis)
 
QString name () const
 
bool antialiasedFill () const
 
bool antialiasedScatters () const
 
bool antialiasedErrorBars () const
 
QPen pen () const
 
QPen selectedPen () const
 
QBrush brush () const
 
QBrush selectedBrush () const
 
QCPAxis * keyAxis () const
 
QCPAxis * valueAxis () const
 
bool selectable () const
 
bool selected () const
 
void setName (const QString &name)
 
void setAntialiasedFill (bool enabled)
 
void setAntialiasedScatters (bool enabled)
 
void setAntialiasedErrorBars (bool enabled)
 
void setPen (const QPen &pen)
 
void setSelectedPen (const QPen &pen)
 
void setBrush (const QBrush &brush)
 
void setSelectedBrush (const QBrush &brush)
 
void setKeyAxis (QCPAxis *axis)
 
void setValueAxis (QCPAxis *axis)
 
Q_SLOT void setSelectable (bool selectable)
 
Q_SLOT void setSelected (bool selected)
 
virtual bool addToLegend ()
 
virtual bool removeFromLegend () const
 
void rescaleAxes (bool onlyEnlarge=false) const
 
void rescaleKeyAxis (bool onlyEnlarge=false) const
 
void rescaleValueAxis (bool onlyEnlarge=false) const
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
 
 ~QCPLayerable ()
 
bool visible () const
 
QCustomPlot * parentPlot () const
 
QCPLayerable * parentLayerable () const
 
QCPLayer * layer () const
 
bool antialiased () const
 
void setVisible (bool on)
 
Q_SLOT bool setLayer (QCPLayer *layer)
 
bool setLayer (const QString &layerName)
 
void setAntialiased (bool enabled)
 
bool realVisibility () const
 

Protected Member Functions

void drawLegendIcon (QCPPainter *painter, const QRectF &rect) const override
 
QCPRange getKeyRange (bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const override
 
QCPRange getValueRange (bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const override
 
- Protected Member Functions inherited from QCPAbstractPlottable
virtual QRect clipRect () const
 
virtual void draw (QCPPainter *painter)=0
 
virtual QCP::Interaction selectionCategory () const
 
void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
virtual QCPRange getKeyRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const =0
 
virtual QCPRange getValueRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const =0
 
void coordsToPixels (double key, double value, double &x, double &y) const
 
const QPointF coordsToPixels (double key, double value) const
 
void pixelsToCoords (double x, double y, double &key, double &value) const
 
void pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const
 
QPen mainPen () const
 
QBrush mainBrush () const
 
void applyFillAntialiasingHint (QCPPainter *painter) const
 
void applyScattersAntialiasingHint (QCPPainter *painter) const
 
void applyErrorBarsAntialiasingHint (QCPPainter *painter) const
 
double distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const
 
- Protected Member Functions inherited from QCPLayerable
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 

Protected Attributes

double mCurrentVal
 
double mMinVal
 
double mMaxVal
 
QPoint mLastPos
 
int mLastRadius
 
- Protected Attributes inherited from QCPAbstractPlottable
QString mName
 
bool mAntialiasedFill
 
bool mAntialiasedScatters
 
bool mAntialiasedErrorBars
 
QPen mPen
 
QPen mSelectedPen
 
QBrush mBrush
 
QBrush mSelectedBrush
 
QPointer< QCPAxis > mKeyAxis
 
QPointer< QCPAxis > mValueAxis
 
bool mSelectable
 
bool mSelected
 
- Protected Attributes inherited from QCPLayerable
bool mVisible
 
QCustomPlot * mParentPlot
 
QPointer< QCPLayerable > mParentLayerable
 
QCPLayer * mLayer
 
bool mAntialiased
 

Additional Inherited Members

- Signals inherited from QCPAbstractPlottable
void selectionChanged (bool selected)
 
void selectableChanged (bool selectable)
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 
- Protected Types inherited from QCPAbstractPlottable
enum  SignDomain { sdNegative, sdBoth, sdPositive }
 

Detailed Description

QCustomPlot: selectable cursor interface.

Constructor & Destructor Documentation

◆ QCPSelectableCursor()

QCPSelectableCursor::QCPSelectableCursor ( QCPAxis *  keyAxis,
QCPAxis *  valueAxis 
)
inlineexplicit

Default constructor.

Member Function Documentation

◆ clearData()

virtual void QCPSelectableCursor::clearData ( )
inlinevirtual

Clears all data in the plottable.

Implements QCPAbstractPlottable.

◆ currentVal()

◆ drawLegendIcon()

void QCPSelectableCursor::drawLegendIcon ( QCPPainter *  painter,
const QRectF &  rect 
) const
inlineoverrideprotectedvirtual

called by QCPLegend::draw (via QCPPlottableLegendItem::draw) to create a graphical representation of this plottable inside rect, next to the plottable name.

The passed painter has its cliprect set to rect, so painting outside of rect won't appear outside the legend icon border.

Implements QCPAbstractPlottable.

◆ getKeyRange()

QCPRange QCPSelectableCursor::getKeyRange ( bool &  foundRange,
QCP::SignDomain  inSignDomain = QCP::sdBoth 
) const
inlineoverrideprotected

◆ getValueRange()

QCPRange QCPSelectableCursor::getValueRange ( bool &  foundRange,
QCP::SignDomain  inSignDomain = QCP::sdBoth,
const QCPRange &  inKeyRange = QCPRange() 
) const
inlineoverrideprotected

◆ isSelectable()

virtual bool QCPSelectableCursor::isSelectable ( QPoint  click) const
inlinevirtual

Returns whether the item is "selectable" when the mouse is clicked at a given position

References mLastPos, and mLastRadius.

Referenced by ccHistogramWindow::mousePressEvent().

◆ maxVal()

double QCPSelectableCursor::maxVal ( ) const
inline

References mMaxVal.

Referenced by range(), and setRange().

◆ minVal()

double QCPSelectableCursor::minVal ( ) const
inline

References mMinVal.

Referenced by range(), and setRange().

◆ pixelToKey()

double QCPSelectableCursor::pixelToKey ( int  pixX) const
inline

Converts a pixel value (X) to the equivalent key.

References QCPAbstractPlottable::keyAxis(), and QCPAxis::pixelToCoord().

Referenced by ccHistogramWindow::mouseMoveEvent().

◆ pixelToValue()

double QCPSelectableCursor::pixelToValue ( int  pixY) const
inline

Converts a pixel value (Y) to the equivalent value.

References QCPAxis::pixelToCoord(), and QCPAbstractPlottable::valueAxis().

◆ range()

void QCPSelectableCursor::range ( double &  minVal,
double &  maxVal 
) const
inline

References maxVal(), minVal(), mMaxVal, and mMinVal.

◆ selectTest()

double QCPSelectableCursor::selectTest ( const QPointF &  pos,
bool  onlySelectable,
QVariant *  details = 0 
) const
inlineoverridevirtual

This function is used to decide whether a click hits a layerable object or not.

pos is a point in pixel coordinates on the QCustomPlot surface. This function returns the shortest pixel distance of this point to the object. If the object is either invisible or the distance couldn't be determined, -1.0 is returned. Further, if onlySelectable is true and the object is not selectable, -1.0 is returned, too.

If the object is represented not by single lines but by an area like a QCPItemText or the bars of a QCPBars plottable, a click inside the area should also be considered a hit. In these cases this function thus returns a constant value greater zero but still below the parent plot's selection tolerance. (typically the selectionTolerance multiplied by 0.99).

Providing a constant value for area objects allows selecting line objects even when they are obscured by such area objects, by clicking close to the lines (i.e. closer than 0.99*selectionTolerance).

The actual setting of the selection state is not done by this function. This is handled by the parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified via the selectEvent/deselectEvent methods.

details is an optional output parameter. Every layerable subclass may place any information in details. This information will be passed to selectEvent when the parent QCustomPlot decides on the basis of this selectTest call, that the object was successfully selected. The subsequent call to selectEvent will carry the details. This is useful for multi-part objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked is only done once in selectTest. The result (i.e. the actually clicked part) can then be placed in details. So in the subsequent selectEvent, the decision which part was selected doesn't have to be done a second time for a single selection operation.

You may pass 0 as details to indicate that you are not interested in those selection details.

See also
selectEvent, deselectEvent, QCustomPlot::setInteractions

Implements QCPAbstractPlottable.

◆ setCurrentVal()

◆ setRange()

void QCPSelectableCursor::setRange ( double  minVal,
double  maxVal 
)
inline

References maxVal(), minVal(), mMaxVal, and mMinVal.

Referenced by ccHistogramWindow::refresh().

Member Data Documentation

◆ mCurrentVal

double QCPSelectableCursor::mCurrentVal
protected

◆ mLastPos

QPoint QCPSelectableCursor::mLastPos
protected

◆ mLastRadius

int QCPSelectableCursor::mLastRadius
protected

◆ mMaxVal

double QCPSelectableCursor::mMaxVal
protected

◆ mMinVal

double QCPSelectableCursor::mMinVal
protected

The documentation for this class was generated from the following file: