The OperationFeatureEditMulti remove. It is deleted, but in the FeatureEdit operation the flag isMultiOperation provide this operation algorithms.
PartSet_Module.h
PartSet_OperationFeatureCreate.h
PartSet_OperationFeatureEdit.h
- PartSet_OperationFeatureEditMulti.h
PartSet_OperationSketchBase.h
PartSet_OperationSketch.h
PartSet_OperationFeatureBase.h
PartSet_Module.cpp
PartSet_OperationFeatureCreate.cpp
PartSet_OperationFeatureEdit.cpp
- PartSet_OperationFeatureEditMulti.cpp
PartSet_OperationSketchBase.cpp
PartSet_OperationSketch.cpp
PartSet_OperationFeatureBase.cpp
#include <PartSet_Module.h>
#include <PartSet_OperationSketch.h>
#include <PartSet_OperationFeatureCreate.h>
-#include <PartSet_OperationFeatureEditMulti.h>
#include <PartSet_OperationFeatureEdit.h>
#include <PartSet_Listener.h>
#include <PartSet_TestOCC.h>
}
if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) {
anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
- } else if (theCmdId == PartSet_OperationFeatureEditMulti::Type()) {
- anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
} else if (theCmdId == PartSet_OperationFeatureEdit::Type()) {
anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
}
#include <PartSet_OperationFeatureEdit.h>
#include <PartSet_Tools.h>
#include <PartSet_OperationSketch.h>
-#include <PartSet_OperationFeatureEditMulti.h>
-
#include <SketchPlugin_Constraint.h>
#include <ModuleBase_OperationDescription.h>
QObject* theParent,
CompositeFeaturePtr theFeature)
: PartSet_OperationFeatureBase(theId, theParent, theFeature),
- myIsBlockedSelection(false)
+ myIsBlockedSelection(false), myIsMultiOperation(false)
{
myIsEditing = true;
}
if (!PartSet_Tools::isContainPresentation(aFeatures, aPrs))
aFeatures.append(aPrs);
}
+ myIsMultiOperation = aFeatures.size() > 1;
// 1. find all features with skipping features with selected vertex shapes
myFeature2Attribute.clear();
// firstly, collect the features without local selection
- /*foreach (ModuleBase_ViewerPrs aPrs, aFeatures) {
+ foreach (ModuleBase_ViewerPrs aPrs, aFeatures) {
const TopoDS_Shape& aShape = aPrs.shape();
if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected
const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
myFeature2Attribute[aFeature] = aList;
}
}
- }*/
+ }
// 2. collect the features with a local selection on them.
// if the list already has this feature, the local selection is skipped
// that means that if the selection contains a feature and a feature with local selected point,
void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection)
{
+ if (myIsMultiOperation)
+ return;
+
ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
if(aActiveWgt && aActiveWgt->isViewerSelector()) {
// Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased
// emit setSelection(aSelected);
//} else
if (aFeature) {
- std::string anOperationType =
- (aSelected.size() > 1) ?
- PartSet_OperationFeatureEditMulti::Type() : PartSet_OperationFeatureEdit::Type();
+ std::string anOperationType = PartSet_OperationFeatureEdit::Type();
restartOperation(anOperationType, aFeature);
}
//}
double aDeltaX = aX - aCurX;
double aDeltaY = anY - aCurY;
+ if (myIsMultiOperation) {
+ std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter = myFeature2Attribute.begin();
+ while (aFeatIter != myFeature2Attribute.end()) {
+ FeaturePtr aFeature = aFeatIter->first;
+ std::list<std::string> anAttributes = aFeatIter->second;
+ // perform edit for the feature
+ if (anAttributes.empty()) {
+ boost::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ if (aSketchFeature) {
+ aSketchFeature->move(aDeltaX, aDeltaY);
+ }
+ }
+ // perform edit for the feature's attribute
+ else {
+ std::list<std::string>::const_iterator anAttrIter = anAttributes.begin(),
+ anAttrEnd = anAttributes.end();
+ for (; anAttrIter != anAttrEnd; anAttrIter++) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aPointAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(*anAttrIter));
+ if (aPointAttr) {
+ aPointAttr->move(aDeltaX, aDeltaY);
+ }
+ }
+ }
+ aFeatIter++;
+ }
+ }
+ else { // multieditoperation
+
boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = boost::dynamic_pointer_cast<
SketchPlugin_Feature>(feature());
ModelAPI_EventCreator::get()->sendUpdated(feature(), anEvent);
}
}
+ } // multieditoperation
}
sendFeatures();
ModuleBase_ISelection* theSelection)
{
theViewer->enableSelection(true);
+ if (myIsMultiOperation) {
+ if (commit()) {
+ std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter = myFeature2Attribute.begin();
+ while (aFeatIter != myFeature2Attribute.end()) {
+ FeaturePtr aFeature = aFeatIter->first;
+ if (aFeature) {
+ emit featureConstructed(aFeature, FM_Deactivation);
+ }
+ aFeatIter++;
+ }
+ }
+ }
+ else { // multieditoperation
ModuleBase_ModelWidget* aActiveWgt = 0;
if (myPropertyPanel)
aActiveWgt = myPropertyPanel->activeWidget();
}// else {
//blockSelection(false);
//}
+ } // multieditoperation
}
void PartSet_OperationFeatureEdit::mouseDoubleClick(
//emit multiSelectionEnabled(true);
//blockSelection(false, false);
+
+ myFeature2Attribute.clear();
}
//void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isRestoreSelection)
{
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
- FeaturePtr aFeature = feature();
- ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
+ std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter = myFeature2Attribute.begin();
+ while (aFeatIter != myFeature2Attribute.end()) {
+ FeaturePtr aFeature = aFeatIter->first;
+ if (aFeature) {
+ ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
+ }
+ aFeatIter++;
+ }
Events_Loop::loop()->flush(anEvent);
flushUpdated();
Point myCurPoint; ///< the current 3D point clicked or moved
bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
+ bool myIsMultiOperation; // the state whether the operation is used for some features
};
#endif
+++ /dev/null
-// File: PartSet_OperationFeatureEditMulti.h
-// Created: 05 May 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_OperationFeatureEditMulti.h>
-#include <PartSet_Tools.h>
-#include <PartSet_OperationSketch.h>
-
-#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_IViewer.h>
-#include <ModuleBase_ISelection.h>
-
-#include <ModelAPI_Events.h>
-
-#include <SketchPlugin_Feature.h>
-#include <GeomDataAPI_Point2D.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-
-#include <ModelAPI_Events.h>
-
-#include <Events_Loop.h>
-
-#include <SketchPlugin_Line.h>
-
-#include <V3d_View.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS.hxx>
-#include <BRep_Tool.hxx>
-
-#include <QMouseEvent>
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-//using namespace std;
-
-PartSet_OperationFeatureEditMulti::PartSet_OperationFeatureEditMulti(const QString& theId,
- QObject* theParent,
- CompositeFeaturePtr theFeature)
- : PartSet_OperationSketchBase(theId, theParent),
- mySketch(theFeature),
- myIsBlockedSelection(false)
-{
- myIsEditing = true;
-}
-
-PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti()
-{
-}
-
-void PartSet_OperationFeatureEditMulti::initSelection(ModuleBase_ISelection* theSelection,
- ModuleBase_IViewer* theViewer)
-{
- // 1. unite selected and hightlighted objects in order to have an opportunity to drag
- // by the highlighted object
- QList<ModuleBase_ViewerPrs> aFeatures;
- aFeatures = theSelection->getSelected();
- QList<ModuleBase_ViewerPrs> aHighlighted = theSelection->getHighlighted();
- // add highlighted elements if they are not selected
- foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) {
- if (!PartSet_Tools::isContainPresentation(aFeatures, aPrs))
- aFeatures.append(aPrs);
- }
-
- // 1. find all features with skipping features with selected vertex shapes
- myFeature2Attribute.clear();
- // firstly, collect the features without local selection
- foreach (ModuleBase_ViewerPrs aPrs, aFeatures) {
- const TopoDS_Shape& aShape = aPrs.shape();
- if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected
- const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
- if (!aVertex.IsNull()) {
- continue;
- }
- }
- else {
- ObjectPtr aObject = aPrs.object();
- if (!aObject)
- continue;
- FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
- if (aFeature && myFeature2Attribute.find(aFeature) == myFeature2Attribute.end()) {
- std::list<std::string> aList;
- // using an empty list as a sign, that this feature should be moved itself
- myFeature2Attribute[aFeature] = aList;
- }
- }
- }
- // 2. collect the features with a local selection on them.
- // if the list already has this feature, the local selection is skipped
- // that means that if the selection contains a feature and a feature with local selected point,
- // the edit is performed for a full feature
- Handle(V3d_View) aView = theViewer->activeView();
- foreach (ModuleBase_ViewerPrs aPrs, aFeatures) {
- const TopoDS_Shape& aShape = aPrs.shape();
- if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected
- const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
- if (aVertex.IsNull())
- continue;
- ObjectPtr aObject = aPrs.object();
- if (!aObject)
- continue;
- FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
- if (!aFeature)
- continue;
- // if the feature is already moved, do nothing for this feature local selection
- if (myFeature2Attribute.find(aFeature) != myFeature2Attribute.end())
- continue;
-
- // append the attribute of the vertex if it is found on the current feature
- gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
- double aVX, aVY;
- PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aVX, aVY);
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D = PartSet_Tools::getFeaturePoint(
- aFeature, aVX, aVY);
- std::string anAttribute = aFeature->data()->id(aPoint2D);
- std::list<std::string> aList;
- if (myFeature2Attribute.find(aFeature) != myFeature2Attribute.end())
- aList = myFeature2Attribute[aFeature];
-
- aList.push_back(anAttribute);
- myFeature2Attribute[aFeature] = aList;
- }
- }
-}
-
-CompositeFeaturePtr PartSet_OperationFeatureEditMulti::sketch() const
-{
- return mySketch;
-}
-
-//void PartSet_OperationFeatureEditMulti::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection)
-//{
-//}
-
-void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer)
-{
- if (!(theEvent->buttons() & Qt::LeftButton))
- return;
-
- if (theViewer->isSelectionEnabled())
- theViewer->enableSelection(false);
-
- Handle(V3d_View) aView = theViewer->activeView();
- gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
-
- //blockSelection(true);
- if (myCurPoint.myIsInitialized) {
- double aCurX, aCurY;
- PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), aView, aCurX, aCurY);
-
- double aX, anY;
- PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY);
-
- double aDeltaX = aX - aCurX;
- double aDeltaY = anY - aCurY;
-
- std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter = myFeature2Attribute.begin();
- while (aFeatIter != myFeature2Attribute.end()) {
- FeaturePtr aFeature = aFeatIter->first;
- std::list<std::string> anAttributes = aFeatIter->second;
- // perform edit for the feature
- if (anAttributes.empty()) {
- boost::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- if (aSketchFeature) {
- aSketchFeature->move(aDeltaX, aDeltaY);
- }
- }
- // perform edit for the feature's attribute
- else {
- std::list<std::string>::const_iterator anAttrIter = anAttributes.begin(),
- anAttrEnd = anAttributes.end();
- for (; anAttrIter != anAttrEnd; anAttrIter++) {
- boost::shared_ptr<GeomDataAPI_Point2D> aPointAttr = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aFeature->data()->attribute(*anAttrIter));
- if (aPointAttr) {
- aPointAttr->move(aDeltaX, aDeltaY);
- }
- }
- }
- aFeatIter++;
- }
- }
- sendFeatures();
-
- myCurPoint.setPoint(aPoint);
-}
-
-void PartSet_OperationFeatureEditMulti::mouseReleased(
- QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
- ModuleBase_ISelection* theSelection)
-{
- theViewer->enableSelection(true);
- if (commit()) {
- std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter = myFeature2Attribute.begin();
- while (aFeatIter != myFeature2Attribute.end()) {
- FeaturePtr aFeature = aFeatIter->first;
- if (aFeature) {
- emit featureConstructed(aFeature, FM_Deactivation);
- }
- aFeatIter++;
- }
- }
-}
-
-void PartSet_OperationFeatureEditMulti::startOperation()
-{
- PartSet_OperationSketchBase::startOperation();
- //emit multiSelectionEnabled(false);
-
- //blockSelection(true);
-
- myCurPoint.clear();
-}
-
-void PartSet_OperationFeatureEditMulti::stopOperation()
-{
- //emit multiSelectionEnabled(true);
-
- //blockSelection(false, true);
-
- myFeature2Attribute.clear();
-}
-
-//void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked,
-// const bool isRestoreSelection)
-//{
-// if (myIsBlockedSelection == isBlocked)
-// return;
-//
-// myIsBlockedSelection = isBlocked;
-// QList<ObjectPtr> aFeatureList;
-//// std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast =
-//// myFeatures.end();
-// /*for(; anIt != aLast; anIt++)
-// aFeatureList.append((*anIt).feature());*/
-// //if (isBlocked) {
-// // emit setSelection(QList<ObjectPtr>());
-// // emit stopSelection(aFeatureList, true);
-// //} else {
-// // emit stopSelection(aFeatureList, false);
-// // if (isRestoreSelection) {
-// // emit setSelection(aFeatureList);
-// // }
-// //}
-//}
-
-void PartSet_OperationFeatureEditMulti::sendFeatures()
-{
- static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
-
- std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter = myFeature2Attribute.begin();
- while (aFeatIter != myFeature2Attribute.end()) {
- FeaturePtr aFeature = aFeatIter->first;
- if (aFeature) {
- ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
- }
- aFeatIter++;
- }
-
- Events_Loop::loop()->flush(anEvent);
- flushUpdated();
-}
-
+++ /dev/null
-// File: PartSet_OperationFeatureEditMulti.h
-// Created: 05 May 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_OperationFeatureEditMulti_H
-#define PartSet_OperationFeatureEditMulti_H
-
-#include "PartSet.h"
-
-#include <PartSet_OperationSketchBase.h>
-#include <QObject>
-#include <QList>
-
-#include <list>
-#include <map>
-
-class QMouseEvent;
-
-/*!
- \class PartSet_OperationFeatureEditMulti
- * \brief The operation for the sketch feature creation
- */
-class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : public PartSet_OperationSketchBase
-{
-Q_OBJECT
- /// Struct to define gp point, with the state is the point is initialized
- struct Point
- {
- /// Constructor
- Point()
- {
- }
- /// Constructor
- /// \param thePoint the point
- Point(gp_Pnt thePoint)
- {
- setPoint(thePoint);
- }
- ~Point()
- {
- }
-
- /// clear the initialized flag.
- void clear()
- {
- myIsInitialized = false;
- }
- /// set the point and switch on the initialized flag
- /// \param thePoint the point
- void setPoint(const gp_Pnt& thePoint)
- {
- myIsInitialized = true;
- myPoint = thePoint;
- }
-
- bool myIsInitialized; /// the state whether the point is set
- gp_Pnt myPoint; /// the point
- };
-
- public:
- /// Returns the operation type key
- static std::string Type()
- {
- return "EditMulti";
- }
-
- public:
- /// Constructor
- /// \param theId the feature identifier
- /// \param theParent the operation parent
- /// \param theFeature the parent feature
- PartSet_OperationFeatureEditMulti(const QString& theId, QObject* theParent,
- CompositeFeaturePtr theFeature);
- /// Destructor
- virtual ~PartSet_OperationFeatureEditMulti();
-
- /// Initialisation of operation with preliminary selection
- /// \param theSelected the list of selected presentations
- /// \param theHighlighted the list of highlighted presentations
- /// \param theViewer a viewer to have the viewer the eye position
- virtual void initSelection(ModuleBase_ISelection* theSelection,
- ModuleBase_IViewer* theViewer);
-
- /// Returns the operation sketch feature
- /// \returns the sketch instance
- virtual CompositeFeaturePtr sketch() const;
-
- /// Processes the mouse pressed in the point
- /// \param theEvent the mouse event
- /// \param theView a viewer to have the viewer the eye position
- /// \param theSelected the list of selected presentations
- /// \param theHighlighted the list of highlighted presentations
- //virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
-
- /// Gives the current mouse point in the viewer
- /// \param theEvent the mouse event
- /// \param theView a viewer to have the viewer the eye position
- virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
-
- /// Gives the current selected objects to be processed by the operation
- /// \param thePoint a point clicked in the viewer
- /// \param theEvent the mouse event
- /// \param theSelected the list of selected presentations
- /// \param theHighlighted the list of highlighted presentations
- virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
- ModuleBase_ISelection* theSelection);
-
- protected:
- /// \brief Virtual method called when operation is started
- /// Virtual method called when operation started (see start() method for more description)
- /// Switch off the multi selection state
- virtual void startOperation();
-
- /// Virtual method called when operation stopped - committed or aborted.
- /// Restore the multi selection state
- virtual void stopOperation();
-
- protected:
- /// Emits a signal about the selection blocking. Emits a signal to change the selection.
- /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
- /// the internal operation features are to be selected
- /// \param isBlocked the state whether the operation is blocked or unblocked
- /// \param isRestoreSelection the state whether the selected objects should be reselected
- //void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
-
- /// Sends the features
- void sendFeatures();
-
-private:
- // the next map should be removed when selection is processed in the move function
- std::map<FeaturePtr, std::list<std::string> > myFeature2Attribute; /// a map of a feature to attributes
-
- CompositeFeaturePtr mySketch; ///< the sketch feature
- Point myCurPoint; ///< the current 3D point clicked or moved
- bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
-};
-
-#endif
#include <PartSet_OperationSketch.h>
#include <PartSet_OperationFeatureEdit.h>
-#include <PartSet_OperationFeatureEditMulti.h>
#include <PartSet_Tools.h>
#include <SketchPlugin_Sketch.h>
//if (aSelected.size() > 0) {
ObjectPtr aFeature = aSelected.first().object();
if (aFeature) {
- std::string anOperationType =
- (aSelected.size() > 1) ?
- PartSet_OperationFeatureEditMulti::Type() : PartSet_OperationFeatureEdit::Type();
+ std::string anOperationType = PartSet_OperationFeatureEdit::Type();
restartOperation(anOperationType, aFeature);
}
}
FeaturePtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(), aView, feature(),
myFeatures);
if (aFeature)
- restartOperation(PartSet_OperationFeatureEditMulti::Type(), aFeature);
+ restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
}
}