Drag of the line during edit line operation.
ModuleBase_IOperation.h
ModuleBase_Operation.h
ModuleBase_OperationDescription.h
- ModuleBase_PropPanelOperation.h
ModuleBase_ModelWidget.h
ModuleBase_WidgetFactory.h
ModuleBase_WidgetPoint2D.h
ModuleBase_IOperation.cpp
ModuleBase_Operation.cpp
ModuleBase_OperationDescription.cpp
- ModuleBase_PropPanelOperation.cpp
ModuleBase_WidgetFactory.cpp
ModuleBase_WidgetPoint2D.cpp
ModuleBase_WidgetSwitch.cpp
/*
* ModuleBase_Operation.cpp
*
- * Created on: May 5, 2014
- * Author: nds
+ * Created on: Apr 2, 2014
+ * Author: sbh
*/
#include "ModuleBase_Operation.h"
/*
* ModuleBase_Operation.h
*
- * Created on: May 5, 2014
- * Author: nds
+ * Created on: Apr 2, 2014
+ * Author: sbh
*/
/*
* ModuleBase_OperationDescription.cpp
*
- * Created on: May 5, 2014
- * Author: nds
+ * Created on: Apr 2, 2014
+ * Author: sbh
*/
#include <ModuleBase_OperationDescription.h>
/*
* ModuleBase_OperationDescription.h
*
- * Created on: May 5, 2014
- * Author: nds
+ * Created on: Apr 2, 2014
+ * Author: sbh
*/
#ifndef MODULEBASE_OPERATIONDESCRIPTION_H
+++ /dev/null
-/*
- * ModuleBase_PropPanelOperation.cpp
- *
- * Created on: Apr 2, 2014
- * Author: sbh
- */
-
-#include <ModuleBase_PropPanelOperation.h>
-#include <QString>
-
-/*!
- \brief Constructor
- \param XGUI_Workshop - workshop for this operation
-
- Constructs an empty operation. Constructor should work very fast because many
- operators may be created after starting workshop but only several from them
- may be used. As result this constructor stores given workshop in myApp field
- and set Waiting status.
- */
-ModuleBase_PropPanelOperation::ModuleBase_PropPanelOperation(const QString& theId, QObject* parent)
-: ModuleBase_Operation(theId, parent)
-{
-}
-
-/*!
- * \brief Destructor
- */
-ModuleBase_PropPanelOperation::~ModuleBase_PropPanelOperation()
-{
-
-}
-
+++ /dev/null
-/*
- * ModuleBase_PropPanelOperation.h
- *
- * Created on: Apr 2, 2014
- * Author: sbh
- */
-
-#ifndef MODULEBASE_PROPPANELOPERATION_H
-#define MODULEBASE_PROPPANELOPERATION_H
-
-#include <ModuleBase.h>
-#include <ModuleBase_Operation.h>
-
-#include <QObject>
-#include <QString>
-
-#include <memory>
-
-/*!
- * \class ModuleBase_PropPanelOperation
- *
- */
-class MODULEBASE_EXPORT ModuleBase_PropPanelOperation: public ModuleBase_Operation
-{
-
- Q_OBJECT
-
-public:
- ModuleBase_PropPanelOperation(const QString& theId = "", QObject* parent = 0);
- virtual ~ModuleBase_PropPanelOperation();
-
- /*!
- * \brief Returns XML representation of the operation's widget.
- * \return XML QString
- *
- * Returns XML representation of the operation's widget.
- */
- const QString& xmlRepresentation() const
- {
- return myXmlRepr;
- }
-
- /*!
- * \brief Sets XML representation of the operation's widget.
- * \param xmlRepr - XML QString
- *
- * Sets XML representation of the operation's widget.
- */
- void setXmlRepresentation(const QString& xmlRepr)
- {
- this->myXmlRepr = xmlRepr;
- }
-
-
- /*
- * Returns a short description of operation (will be
- * inserted in title of property panel)
- */
- const QString& description() const
- {
- return myDescription;
- }
-
- /*
- * Sets a short description of operation (will be
- * inserted in title of property panel)
- */
- void setDescription(const QString& theDescription)
- {
- this->myDescription = theDescription;
- }
-
-private:
- //!< Next fields could be extracted into a subclass;
- QString myXmlRepr;
- QString myDescription;
-};
-
-#endif //MODULEBASE_PROPPANELOPERATION_H
#include <ModuleBase_MetaWidget.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_PropPanelOperation.h>
#include <ModuleBase_WidgetPoint2D.h>
#include <ModuleBase_WidgetSwitch.h>
connect(myWorkshop->selector(), SIGNAL(selectionChanged()),
this, SLOT(onSelectionChanged()));
+ connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)),
+ this, SLOT(onMousePressed(QMouseEvent*)));
connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)),
this, SLOT(onMouseReleased(QMouseEvent*)));
connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)),
void PartSet_Module::launchOperation(const QString& theCmdId)
{
- ModuleBase_Operation* anOperation = createOperation(theCmdId);
+ ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
sendOperation(anOperation);
}
}
}
+void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
+{
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
+ myWorkshop->operationMgr()->currentOperation());
+ if (aPreviewOp)
+ {
+ gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(theEvent->pos(),
+ myWorkshop->viewer()->activeView());
+ aPreviewOp->mousePressed(aPnt, theEvent);
+ }
+}
+
void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
{
- QPoint aPoint = theEvent->pos();
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (aPreviewOp) {
- XGUI_SelectionMgr* aSelector = myWorkshop->selector();
- if (aSelector) {
- Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
- if ( !aView3d.IsNull() ) {
- gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
- aPreviewOp->mouseReleased(aPnt);
- }
- }
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
+ myWorkshop->operationMgr()->currentOperation());
+ if (aPreviewOp)
+ {
+ gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(theEvent->pos(),
+ myWorkshop->viewer()->activeView());
+ aPreviewOp->mouseReleased(aPnt, theEvent);
}
}
void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
{
- QPoint aPoint = theEvent->pos();
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (aPreviewOp) {
- Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
- if ( !aView3d.IsNull() ) {
- gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
- aPreviewOp->mouseMoved(aPnt);
- }
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
+ myWorkshop->operationMgr()->currentOperation());
+ if (aPreviewOp)
+ {
+ gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(theEvent->pos(),
+ myWorkshop->viewer()->activeView());
+ aPreviewOp->mouseMoved(aPnt, theEvent);
}
}
visualizePreview(theFeature, isDisplay);
}
-ModuleBase_Operation* PartSet_Module::createOperation(const QString& theCmdId)
+ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId)
{
- std::string aStdCmdId = theCmdId.toStdString();
- if (aStdCmdId == "EditLine")
- aStdCmdId = "SketchLine";
+ // get operation xml description
+ std::string aStdCmdId = theCmdId;
+ if (aStdCmdId == PartSet_OperationEditLine::Type())
+ aStdCmdId = PartSet_OperationSketchLine::Type();
std::string aPluginFileName = featureFile(aStdCmdId);
Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
aWdgReader.readAll();
std::string aXmlCfg = aWdgReader.featureWidgetCfg(aStdCmdId);
std::string aDescription = aWdgReader.featureDescription(aStdCmdId);
+
+ // create the operation
ModuleBase_Operation* anOperation;
- if (theCmdId == "Sketch" ) {
- anOperation = new PartSet_OperationSketch(theCmdId, this);
+ if (theCmdId == PartSet_OperationSketch::Type()) {
+ anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
}
- else if(theCmdId == "SketchLine" || theCmdId == "EditLine") {
+ else if(theCmdId == PartSet_OperationSketchLine::Type() ||
+ theCmdId == PartSet_OperationEditLine::Type()) {
ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
boost::shared_ptr<ModelAPI_Feature> aSketchFeature;
if (aCurOperation)
aSketchFeature = aCurOperation->feature();
- if (theCmdId == "SketchLine")
- anOperation = new PartSet_OperationSketchLine(theCmdId, this, aSketchFeature);
+ if (theCmdId == PartSet_OperationSketchLine::Type())
+ anOperation = new PartSet_OperationSketchLine(theCmdId.c_str(), this, aSketchFeature);
else
- anOperation = new PartSet_OperationEditLine(theCmdId, this, aSketchFeature);
+ anOperation = new PartSet_OperationEditLine(theCmdId.c_str(), this, aSketchFeature);
}
else {
- anOperation = new ModuleBase_Operation(theCmdId, this);
+ anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
}
anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
- // connect
+ // connect the operation
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
connect(aPreviewOp, SIGNAL(featureConstructed(boost::shared_ptr<ModelAPI_Feature>, int)),
this, SLOT(onPlaneSelected(double, double, double)));
}
}
-
return anOperation;
}
/// SLOT, that is called by the selection in the viewer is changed.
/// The selection is sent to the current operation if it listens selection.
void onSelectionChanged();
- /// SLOT, that is called by mouse click in the viewer.
+ /// SLOT, that is called by mouse press in the viewer.
+ /// The mouse released point is sent to the current operation to be processed.
+ /// \param theEvent the mouse event
+ void onMousePressed(QMouseEvent* theEvent);
+ /// SLOT, that is called by mouse release in the viewer.
/// The mouse released point is sent to the current operation to be processed.
/// \param theEvent the mouse event
void onMouseReleased(QMouseEvent* theEvent);
- /// SLOT, that is called by the selection in the viewer is changed.
+ /// SLOT, that is called by mouse move in the viewer.
/// The mouse moved point is sent to the current operation to be processed.
/// \param theEvent the mouse event
void onMouseMoved(QMouseEvent* theEvent);
protected:
/// Creates a new operation
/// \param theCmdId the operation name
- ModuleBase_Operation* createOperation(const QString& theCmdId);
+ ModuleBase_Operation* createOperation(const std::string& theCmdId);
/// Sends the operation
/// \param theOperation the operation
// Author: Natalia ERMOLAEVA
#include <PartSet_OperationEditLine.h>
+#include <PartSet_Tools.h>
#include <SketchPlugin_Feature.h>
#include <GeomDataAPI_Point2D.h>
-#include <GeomDataAPI_Point.h>
-#include <GeomDataAPI_Dir.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
-#include <SketchPlugin_Sketch.h>
#include <SketchPlugin_Line.h>
#ifdef _DEBUG
#include <QDebug>
#endif
+#include <QMouseEvent>
+
using namespace std;
PartSet_OperationEditLine::PartSet_OperationEditLine(const QString& theId,
std::list<int> PartSet_OperationEditLine::getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const
{
std::list<int> aModes;
- //if (theFeature != feature())
- // aModes.push_back(TopAbs_VERTEX);
+ aModes.push_back(TopAbs_VERTEX);
+ aModes.push_back(TopAbs_EDGE);
return aModes;
}
setFeature(theFeature);
}
-void PartSet_OperationEditLine::mouseReleased(const gp_Pnt& thePoint)
+void PartSet_OperationEditLine::mousePressed(const gp_Pnt& thePoint, QMouseEvent* theEvent)
{
- /*switch (myPointSelectionMode)
- {
- case SM_FirstPoint: {
- setLinePoint(thePoint, LINE_ATTR_START);
- myPointSelectionMode = SM_SecondPoint;
- }
- break;
- case SM_SecondPoint: {
- setLinePoint(thePoint, LINE_ATTR_END);
- myPointSelectionMode = SM_None;
- }
- break;
- case SM_None: {
-
- }
- break;
- default:
- break;
- }
-*/
+ if (!(theEvent->buttons() & Qt::LeftButton))
+ return;
+ myCurPressed = thePoint;
}
-void PartSet_OperationEditLine::mouseMoved(const gp_Pnt& thePoint)
+void PartSet_OperationEditLine::mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent)
{
-/* switch (myPointSelectionMode)
- {
- case SM_SecondPoint:
- setLinePoint(thePoint, LINE_ATTR_END);
- break;
- case SM_None: {
- boost::shared_ptr<ModelAPI_Feature> aPrevFeature = feature();
- // stop the last operation
- commitOperation();
- document()->finishOperation();
- //emit changeSelectionMode(aPrevFeature, TopAbs_VERTEX);
- // start a new operation
- document()->startOperation();
- startOperation();
- // use the last point of the previous feature as the first of the new one
- setLinePoint(aPrevFeature, LINE_ATTR_END, LINE_ATTR_START);
- myPointSelectionMode = SM_SecondPoint;
-
- emit featureConstructed(aPrevFeature, FM_Deactivation);
- }
- break;
- default:
- break;
- }
-*/
-}
+ if (!(theEvent->buttons() & Qt::LeftButton))
+ return;
-void PartSet_OperationEditLine::keyReleased(const int theKey)
-{
-/* switch (theKey) {
- case Qt::Key_Escape: {
- if (myPointSelectionMode != SM_None)
- emit featureConstructed(feature(), FM_Abort);
- abort();
- }
- break;
- case Qt::Key_Return: {
- if (myPointSelectionMode != SM_None) {
- emit featureConstructed(feature(), FM_Abort);
- myPointSelectionMode = SM_FirstPoint;
- document()->abortOperation();
- }
- else
- myPointSelectionMode = SM_FirstPoint;
- }
- break;
- default:
- break;
- }
- */
+ double aCurX, aCurY;
+ PartSet_Tools::ConvertTo2D(myCurPressed, mySketch, aCurX, aCurY);
+
+ double aX, anY;
+ PartSet_Tools::ConvertTo2D(thePoint, mySketch, aX, anY);
+
+ double aDeltaX = aX - aCurX;
+ double aDeltaY = anY - aCurY;
+
+ moveLinePoint(aDeltaX, aDeltaY, LINE_ATTR_START);
+ moveLinePoint(aDeltaX, aDeltaY, LINE_ATTR_END);
+ myCurPressed = thePoint;
}
void PartSet_OperationEditLine::setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
commit();
if (theFeature)
- emit launchOperation("EditLine", theFeature);
+ emit launchOperation(PartSet_OperationEditLine::Type(), theFeature);
}
void PartSet_OperationEditLine::startOperation()
{
- //PartSet_OperationSketchBase::startOperation();
- //myPointSelectionMode = SM_FirstPoint;
-}
-
-void PartSet_OperationEditLine::stopOperation()
-{
- PartSet_OperationSketchBase::stopOperation();
- //myPointSelectionMode = SM_None;
+ // do nothing in order to do not create a new feature
}
boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature()
{
+ // do nothing in order to do not create a new feature
return boost::shared_ptr<ModelAPI_Feature>();
}
-void PartSet_OperationEditLine::setLinePoint(const gp_Pnt& thePoint,
+void PartSet_OperationEditLine::moveLinePoint(double theDeltaX, double theDeltaY,
const std::string& theAttribute)
{
boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
- double aX = 0;
- double anY = 0;
- convertTo2D(thePoint, aX, anY);
- aPoint->setValue(aX, anY);
-}
-
-void PartSet_OperationEditLine::setLinePoint(boost::shared_ptr<ModelAPI_Feature> theSourceFeature,
- const std::string& theSourceAttribute,
- const std::string& theAttribute)
-{
- boost::shared_ptr<ModelAPI_Data> aData = theSourceFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theSourceAttribute));
- double aX = aPoint->x();
- double anY = aPoint->y();
-
- aData = feature()->data();
- aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
- aPoint->setValue(aX, anY);
-}
-
-void PartSet_OperationEditLine::convertTo2D(const gp_Pnt& thePoint, double& theX, double& theY)
-{
- if (!mySketch)
- return;
-
- boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
- boost::shared_ptr<ModelAPI_Data> aData = mySketch->data();
-
- boost::shared_ptr<GeomDataAPI_Point> anOrigin =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
-
- boost::shared_ptr<GeomDataAPI_Dir> aX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
- boost::shared_ptr<GeomDataAPI_Dir> anY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
-
- gp_Pnt aVec(thePoint.X() - anOrigin->x(), thePoint.Y() - anOrigin->y(), thePoint.Z() - anOrigin->z());
- theX = aVec.X() * aX->x() + aVec.Y() * aX->y() + aVec.Z() * aX->z();
- theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z();
+ aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY);
}
#include <PartSet_OperationSketchBase.h>
#include <QObject>
+class QMouseEvent;
+
/*!
\class PartSet_OperationEditLine
* \brief The operation for the sketch feature creation
class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase
{
Q_OBJECT
+public:
+ /// Returns the operation type key
+ static std::string Type() { return "EditLine"; }
+
public:
/// Constructor
/// \param theId the feature identifier
/// \param theFeature the feature
virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature);
- /// Gives the current selected objects to be processed by the operation
+ /// Processes the mouse pressed in the point
/// \param thePoint a point clicked in the viewer
- virtual void mouseReleased(const gp_Pnt& thePoint);
+ /// \param theEvent the mouse event
+ virtual void mousePressed(const gp_Pnt& thePoint, QMouseEvent* theEvent);
/// Gives the current mouse point in the viewer
/// \param thePoint a point clicked in the viewer
- virtual void mouseMoved(const gp_Pnt& thePoint);
- /// Processes the key pressed in the view
- /// \param theKey a key value
- virtual void keyReleased(const int theKey);
+ /// \param theEvent the mouse event
+ virtual void mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent);
/// Gives the current selected objects to be processed by the operation
/// \param theFeature the selected feature
virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
const TopoDS_Shape& theShape);
-signals:
- /// signal about the sketch plane is selected
- /// \param theX the value in the X direction of the plane
- /// \param theX the value in the Y direction value of the plane
- /// \param theX the value in the Z direction of the plane
- void localContextChanged(boost::shared_ptr<ModelAPI_Feature> theFeature,
- int theMode);
-
protected:
/// \brief Virtual method called when operation is started
/// Virtual method called when operation started (see start() method for more description)
/// After the parent operation body perform, set sketch feature to the created line feature
virtual void startOperation();
- /// \brief Virtual method called when operation is started
- /// Virtual method called when operation stopped - committed or aborted.
- /// After the parent operation body perform, reset selection point mode of the operation
- virtual void stopOperation();
-
/// Creates an operation new feature
/// Returns NULL feature. This is an operation of edition, not creation.
/// \returns the created feature
protected:
/// \brief Save the point to the line.
- /// \param thePoint the 3D point in the viewer
- /// \param theAttribute the start or end attribute of the line
- void setLinePoint(const gp_Pnt& thePoint, const std::string& theAttribute);
-
- /// \brief Set the point to the line by the point of the source line.
- /// \param theSourceFeature the feature, where the point is obtained
- /// \param theSourceAttribute the start or end attribute of the source line
+ /// \param theDeltaX the delta for X coordinate is moved
+ /// \param theDeltaY the delta for Y coordinate is moved
/// \param theAttribute the start or end attribute of the line
- void setLinePoint(boost::shared_ptr<ModelAPI_Feature> theSourceFeature,
- const std::string& theSourceAttribute,
- const std::string& theAttribute);
- /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
- /// \param thePoint the 3D point in the viewer
- /// \param theX the X coordinate
- /// \param theY the Y coordinate
- void convertTo2D(const gp_Pnt& thePoint, double& theX, double& theY);
-
-protected:
- ///< Structure to lists the possible types of point selection modes
- enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_None};
+ void moveLinePoint(double theDeltaX, double theDeltaY,
+ const std::string& theAttribute);
private:
boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
- //PointSelectionMode myPointSelectionMode; ///< point selection mode
+ gp_Pnt myCurPressed; ///< the current 3D point clicked or moved
};
#endif
#include <PartSet_OperationSketch.h>
+#include <PartSet_OperationEditLine.h>
+
#include <SketchPlugin_Sketch.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDouble.h>
myIsEditMode = true;
}
else if (theFeature)
- emit launchOperation("EditLine", theFeature);
+ emit launchOperation(PartSet_OperationEditLine::Type(), theFeature);
}
void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBase
{
Q_OBJECT
+public:
+ /// Returns the operation type key
+ static std::string Type() { return "Sketch"; }
+
public:
/// Constructor
/// \param theId the feature identifier
#include <ModuleBase_Operation.h>
#include <QObject>
+class QMouseEvent;
+
class GeomAPI_Shape;
/*!
virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
const TopoDS_Shape& theShape) {};
+ /// Processes the mouse pressed in the point
+ /// \param thePoint a point clicked in the viewer
+ /// \param theEvent the mouse event
+ virtual void mousePressed(const gp_Pnt& thePoint, QMouseEvent* theEvent) {};
+
/// Processes the mouse release in the point
/// \param thePoint a point clicked in the viewer
- virtual void mouseReleased(const gp_Pnt& thePoint) {};
+ /// \param theEvent the mouse event
+ virtual void mouseReleased(const gp_Pnt& thePoint, QMouseEvent* theEvent) {};
/// Processes the mouse move in the point
/// \param thePoint a 3D point clicked in the viewer
- virtual void mouseMoved(const gp_Pnt& thePoint) {};
+ /// \param theEvent the mouse event
+ virtual void mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent) {};
/// Processes the key pressed in the view
/// \param theKey a key value
#include <PartSet_OperationSketchLine.h>
+#include <PartSet_Tools.h>
+
#include <SketchPlugin_Feature.h>
#include <GeomDataAPI_Point2D.h>
-#include <GeomDataAPI_Point.h>
-#include <GeomDataAPI_Dir.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
-#include <SketchPlugin_Sketch.h>
#include <SketchPlugin_Line.h>
#ifdef _DEBUG
return aModes;
}
-void PartSet_OperationSketchLine::mouseReleased(const gp_Pnt& thePoint)
+void PartSet_OperationSketchLine::mouseReleased(const gp_Pnt& thePoint, QMouseEvent* /*theEvent*/)
{
switch (myPointSelectionMode)
{
}
break;
case SM_None: {
-
}
break;
default:
}
}
-void PartSet_OperationSketchLine::mouseMoved(const gp_Pnt& thePoint)
+void PartSet_OperationSketchLine::mouseMoved(const gp_Pnt& thePoint, QMouseEvent* /*theEvent*/)
{
switch (myPointSelectionMode)
{
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
- double aX = 0;
- double anY = 0;
- convertTo2D(thePoint, aX, anY);
+ double aX, anY;
+ PartSet_Tools::ConvertTo2D(thePoint, mySketch, aX, anY);
aPoint->setValue(aX, anY);
}
aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
aPoint->setValue(aX, anY);
}
-
-void PartSet_OperationSketchLine::convertTo2D(const gp_Pnt& thePoint, double& theX, double& theY)
-{
- if (!mySketch)
- return;
-
- boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
- boost::shared_ptr<ModelAPI_Data> aData = mySketch->data();
-
- boost::shared_ptr<GeomDataAPI_Point> anOrigin =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
-
- boost::shared_ptr<GeomDataAPI_Dir> aX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
- boost::shared_ptr<GeomDataAPI_Dir> anY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
-
- gp_Pnt aVec(thePoint.X() - anOrigin->x(), thePoint.Y() - anOrigin->y(), thePoint.Z() - anOrigin->z());
- theX = aVec.X() * aX->x() + aVec.Y() * aX->y() + aVec.Z() * aX->z();
- theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z();
-}
#include <PartSet_OperationSketchBase.h>
#include <QObject>
+class QMouseEvent;
+
/*!
\class PartSet_OperationSketchLine
* \brief The operation for the sketch feature creation
class PARTSET_EXPORT PartSet_OperationSketchLine : public PartSet_OperationSketchBase
{
Q_OBJECT
+
+public:
+ /// Returns the operation type key
+ static std::string Type() { return "SketchLine"; }
+
public:
/// Constructor
/// \param theId the feature identifier
/// Gives the current selected objects to be processed by the operation
/// \param thePoint a point clicked in the viewer
- virtual void mouseReleased(const gp_Pnt& thePoint);
+ /// \param theEvent the mouse event
+ virtual void mouseReleased(const gp_Pnt& thePoint, QMouseEvent* theEvent);
/// Gives the current mouse point in the viewer
/// \param thePoint a point clicked in the viewer
- virtual void mouseMoved(const gp_Pnt& thePoint);
+ /// \param theEvent the mouse event
+ virtual void mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent);
/// Processes the key pressed in the view
/// \param theKey a key value
virtual void keyReleased(const int theKey);
-signals:
- /// signal about the sketch plane is selected
- /// \param theX the value in the X direction of the plane
- /// \param theX the value in the Y direction value of the plane
- /// \param theX the value in the Z direction of the plane
- void localContextChanged(boost::shared_ptr<ModelAPI_Feature> theFeature,
- int theMode);
-
protected:
/// \brief Virtual method called when operation is started
/// Virtual method called when operation started (see start() method for more description)
void setLinePoint(boost::shared_ptr<ModelAPI_Feature> theSourceFeature,
const std::string& theSourceAttribute,
const std::string& theAttribute);
- /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
- /// \param thePoint the 3D point in the viewer
- /// \param theX the X coordinate
- /// \param theY the Y coordinate
- void convertTo2D(const gp_Pnt& thePoint, double& theX, double& theY);
protected:
///< Structure to lists the possible types of point selection modes
#include <ProjLib.hxx>
#include <ElSLib.hxx>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <GeomDataAPI_Point.h>
+#include <GeomDataAPI_Dir.h>
+#include <SketchPlugin_Sketch.h>
+
#ifdef _DEBUG
#include <QDebug>
#endif
gp_Pnt PartSet_Tools::ConvertClickToPoint(QPoint thePoint, Handle(V3d_View) theView)
{
+ if (theView.IsNull())
+ return gp_Pnt();
+
V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
theView->Eye( XEye, YEye, ZEye );
gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
return ResultPoint;
}
+
+void PartSet_Tools::ConvertTo2D(const gp_Pnt& thePoint, boost::shared_ptr<ModelAPI_Feature> theSketch,
+ double& theX, double& theY)
+{
+ if (!theSketch)
+ return;
+
+ boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
+ boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
+
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+
+ boost::shared_ptr<GeomDataAPI_Dir> aX =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
+ boost::shared_ptr<GeomDataAPI_Dir> anY =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
+
+ gp_Pnt aVec(thePoint.X() - anOrigin->x(), thePoint.Y() - anOrigin->y(), thePoint.Z() - anOrigin->z());
+ theX = aVec.X() * aX->x() + aVec.Y() * aX->y() + aVec.Z() * aX->z();
+ theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z();
+}
#include <QPoint>
+#include <boost/shared_ptr.hpp>
+
class Handle_V3d_View;
+class ModelAPI_Feature;
/*!
\class PartSet_Tools
/// \param theView a 3D view
static gp_Pnt ConvertClickToPoint(QPoint thePoint, Handle_V3d_View theView);
+ /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
+ /// \param thePoint the 3D point in the viewer
+ /// \param theSketch the sketch feature
+ /// \param theX the X coordinate
+ /// \param theY the Y coordinate
+ static void ConvertTo2D(const gp_Pnt& thePoint, boost::shared_ptr<ModelAPI_Feature> theSketch,
+ double& theX, double& theY);
};
#endif
#include <XGUI_Constants.h>
#include <XGUI_PropertyPanel.h>
-#include <ModuleBase_PropPanelOperation.h>
-
#include <QWidget>
#include <QVBoxLayout>
#include <QFrame>