../GeomAlgoAPI
../GeomValidators
../Events
+ ../Config
+ ${CAS_INCLUDE_DIRS}
)
SET(PROJECT_LIBRARIES
GeomAPI
GeomAlgoAPI
GeomValidators
+ Config
+ ${CAS_VIEWER}
+ ${CAS_SHAPE}
)
ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS)
#include <GeomAlgoAPI_ShapeTools.h>
+#include <Config_PropManager.h>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <AIS_LengthDimension.hxx>
+#include <AIS_RadiusDimension.hxx>
+#include <AIS_AngleDimension.hxx>
+#include <BRepExtrema_DistShapeShape.hxx>
+
#include <iomanip>
#include <sstream>
-FeaturesPlugin_Measurement::FeaturesPlugin_Measurement()
+FeaturesPlugin_Measurement::FeaturesPlugin_Measurement() : mySceenScale(1)
{
}
aValues->setSize(1);
aValues->setValue(0, anAngleValue);
}
+
+AISObjectPtr FeaturesPlugin_Measurement::getAISObject(AISObjectPtr thePrevious)
+{
+ AISObjectPtr anAIS;
+ std::string aKind = string(MEASURE_KIND())->value();
+ if (aKind == MEASURE_LENGTH())
+ anAIS = lengthDimension(thePrevious);
+ else if (aKind == MEASURE_DISTANCE())
+ anAIS = distanceDimension(thePrevious);
+ else if (aKind == MEASURE_RADIUS())
+ anAIS = radiusDimension(thePrevious);
+ else if (aKind == MEASURE_ANGLE())
+ anAIS = angleDimension(thePrevious);
+ else if (aKind == MEASURE_ANGLE_POINTS())
+ anAIS = angleByPointsDimension(thePrevious);
+ setupDimension(anAIS);
+ return anAIS;
+}
+
+AISObjectPtr FeaturesPlugin_Measurement::lengthDimension(AISObjectPtr thePrevious)
+{
+ AISObjectPtr aAISObj;
+ if (!myScreenPlane.get())
+ return aAISObj;
+
+ AttributeSelectionPtr aSelectedFeature = selection(EDGE_FOR_LENGTH_ID());
+
+ GeomShapePtr aShape;
+ GeomEdgePtr anEdge;
+ if (aSelectedFeature && aSelectedFeature->isInitialized()) {
+ aShape = aSelectedFeature->value();
+ if (!aShape && aSelectedFeature->context())
+ aShape = aSelectedFeature->context()->shape();
+ }
+ if (aShape && aShape->isEdge())
+ anEdge = GeomEdgePtr(new GeomAPI_Edge(aShape));
+ if (anEdge) {
+ TopoDS_Edge aTEdge = TopoDS::Edge(anEdge->impl<TopoDS_Shape>());
+ GeomPointPtr aPoint1 = anEdge->firstPoint();
+ GeomPointPtr aPoint2 = anEdge->lastPoint();
+
+ gp_Pnt aPnt1(aPoint1->impl<gp_Pnt>());
+ gp_Pnt aPnt2(aPoint2->impl<gp_Pnt>());
+
+ double aLength = aPnt1.Distance(aPnt2);
+ gp_Pln aPlane = myScreenPlane->impl<gp_Pln>(); // gce_MP.Value();
+ aPlane.SetLocation(aPnt1);
+
+ Handle(AIS_LengthDimension) aDim;
+ if (thePrevious.get()) {
+ aAISObj = thePrevious;
+ Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ aDim = Handle(AIS_LengthDimension)::DownCast(aAIS);
+ if (aDim.IsNull()) {
+ aDim = new AIS_LengthDimension(aTEdge, aPlane);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ } else {
+ aDim->SetMeasuredGeometry(aTEdge, aPlane);
+ }
+ } else {
+ aDim = new AIS_LengthDimension(aTEdge, aPlane);
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ }
+ aDim->SetFlyout(aLength / 3.);
+ }
+ return aAISObj;
+}
+
+AISObjectPtr FeaturesPlugin_Measurement::distanceDimension(AISObjectPtr thePrevious)
+{
+ AISObjectPtr aAISObj;
+ if (!myScreenPlane.get())
+ return aAISObj;
+
+ AttributeSelectionPtr aFirstFeature = selection(DISTANCE_FROM_OBJECT_ID());
+ AttributeSelectionPtr aSecondFeature = selection(DISTANCE_TO_OBJECT_ID());
+ if (aFirstFeature.get() && aSecondFeature.get()) {
+ GeomShapePtr aShape1;
+ GeomShapePtr aShape2;
+ if (aFirstFeature->isInitialized() && aSecondFeature->isInitialized()) {
+ aShape1 = aFirstFeature->value();
+ if (!aShape1 && aFirstFeature->context())
+ aShape1 = aFirstFeature->context()->shape();
+ aShape2 = aSecondFeature->value();
+ if (!aShape2 && aSecondFeature->context())
+ aShape2 = aSecondFeature->context()->shape();
+ }
+
+ if (aShape1 && aShape2) {
+ const TopoDS_Shape& aShp1 = aShape1->impl<TopoDS_Shape>();
+ const TopoDS_Shape& aShp2 = aShape2->impl<TopoDS_Shape>();
+ BRepExtrema_DistShapeShape aDist(aShp1, aShp2);
+ aDist.Perform();
+ if (aDist.IsDone()) {
+ gp_Pnt aPnt1 = aDist.PointOnShape1(1);
+ gp_Pnt aPnt2 = aDist.PointOnShape2(1);
+ double aDistance = aDist.Value();
+ gp_Pln aPlane = myScreenPlane->impl<gp_Pln>();
+ aPlane.SetLocation(aPnt1);
+
+ Handle(AIS_LengthDimension) aDim;
+ if (thePrevious.get()) {
+ aAISObj = thePrevious;
+ Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ aDim = Handle(AIS_LengthDimension)::DownCast(aAIS);
+ if (aDim.IsNull()) {
+ aDim = new AIS_LengthDimension(aPnt1, aPnt2, aPlane);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ } else {
+ aDim->SetMeasuredGeometry(aPnt1, aPnt2, aPlane);
+ aDim->SetFlyout(aDistance / 3.);
+ }
+ } else {
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ aDim = new AIS_LengthDimension(aPnt1, aPnt2, aPlane);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ }
+ aDim->SetFlyout(aDistance / 3.);
+ }
+ }
+ }
+ return aAISObj;
+}
+
+AISObjectPtr FeaturesPlugin_Measurement::radiusDimension(AISObjectPtr thePrevious)
+{
+ AISObjectPtr aAISObj;
+ AttributeSelectionPtr aSelectedFeature = selection(CIRCULAR_OBJECT_ID());
+
+ GeomShapePtr aShape;
+ if (aSelectedFeature && aSelectedFeature->isInitialized()) {
+ aShape = aSelectedFeature->value();
+ if (!aShape && aSelectedFeature->context())
+ aShape = aSelectedFeature->context()->shape();
+ }
+ if (aShape.get()) {
+ TopoDS_Shape aShp = aShape->impl<TopoDS_Shape>();
+ Handle(AIS_RadiusDimension) aDim;
+ if (thePrevious.get()) {
+ aAISObj = thePrevious;
+ Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ Handle(AIS_RadiusDimension) aDim = Handle(AIS_RadiusDimension)::DownCast(aAIS);
+ if (aDim.IsNull()) {
+ aDim = new AIS_RadiusDimension(aShp);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ } else
+ aDim->SetMeasuredGeometry(aShp);
+ } else {
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ Handle(AIS_RadiusDimension) aDim = new AIS_RadiusDimension(aShp);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ }
+ }
+ return aAISObj;
+}
+
+AISObjectPtr FeaturesPlugin_Measurement::angleDimension(AISObjectPtr thePrevious)
+{
+ AISObjectPtr aAISObj;
+ AttributeSelectionPtr aFirstFeature = selection(ANGLE_FROM_EDGE_ID());
+ GeomShapePtr aShape1;
+ GeomEdgePtr anEdge1;
+ if (aFirstFeature && aFirstFeature->isInitialized()) {
+ aShape1 = aFirstFeature->value();
+ if (!aShape1 && aFirstFeature->context())
+ aShape1 = aFirstFeature->context()->shape();
+ }
+ if (aShape1 && aShape1->isEdge())
+ anEdge1 = GeomEdgePtr(new GeomAPI_Edge(aShape1));
+
+ AttributeSelectionPtr aSecondFeature = selection(ANGLE_TO_EDGE_ID());
+ GeomShapePtr aShape2;
+ GeomEdgePtr anEdge2;
+ if (aSecondFeature && aSecondFeature->isInitialized()) {
+ aShape2 = aSecondFeature->value();
+ if (!aShape2 && aSecondFeature->context())
+ aShape2 = aSecondFeature->context()->shape();
+ }
+ if (aShape2 && aShape2->isEdge())
+ anEdge2 = GeomEdgePtr(new GeomAPI_Edge(aShape2));
+
+ if (anEdge1.get() && anEdge2.get()) {
+ TopoDS_Edge aTEdge1 = TopoDS::Edge(anEdge1->impl<TopoDS_Shape>());
+ TopoDS_Edge aTEdge2 = TopoDS::Edge(anEdge2->impl<TopoDS_Shape>());
+ Handle(AIS_AngleDimension) aDim;
+ if (thePrevious.get()) {
+ aAISObj = thePrevious;
+ Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ aDim = Handle(AIS_AngleDimension)::DownCast(aAIS);
+ if (aDim.IsNull()) {
+ aDim = new AIS_AngleDimension(aTEdge1, aTEdge2);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ } else
+ aDim->SetMeasuredGeometry(aTEdge1, aTEdge2);
+ } else {
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ aDim = new AIS_AngleDimension(aTEdge1, aTEdge2);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ }
+ }
+ return aAISObj;
+}
+
+AISObjectPtr FeaturesPlugin_Measurement::angleByPointsDimension(AISObjectPtr thePrevious)
+{
+ AISObjectPtr aAISObj;
+ GeomVertexPtr aVertex1 = selectionToVertex(selection(ANGLE_POINT1_ID()));
+ GeomVertexPtr aVertex2 = selectionToVertex(selection(ANGLE_POINT2_ID()));
+ GeomVertexPtr aVertex3 = selectionToVertex(selection(ANGLE_POINT3_ID()));
+
+ if (aVertex1.get() && aVertex2.get() && aVertex3.get()) {
+ GeomPointPtr aPoint1 = aVertex1->point();
+ GeomPointPtr aPoint2 = aVertex2->point();
+ GeomPointPtr aPoint3 = aVertex3->point();
+ gp_Pnt aPnt1(aPoint1->impl<gp_Pnt>());
+ gp_Pnt aPnt2(aPoint2->impl<gp_Pnt>());
+ gp_Pnt aPnt3(aPoint3->impl<gp_Pnt>());
+
+ if (thePrevious.get()) {
+ aAISObj = thePrevious;
+ Handle(AIS_InteractiveObject) aAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ Handle(AIS_AngleDimension) aDim = Handle(AIS_AngleDimension)::DownCast(aAIS);
+ if (aDim.IsNull()) {
+ aDim = new AIS_AngleDimension(aPnt1, aPnt2, aPnt3);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ } else
+ aDim->SetMeasuredGeometry(aPnt1, aPnt2, aPnt3);
+ } else {
+ Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aPnt1, aPnt2, aPnt3);
+ aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aDim));
+ }
+ }
+ return aAISObj;
+}
+
+
+void FeaturesPlugin_Measurement::setupDimension(AISObjectPtr theDim)
+{
+ if (theDim.get()) {
+ Handle(AIS_InteractiveObject) aAIS = theDim->impl<Handle(AIS_InteractiveObject)>();
+ Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAIS);
+ int aSize = Config_PropManager::integer("Visualization", "dimension_arrow_size");
+ int aTextSize = Config_PropManager::integer("Visualization", "dimension_value_size");
+
+ Handle(Prs3d_DimensionAspect) anAspect = aDim->DimensionAspect();
+ anAspect->MakeArrows3d(false);
+ anAspect->MakeText3d(false);
+ anAspect->MakeTextShaded(false);
+ anAspect->MakeUnitsDisplayed(false);
+ anAspect->MakeUnitsDisplayed(false);
+ anAspect->TextAspect()->SetFont(Config_PropManager::string("Visualization",
+ "dimension_font").c_str());
+ anAspect->TextAspect()->SetHeight(aTextSize / mySceenScale);
+ anAspect->ArrowAspect()->SetLength(aSize / mySceenScale);
+ anAspect->SetExtensionSize((aTextSize / mySceenScale + aSize) / 2.0);
+ aDim->SetDimensionAspect(anAspect);
+
+ aDim->SetZLayer(1);
+ std::vector<int> aColor = Config_PropManager::color("Visualization", "sketch_dimension_color");
+ theDim->setColor(aColor[0], aColor[1], aColor[2]);
+ }
+}
#include "FeaturesPlugin.h"
#include <ModelAPI_Feature.h>
+#include <GeomAPI_IPresentable.h>
+#include <GeomAPI_IScreenParams.h>
+
/// \class FeaturesPlugin_Measurement
/// \ingroup Plugins
/// \brief Feature for calculation metrics.
/// * distance between shapes,
/// * radius of arc or cylindrical faces,
/// * angle between edges.
-class FeaturesPlugin_Measurement : public ModelAPI_Feature
+class FeaturesPlugin_Measurement : public ModelAPI_Feature,
+ public GeomAPI_IPresentable,
+ public GeomAPI_IScreenParams
{
public:
/// Feature kind.
/// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
virtual bool isMacro() const { return true; }
+ /** Returns the AIS preview
+ * \param thePrevious - defines a presentation if it was created previously
+ */
+ FEATURESPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
+
+ /// Set current screen plane
+ /// \param theScreenPlane the screen plane
+ virtual void setScreenPlane(GeomPlanePtr theScreenPlane) {
+ myScreenPlane = theScreenPlane;
+ }
+
+ /// Set current view scale
+ /// \param theScale the view scale
+ virtual void setViewScale(double theScale) {
+ mySceenScale = theScale;
+ }
+
/// Use plugin manager for features creation
FeaturesPlugin_Measurement();
void computeAngle();
/// Compute angle by three points
void computeAngleByPoints();
+
+ /// Create length dimension presentation
+ /// \param thePrevious previous version of presentation
+ AISObjectPtr lengthDimension(AISObjectPtr thePrevious);
+
+ /// Create distance dimension presentation
+ /// \param thePrevious previous version of presentation
+ AISObjectPtr distanceDimension(AISObjectPtr thePrevious);
+
+ /// Create radius dimension presentation
+ /// \param thePrevious previous version of presentation
+ AISObjectPtr radiusDimension(AISObjectPtr thePrevious);
+
+ /// Create angle dimension presentation
+ /// \param thePrevious previous version of presentation
+ AISObjectPtr angleDimension(AISObjectPtr thePrevious);
+
+ /// Create angle by points dimension presentation
+ /// \param thePrevious previous version of presentation
+ AISObjectPtr angleByPointsDimension(AISObjectPtr thePrevious);
+
+ /// Set dimension presentation parameters
+ void setupDimension(AISObjectPtr theDim);
+
+ GeomPlanePtr myScreenPlane; //< a plane of current screen
+ double mySceenScale; //< a scale of current view
};
#endif
GeomAPI_Ellipse.h
GeomAPI_Ellipse2d.h
GeomAPI_Tools.h
+ GeomAPI_IScreenParams.h
)
SET(PROJECT_SOURCES
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef GeomAPI_IScreenParams_H_
+#define GeomAPI_IScreenParams_H_
+
+#include "GeomAPI_Pln.h"
+
+/**
+* A class which defines an interface of object which has to be provided with
+* current screen parameters
+*/
+class GeomAPI_IScreenParams
+{
+public:
+ virtual ~GeomAPI_IScreenParams() {}
+
+ /**
+ * Set plane of active view screen
+ * \param theScreenPlane - the screen plane
+ */
+ virtual void setScreenPlane(GeomPlanePtr theScreenPlane) = 0;
+
+ /**
+ * Set a scale of active view
+ * \param theScale a view scale
+ */
+ virtual void setViewScale(double theScale) = 0;
+};
+
+typedef std::shared_ptr<GeomAPI_IScreenParams> GeomScreenParamsPtr;
+
+#endif
\ No newline at end of file
"Hidden faces transparency",
Config_Prop::DblSpin,
"0.8");
+ std::ostringstream aStream;
+ aStream << SketcherPrs_Tools::getDefaultArrowSize();
+ Config_PropManager::registerProp("Visualization", "dimension_arrow_size",
+ "Dimension arrow size", Config_Prop::IntSpin, aStream.str());
+
+ Config_PropManager::registerProp("Visualization", "dimension_font", "Dimension font",
+ Config_Prop::String, "Times-bold");
+
+ aStream.str("");
+ aStream.clear();
+ aStream << SketcherPrs_Tools::getDefaultTextHeight();
+ Config_PropManager::registerProp("Visualization", "dimension_value_size",
+ "Dimension value size", Config_Prop::IntSpin, aStream.str());
+
+ Config_PropManager::registerProp("Visualization", "sketch_dimension_color",
+ "Sketch dimension color",
+ Config_Prop::Color, SKETCH_DIMENSION_COLOR);
}
//******************************************************
if (aView.IsNull())
return;
+ bool isModified = false;
ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
if (aCurrentOperation &&
(PartSet_SketcherMgr::isSketchOperation(aCurrentOperation) ||
- sketchMgr()->isNestedSketchOperation(aCurrentOperation)))
+ sketchMgr()->isNestedSketchOperation(aCurrentOperation) ||
+ (aCurrentOperation->id() == "Measurement")))
{
double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
SketcherPrs_Tools::setArrowSize(aLen);
const double aCurScale = aViewer->activeView()->Camera()->Scale();
aViewer->SetScale(aViewer->activeView(), aCurScale);
- bool isModified = false;
QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
foreach (AISObjectPtr aAIS, aPrsList) {
Handle(AIS_InteractiveObject) aAisObj = aAIS->impl<Handle(AIS_InteractiveObject)>();
if (isModified)
aDisplayer->updateViewer();
}
+
}
//******************************************************
"Sketch auxiliary entity color",
Config_Prop::Color, SKETCH_AUXILIARY_COLOR);
- Config_PropManager::registerProp("Visualization", "sketch_dimension_color",
- "Sketch dimension color",
- Config_Prop::Color, SKETCH_DIMENSION_COLOR);
-
Config_PropManager::registerProp("Visualization", "sketch_overconstraint_color",
"Sketch overconstraint color",
Config_Prop::Color, SKETCH_OVERCONSTRAINT_COLOR);
Config_Prop::Color, XY_PLANE_COLOR);
#endif
- Config_PropManager::registerProp(SKETCH_TAB_NAME, "dimension_font", "Dimension font",
- Config_Prop::String, "Times-bold");
- std::ostringstream aStream;
- aStream << SketcherPrs_Tools::getDefaultTextHeight();
-
- Config_PropManager::registerProp(SKETCH_TAB_NAME, "dimension_value_size",
- "Dimension value size", Config_Prop::IntSpin, aStream.str());
- aStream.str("");
- aStream.clear();
- aStream << SketcherPrs_Tools::getDefaultArrowSize();
- Config_PropManager::registerProp(SKETCH_TAB_NAME, "dimension_arrow_size",
- "Dimension arrow size", Config_Prop::IntSpin, aStream.str());
}
FeaturePtr SketchPlugin_Plugin::createFeature(std::string theFeatureID)
theDimAspect->SetExtensionSize(
(theTextSize / aViewerScale + SketcherPrs_Tools::getArrowSize()) / 2.0);
}
- theDimAspect->TextAspect()->SetFont(Config_PropManager::string(SKETCH_TAB_NAME,
+ theDimAspect->TextAspect()->SetFont(Config_PropManager::string("Visualization",
"dimension_font").c_str());
theDimAspect->SetArrowTailSize(theDimAspect->ArrowAspect()->Length());
int getConfigArrowSize()
{
- return Config_PropManager::integer(SKETCH_TAB_NAME, "dimension_arrow_size");
+ return Config_PropManager::integer("Visualization", "dimension_arrow_size");
}
static double MyTextHeight = 16;
double getConfigTextHeight()
{
- return Config_PropManager::integer(SKETCH_TAB_NAME, "dimension_value_size");
+ return Config_PropManager::integer("Visualization", "dimension_value_size");
}
double getFlyoutDistance(const ModelAPI_Feature* theConstraint)
#include <GeomAPI_Shape.h>
#include <GeomAPI_IPresentable.h>
#include <GeomAPI_ICustomPrs.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_IScreenParams.h>
#include <SUIT_ResourceMgr.h>
GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
bool isShading = false;
if (aPrs.get() != NULL) {
+ GeomScreenParamsPtr aScreen = std::dynamic_pointer_cast<GeomAPI_IScreenParams>(theObject);
+ if (aScreen.get()) {
+ aScreen->setScreenPlane(getScreenPlane());
+ aScreen->setViewScale(getViewScale());
+ }
anAIS = aPrs->getAISObject(anAIS);
- if (anAIS.get()) {
+ //if (anAIS.get()) {
// correct deviation coefficient for
/*Handle(AIS_InteractiveObject) anAISPrs = anAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISPrs.IsNull()) {
//ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, anAISPrs->Attributes());
}
}*/
- }
+ //}
} else {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (aResult.get() != NULL) {
GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
if (aPrs) {
+ GeomScreenParamsPtr aScreen = std::dynamic_pointer_cast<GeomAPI_IScreenParams>(theObject);
+ if (aScreen.get()) {
+ aScreen->setScreenPlane(getScreenPlane());
+ aScreen->setViewScale(getViewScale());
+ }
AISObjectPtr aAIS_Obj = aPrs->getAISObject(aAISObj);
if (!aAIS_Obj) {
aRedisplayed = erase(theObject, theUpdateViewer);
{
return myWorkshop->selectionActivate();
}
+
+//**************************************************************
+GeomPlanePtr XGUI_Displayer::getScreenPlane() const
+{
+ GeomPlanePtr aResult;
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (!aContext.IsNull()) {
+ Handle(V3d_Viewer) aViewer = aContext->CurrentViewer();
+ Handle(V3d_View) aView;
+ for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) {
+ aView = aViewer->ActiveView();
+ break;
+ }
+ if (!aView.IsNull()) {
+ double aEyeX, aEyeY, aEyeZ;
+ aView->Eye(aEyeX, aEyeY, aEyeZ);
+
+ double aProjX, aProjY, aProjZ;
+ aView->Proj(aProjX, aProjY, aProjZ);
+
+ GeomPointPtr aPnt = GeomPointPtr(new GeomAPI_Pnt(aEyeX, aEyeY, aEyeZ));
+ GeomDirPtr aDir = GeomDirPtr(new GeomAPI_Dir(aProjX, aProjY, aProjZ));
+
+ aResult = GeomPlanePtr(new GeomAPI_Pln(aPnt, aDir));
+ }
+ }
+ return aResult;
+}
+
+double XGUI_Displayer::getViewScale() const
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (!aContext.IsNull()) {
+ Handle(V3d_Viewer) aViewer = aContext->CurrentViewer();
+ Handle(V3d_View) aView;
+ for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) {
+ aView = aViewer->ActiveView();
+ break;
+ }
+ return aView->Camera()->Scale();
+ }
+ return 1;
+}
#include <GeomAPI_AISObject.h>
#include <GeomAPI_ICustomPrs.h>
+#include <GeomAPI_Pln.h>
#include <ModelAPI_Result.h>
/// \return a boolean value
static bool isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject);
+
+ /// Returns screen plane of active view
+ GeomPlanePtr getScreenPlane() const;
+
+ /// Returns scale of active view
+ double getViewScale() const;
+
signals:
/// Signal on object display
/// \param theObject a data object