/// attribute name of referenced face
inline static const std::string& FACE_ID()
{
- static const std::string MY_FACE_ID("FeaturesPlugin_Extrusion::FACE_ID()");
+ static const std::string MY_FACE_ID("extrusion_face");
return MY_FACE_ID;
}
/// attribute name of extrusion size
inline static const std::string& SIZE_ID()
{
- static const std::string MY_SIZE_ID("FeaturesPlugin_Extrusion::SIZE_ID()");
+ static const std::string MY_SIZE_ID("extrusion_size");
return MY_SIZE_ID;
}
/// attribute name of reverse direction
inline static const std::string& REVERSE_ID()
{
- static const std::string MY_REVERSE_ID("FeaturesPlugin_Extrusion::REVERSE_ID()");
+ static const std::string MY_REVERSE_ID("extrusion_reverse");
return MY_REVERSE_ID;
}
if (aFeature) {
if (myModule->workshop()->displayer()->isVisible(aFeature->firstResult()) ||
aType == EVENT_OBJECT_CREATED) {
- myModule->visualizePreview(aFeature, true, false);
- //if (aType == EVENT_OBJECT_CREATED)
myModule->activateFeature(aFeature, true);
+ // TODO myModule->visualizePreview(aFeature, true, false);
}
}
}
#endif
-//const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color
-const double SKETCH_WIDTH = 4.0; /// the plane edge width
-// face of the square-face displayed for selection of general plane
-const double PLANE_SIZE = 200;
-
-
/*!Create and return new instance of XGUI_Module*/
extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop)
{
std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
- PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
- if (aSketchOp) {
- if ((!aSketchOp->hasSketchPlane()) && (aSelected.size() > 0)) {
- Handle(AIS_InteractiveObject) aAIS = aSelected.front().interactive();
- if ((aAIS == myXPlane->impl<Handle(AIS_InteractiveObject)>()) ||
- (aAIS == myYPlane->impl<Handle(AIS_InteractiveObject)>()) ||
- (aAIS == myZPlane->impl<Handle(AIS_InteractiveObject)>()) ) {
-
- Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAIS);
- aSketchOp->setSketchPlane(aAISShape->Shape());
- }
- } else
- aSketchOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
- } else
- aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
+ aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
}
}
void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
{
- erasePlanes();
+ //erasePlanes();
myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
myWorkshop->actionsMgr()->update();
void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
{
- bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
+ ModelAPI_EventCreator::get()->sendUpdated(theFeature,
+ Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+
+/* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
// TODO visualizePreview(theFeature, isDisplay, false);
if (!isDisplay) {
ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
aLast = aList.end();
- for (; anIt != aLast; anIt++)
- visualizePreview((*anIt), false, false);
- aDisplayer->updateViewer();
+ //TODO for (; anIt != aLast; anIt++)
+ // visualizePreview((*anIt), false, false);
+ //aDisplayer->updateViewer();
}
}
if (theMode == PartSet_OperationSketchBase::FM_Activation ||
theMode == PartSet_OperationSketchBase::FM_Deactivation)
- activateFeature(theFeature, true);
+ activateFeature(theFeature, true);*/
}
ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
Events_Loop::loop()->send(aMessage);
}
-boost::shared_ptr<GeomAPI_Shape> getPlane(double theX, double theY, double theZ)
-{
- boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
- boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
- return GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
-}
-
-void PartSet_Module::showPlanes()
-{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- // Show selection planes
- if (!myXPlane) {
- boost::shared_ptr<GeomAPI_Shape> aPlaneX = getPlane(1, 0, 0);
- myXPlane = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
- myXPlane->createShape(aPlaneX);
- myXPlane->setColor(Colors::COLOR_RED);
- myXPlane->setWidth(SKETCH_WIDTH);
- }
- if (!myYPlane) {
- boost::shared_ptr<GeomAPI_Shape> aPlaneY = getPlane(0, 1, 0);
- myYPlane = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
- myYPlane->createShape(aPlaneY);
- myYPlane->setColor(Colors::COLOR_GREEN);
- myYPlane->setWidth(SKETCH_WIDTH);
- }
- if (!myZPlane) {
- boost::shared_ptr<GeomAPI_Shape> aPlaneZ = getPlane(0, 0, 1);
- myZPlane = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
- myZPlane->createShape(aPlaneZ);
- myZPlane->setColor(Colors::COLOR_BLUE);
- myZPlane->setWidth(SKETCH_WIDTH);
- }
- aDisplayer->display(myXPlane, false);
- aDisplayer->display(myYPlane, false);
- aDisplayer->display(myZPlane, false);
- aDisplayer->updateViewer();
-}
-
-void PartSet_Module::erasePlanes()
-{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- aDisplayer->erase(myXPlane, false);
- aDisplayer->erase(myYPlane, false);
- aDisplayer->erase(myZPlane, false);
- aDisplayer->updateViewer();
-}
-void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
+/*void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
const bool isUpdateViewer)
{
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
if (isUpdateViewer)
aDisplayer->updateViewer();
-}
+}*/
void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
{
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
- PartSet_OperationSketch* aOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
- if (!aOp) {
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
- isUpdateViewer);
- }
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
+ isUpdateViewer);
}
}
boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
if (!aSPFeature)
continue;
- visualizePreview((*anIt), true, false);
+ //visualizePreview((*anIt), true, false);
aDisplayer->activateInLocalContext((*anIt)->firstResult(), aModes, false);
}
aDisplayer->updateViewer();
/// \param theFeature the feature instance to be displayed
/// \param isDisplay the state whether the presentation should be displayed or erased
/// \param isUpdateViewer the flag whether the viewer should be updated
- void visualizePreview(FeaturePtr theFeature, bool isDisplay,
- const bool isUpdateViewer = true);
+ //void visualizePreview(FeaturePtr theFeature, bool isDisplay,
+ // const bool isUpdateViewer = true);
/// Activates the feature in the displayer
/// \param theFeature the feature instance to be displayed
//! Edits the feature
void editFeature(FeaturePtr theFeature);
-
- //! Shopws working planes in viewer 3d
- void showPlanes();
- void erasePlanes();
-
private:
XGUI_Workshop* myWorkshop;
PartSet_Listener* myListener;
std::map<std::string, std::string> myFeaturesInFiles;
-
- boost::shared_ptr<GeomAPI_AISObject> myXPlane;
- boost::shared_ptr<GeomAPI_AISObject> myYPlane;
- boost::shared_ptr<GeomAPI_AISObject> myZPlane;
};
#endif
}
}
ObjectPtr aFeature;
- if (!theSelected.empty()) {
+/* TODO if (!theSelected.empty()) {
ModuleBase_ViewerPrs aPrs = theSelected.front();
aFeature = aPrs.object();
- } else
- aFeature = feature(); // for the widget distance only
+ } else*/
+ aFeature = feature(); // for the widget distance only
bool isApplyed = setWidgetValue(aFeature, aX, anY);
if (isApplyed) {
{
}
-std::list<int> PartSet_OperationSketch::getSelectionModes(FeaturePtr theFeature) const
+std::list<int> PartSet_OperationSketch::getSelectionModes(ObjectPtr theFeature) const
{
std::list<int> aModes;
if (!hasSketchPlane())
else
myFeatures = theHighlighted;
+ } else {
+ if (!theHighlighted.empty()) {
+ ModuleBase_ViewerPrs aPrs = theHighlighted.front();
+ const TopoDS_Shape& aShape = aPrs.shape();
+ if (!aShape.IsNull())
+ setSketchPlane(aShape);
+ }
}
}
/// 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(FeaturePtr theFeature) const;
+ virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
/// Initializes the operation with previously created feature. It is used in sequental operations
virtual void initFeature(FeaturePtr theFeature);
#include "SketchPlugin.h"
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Sketch.h>
+#include <GeomAPI_IPresentable.h>
/**\class SketchPlugin_Arc
* \ingroup DataModel
* \brief Feature for creation of the new arc of circle in PartSet.
*/
-class SketchPlugin_Arc: public SketchPlugin_Feature
+class SketchPlugin_Arc: public SketchPlugin_Feature//, public GeomAPI_IPresentable
{
public:
/// Arc feature kind
#include "SketchPlugin.h"
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Sketch.h>
+#include <GeomAPI_IPresentable.h>
/**\class SketchPlugin_Circle
* \ingroup DataModel
* \brief Feature for creation of the new circle in PartSet.
*/
-class SketchPlugin_Circle: public SketchPlugin_Feature
+class SketchPlugin_Circle: public SketchPlugin_Feature//, public GeomAPI_IPresentable
{
public:
/// Circle feature kind
using namespace std;
+const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color
+const double SKETCH_WIDTH = 4.0; /// the plane edge width
+// face of the square-face displayed for selection of general plane
+const double PLANE_SIZE = 200;
+
+
SketchPlugin_Sketch::SketchPlugin_Sketch()
{
}
return boost::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir()));
}
+
+void addPlane(double theX, double theY, double theZ, std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes)
+{
+ boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
+ boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
+ boost::shared_ptr<GeomAPI_Shape> aFace =
+ GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
+ theShapes.push_back(aFace);
+}
+
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::
+ getAISObject(boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+{
+ boost::shared_ptr<GeomDataAPI_Dir> aNorm =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+
+ if (!aNorm || (aNorm->x() == 0 && aNorm->y() == 0 && aNorm->z() == 0)) {
+ boost::shared_ptr<GeomAPI_AISObject> aAIS = thePrevious;
+ if (!aAIS) {
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
+
+ addPlane(1, 0, 0, aFaces); // YZ plane
+ addPlane(0, 1, 0, aFaces); // XZ plane
+ addPlane(0, 0, 1, aFaces); // XY plane
+ boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
+ aAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
+ aAIS->createShape(aCompound);
+ aAIS->setColor(SKETCH_PLANE_COLOR);
+ aAIS->setWidth(SKETCH_WIDTH);
+ }
+ return aAIS;
+ }
+ return boost::shared_ptr<GeomAPI_AISObject>();
+}
#include <SketchPlugin_Feature.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Pln.h>
+#include <GeomAPI_IPresentable.h>
#include <list>
/**\class SketchPlugin_Sketch
* \ingroup DataModel
* \brief Feature for creation of the new part in PartSet.
*/
-class SketchPlugin_Sketch: public SketchPlugin_Feature
+class SketchPlugin_Sketch: public SketchPlugin_Feature, public GeomAPI_IPresentable
{
public:
/// Sketch feature kind
/// Returns the basis plane for the sketch
boost::shared_ptr<GeomAPI_Pln> plane();
+
+ virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+ boost::shared_ptr<GeomAPI_AISObject> thePrevious);
+
protected:
/// Creates a plane and append it to the list
/// \param theX the X normal value
} else {
boost::shared_ptr<GeomAPI_AISObject> anAIS;
- ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult) {
- boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
- if (aShapePtr) {
- anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
- anAIS->createShape(aShapePtr);
- }
+ GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+ if (aPrs) {
+ anAIS = aPrs->getAISObject(boost::shared_ptr<GeomAPI_AISObject>());
} else {
- GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
- if (aPrs) {
- anAIS = aPrs->getAISObject(boost::shared_ptr<GeomAPI_AISObject>());
+ ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult) {
+ boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+ if (aShapePtr) {
+ anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
+ anAIS->createShape(aShapePtr);
+ }
}
}
if (anAIS)
if (!isVisible(theObject))
return;
- ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult) {
- boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
- if (aShapePtr) {
- boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
- Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
- if (!aAISShape.IsNull()) {
- aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
- AISContext()->Redisplay(aAISShape, isUpdateViewer);
- }
+ boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+ GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+ if (aPrs) {
+ boost::shared_ptr<GeomAPI_AISObject> aAIS_Obj = aPrs->getAISObject(aAISObj);
+ if (aAISObj && !aAIS_Obj) {
+ erase(theObject, isUpdateViewer);
+ return;
}
+ Handle(AIS_InteractiveObject) aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
+ AISContext()->Redisplay(aAISIO, isUpdateViewer);
} else {
- GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
- if (aPrs) {
- boost::shared_ptr<GeomAPI_AISObject> aAISObj = aPrs->getAISObject(getAISObject(theObject));
- Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
- AISContext()->Redisplay(aAISIO, isUpdateViewer);
+ ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult) {
+ boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+ if (aShapePtr) {
+ Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
+ if (!aAISShape.IsNull()) {
+ aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
+ AISContext()->Redisplay(aAISShape, isUpdateViewer);
+ }
+ }
}
}
}
aContext->ClearCurrents(false);
aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
}
+/* std::list<int>::const_iterator anIt;
+ for (anIt = theModes.begin(); anIt != theModes.end(); anIt++)
+ aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt));
+ */
// display or redisplay presentation
Handle(AIS_InteractiveObject) anAIS;
if (isVisible(theResult))