]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #283 All sketcher commands are disabled until sketcher plane is selected
authorsbh <sergey.belash@opencascade.com>
Fri, 28 Nov 2014 13:23:13 +0000 (16:23 +0300)
committersbh <sergey.belash@opencascade.com>
Fri, 28 Nov 2014 13:23:13 +0000 (16:23 +0300)
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationSketch.h [new file with mode: 0644]
src/PartSet/PartSet_WidgetSketchLabel.cpp

index a6c9c34e800b17fd35ffab39650ed045e2e8dfc2..c313a6ec9ab9434d2136ba1ad98fa809dd09a90e 100644 (file)
@@ -13,6 +13,7 @@ SET(PROJECT_HEADERS
        PartSet_WidgetPoint2d.h
        PartSet_WidgetPoint2dDistance.h
        PartSet_WidgetShapeSelector.h
+       PartSet_OperationSketch.h
 )
 
 SET(PROJECT_SOURCES
@@ -24,6 +25,7 @@ SET(PROJECT_SOURCES
        PartSet_WidgetPoint2d.cpp
        PartSet_WidgetPoint2dDistance.cpp
        PartSet_WidgetShapeSelector.cpp
+       PartSet_OperationSketch.cpp
 )
 
 SET(PROJECT_RESOURCES 
index e115736c35b88993ef33b63eb81f03514f86b102..d000d332717962236a9fb228c5a6992943012d46 100644 (file)
@@ -1,22 +1,16 @@
 #include "PartSet_Module.h"
-//#include <PartSet_OperationSketch.h>
-//#include <PartSet_OperationFeatureCreate.h>
-//#include <PartSet_OperationFeatureEdit.h>
-//#include <PartSet_Listener.h>
-//#include <PartSet_TestOCC.h>
-#include "PartSet_WidgetSketchLabel.h"
-#include "PartSet_Validators.h"
-#include "PartSet_Tools.h"
-#include "PartSet_WidgetPoint2D.h"
-#include "PartSet_WidgetPoint2dDistance.h"
-#include "PartSet_WidgetShapeSelector.h"
+#include <PartSet_OperationSketch.h>
+#include <PartSet_WidgetSketchLabel.h>
+#include <PartSet_Validators.h>
+#include <PartSet_Tools.h>
+#include <PartSet_WidgetPoint2D.h>
+#include <PartSet_WidgetPoint2dDistance.h>
+#include <PartSet_WidgetShapeSelector.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_IViewWindow.h>
 #include <ModuleBase_IPropertyPanel.h>
-//#include <ModuleBase_OperationDescription.h>
-//#include <ModuleBase_WidgetFactory.h>
 
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
 #include <SketchPlugin_ConstraintRadius.h>
 #include <SketchPlugin_ConstraintRigid.h>
 
-//#include <Config_PointerMessage.h>
-//#include <Config_ModuleReader.h>
-//#include <Config_WidgetReader.h>
-//#include <Events_Loop.h>
-//#include <Events_Message.h>
-//#include <Events_Error.h>
-
-//#include <GeomAPI_Shape.h>
-//#include <GeomAPI_AISObject.h>
-//#include <AIS_Shape.hxx>
-//#include <AIS_DimensionSelectionMode.hxx>
-
 #include <StdSelect_TypeOfFace.hxx>
 
 #include <QObject>
@@ -101,19 +83,6 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
           this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-  //myListener = new PartSet_Listener(this);
-
-//  connect(myWorkshop, SIGNAL(operationStarted(ModuleBase_Operation*)), 
-//    this, SLOT(onOperationStarted(ModuleBase_Operation*)));
-
-//  connect(myWorkshop, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
-//          SLOT(onOperationStopped(ModuleBase_Operation*)));
-
-  //XGUI_Workshop* aXWshop = xWorkshop();
-  //XGUI_ContextMenuMgr* aContextMenuMgr = aXWshop->contextMenuMgr();
-  //connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
-  //        SLOT(onContextMenuCommand(const QString&, bool)));
-
 }
 
 PartSet_Module::~PartSet_Module()
@@ -245,38 +214,8 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::onSelectionChanged()
 {
-  // Activate edit operation for sketcher objects
-  //ModuleBase_ISelection* aSelect = myWorkshop->selection();
-  //QObjectPtrList aObjects = aSelect->selectedPresentations();
-  //if (aObjects.size() == 1) {
-  //  FeaturePtr aFeature = ModelAPI_Feature::feature(aObjects.first());
-  //  if (aFeature) {
-  //    std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
-  //              std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-  //    if (aSPFeature) {
-  //      editFeature(aSPFeature);
-  //    }
-  //  }
-  //}
 }
 
-//ModuleBase_Operation* PartSet_Module::getNewOperation(const std::string& theFeatureId)
-//{
-//  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
-//  if (aOperation) {
-//    // If the current operation is sketcher sub-operation then we have to create 
-//    // Costomized operation
-//    if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
-//      PartSet_Operation* aPSOp = new PartSet_Operation(theFeatureId.c_str(), this);
-//      aPSOp->setWorkshop(myWorkshop);
-//      connect(myWorkshop, SIGNAL(selectionChanged()), aPSOp, SLOT(onSelectionChanged()));
-//      return aPSOp;
-//    }
-//  }
-//  return ModuleBase_IModule::getNewOperation(theFeatureId);
-//}
-
-
 void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
   if (!(theEvent->buttons() & Qt::LeftButton))
@@ -365,6 +304,16 @@ void PartSet_Module::launchEditing()
   }
 }
 
+/// Returns new instance of operation object (used in createOperation for customization)
+ModuleBase_Operation* PartSet_Module::getNewOperation(const std::string& theFeatureId)
+{
+  if (theFeatureId == PartSet_OperationSketch::Type()) {
+    return new PartSet_OperationSketch(theFeatureId.c_str(), this);
+  }
+  return ModuleBase_IModule::getNewOperation(theFeatureId);
+}
+
+
 void PartSet_Module::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
   if (myIsDragging) {
@@ -434,430 +383,6 @@ void PartSet_Module::onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& t
   }
 }
 
-
-//void PartSet_Module::featureCreated(QAction* theFeature)
-//{
-//  connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
-//}
-
-//std::string PartSet_Module::featureFile(const std::string& theFeatureId)
-//{
-//  return myFeaturesInFiles[theFeatureId];
-//}
-
-/*
- *
- */
-//void PartSet_Module::onFeatureTriggered()
-//{
-//  QAction* aCmd = dynamic_cast<QAction*>(sender());
-//  //Do nothing on uncheck
-//  if (aCmd->isCheckable() && !aCmd->isChecked())
-//    return;
-//  launchOperation(aCmd->data().toString());
-//}
-
-
-//void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
-//{
-//  XGUI_Workshop* aXWshp = xWorkshop();
-//  XGUI_Displayer* aDisplayer = aXWshp->displayer();
-//  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
-//  if (aPreviewOp) {
-//    XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
-//    connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
-//            SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
-//
-//    //aDisplayer->deactivateObjectsOutOfContext();
-//    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
-//    if (aSketchOp) {
-//      if (aSketchOp->isEditOperation()) {
-//        setSketchingMode(getSketchPlane(aSketchOp->feature()));
-//      } else {
-//        aDisplayer->openLocalContext();
-//        aDisplayer->activateObjectsOutOfContext(QIntList());
-//        myPlaneFilter = new StdSelect_FaceFilter(StdSelect_Plane);
-//        aDisplayer->addSelectionFilter(myPlaneFilter);
-//        QIntList aModes = sketchSelectionModes(aPreviewOp->feature());
-//        aDisplayer->setSelectionModes(aModes);
-//      } 
-//    }
-//  }
-//}
-
-//void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
-//{
-//  if (!theOperation)
-//    return;
-//  XGUI_Workshop* aXWshp = xWorkshop();
-//  XGUI_Displayer* aDisplayer = aXWshp->displayer();
-//  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
-//  if (aPreviewOp) {
-//    XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
-//
-//    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
-//    if (aSketchOp) {
-//      aDisplayer->closeLocalContexts();
-//    } else {
-//      PartSet_OperationFeatureCreate* aCreationOp = 
-//        dynamic_cast<PartSet_OperationFeatureCreate*>(aPreviewOp);
-//      if (aCreationOp) {
-//        // Activate just created object for selection
-//        FeaturePtr aFeature = aCreationOp->feature();
-//        QIntList aModes = sketchSelectionModes(aFeature);
-//        const std::list<ResultPtr>& aResults = aFeature->results();
-//        std::list<ResultPtr>::const_iterator anIt, aLast = aResults.end();
-//        for (anIt = aResults.begin(); anIt != aLast; anIt++) {
-//          aDisplayer->activate(*anIt, aModes);
-//        }
-//        aDisplayer->activate(aFeature, aModes);
-//        aDisplayer->clearSelected();
-//      }
-//    }
-//  }// else {
-//    // Activate results of current feature for selection
-//    //FeaturePtr aFeature = theOperation->feature();
-//    //XGUI_Displayer* aDisplayer = aXWshp->displayer();
-//    //std::list<ResultPtr> aResults = aFeature->results();
-//    //std::list<ResultPtr>::const_iterator aIt;
-//    //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-//    //  aDisplayer->activate(*aIt);
-//    //}    
-//  //}
-//}
-
-//void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
-//{
-//  QList<ObjectPtr> aFeatures = workshop()->selection()->selectedObjects();
-//  if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
-//    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
-//    if (aFeature)
-//      editFeature(aFeature);
-//  }
-//}
-
-//void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
-//{
-//  XGUI_Workshop* aXWshp = xWorkshop();
-//  PartSet_OperationSketchBase* aPreviewOp = 
-//    dynamic_cast<PartSet_OperationSketchBase*>(workshop()->currentOperation());
-//  if (aPreviewOp) {
-//    ModuleBase_ISelection* aSelection = workshop()->selection();
-//    aPreviewOp->mousePressed(theEvent, myWorkshop->viewer(), aSelection);
-//  }
-//}
-
-//void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
-//{
-//  PartSet_OperationSketchBase* aPreviewOp = 
-//    dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-//  if (aPreviewOp) {
-//    ModuleBase_ISelection* aSelection = workshop()->selection();
-//    // Initialise operation with preliminary selection
-//    aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer(), aSelection);
-//  }
-//}
-
-//void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
-//{
-//  PartSet_OperationSketchBase* aPreviewOp = 
-//    dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-//  if (aPreviewOp)
-//    aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer());
-//}
-
-//void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
-//{
-//  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-//  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-//  if (aPreviewOp) {
-//    aPreviewOp->keyReleased(theEvent->key());
-//  }
-//}
-
-//void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
-//{
-//  PartSet_OperationSketchBase* aPreviewOp = 
-//    dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-//  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
-//  if (aPreviewOp && (!aView.IsNull())) {
-//    ModuleBase_ISelection* aSelection = workshop()->selection();
-//    // Initialise operation with preliminary selection
-//    aPreviewOp->mouseDoubleClick(theEvent, aView, aSelection);
-//  }
-//}
-
-//void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
-//{
-//  myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
-//}
-
-//void PartSet_Module::onSketchLaunched()
-//{
-//  xWorkshop()->actionsMgr()->update();
-//  // Set working plane
-//  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-//  FeaturePtr aSketch = anOperation->feature();
-//  setSketchingMode(getSketchPlane(aSketch));
-//}
-
-//void PartSet_Module::onFitAllView()
-//{
-//  myWorkshop->viewer()->fitAll();
-//}
-
-//void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject)
-//{
-//  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-//
-//  std::string aKind = aFeature ? aFeature->getKind() : "";
-//  ModuleBase_Operation* anOperation = createOperation(theName, aKind);
-//
-//  PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-//  if (aSketchOp) {
-//    PartSet_OperationFeatureCreate* aCreateOp = dynamic_cast<PartSet_OperationFeatureCreate*>(anOperation);
-//    if (aCreateOp)
-//      aCreateOp->initFeature(aFeature);
-//    else {
-//      anOperation->setFeature(aFeature);
-//    }
-//    ModuleBase_ISelection* aSelection = workshop()->selection();
-//    // Initialise operation with preliminary selection
-//    aSketchOp->initSelection(aSelection, myWorkshop->viewer());
-//  } else if (aFeature) { // In case of edit operation: set the previously created feature to the operation
-//    anOperation->setFeature(aFeature);
-//    ////Deactivate result of current feature in order to avoid its selection
-//    XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-//    std::list<ResultPtr> aResults = aFeature->results();
-//    std::list<ResultPtr>::const_iterator aIt;
-//    for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-//      aDisplayer->deactivate(*aIt);
-//    }
-//  }
-//  sendOperation(anOperation);
-//  xWorkshop()->actionsMgr()->updateCheckState();
-//}
-
-//void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
-//{
-//  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-//  aViewer->enableMultiselection(theEnabled);
-//}
-
-//void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
-//{
-//  XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-//  //if (!isStop) {
-//  //  foreach(ObjectPtr aObject, theFeatures) {
-//  //    activateFeature(aObject);
-//  //  }
-//  //}
-//  aDisplayer->stopSelection(theFeatures, isStop, false);
-//
-//  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-//  aViewer->enableSelection(!isStop);
-//
-//  aDisplayer->updateViewer();
-//}
-
-//void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
-//{
-//  XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-//  aDisplayer->setSelected(theFeatures, false);
-//  aDisplayer->updateViewer();
-//}
-
-//void PartSet_Module::setSketchingMode(const gp_Pln& thePln)
-//{
-//  XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-//  if (!myPlaneFilter.IsNull()) {
-//    aDisplayer->removeSelectionFilter(myPlaneFilter);
-//    myPlaneFilter.Nullify();
-//  }
-//  QIntList aModes;
-//  // Clear standard selection modes
-//  aDisplayer->setSelectionModes(aModes);
-//  aDisplayer->openLocalContext();
-//
-//  // Set filter
-//  mySketchFilter = new ModuleBase_ShapeInPlaneFilter(thePln);
-//  aDisplayer->addSelectionFilter(mySketchFilter);
-//
-//  // Get default selection modes
-//  aModes = sketchSelectionModes(ObjectPtr());
-//  aDisplayer->activateObjectsOutOfContext(aModes);
-//}
-
-//void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
-//{
-//  bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
-//  ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
-//  PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
-//  if (aPrevOp) {
-//    std::list<FeaturePtr> aList = aPrevOp->subFeatures();
-//    XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-//    QIntList aModes = sketchSelectionModes(aPrevOp->feature());
-//    std::list<FeaturePtr>::iterator aSFIt;
-//    for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
-//      std::list<ResultPtr> aResults = (*aSFIt)->results();
-//      std::list<ResultPtr>::iterator aIt;
-//      for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
-//        if (!isDisplay)
-//          aDisplayer->erase((*aIt), false);
-//      }
-//      if (!isDisplay)
-//        aDisplayer->erase((*aSFIt), false);
-//    }
-//    //aDisplayer->deactivateObjectsOutOfContext();
-//  }
-//  if (isDisplay)
-//    ModelAPI_EventCreator::get()->sendUpdated(
-//        theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
-//}
-
-//ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
-//                                                      const std::string& theFeatureKind)
-//{
-//  // create the operation
-//  ModuleBase_Operation* anOperation = 0;
-//  if (theCmdId == PartSet_OperationSketch::Type()) {
-//    anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
-//  } else {
-//    ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
-//    CompositeFeaturePtr aSketch;
-//    PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
-//    if (aPrevOp) {
-//      aSketch = aPrevOp->sketch();
-//    }
-//    if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) {
-//      anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
-//    } else if (theCmdId == PartSet_OperationFeatureEdit::Type()) {
-//      anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
-//    }
-//  }
-//
-//  if (!anOperation) {
-//    anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
-//  }
-//
-//  // set operation description and list of widgets corresponding to the feature xml definition
-//  std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
-//
-//  std::string aPluginFileName = featureFile(aFeatureKind);
-//  Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
-//  aWdgReader.readAll();
-//  std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
-//  std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
-//
-//  anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
-//  anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
-//
-//  // connect the operation
-//  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-//  if (aPreviewOp) {
-//    connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)), this,
-//            SLOT(onFeatureConstructed(ObjectPtr, int)));
-//    connect(aPreviewOp, SIGNAL(restartRequired(std::string, ObjectPtr)), this,
-//            SLOT(onRestartOperation(std::string, ObjectPtr)));
-//    // If manage multi selection the it will be impossible to select more then one
-//    // object under operation Edit
-////    connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this,
-////            SLOT(onMultiSelectionEnabled(bool)));
-//
-//    connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)), this,
-//            SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
-//    connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)), this,
-//            SLOT(onSetSelection(const QList<ObjectPtr>&)));
-//
-//    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
-//    if (aSketchOp) {
-//      connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this,
-//              SLOT(onPlaneSelected(double, double, double)));
-//      connect(aSketchOp, SIGNAL(fitAllView()), this, SLOT(onFitAllView()));
-//      connect(aSketchOp, SIGNAL(launchSketch()), this, SLOT(onSketchLaunched()));
-//    }
-//  }
-//
-//  return anOperation;
-//}
-
-
-//void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
-//{
-//  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-//  if (!anOperation)
-//    return;
-//
-//  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-//  if (!aPreviewOp)
-//    return;
-//
-//  FeaturePtr aFeature = aPreviewOp->feature();
-//  if (!aFeature || aFeature->getKind() != theCmdId)
-//    return;
-//
-//  XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-//  // Hide result of sketch
-//  std::list<ResultPtr> aResults = aFeature->results();
-//  std::list<ResultPtr>::const_iterator aIt;
-//  for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt)
-//    aDisplayer->erase(*aIt, false);
-//
-//  std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
-//
-//  std::list<FeaturePtr>::const_iterator anIt = aList.begin(), aLast = aList.end();
-//  for (; anIt != aLast; anIt++) {
-//    std::shared_ptr<SketchPlugin_Feature> aSPFeature = std::dynamic_pointer_cast<
-//        SketchPlugin_Feature>(*anIt);
-//    if (!aSPFeature)
-//      continue;
-//    std::list<ResultPtr> aResults = aSPFeature->results();
-//    std::list<ResultPtr>::const_iterator aRIt;
-//    for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
-//      aDisplayer->display((*aRIt), false);
-//      aDisplayer->activate((*aRIt), sketchSelectionModes((*aRIt)));
-//    }
-//    aDisplayer->display(aSPFeature, false);
-//    aDisplayer->activate(aSPFeature, sketchSelectionModes(aSPFeature));
-//  }
-//  aDisplayer->updateViewer();
-//}
-
-//void PartSet_Module::editFeature(FeaturePtr theFeature)
-//{
-//  if (!theFeature)
-//    return;
-
-//  if (theFeature->getKind() == SKETCH_KIND) {
-  //FeaturePtr aFeature = theFeature;
-  //if (XGUI_Tools::isModelObject(aFeature)) {
-  //  ObjectPtr aObject = std::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
-  //  aFeature = aObject->featureRef();
-  //}
-
-  //if (aFeature) {
-//  onRestartOperation(theFeature->getKind(), theFeature);
-//  updateCurrentPreview(theFeature->getKind());
-  //}
-//  }
-//}
-
-//void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
-//{
-//  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
-//
-//  PartSet_OperationSketchBase* aPreviewOp = 
-//    dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-//  if (!aPreviewOp)
-//    return;
-//
-//  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-//      aFeature->data()->attribute(theAttribute));
-//
-//  PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute, aPoint->x(),
-//                                aPoint->y());
-//}
-
 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
                                             Config_WidgetAPI* theWidgetApi, std::string theParentId,
                                             QList<ModuleBase_ModelWidget*>& theModelWidgets)
@@ -900,69 +425,3 @@ QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget*
   }else
     return 0;
 }
-
-
-//XGUI_Workshop* PartSet_Module::xWorkshop() const
-//{
-//  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
-//  if (aConnector) {
-//    return aConnector->workshop();
-//  }
-//  return 0;
-//}
-
-
-//QIntList PartSet_Module::sketchSelectionModes(ObjectPtr theFeature)
-//{
-//  QIntList aModes;
-//  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
-//  if (aFeature) {
-//    if (aFeature->getKind() == SketchPlugin_Sketch::ID()) {
-//      aModes.append(TopAbs_FACE);
-//      return aModes;
-//    } else if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
-//      aModes.append(AIS_DSM_Text);
-//      aModes.append(AIS_DSM_Line);
-//      return aModes;
-//    }
-//  } 
-//  aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
-//  aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
-//  return aModes;
-//}
-
-
-//gp_Pln PartSet_Module::getSketchPlane(FeaturePtr theSketch) const
-//{
-//  DataPtr aData = theSketch->data();
-//  std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
-//      aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
-//  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-//      aData->attribute(SketchPlugin_Sketch::NORM_ID()));
-//  gp_Pnt aOrig(anOrigin->x(), anOrigin->y(), anOrigin->z());
-//  gp_Dir aDir(aNorm->x(), aNorm->y(), aNorm->z());
-//  return gp_Pln(aOrig, aDir);
-//}
-
-
-//void PartSet_Module::onSelectionChanged()
-//{
-//  ModuleBase_ISelection* aSelect = myWorkshop->selection();
-//  QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
-//  // We need to stop edit operation if selection is cleared
-//  if (aSelected.size() == 0) {
-//    // do not perform commit of the current edit operation here, because
-//    // this functionality is realized inside this operation
-//    /*PartSet_OperationFeatureEdit* anEditOp = 
-//      dynamic_cast<PartSet_OperationFeatureEdit*>(myWorkshop->currentOperation());
-//    if (!anEditOp)
-//      return;
-//    anEditOp->commit();*/
-//  } else {
-//    PartSet_OperationSketchBase* aSketchOp = 
-//      dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-//    if (aSketchOp) {
-//      aSketchOp->selectionChanged(aSelect);
-//    }
-//  }
-//}
index 3e6a7d2a054f889709162f7792d768dfb2797047..7c90584b8548ce9914254f306e0c1f18acba31a8 100644 (file)
@@ -31,89 +31,16 @@ Q_OBJECT
   PartSet_Module(ModuleBase_IWorkshop* theWshop);
   virtual ~PartSet_Module();
 
-  /// Reads description of features from XML file 
-  //virtual void createFeatures();
-
-  /// Called on creation of menu item in desktop
-  //virtual void featureCreated(QAction* 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);
-
-  /// Updates current operation preview, if it has it.
-  /// \param theCmdId the operation name
-  //void updateCurrentPreview(const std::string& theCmdId);
-
   /// Creates custom widgets for property panel
   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,
                                       QList<ModuleBase_ModelWidget*>& theModelWidgets);
 
-  //XGUI_Workshop* xWorkshop() const;
-
-
-  /// Returns list of selection modes for the given object for sketch operation
-  //static QIntList sketchSelectionModes(ObjectPtr theFeature);
-
   /// Call back forlast tuning of property panel before operation performance
   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
 
   QStringList sketchOperationIdList() const;
 
- public slots:
-  //void onFeatureTriggered();
-  /// SLOT, that is called after the operation is started. Connect on the focus activated signal
-  //void onOperationStarted(ModuleBase_Operation* theOperation);
-  /// SLOT, that is called after the operation is stopped. Switched off the modfications performed
-  /// by the operation start
-  //void onOperationStopped(ModuleBase_Operation* theOperation);
-  /// SLOT, that is called afetr the popup menu action clicked.
-  //void onContextMenuCommand(const QString& theId, bool isChecked);
-
-  /// SLOT, to apply to the current viewer the operation
-  /// \param theX the X projection value
-  /// \param theY the Y projection value
-  /// \param theZ the Z projection value
-  //void onPlaneSelected(double theX, double theY, double theZ);
-
-  /// SLOT, to fit all current viewer
-  //void onFitAllView();
-
-  //void onRestartOperation(std::string theName, ObjectPtr theFeature);
-
-  /// SLOT, to switch on/off the multi selection in the viewer
-  /// \param theEnabled the enabled state
-  //void onMultiSelectionEnabled(bool theEnabled);
-
-  /// SLOT, to stop or start selection mode for the features
-  /// \param theFeatures a list of features to be disabled
-  /// \param theToStop the boolean state whether it it stopped or non stopped
-  //void onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop);
-
-  /// SLOT, to set selection
-  /// \param theFeatures a list of features to be selected
-  //void onSetSelection(const QList<ObjectPtr>& theFeatures);
-
-  /// SLOT, Defines Sketch editing mode
-  /// \param thePln - plane of current sketch
-  //void setSketchingMode(const gp_Pln& thePln);
-
-  /// 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(ObjectPtr theFeature, int theMode);
-
-  /// Slot which reacts to the point 2d set to the feature. Creates a constraint
-  /// \param the feature
-  /// \param the attribute of the feature
-  //void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute);
-
-  /// Called when sketch is launched
-  //void onSketchLaunched();
-
 protected slots:
   /// Called when previous operation is finished
   virtual void onOperationComitted(ModuleBase_Operation* theOperation);
@@ -127,9 +54,6 @@ protected slots:
   /// Called when previous operation is finished
   virtual void onSelectionChanged();
 
-  /// Called on selection changed event
-  //virtual void onSelectionChanged();
-
   /// 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
@@ -145,28 +69,15 @@ protected slots:
   /// \param theEvent the mouse event
   virtual void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
-  /// SLOT, that is called by the mouse double click in the viewer.
-  /// \param theEvent the mouse event
-  //virtual void onMouseDoubleClick(QMouseEvent* theEvent);
-
-  /// SLOT, that is called by the key in the viewer is clicked.
-  /// \param theEvent the mouse event
-  //virtual void onKeyRelease(QKeyEvent* theEvent);
-
   /// Launches the operation from current highlighting
   void launchEditing();
 
  protected:
-  /// Register validators for this module
-  virtual void registerValidators();
-
   /// Returns new instance of operation object (used in createOperation for customization)
-  //virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
-
-  //! Edits the feature
-  //void editFeature(FeaturePtr theFeature);
+  virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
 
-  //gp_Pln getSketchPlane(FeaturePtr theSketch) const;
+  /// Register validators for this module
+  virtual void registerValidators();
 
  private slots:
    void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
@@ -180,13 +91,7 @@ protected slots:
   /// Breaks sequense of automatically resterted operations
   void breakOperationSequence();
 
-  //XGUI_Workshop* myWorkshop;
-  //PartSet_Listener* myListener;
-
-  //std::map<std::string, std::string> myFeaturesInFiles;
-
-  //Handle(StdSelect_FaceFilter) myPlaneFilter;
-  //Handle(ModuleBase_ShapeInPlaneFilter) mySketchFilter;
+ private:
    QString myLastOperationId;
    FeaturePtr myLastFeature;
 
diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp
new file mode 100644 (file)
index 0000000..fdf2ff6
--- /dev/null
@@ -0,0 +1,54 @@
+// File:        PartSet_OperationSketch.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationSketch.h>
+#include <PartSet_Tools.h>
+
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_ConstraintLength.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_Events.h>
+
+#include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomDataAPI_Point.h>
+#include <GeomDataAPI_Dir.h>
+#include <GeomAPI_XYZ.h>
+
+#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_ISelection.h>
+#include <ModuleBase_IViewer.h>
+#include <Events_Loop.h>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+#include <QMouseEvent>
+
+using namespace std;
+
+PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId, QObject* theParent)
+    : ModuleBase_Operation(theId, theParent)
+{
+}
+
+PartSet_OperationSketch::~PartSet_OperationSketch()
+{
+}
+
+bool PartSet_OperationSketch::isNestedOperationsEnabled() const
+{
+  bool aHasSketchPlane = false;
+  if (feature()) {
+    std::shared_ptr<ModelAPI_Data> aData = feature()->data();
+    AttributeDoublePtr anAttr;
+    std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+        aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+    aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
+  }
+  return aHasSketchPlane;
+}
diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h
new file mode 100644 (file)
index 0000000..f16a418
--- /dev/null
@@ -0,0 +1,43 @@
+// File:        PartSet_OperationSketch.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationSketch_H
+#define PartSet_OperationSketch_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_Operation.h>
+#include <SketchPlugin_Sketch.h>
+
+/*!
+ \class PartSet_OperationSketch
+ * \brief The operation for the sketch feature creation
+ */
+class PARTSET_EXPORT PartSet_OperationSketch : public ModuleBase_Operation
+{
+Q_OBJECT
+
+ public:
+  /// Returns the operation type key
+  static std::string Type()
+  {
+    return SketchPlugin_Sketch::ID();
+  }
+
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  PartSet_OperationSketch(const QString& theId, QObject* theParent);
+  /// Destructor
+  virtual ~PartSet_OperationSketch();
+
+  /// Returns whether the nested operations are enabled.
+  /// The state can depend on the operation current state.
+  /// It returns true after the sketch plane is choosen.
+  /// \return enabled state
+  virtual bool isNestedOperationsEnabled() const;
+
+};
+
+#endif
index def4e042e0e30b19c833cf5a2c6c40d577d184c5..a766918818c43b5f06ddeae28c6d4336c019b055 100644 (file)
@@ -10,6 +10,7 @@
 #include <XGUI_SelectionMgr.h>
 #include <XGUI_Selection.h>
 #include <XGUI_ViewerProxy.h>
+#include <XGUI_ActionsMgr.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_ViewerPrs.h>
@@ -104,6 +105,8 @@ void PartSet_WidgetSketchLabel::onPlaneSelected()
         aDisp->removeSelectionFilter(myPlaneFilter);
         aDisp->closeLocalContexts();
         setSketchingMode();
+        XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr();
+        anActMgr->update();
       }
     }
   }