Set plane for sketch and erase the sketch preview.
${CMAKE_SOURCE_DIR}/src/Events
${CMAKE_SOURCE_DIR}/src/ModuleBase
${CMAKE_SOURCE_DIR}/src/ModelAPI
+ ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI
${CMAKE_SOURCE_DIR}/src/SketchPlugin
${CMAKE_SOURCE_DIR}/src/GeomAPI
${CAS_INCLUDE_DIRS}
)
# The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
-TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI)
+TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI GeomAlgoAPI)
ADD_DEPENDENCIES(PartSet ModuleBase)
if (aPreviewOp) {
XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
if (aViewer) {
- AIS_ListOfInteractive aList;
- aViewer->getSelectedObjects(aList);
- aPreviewOp->setSelectedObjects(aList);
+ NCollection_List<TopoDS_Shape> aList;
+ aViewer->getSelectedShapes(aList);
+ aPreviewOp->setSelectedShapes(aList);
}
}
}
}
else {
myWorkshop->displayer()->GlobalSelection(false);
- myWorkshop->displayer()->Erase(anOperation->feature(), aPreviewOp->preview());
+ myWorkshop->displayer()->Erase(anOperation->feature());
}
}
#include <PartSet_OperationSketch.h>
-#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <GeomAlgoAPI_FaceBuilder.h>
#include <AIS_Shape.hxx>
#include <AIS_ListOfInteractive.hxx>
return TopAbs_FACE;
}
-void PartSet_OperationSketch::setSelectedObjects(const AIS_ListOfInteractive& theList)
+void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
{
if (theList.IsEmpty())
return;
- // 1. get selected fase
- Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(theList.First());
- if (anAISShape.IsNull())
- return;
-
- const TopoDS_Shape& aShape = anAISShape->Shape();
- boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
- aRes->setImpl(new TopoDS_Shape(aShape));
+ // get selected shape
+ const TopoDS_Shape& aShape = theList.First();
+ boost::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
+ aGShape->setImpl(new TopoDS_Shape(aShape));
// get plane parameters
- double anX = 1, anY = 0, aZ = 0, anOrigin = 0;
+ boost::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
// set plane parameters to feature
- //boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- //boost::shared_ptr<ModelAPI_AttributeDocRef> anAttr = aData->docRef(SKETCH_ATTR_X);
- //anAttr->setValue(anX);
+ boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+ double anA, aB, aC, aD;
+ aPlane->coefficients(anA, aB, aC, aD);
+
+ boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
+
+ aData->real(SKETCH_ATTR_PLANE_A)->setValue(anA);
+ aData->real(SKETCH_ATTR_PLANE_B)->setValue(aB);
+ aData->real(SKETCH_ATTR_PLANE_C)->setValue(aC);
+ aData->real(SKETCH_ATTR_PLANE_D)->setValue(aD);
+
+ //emit viewPlaneChanged();
commit();
}
virtual int getSelectionMode() const;
/// Gives the current selected objects to be processed by the operation
- /// \param theList a list of interactive selected objects
- virtual void setSelectedObjects(const AIS_ListOfInteractive& theList);
+ /// \param theList a list of interactive selected shapes
+ virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList);
};
#endif
#include "PartSet.h"
#include <TopoDS_Shape.hxx>
+#include <NCollection_List.hxx>
#include <ModuleBase_PropPanelOperation.h>
#include <QObject>
-class AIS_ListOfInteractive;
-
/*!
\class PartSet_OperationSketchBase
* \brief The base operation for the sketch features.
/// Gives the current selected objects to be processed by the operation
/// \param a list of interactive selected objects
- virtual void setSelectedObjects(const AIS_ListOfInteractive& aList) = 0;
+ virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList) = 0;
};
#endif
#include <AIS_InteractiveContext.hxx>
#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_Shape.hxx>
Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
+ std::vector<Handle(AIS_InteractiveObject)> aDispAIS;
+ if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end()) {
+ aDispAIS = myFeature2AISObjectMap[theFeature];
+ }
+ aDispAIS.push_back(anAIS);
+ myFeature2AISObjectMap[theFeature] = aDispAIS;
+
aContext->Display(anAIS, Standard_False);
if (isUpdateViewer)
}
void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
- const TopoDS_Shape& theShape, const bool isUpdateViewer)
+ const bool isUpdateViewer)
{
+ if (myFeature2AISObjectMap.find(theFeature) == myFeature2AISObjectMap.end())
+ return;
+
+ std::vector<Handle(AIS_InteractiveObject)> aDispAIS = myFeature2AISObjectMap[theFeature];
+ std::vector<Handle(AIS_InteractiveObject)>::const_iterator anIt = aDispAIS.begin(),
+ aLast = aDispAIS.end();
Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
- aContext->EraseAll();
+ for (; anIt != aLast; anIt++) {
+ Handle(AIS_InteractiveObject) anAIS = *anIt;
+ Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+ if (anAISShape.IsNull())
+ continue;
+ aContext->Erase(anAISShape);
+ }
+
if (isUpdateViewer)
aContext->UpdateCurrentViewer();
}
Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
+ std::vector<Handle(AIS_InteractiveObject)> aDispAIS;
+ if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end()) {
+ aDispAIS = myFeature2AISObjectMap[theFeature];
+ }
+ aDispAIS.push_back(anAIS);
+ myFeature2AISObjectMap[theFeature] = aDispAIS;
aContext->Display(anAIS, Standard_False);
+
AIS_ListOfInteractive anAISList;
anAISList.Append(anAIS);
myViewer->setLocalSelection(anAISList, theMode, true);
#include <boost/shared_ptr.hpp>
#include <TopoDS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
+
+#include <map>
+#include <vector>
class XGUI_Viewer;
class ModelAPI_Feature;
+
/**\class XGUI_Displayer
* \ingroup GUI
* \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
/// Erase the feature and a shape.
/// \param theFeature a feature instance
- /// \param theFeature a shape
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
- void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
- const bool isUpdateViewer = true);
+ void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
/// Deactivates selection of sub-shapes
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
protected:
XGUI_Viewer* myViewer; ///< the viewer where the objects should be visualized
+ std::map<boost::shared_ptr<ModelAPI_Feature>, std::vector<Handle(AIS_InteractiveObject)> > myFeature2AISObjectMap;
};
#endif
theList.Append(myAISContext->SelectedInteractive());
}
+void XGUI_Viewer::getSelectedShapes(NCollection_List<TopoDS_Shape>& theList)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+
+ for (ic->InitSelected(); ic->MoreSelected(); ic->NextSelected()) {
+ TopoDS_Shape aShape = ic->SelectedShape();
+ if (!aShape.IsNull())
+ theList.Append(aShape);
+ }
+}
+
void XGUI_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList)
{
AIS_ListIteratorOfListOfInteractive aIt;
#include <V3d_Viewer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Trihedron.hxx>
+#include <NCollection_List.hxx>
+#include <TopoDS_Shape.hxx>
class XGUI_MainWindow;
class QMdiSubWindow;
/// \param theList - list to be filled with selected objects
void getSelectedObjects(AIS_ListOfInteractive& theList);
+ /// Return shapes selected in 3D viewer
+ /// \param theList - list to be filled with selected shapes
+ void getSelectedShapes(NCollection_List<TopoDS_Shape>& theList);
+
/// Selects objects in 3D viewer. Other selected objects are left as selected
/// \param theList - list objects to be selected
void setObjectsSelected(const AIS_ListOfInteractive& theList);
//******************************************************
void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
{
- myMainWindow->hidePropertyPanel();
- updateCommandStatus();
+ ModuleBase_PropPanelOperation* aOperation =
+ (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
- XGUI_MainMenu* aMenu = myMainWindow->menuObject();
- aMenu->restoreCommandState();
+ if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
+ updateCommandStatus();
+ } else {
+ myMainWindow->hidePropertyPanel();
+ updateCommandStatus();
+
+ XGUI_MainMenu* aMenu = myMainWindow->menuObject();
+ aMenu->restoreCommandState();
+ }
}
/*