ConstructionPlugin_Plugin.h
ConstructionPlugin_Point.h
ConstructionPlugin_Axis.h
+ ConstructionPlugin_Plane.h
)
SET(PROJECT_SOURCES
ConstructionPlugin_Plugin.cpp
ConstructionPlugin_Point.cpp
ConstructionPlugin_Axis.cpp
+ ConstructionPlugin_Plane.cpp
)
SET(XML_RESOURCES
plugin-Construction.xml
point_widget.xml
axis_widget.xml
+ plane_widget.xml
)
SET(PROJECT_LIBRARIES
using namespace std;
-static const double MINIMAL_LENGTH = 1.e-5;
+static const double MINIMAL_LENGTH = 1.e-5;
ConstructionPlugin_Axis::ConstructionPlugin_Axis()
{
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ConstructionPlugin_Plane.cpp
+// Created: 12 Dec 2014
+// Author: Vitaly Smetannikov
+
+#include "ConstructionPlugin_Plane.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <GeomAlgoAPI_FaceBuilder.h>
+
+
+#define PLANE_SIZE 300
+
+ConstructionPlugin_Plane::ConstructionPlugin_Plane()
+{
+}
+
+void ConstructionPlugin_Plane::initAttributes()
+{
+ data()->addAttribute(FACE_ATTR, ModelAPI_AttributeSelection::type());
+ data()->addAttribute(DISTANCE_ATTR, ModelAPI_AttributeDouble::type());
+}
+
+void ConstructionPlugin_Plane::execute()
+{
+ AttributeSelectionPtr aFaceAttr = data()->selection(FACE_ATTR);
+ AttributeDoublePtr aDistAttr = data()->real(DISTANCE_ATTR);
+ if ((aFaceAttr.get() != NULL) && (aDistAttr.get() != NULL) &&
+ aFaceAttr->isInitialized() && aDistAttr->isInitialized()) {
+
+ double aDist = aDistAttr->value();
+ GeomShapePtr aShape = aFaceAttr->value();
+ if (aShape.get() != NULL) {
+ std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_FaceBuilder::plane(aShape);
+ std::shared_ptr<GeomAPI_Pnt> aOrig = aPln->location();
+ std::shared_ptr<GeomAPI_Dir> aDir = aPln->direction();
+
+ aOrig->translate(aDir, aDist);
+ std::shared_ptr<GeomAPI_Shape> aPlane =
+ GeomAlgoAPI_FaceBuilder::square(aOrig, aDir, PLANE_SIZE);
+ ResultConstructionPtr aConstr = document()->createConstruction(data());
+ aConstr->setShape(aPlane);
+ setResult(aConstr);
+ }
+ }
+}
+
+void ConstructionPlugin_Plane::customisePresentation(AISObjectPtr thePrs)
+{
+ thePrs->setColor(50, 255, 50);
+ thePrs->setTransparensy(0.6);
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ConstructionPlugin_Plane.h
+// Created: 12 Dec 2014
+// Author: Vitaly Smetannikov
+
+#ifndef ConstructionPlugin_Plane_H
+#define ConstructionPlugin_Plane_H
+
+#include "ConstructionPlugin.h"
+#include <ModelAPI_Feature.h>
+#include <GeomAPI_ICustomPrs.h>
+
+/// Point kind
+const std::string CONSTRUCTION_PLANE_KIND("Plane");
+
+/// attribute name for base face
+const std::string FACE_ATTR = "planeFace";
+
+/// attribute name for distance
+const std::string DISTANCE_ATTR = "distance";
+
+/**\class ConstructionPlugin_Axis
+ * \ingroup DataModel
+ * \brief Feature for creation of the new axis in PartSet.
+ */
+class ConstructionPlugin_Plane : public ModelAPI_Feature, public GeomAPI_ICustomPrs
+{
+ public:
+ /// Returns the kind of a feature
+ CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = CONSTRUCTION_PLANE_KIND;
+ return MY_KIND;
+ }
+
+ /// Creates a new part document if needed
+ CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Construction result is allways recomuted on the fly
+ CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
+
+ /// Use plugin manager for features creation
+ ConstructionPlugin_Plane();
+
+ /// Customize presentation of the feature
+ virtual void customisePresentation(AISObjectPtr thePrs);
+};
+
+#endif
\ No newline at end of file
#include "ConstructionPlugin_Plugin.h"
#include "ConstructionPlugin_Point.h"
#include "ConstructionPlugin_Axis.h"
+#include "ConstructionPlugin_Plane.h"
#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
else if (theFeatureID == CONSTRUCTION_AXIS_KIND) {
return FeaturePtr(new ConstructionPlugin_Axis);
}
+ else if (theFeatureID == CONSTRUCTION_PLANE_KIND) {
+ return FeaturePtr(new ConstructionPlugin_Plane);
+ }
// feature of such kind is not found
return FeaturePtr();
}
--- /dev/null
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<source>
+ <shape_selector id="planeFace"
+ label="Plane face"
+ tooltip="Select a planar face for plane definition"
+ shape_types="face"
+ use_subshapes="true" />
+ <doublevalue id="distance"
+ label="Distance"
+ tooltip="Distance from selected face to plane"
+ default="0" />
+</source>
id="Plane"
title="Plane"
tooltip="Create a new plane"
- icon=":icons/plane.png"
- keysequence=""
- internal="true" />
+ icon=":icons/plane.png">
+ <source path="plane_widget.xml" />
+ </feature>
</group>
</workbench>
-</plugin>
\ No newline at end of file
+</plugin>
#include <BRepBndLib.hxx>
#include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
#include <AIS_LengthDimension.hxx>
#include <AIS_ParallelRelation.hxx>
#include <AIS_PerpendicularRelation.hxx>
aDrawer->LineAspect()->SetTypeOfLine((Aspect_TypeOfLine)theStyle);
if (aDrawer->HasWireAspect())
aDrawer->WireAspect()->SetTypeOfLine((Aspect_TypeOfLine)theStyle);
- //else {
- // Quantity_NameOfColor aCol = Quantity_NOC_RED;
- // aDrawer->SetLineAspect(new Prs3d_LineAspect(aCol, (Aspect_TypeOfLine)theStyle, 1));
- //}
+ }
+}
+
+
+void GeomAPI_AISObject::setTransparensy(double theVal)
+{
+ Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull()) {
+ Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
+ if (!aContext.IsNull())
+ aContext->SetTransparency(anAIS, theVal, false);
}
}
/// Set line type of edges
/// Has to be defined according to Aspect_TypeOfLine
void setLineStyle(int theStyle);
+
+ /// Set transparency of the presentation (theVal = 0 ... 1)
+ void setTransparensy(double theVal);
};
//! Pointer on attribute object
double aY = aVec.X() * theDirY->x() + aVec.Y() * theDirY->y() + aVec.Z() * theDirY->z();
return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
}
+
+
+void GeomAPI_Pnt::translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist)
+{
+ gp_Vec aVec(theDir->impl<gp_Dir>());
+ aVec.Normalize();
+ aVec.Multiply(theDist);
+ MY_PNT->Translate(aVec);
+}
std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
const std::shared_ptr<GeomAPI_Dir>& theDirX,
const std::shared_ptr<GeomAPI_Dir>& theDirY);
+
+ /// Translates the point along direction theDir on distance theDist
+ void translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist);
};
#endif
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
myResult2AISObjectMap[theObject] = theAIS;
+ aContext->Display(anAISIO, false);
+ aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
+
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
if (aFeature.get() != NULL) {
GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
if (aCustPrs.get() != NULL)
aCustPrs->customisePresentation(theAIS);
}
- aContext->Display(anAISIO, false);
- aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, isUpdateViewer);
if (aContext->HasOpenedContext()) {
if (myUseExternalObjects) {
if (myActiveSelectionModes.size() == 0)
}
}
}
+ if (isUpdateViewer)
+ updateViewer();
}
void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer)