]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2504: Dimension presentations were added
authorvsv <vsv@opencascade.com>
Tue, 31 Jul 2018 14:06:53 +0000 (17:06 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 10 Aug 2018 07:37:22 +0000 (10:37 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp
src/FeaturesPlugin/FeaturesPlugin_Measurement.h
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI_IScreenParams.h [new file with mode: 0644]
src/PartSet/PartSet_Module.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_Tools.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index 3159cfe72174c4de6a2cc6471cf33a75c5946b86..9d466ae6797e21961aaa5c28ce75b13be4bf27b5 100644 (file)
@@ -133,6 +133,8 @@ INCLUDE_DIRECTORIES(
   ../GeomAlgoAPI
   ../GeomValidators
   ../Events
+  ../Config
+  ${CAS_INCLUDE_DIRS}
 )
 
 SET(PROJECT_LIBRARIES
@@ -141,6 +143,9 @@ SET(PROJECT_LIBRARIES
     GeomAPI
     GeomAlgoAPI
     GeomValidators
+    Config
+    ${CAS_VIEWER}
+    ${CAS_SHAPE}
 )
 
 ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS)
index f038ecc954c613a43005cfe84be48b0d4755a247..56cc199db42d8679483f91ab3281795c2f17948b 100644 (file)
 
 #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)
 {
 }
 
@@ -305,3 +315,267 @@ void FeaturesPlugin_Measurement::computeAngleByPoints()
   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]);
+  }
+}
index 27eefc4d55f25dcee09624fb5cdb5f93f0e48c51..562d998a7537e3f75074510b93ae62465c40a4b9 100644 (file)
@@ -24,6 +24,9 @@
 #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.
@@ -33,7 +36,9 @@
 /// * 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.
@@ -182,6 +187,23 @@ public:
   /// 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();
 
@@ -196,6 +218,32 @@ private:
   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
index 01594414d72d757a34602d7ed554f58abf7c0976..d42c54c57ebb8ee1f7634b9789bc62684a62261e 100644 (file)
@@ -60,6 +60,7 @@ SET(PROJECT_HEADERS
     GeomAPI_Ellipse.h
     GeomAPI_Ellipse2d.h
     GeomAPI_Tools.h
+       GeomAPI_IScreenParams.h
 )
 
 SET(PROJECT_SOURCES
diff --git a/src/GeomAPI/GeomAPI_IScreenParams.h b/src/GeomAPI/GeomAPI_IScreenParams.h
new file mode 100644 (file)
index 0000000..8a6c092
--- /dev/null
@@ -0,0 +1,50 @@
+// 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
index 2cf51fbe1b9073d0e70154e24afa21a90972169f..99342671c2557ba5ae34287931e792af18114bb3 100755 (executable)
@@ -207,6 +207,23 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
                                    "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);
 }
 
 //******************************************************
@@ -1120,10 +1137,12 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
   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());
 
@@ -1131,7 +1150,6 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
     SketcherPrs_Tools::setArrowSize(aLen);
     const double aCurScale = aViewer->activeView()->Camera()->Scale();
     aViewer->SetScale(aViewer->activeView(), aCurScale);
-    bool isModified = false;
     QList<Handle(AIS_InteractiveObject)> aPrsList = aDisplayer->displayedPresentations();
     foreach(Handle(AIS_InteractiveObject) aAisObj, aPrsList) {
       Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
@@ -1144,6 +1162,7 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
     if (isModified)
       aDisplayer->updateViewer();
   }
+
 }
 
 //******************************************************
index a392b6ef74c1536958545b24cd07f46460f5fbce..4d5aa02e12c1e81f5528ad8699f5d95b04f19a3f 100644 (file)
@@ -156,10 +156,6 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
                                    "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);
@@ -178,18 +174,6 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
                                    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)
index 12e9e1270ee0a6352d324ac84066a855f4c4a695..34c7401d2d23bb865c528357a6c0d9cd633390d6 100644 (file)
@@ -94,7 +94,7 @@ void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect,
     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());
index 97aa2d015e73615ad0953aa8cd45a99de2700a93..1054f66c75c81760dc1a013779e95642e872fa7e 100644 (file)
@@ -242,7 +242,7 @@ int getDefaultArrowSize()
 
 int getConfigArrowSize()
 {
-  return Config_PropManager::integer(SKETCH_TAB_NAME, "dimension_arrow_size");
+  return Config_PropManager::integer("Visualization", "dimension_arrow_size");
 }
 
 static double MyTextHeight = 16;
@@ -263,7 +263,7 @@ double getDefaultTextHeight()
 
 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)
index 5c3654aca85b2b72b9aa02bda1128804ce81343d..364153dcaf508a16d9e640cae364ef056d284429 100644 (file)
@@ -50,6 +50,8 @@
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_IPresentable.h>
 #include <GeomAPI_ICustomPrs.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_IScreenParams.h>
 
 #include <SUIT_ResourceMgr.h>
 
@@ -163,8 +165,13 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
     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()) {
@@ -175,7 +182,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
               //ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, anAISPrs->Attributes());
           }
         }*/
-      }
+      //}
     } else {
       ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
       if (aResult.get() != NULL) {
@@ -324,6 +331,11 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
 
   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);
@@ -1119,3 +1131,46 @@ XGUI_SelectionActivate* XGUI_Displayer::selectionActivate() const
 {
   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;
+}
index 870c06af708ea5218520a3d6f03628754ff405ad..5da345d703014df4c315506532308ff7bcf6ebe8 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <GeomAPI_AISObject.h>
 #include <GeomAPI_ICustomPrs.h>
+#include <GeomAPI_Pln.h>
 
 #include <ModelAPI_Result.h>
 
@@ -351,6 +352,13 @@ class XGUI_EXPORT XGUI_Displayer: public QObject
   /// \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