You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.5 KiB
C

1 month ago
#ifndef _OPCONSTRUCTRECTANGLE_H
#define _OPCONSTRUCTRECTANGLE_H
#include "OBaseOperator.h"
//interface of the HOpConstruction class
// draws a 2D box in view port based on pointer first position and last position
// Derived classes access the Points for the rectangle in HBaseOperator members
// m_ptFirst and m_ptLast; Points are stored in window space.
namespace OSGView
{
class OpConstructRectangle : public OBaseOperator
{
public:
OpConstructRectangle();
OpConstructRectangle(osgViewer::Viewer* pViewer);
virtual ~OpConstructRectangle();
/*!
\returns A pointer to a character string denoting the name of the operator which is 'Construct Rectangle'.
*/
virtual const char * GetName() {return "OpConstructRectangle";}
/*!
OnLButtonDown records the first mouse position and initiates the rectangle-drawing mechanism.
\param hevent An GUIEventAdapter object containing information about the current event.
\return An #HOperatorReturn indicating the status of the event.
*/
virtual int OnLButtonDown(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
/*!
OnLButtonDownAndMove draws a rubberbanded line from the first point in the rectangle to the current mouse position.
Note that the basic drawing work is done by HUtility::InsertRectangle, while OnLButtonDownAndMove keeps track of
the current points and draws the rubberband centroid.
\param hevent An GUIEventAdapter object containing information about the current event.
\return An #HOperatorReturn indicating the status of the event.
*/
virtual int OnLButtonDownAndMove(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
/*!
OnLButtonUp finalizes the size of the rectangle and cleans up.
\param hevent An GUIEventAdapter object containing information about the current event.
\return An #HOperatorReturn indicating the status of the event.
*/
virtual int OnLButtonUp(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
osg::Vec3 GetRectangleStartPt() const {return m_ptRectangle[0];}
osg::Vec3 GetRectangleEndPt() const {return m_ptRectangle[1];}
bool GetRectangleExistFlag() {return m_bRectangleExists;}
protected:
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
protected:
bool m_bRectangleExists; /*!< The boolean indicating whether the rectangle exists. */
osg::Vec3 m_ptRectangle[2]; /*!< The first and last points in the rectangle stored in window space. */
osg::ref_ptr<osg::Group> m_ConstructLayer;
};
}
#endif