Isis Developer Reference
Isis::RubberBandTool Class Reference

Rubber banding tool. More...

#include <RubberBandTool.h>

Inheritance diagram for Isis::RubberBandTool:
Inheritance graph
Collaboration diagram for Isis::RubberBandTool:
Collaboration graph

Public Types

enum  RubberBandMode {
  AngleMode, CircleMode, EllipseMode, LineMode,
  RectangleMode, RotatedRectangleMode, PolygonMode, SegmentedLineMode
}
 

Public Slots

void escapeKeyPress ()
 
void activate (bool)
 Activates the tool. More...
 
virtual void updateTool ()
 Updates the tool. More...
 
void setCubeViewport (MdiCubeViewport *cvp)
 Sets the current viewport to the given cvp. More...
 

Signals

void modeChanged ()
 
void bandingComplete ()
 
void measureChange ()
 
void clearWarningSignal ()
 
void toolActivated ()
 
void viewportChanged ()
 

Public Member Functions

 RubberBandTool (QWidget *parent=NULL)
 This is the constructor. More...
 
virtual ~RubberBandTool ()
 
void enable (RubberBandMode mode, bool showIndicatorColors=false)
 This is called when changing modes or turning on. More...
 
void disable ()
 This is called when something is not using me, so turn off events, reset & repaint to clear the clear. More...
 
void setDrawActiveViewportOnly (bool activeOnly=false)
 This called to set whether rubber band is drawn on active viewport only rather than all linked viewports. More...
 
QList< QPoint > vertices ()
 This method returns the vertices. More...
 
RubberBandMode currentMode ()
 
double area ()
 
Angle angle ()
 
geos::geom::Geometry * geometry ()
 
QRect rectangle ()
 This method returns a rectangle from the vertices set by the RubberBandTool. More...
 
Qt::MouseButton mouseButton ()
 This method returns the mouse button modifier. More...
 
void paintViewport (MdiCubeViewport *vp, QPainter *painter)
 This is the main paint method for the rubber bands. More...
 
bool isValid ()
 This returns true if we can return complete & valid data. More...
 
bool figureComplete ()
 
bool figureValid ()
 
bool figureIsPoint ()
 
void enablePoints (unsigned int pixTolerance=2)
 
void enableAllClicks ()
 
void clear ()
 clears the rubber band! More...
 
void addTo (ViewportMainWindow *mw)
 Adds the tool to the application. More...
 
void addTo (ToolPad *toolpad)
 Adds the tool to the toolpad. More...
 
virtual void addTo (QMenu *menu)
 
virtual void addTo (Workspace *ws)
 Adds the given workspace to the cubeviewport list. More...
 
virtual QString menuName () const
 Anytime a tool is created, you must give it a name for the menu. More...
 
virtual void addToPermanent (QToolBar *toolbar)
 
void addToActive (QToolBar *toolbar)
 
QString toolIconDir () const
 returns the path to the icon directory. More...
 
RubberBandToolrubberBandTool ()
 
void setList (ToolList *currentList)
 

Protected Types

typedef QVector< MdiCubeViewport * > CubeViewportList
 A list of cubeviewports. More...
 

Protected Slots

void mouseMove (QPoint p, Qt::MouseButton)
 If tracking is not enabled, this does nothing. More...
 
void mouseDoubleClick (QPoint p)
 This triggers on a second mouse press. More...
 
void mouseButtonPress (QPoint p, Qt::MouseButton s)
 If the click is not the left mouse button, this does nothing. More...
 
void mouseButtonRelease (QPoint p, Qt::MouseButton s)
 If this is not the left mouse button, this does nothing. More...
 
virtual void rubberBandComplete ()
 
virtual void screenPixelsChanged ()
 This is called when actions change which pixels from the cube are displayed. More...
 
virtual void mouseEnter ()
 
virtual void mouseMove (QPoint p)
 
virtual void mouseLeave ()
 

Protected Member Functions

void enableRubberBandTool ()
 Anytime a tool is created, you may use the rubber band tool. More...
 
void scaleChanged ()
 
virtual void updateMeasure ()
 
virtual void stretchRequested (MdiCubeViewport *, int)
 
void registerTool (MdiCubeViewport *viewport)
 Registers the tool to the viewport. More...
 
MdiCubeViewportcubeViewport () const
 Return the current cubeviewport. More...
 
CubeViewportListcubeViewportList () const
 Return the list of cubeviewports. More...
 
virtual QActiontoolPadAction (ToolPad *toolpad)
 Anytime a tool is created, you must setup a tool pad action with it. More...
 
virtual QWidgetcreateToolBarWidget (QStackedWidget *parent)
 Anytime a tool is created, you must add it to the tool bar. More...
 
virtual void addConnections (MdiCubeViewport *cvp)
 Anytime a tool is created, you must add the connections for it. More...
 
virtual void removeConnections (MdiCubeViewport *cvp)
 Anytime a tool is created, you must be able to remove it's connections. More...
 
Workspaceworkspace ()
 

Detailed Description

Rubber banding tool.

Author
2007-09-11 Steven Lambright

Member Typedef Documentation

◆ CubeViewportList

typedef QVector< MdiCubeViewport * > Isis::Tool::CubeViewportList
protectedinherited

A list of cubeviewports.

Member Enumeration Documentation

◆ RubberBandMode

Enumerator
AngleMode 
CircleMode 
EllipseMode 
LineMode 
RectangleMode 
RotatedRectangleMode 
PolygonMode 
SegmentedLineMode 

Constructor & Destructor Documentation

◆ RubberBandTool()

Isis::RubberBandTool::RubberBandTool ( QWidget parent = NULL)

This is the constructor.

It's private because this class is a singleton.

Parameters
parent

References Isis::Tool::activate(), and LineMode.

◆ ~RubberBandTool()

Isis::RubberBandTool::~RubberBandTool ( )
virtual

Member Function Documentation

◆ activate

◆ addConnections()

virtual void Isis::Tool::addConnections ( MdiCubeViewport cvp)
inlineprotectedvirtualinherited

Anytime a tool is created, you must add the connections for it.

Parameters
cvp

Reimplemented in Isis::WindowTool, and Isis::TrackTool.

◆ addTo() [1/4]

◆ addTo() [2/4]

void Isis::Tool::addTo ( ToolPad toolpad)
inherited

Adds the tool to the toolpad.

Parameters
toolpad

References Isis::Tool::activate(), Isis::ToolPad::addAction(), and Isis::Tool::toolPadAction().

◆ addTo() [3/4]

◆ addTo() [4/4]

void Isis::Tool::addTo ( Workspace ws)
virtualinherited

Adds the given workspace to the cubeviewport list.

Parameters
ws

Reimplemented in Isis::WindowTool, Isis::SpecialPixelTool, Isis::FileTool, and Isis::EditTool.

References Isis::Tool::registerTool(), and Isis::Tool::setCubeViewport().

◆ addToActive()

void Isis::Tool::addToActive ( QToolBar toolbar)
inherited

◆ addToPermanent()

virtual void Isis::Tool::addToPermanent ( QToolBar toolbar)
inlinevirtualinherited

◆ angle()

Angle Isis::RubberBandTool::angle ( )

◆ area()

double Isis::RubberBandTool::area ( )

◆ bandingComplete

void Isis::RubberBandTool::bandingComplete ( )
signal

◆ clear()

void Isis::RubberBandTool::clear ( )

clears the rubber band!

Referenced by Isis::StereoTool::rubberBandComplete().

◆ clearWarningSignal

void Isis::Tool::clearWarningSignal ( )
signalinherited

◆ createToolBarWidget()

virtual QWidget* Isis::Tool::createToolBarWidget ( QStackedWidget *  parent)
inlineprotectedvirtualinherited

◆ cubeViewport()

MdiCubeViewport* Isis::Tool::cubeViewport ( ) const
inlineprotectedinherited

Return the current cubeviewport.

Returns
CubeViewport*

Referenced by Isis::TrackTool::addConnections(), Isis::WindowTool::addConnections(), Isis::StretchTool::deleteFromCube(), Isis::FileTool::discard(), Isis::FileTool::exportToList(), Isis::FileTool::exportView(), Isis::StretchTool::loadStretchFromCube(), Isis::SunShadowTool::mouseButtonPress(), Isis::EditTool::mouseButtonRelease(), Isis::ControlNetTool::mouseButtonRelease(), Isis::FeatureNomenclatureTool::mouseButtonRelease(), Isis::FindTool::mouseButtonRelease(), Isis::MatchTool::mouseButtonRelease(), Isis::PanTool::mouseButtonRelease(), Isis::QnetTool::mouseButtonRelease(), mouseButtonRelease(), Isis::StretchTool::mouseButtonRelease(), Isis::AdvancedTrackTool::mouseLeave(), Isis::SunShadowTool::mouseMove(), Isis::TrackTool::mouseMove(), mouseMove(), Isis::ScatterPlotTool::mouseMove(), Isis::FindTool::paintViewport(), paintViewport(), Isis::SunShadowTool::paintViewport(), Isis::FileTool::print(), Isis::HistogramTool::refreshPlot(), Isis::SpatialPlotTool::refreshPlot(), Isis::SpectralPlotTool::refreshPlot(), Isis::TrackTool::removeConnections(), Isis::WindowTool::removeConnections(), Isis::EditTool::rubberBandComplete(), Isis::HistogramTool::rubberBandComplete(), Isis::MeasureTool::rubberBandComplete(), Isis::StereoTool::rubberBandComplete(), Isis::StretchTool::rubberBandComplete(), Isis::ZoomTool::rubberBandComplete(), Isis::FileTool::save(), Isis::FileTool::saveAs(), Isis::FileTool::saveAsCubeByOption(), Isis::FileTool::saveInfo(), Isis::StretchTool::saveStretchToCube(), Isis::ScatterPlotTool::showNewScatterPlotConfig(), Isis::StretchTool::stretchGlobal(), Isis::StretchTool::stretchGlobalAllBands(), Isis::StretchTool::stretchRegional(), Isis::StretchTool::updateAdvStretchDialogforAll(), Isis::StretchTool::updateHistograms(), Isis::MeasureTool::updateMeasure(), Isis::AbstractPlotTool::updateTool(), Isis::BandTool::updateTool(), Isis::BlinkTool::updateTool(), Isis::EditTool::updateTool(), Isis::FileTool::updateTool(), Isis::FindTool::updateTool(), Isis::SpecialPixelTool::updateTool(), Isis::StretchTool::updateTool(), Isis::SunShadowTool::updateTool(), Isis::WindowTool::updateTool(), Isis::ZoomTool::updateTool(), and Isis::AbstractPlotTool::viewportsToPlot().

◆ cubeViewportList()

◆ currentMode()

RubberBandTool::RubberBandMode Isis::RubberBandTool::currentMode ( )

◆ disable()

void Isis::RubberBandTool::disable ( )

This is called when something is not using me, so turn off events, reset & repaint to clear the clear.

References Isis::Tool::activate().

Referenced by Isis::EditTool::enableRubberBandTool(), Isis::Tool::enableRubberBandTool(), and Isis::RubberBandComboBox::selectionChanged().

◆ enable()

void Isis::RubberBandTool::enable ( RubberBandMode  mode,
bool  showIndicatorColors = false 
)

This is called when changing modes or turning on.

So, set the mode, reset, and activate our event handlers.

Parameters
mode
showIndicatorColorsColor the first side of figures differently

References Isis::Tool::activate(), and modeChanged().

Referenced by Isis::EditTool::enableRubberBandTool(), Isis::StereoTool::enableRubberBandTool(), Isis::StretchTool::enableRubberBandTool(), and Isis::ZoomTool::enableRubberBandTool().

◆ enableAllClicks()

void Isis::RubberBandTool::enableAllClicks ( )

◆ enablePoints()

void Isis::RubberBandTool::enablePoints ( unsigned int  pixTolerance = 2)

◆ enableRubberBandTool()

void Isis::RubberBandTool::enableRubberBandTool ( )
inlineprotectedvirtual

Anytime a tool is created, you may use the rubber band tool.

Enable the use of the rubberband tool.

Reimplemented from Isis::Tool.

◆ escapeKeyPress

void Isis::RubberBandTool::escapeKeyPress ( )
slot

◆ figureComplete()

bool Isis::RubberBandTool::figureComplete ( )

◆ figureIsPoint()

bool Isis::RubberBandTool::figureIsPoint ( )

◆ figureValid()

◆ geometry()

geos::geom::Geometry * Isis::RubberBandTool::geometry ( )

◆ isValid()

bool Isis::RubberBandTool::isValid ( )

This returns true if we can return complete & valid data.

References figureComplete(), and figureValid().

◆ measureChange

void Isis::RubberBandTool::measureChange ( )
signal

Referenced by mouseMove().

◆ menuName()

virtual QString Isis::Tool::menuName ( ) const
inlinevirtualinherited

◆ modeChanged

void Isis::RubberBandTool::modeChanged ( )
signal

Referenced by enable().

◆ mouseButton()

Qt::MouseButton Isis::RubberBandTool::mouseButton ( )

This method returns the mouse button modifier.

Returns
MouseButton Mouse button modifier on last release

Referenced by mouseMove(), and Isis::ZoomTool::rubberBandComplete().

◆ mouseButtonPress

void Isis::RubberBandTool::mouseButtonPress ( QPoint  p,
Qt::MouseButton  s 
)
protectedslot

If the click is not the left mouse button, this does nothing.

This will set mouseDown as true. When the calculations are complete, p_mouseDown is set to true.

For drag-only, A press means starting a new rubber band so reset & record the point. This applies to CircleModes, Eliipsoids, LineModes and RectangleModes.

For Rotated RectangleModes, A mount press means we're starting over, setting the first point, or completing. For the first two, simply reset and record the point. For the latter, figure out the corners and store those points.

For polygons, A press means record the current point. Reset first if we're not currently drawing.

Parameters
p
s

References AngleMode, CircleMode, EllipseMode, LineMode, PolygonMode, RectangleMode, RotatedRectangleMode, and SegmentedLineMode.

◆ mouseButtonRelease

void Isis::RubberBandTool::mouseButtonRelease ( QPoint  p,
Qt::MouseButton  s 
)
protectedslot

If this is not the left mouse button, this does nothing.

This will set mouseDown as false. When the calculations are complete, p_doubleClicking is set to false. The double click event occurs with `the press event so it's safe to set that flag here.

The implementation differs, based on the mode, as follows:

For angles, This signifies a click. We're always setting one of the three vertexes, but if there is an already complete vertex go ahead and reset first to start a new angle.

For circles, Since this is a drag-only rubber band, a release signifies a complete. Figure out the corner, based on the mouse location, and push it onto the back of the vertex list and emit a complete.

For EllipseModes, Since this is a drag-only rubber band, a release signifies a complete. We know the corner, it's the mouse loc, push it onto the back of the vertex list and emit a complete.

For lines, Since this is a drag-only rubber band, a release signifies a complete. We know the end point, push it onto the back of the vertex list and emit a complete.

For rectangles, Since this is a drag-only rubber band, a release signifies a complete. We know the opposite corner, figure out the others and push them onto the back of the vertex list and emit a complete.

For rotated rectangles, If we're finishing dragging the first side, store the end point.

For polygons, Do nothing, this is taken care of on press.

Parameters
pCurrent mouse Location
sWhich mouse button was released

References AngleMode, bandingComplete(), CircleMode, Isis::Tool::cubeViewport(), Isis::Tool::cubeViewportList(), EllipseMode, Isis::MdiCubeViewport::isLinked(), LineMode, PolygonMode, RectangleMode, RotatedRectangleMode, SegmentedLineMode, and vertices().

◆ mouseDoubleClick

void Isis::RubberBandTool::mouseDoubleClick ( QPoint  p)
protectedslot

This triggers on a second mouse press.

Only polygons care about this, and it signifies an end of shape. So, if we're in polygon mode, stop tracking the mouse and emit a complete.

Parameters
p

References AngleMode, bandingComplete(), CircleMode, EllipseMode, LineMode, PolygonMode, RectangleMode, RotatedRectangleMode, and SegmentedLineMode.

◆ mouseEnter

virtual void Isis::Tool::mouseEnter ( )
inlineprotectedvirtualslotinherited

◆ mouseLeave

virtual void Isis::Tool::mouseLeave ( )
inlineprotectedvirtualslotinherited

◆ mouseMove [1/2]

void Isis::Tool::mouseMove ( QPoint  p)
protectedvirtualslotinherited
Parameters
p

◆ mouseMove [2/2]

void Isis::RubberBandTool::mouseMove ( QPoint  p,
Qt::MouseButton  mouseButton 
)
protectedslot

If tracking is not enabled, this does nothing.

This will first update the mouse location for painting purposes.

Most of the implementation is a matter of emitting measureChanges: For angles, if the first two vertices are specified a measureChange will be emitted. For circles, if the center of the circle is known a measureChange will be emitted. For EllipseModes, if the center of the EllipseMode is known a measureChange will be emitted. For lines, if the first point of the line is known a measureChange will be emitted. For rectangles, if the starting point is known a measureChange will be emitted. For rotated rectangles, if the first side is specified a measureChange will be emitted.

However, there is one exception: For polygons, if the mouse button is pressed the mouse location is recorded as a valid vertex.

Parameters
pCurrent mouse Location

References AngleMode, CircleMode, Isis::Tool::cubeViewport(), Isis::Tool::cubeViewportList(), EllipseMode, Isis::MdiCubeViewport::isLinked(), LineMode, measureChange(), mouseButton(), PolygonMode, RectangleMode, RotatedRectangleMode, and SegmentedLineMode.

◆ paintViewport()

void Isis::RubberBandTool::paintViewport ( MdiCubeViewport vp,
QPainter *  painter 
)
virtual

This is the main paint method for the rubber bands.

For angles and lines, simply connect the known vertices.vertices[0].x() For polygons, paint the vertices & close if completed the shape. For circles, figure out the circle's square and draw the circle inside of it. For EllipseModes, figure out the EllipseMode's rectangle and draw the circle inside of it. For rectangles, paint the rectangle either to the mouse or back to the start depending on if the shape is complete. For rotated rectangles, if we can interpolate extra sides draw them and draw all known sides.

Parameters
vp
painter

Reimplemented from Isis::Tool.

References AngleMode, CircleMode, Isis::Tool::cubeViewport(), EllipseMode, figureIsPoint(), Isis::MdiCubeViewport::isLinked(), LineMode, PolygonMode, RectangleMode, RotatedRectangleMode, SegmentedLineMode, and vertices().

◆ rectangle()

QRect Isis::RubberBandTool::rectangle ( )

This method returns a rectangle from the vertices set by the RubberBandTool.

It calculates the upper left and bottom right points for the rectangle and properly initializes a QRect object with these vertices. If the RubberBandTool is in the incorrect mode, or the rectangle is not valid it will return an error message.

Returns
QRect The QRect the user selected on the viewport in pixels

References currentMode(), figureValid(), RectangleMode, and vertices().

Referenced by Isis::EditTool::rubberBandComplete(), Isis::StretchTool::rubberBandComplete(), and Isis::ZoomTool::rubberBandComplete().

◆ registerTool()

void Isis::Tool::registerTool ( MdiCubeViewport viewport)
protectedinherited

Registers the tool to the viewport.

Parameters
viewport

References Isis::MdiCubeViewport::registerTool(), and Isis::Tool::stretchRequested().

Referenced by Isis::Tool::addTo().

◆ removeConnections()

virtual void Isis::Tool::removeConnections ( MdiCubeViewport cvp)
inlineprotectedvirtualinherited

Anytime a tool is created, you must be able to remove it's connections.

Parameters
cvp

Reimplemented in Isis::WindowTool, Isis::TrackTool, and Isis::MeasureTool.

◆ rubberBandComplete

virtual void Isis::Tool::rubberBandComplete ( )
inlineprotectedvirtualslotinherited

◆ rubberBandTool()

◆ scaleChanged()

void Isis::RubberBandTool::scaleChanged ( )
protectedvirtual

Reimplemented from Isis::Tool.

◆ screenPixelsChanged

virtual void Isis::Tool::screenPixelsChanged ( )
inlineprotectedvirtualslotinherited

This is called when actions change which pixels from the cube are displayed.

◆ setCubeViewport

void Isis::Tool::setCubeViewport ( MdiCubeViewport cvp)
slotinherited

Sets the current viewport to the given cvp.

Parameters
cvp

References Isis::Tool::updateTool(), and Isis::Tool::viewportChanged().

Referenced by Isis::Tool::addTo(), and Isis::FileTool::closeAll().

◆ setDrawActiveViewportOnly()

void Isis::RubberBandTool::setDrawActiveViewportOnly ( bool  activeOnly = false)

◆ setList()

void Isis::Tool::setList ( ToolList currentList)
inherited

Referenced by Isis::ToolList::append().

◆ stretchRequested()

virtual void Isis::Tool::stretchRequested ( MdiCubeViewport ,
int   
)
inlineprotectedvirtualinherited

Reimplemented in Isis::StretchTool.

Referenced by Isis::Tool::registerTool().

◆ toolActivated

◆ toolIconDir()

◆ toolPadAction()

virtual QAction* Isis::Tool::toolPadAction ( ToolPad toolpad)
inlineprotectedvirtualinherited

◆ updateMeasure()

virtual void Isis::Tool::updateMeasure ( )
inlineprotectedvirtualinherited

◆ updateTool

◆ vertices()

QList< QPoint > Isis::RubberBandTool::vertices ( )

This method returns the vertices.

The return value is mode-specific, and the return will be consistent whether in a measureChange or bandingComplete slot.

The return values are always in pixels.

The return values are as follows: For angles, the return will always be of size 3. The elements at 0 and 2 are the edges of the angle, while the element at 1 is the vertex of the angle.

For circles, the return will always be of size 2. The element at 0 is the center of the circle, and the element at 1 is offset by the radius in both directions.

For EllipseModes, the return will always be of size 2. The element at 0 is the center of the circle, and the element at 1 is offset by the radius in both directions.

For lines, the return will always be of size 2. The elements are the start and end points.

For rectangles, the return will always be of size 4. The elements will be the corners, in either a clockwise or counter-clockwise direction.

For rotated rectangles, the same applies.

For polygons, the return will be a list of vertices in the order that the user drew them.

**It is NOT valid to call this unless you're in a measureChange or bandingComplete slot.

Returns
QList<QPoint>

References AngleMode, CircleMode, EllipseMode, figureComplete(), LineMode, PolygonMode, RectangleMode, RotatedRectangleMode, and SegmentedLineMode.

Referenced by angle(), figureIsPoint(), figureValid(), geometry(), mouseButtonRelease(), paintViewport(), rectangle(), Isis::HistogramTool::refreshPlot(), Isis::SpatialPlotTool::refreshPlot(), Isis::SpectralPlotTool::refreshPlot(), and Isis::ZoomTool::rubberBandComplete().

◆ viewportChanged

◆ workspace()


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