Edit line.
PartSet.h
PartSet_Listener.h
PartSet_Module.h
+ PartSet_OperationEditLine.h
PartSet_OperationSketchBase.h
PartSet_OperationSketch.h
PartSet_OperationSketchLine.h
SET(PROJECT_SOURCES
PartSet_Listener.cpp
PartSet_Module.cpp
+ PartSet_OperationEditLine.cpp
PartSet_OperationSketchBase.cpp
PartSet_OperationSketch.cpp
PartSet_OperationSketchLine.cpp
#include <PartSet_Module.h>
#include <PartSet_OperationSketch.h>
#include <PartSet_OperationSketchLine.h>
+#include <PartSet_OperationEditLine.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationDescription.h>
#include <PartSet_Listener.h>
void PartSet_Module::launchOperation(const QString& theCmdId)
{
- std::string aStdCmdId = theCmdId.toStdString();
- 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);
- ModuleBase_Operation* aPartSetOp;
- if (theCmdId == "Sketch" ) {
- aPartSetOp = new PartSet_OperationSketch(theCmdId, this);
- }
- else if(theCmdId == "SketchLine") {
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- boost::shared_ptr<ModelAPI_Feature> aSketchFeature;
- if (anOperation)
- aSketchFeature = anOperation->feature();
- aPartSetOp = new PartSet_OperationSketchLine(theCmdId, this, aSketchFeature);
- }
- else {
- aPartSetOp = new ModuleBase_Operation(theCmdId, this);
- }
- aPartSetOp->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
- aPartSetOp->getDescription()->setDescription(QString::fromStdString(aDescription));
-
- //TODO(sbh): Implement static method to extract event id [SEID]
- static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetModuleEvent");
- Config_PointerMessage aMessage(aModuleEvent, this);
- aMessage.setPointer(aPartSetOp);
- Events_Loop::loop()->send(aMessage);
+ ModuleBase_Operation* anOperation = createOperation(theCmdId);
+ sendOperation(anOperation);
}
void PartSet_Module::onOperationStarted()
if (aSketchOp) {
connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
this, SLOT(onPlaneSelected(double, double, double)));
+ connect(aSketchOp, SIGNAL(launchOperation(std::string, boost::shared_ptr<ModelAPI_Feature>)),
+ this, SLOT(onLaunchOperation(std::string, boost::shared_ptr<ModelAPI_Feature>)));
+
}
}
}
if (aSelector) {
NCollection_List<TopoDS_Shape> aList;
aSelector->selectedShapes(aList);
- aPreviewOp->setSelectedShapes(aList);
+
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ boost::shared_ptr<ModelAPI_Feature> aFeature;
+ if (!aList.IsEmpty()) {
+ const TopoDS_Shape& aShape = aList.First();
+ aFeature = aDisplayer->GetFeature(aShape);
+ aPreviewOp->setSelected(aFeature, aShape);
+ }
}
}
}
if (anOperation) {
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
- aPreviewOp->setEditMode(true);
visualizePreview(aPreviewOp->feature(), false);
}
}
myWorkshop->actionsMgr()->setNestedActionsEnabled(true);
}
+void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+ ModuleBase_Operation* anOperation = createOperation(theName.c_str());
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+ if (aPreviewOp)
+ {
+ aPreviewOp->init(theFeature);
+ }
+ sendOperation(anOperation);
+}
+
void PartSet_Module::onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
int theMode)
{
visualizePreview(theFeature, isDisplay);
}
+ModuleBase_Operation* PartSet_Module::createOperation(const QString& theCmdId)
+{
+ std::string aStdCmdId = theCmdId.toStdString();
+ if (aStdCmdId == "EditLine")
+ aStdCmdId = "SketchLine";
+ 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);
+ ModuleBase_Operation* anOperation;
+ if (theCmdId == "Sketch" ) {
+ anOperation = new PartSet_OperationSketch(theCmdId, this);
+ }
+ else if(theCmdId == "SketchLine" || theCmdId == "EditLine") {
+ 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);
+ else
+ anOperation = new PartSet_OperationEditLine(theCmdId, this, aSketchFeature);
+ }
+ else {
+ anOperation = new ModuleBase_Operation(theCmdId, this);
+ }
+ anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
+ anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
+
+ return anOperation;
+}
+
+void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
+{
+ //TODO(sbh): Implement static method to extract event id [SEID]
+ static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetModuleEvent");
+ Config_PointerMessage aMessage(aModuleEvent, this);
+ aMessage.setPointer(theOperation);
+ Events_Loop::loop()->send(aMessage);
+}
+
void PartSet_Module::visualizePreview(boost::shared_ptr<ModelAPI_Feature> theFeature, bool isDisplay)
{
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
virtual QStringList nestedFeatures(QString theFeature);
std::string featureFile(const std::string&);
+ /// Creates an operation and send it to loop
+ /// \param theCmdId the operation name
virtual void launchOperation(const QString& theCmdId);
/// Displays or erase the current operation preview, if it has it.
/// \param theZ the Z projection value
void onPlaneSelected(double theX, double theY, double theZ);
+ void onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
+
/// SLOT, to visualize the feature in another local context mode
/// \param theFeature the feature to be put in another local context mode
/// \param theMode the mode appeared on the feature
void onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
int theMode);
+protected:
+ /// Creates a new operation
+ /// \param theCmdId the operation name
+ ModuleBase_Operation* createOperation(const QString& theCmdId);
+
+ /// Sends the operation
+ /// \param theOperation the operation
+ void sendOperation(ModuleBase_Operation* theOperation);
private:
XGUI_Workshop* myWorkshop;
--- /dev/null
+// File: PartSet_OperationEditLine.h
+// Created: 05 May 2014
+// Author: Natalia ERMOLAEVA
+
+#include <PartSet_OperationEditLine.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
+
+using namespace std;
+
+PartSet_OperationEditLine::PartSet_OperationEditLine(const QString& theId,
+ QObject* theParent,
+ boost::shared_ptr<ModelAPI_Feature> theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature)
+{
+}
+
+PartSet_OperationEditLine::~PartSet_OperationEditLine()
+{
+}
+
+bool PartSet_OperationEditLine::isGranted() const
+{
+ return true;
+}
+
+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);
+ return aModes;
+}
+
+void PartSet_OperationEditLine::init(boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+ setFeature(theFeature);
+}
+
+void PartSet_OperationEditLine::mouseReleased(const gp_Pnt& thePoint)
+{
+ /*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;
+ }
+*/
+}
+
+void PartSet_OperationEditLine::mouseMoved(const gp_Pnt& thePoint)
+{
+/* 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;
+ }
+*/
+}
+
+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;
+ }
+ */
+}
+
+void PartSet_OperationEditLine::setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape)
+{
+ if (theFeature == feature())
+ return;
+
+ commit();
+
+ if (theFeature)
+ emit launchOperation("EditLine", theFeature);
+}
+
+void PartSet_OperationEditLine::startOperation()
+{
+ //PartSet_OperationSketchBase::startOperation();
+ //myPointSelectionMode = SM_FirstPoint;
+}
+
+void PartSet_OperationEditLine::stopOperation()
+{
+ PartSet_OperationSketchBase::stopOperation();
+ //myPointSelectionMode = SM_None;
+}
+
+boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature()
+{
+ return boost::shared_ptr<ModelAPI_Feature>();
+}
+
+void PartSet_OperationEditLine::setLinePoint(const gp_Pnt& thePoint,
+ 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();
+}
--- /dev/null
+// File: PartSet_OperationEditLine.h
+// Created: 05 May 2014
+// Author: Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationEditLine_H
+#define PartSet_OperationEditLine_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <QObject>
+
+/*!
+ \class PartSet_OperationEditLine
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase
+{
+ Q_OBJECT
+public:
+ /// Constructor
+ /// \param theId the feature identifier
+ /// \param theParent the operation parent
+ /// \param theFeature the parent feature
+ PartSet_OperationEditLine(const QString& theId, QObject* theParent,
+ boost::shared_ptr<ModelAPI_Feature> theFeature);
+ /// Destructor
+ virtual ~PartSet_OperationEditLine();
+
+ /// Returns that this operator can be started above already running one.
+ /// The runned operation should be the sketch feature modified operation
+ virtual bool isGranted() const;
+
+ /// Returns the operation local selection mode
+ /// \param theFeature the feature object to get the selection mode
+ /// \return the selection mode
+ virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
+
+ /// Initializes some fields accorging to the feature
+ /// \param theFeature the feature
+ virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature);
+
+ /// 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);
+ /// 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);
+
+ /// Gives the current selected objects to be processed by the operation
+ /// \param theFeature the selected feature
+ /// \param theShape the selected shape
+ 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
+ virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
+
+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 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};
+
+private:
+ boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
+ //PointSelectionMode myPointSelectionMode; ///< point selection mode
+};
+
+#endif
return aModes;
}
-void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
+void PartSet_OperationSketch::setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape)
{
- if (theList.IsEmpty())
- return;
-
- if (isEditMode())
- return;
+ if (!isEditMode()) {
+ setSketchPlane(theShape);
+ setEditMode(true);
+ }
+ else if (theFeature)
+ emit launchOperation("EditLine", theFeature);
+}
+void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
+{
// get selected shape
- const TopoDS_Shape& aShape = theList.First();
boost::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
- aGShape->setImpl(new TopoDS_Shape(aShape));
+ aGShape->setImpl(new TopoDS_Shape(theShape));
// get plane parameters
boost::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
boost::shared_ptr<GeomDataAPI_Dir> aDirY =
boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
aDirY->setValue(aC, anA, aB);
-
boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
emit planeSelected(aDir->x(), aDir->y(), aDir->z());
-
- //commit();
- //SketchPlugin_Sketch::setActive(myFeature);
}
+
virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
/// Gives the current selected objects to be processed by the operation
- /// \param theList a list of interactive selected shapes
- /// \param theSelectedPoint a point clidked in the viewer
- virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList);
+ /// \param theFeature the selected feature
+ /// \param theShape the selected shape
+ 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 Y direction value of the plane
/// \param theX the value in the Z direction of the plane
void planeSelected(double theX, double theY, double theZ);
+
+protected:
+ /// Set the plane to the current sketch
+ /// \param theShape the shape
+ void setSketchPlane(const TopoDS_Shape& theShape);
};
#endif
/// \return the selection mode
virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const = 0;
+ /// Initializes some fields accorging to the feature
+ /// \param theFeature the feature
+ virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature) {}
+
/// Gives the current selected objects to be processed by the operation
- /// \param theList a list of interactive selected shapes
- virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList) {};
+ /// \param theFeature the selected feature
+ /// \param theShape the selected shape
+ virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape) {};
/// Processes the mouse release in the point
/// \param thePoint a point clicked in the viewer
/// \param theMode the mode of the feature modification
void featureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
int theMode);
+ /// signal about the request to launch operation
+ /// theName the operation name
+ /// theFeature the operation argument
+ void launchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
public:
/// temporary code to provide edition mode
myPointSelectionMode = SM_None;
}
-void PartSet_OperationSketchLine::createFeature()
+boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::createFeature()
{
- PartSet_OperationSketchBase::createFeature();
+ boost::shared_ptr<ModelAPI_Feature> aNewFeature = PartSet_OperationSketchBase::createFeature();
if (mySketch) {
boost::shared_ptr<SketchPlugin_Feature> aFeature =
boost::dynamic_pointer_cast<SketchPlugin_Feature>(mySketch);
- aFeature->addSub(feature());
+ aFeature->addSub(aNewFeature);
}
- //emit featureConstructed(aPrevFeature, FM_Activation);
+ //emit featureConstructed(aNewFeature, FM_Activation);
+ return aNewFeature;
}
void PartSet_OperationSketchLine::setLinePoint(const gp_Pnt& thePoint,
/// After the parent operation body perform, reset selection point mode of the operation
virtual void stopOperation();
- /// Creates a new feature and save it in the operation internal field.
- /// In addition to the default realization it set a sketch feature to the created feature
- virtual void createFeature();
+ /// Creates an operation new feature
+ /// In addition to the default realization it appends the created line feature to
+ /// the sketch feature
+ /// \returns the created feature
+ virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
protected:
/// \brief Save the point to the line.
aContext->UpdateCurrentViewer();
}
+boost::shared_ptr<ModelAPI_Feature> XGUI_Displayer::GetFeature(const TopoDS_Shape& theShape)
+{
+ boost::shared_ptr<ModelAPI_Feature> aFeature;
+
+ FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
+ aFLast = myFeature2AISObjectMap.end();
+ for (; aFIt != aFLast && !aFeature; aFIt++)
+ {
+ std::vector<Handle(AIS_InteractiveObject)> aDispAIS = (*aFIt).second;
+ std::vector<Handle(AIS_InteractiveObject)>::const_iterator anIt = aDispAIS.begin(),
+ aLast = aDispAIS.end();
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ for (; anIt != aLast && !aFeature; anIt++) {
+ Handle(AIS_InteractiveObject) anAIS = *anIt;
+ Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+ if (!anAISShape.IsNull() && anAISShape->Shape() == theShape) {
+ aFeature = (*aFIt).first;
+ }
+ }
+ }
+
+ return aFeature;
+}
+
void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
const bool isUpdateViewer)
{
void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
const bool isUpdateViewer = true);
+ /// Returns the feature, that was displayed with this shape
+ /// \param theShape a shape
+ boost::shared_ptr<ModelAPI_Feature> GetFeature( const TopoDS_Shape& theShape );
+
/// Display the shape and activate selection of sub-shapes
/// \param theFeature a feature instance
/// \param theShape a shape
protected:
XGUI_Workshop* myWorkshop;
- std::map<boost::shared_ptr<ModelAPI_Feature>, std::vector<Handle(AIS_InteractiveObject)> > myFeature2AISObjectMap;
+
+ typedef std::map<boost::shared_ptr<ModelAPI_Feature>, std::vector<Handle(AIS_InteractiveObject)> > FeatureToAISMap;
+ FeatureToAISMap myFeature2AISObjectMap;
};
#endif
(ModuleBase_Operation*)(aPartSetMsg->pointer());
if (myOperationMgr->startOperation(anOperation)) {
+ myPropertyPanel->updateContentWidget(anOperation->feature());
if (anOperation->getDescription()->xmlRepresentation().isEmpty()) {
anOperation->commit();
updateCommandStatus();