]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Set selection area of dimensions adaptive to viewer scale
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 15 Jun 2015 13:00:40 +0000 (16:00 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 15 Jun 2015 13:01:01 +0000 (16:01 +0300)
src/ModuleBase/ModuleBase_IViewer.h
src/NewGeom/NewGeom_SalomeViewer.cpp
src/PartSet/PartSet_Module.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_Radius.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_Tools.cpp
src/SketcherPrs/SketcherPrs_Tools.h
src/XGUI/XGUI_ViewerProxy.cpp

index feed61ee2ac2adff4aed87bae1cbffe64cb72a11..b08d49e7246bfab55804962611292d7ce9f1c548 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "ModuleBase.h"
 #include <QObject>
+#include <QMap>
 #include <AIS_InteractiveContext.hxx>
 #include <V3d_View.hxx>
 
@@ -75,6 +76,15 @@ Q_OBJECT
   /// Update current viewer
   virtual void update() = 0;
 
+  const double Scale(const Handle(V3d_View)& theView)
+  {
+    if (!myWindowScale.contains(theView))
+      myWindowScale.insert(theView, theView->Camera()->Scale());
+    return myWindowScale[theView];
+  }
+
+  void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; }
+
   /// Method returns True if the viewer can process editing objects 
   /// by mouse drugging. If this is impossible thet it has to return False.
   virtual bool canDragByMouse() const { return true; }
@@ -122,6 +132,9 @@ signals:
   /// Signal emitted on transformation of view point in view window
   /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
   void viewTransformed(int theTransformation);
+
+  protected:
+    QMap<Handle(V3d_View), double> myWindowScale;
 };
 
 #endif
index 8bc67c748f7dc50bb8ef68125108aeac44d0a8dc..4539bbdbc6aaed27943fd36be319c61570e099a4 100644 (file)
@@ -223,6 +223,8 @@ void NewGeom_SalomeViewer::onTryCloseView(SUIT_ViewWindow*)
 //**********************************************
 void NewGeom_SalomeViewer::onDeleteView(SUIT_ViewWindow*)
 {
+  if(myWindowScale.contains(myView->v3dView()))
+    myWindowScale.remove(myView->v3dView());
   emit deleteView(myView);
 }
 
@@ -238,6 +240,8 @@ void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView)
     connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
       this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
 
+  myWindowScale.insert (aView->getViewPort()->getView(), aView->getViewPort()->getView()->Camera()->Scale());
+
   emit viewCreated(myView);
 }
 
index a1908ff43b7395a8ade484b6377f20e88ad635cd..6939718d0803198f78e1f150618cc66fd3d34da8 100644 (file)
@@ -682,7 +682,12 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
     return;
   double aLen = aView->Convert(20);
 
+  double aPrevLen = SketcherPrs_Tools::getArrowSize();
   SketcherPrs_Tools::setArrowSize(aLen);
+  const double aPrevScale = aViewer->Scale(aViewer->activeView());
+  const double aCurScale = aViewer->activeView()->Camera()->Scale();
+  aViewer->SetScale(aViewer->activeView(), aCurScale);
+  SketcherPrs_Tools::setTextHeight (aCurScale / aPrevScale * SketcherPrs_Tools::getTextHeight());
   bool isModified = false;
   QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
   foreach (AISObjectPtr aAIS, aPrsList) {
index 9a4509794036c4cfdca5447d6441b4b3b27b54d8..39d5cfcd7b3690093ac2c62ee46a5852d00b9d95 100644 (file)
@@ -40,10 +40,10 @@ myConstraint(theConstraint), myPlane(thePlane)
   myAspect->MakeText3d(false);
   myAspect->MakeTextShaded(false);
   myAspect->MakeUnitsDisplayed(false);
-  myAspect->TextAspect()->SetHeight(MyTextHeight);
+  myAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight());
   myAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize());
 
-  SetSelToleranceForText2d(MyTextHeight);
+  SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight());
   SetDimensionAspect(myAspect);
 }
 
@@ -178,5 +178,6 @@ void SketcherPrs_LengthDimension::ComputeSelection(const Handle(SelectMgr_Select
     return;
   }
   }
+  SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight());
   AIS_LengthDimension::ComputeSelection(aSelection, aMode);
 }
index 11eec07340e2788aa3b20507f56205dd15da8cc7..c08d7ab9430db8523b308bc025595686ec6a360f 100644 (file)
@@ -32,11 +32,11 @@ SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint,
   myAspect->MakeText3d(false);
   myAspect->MakeTextShaded(false);
   myAspect->MakeUnitsDisplayed(false);
-  myAspect->TextAspect()->SetHeight(MyTextHeight);
+  myAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight());
   myAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize());
   
   SetDimensionAspect(myAspect);
-  SetSelToleranceForText2d(MyTextHeight);
+  SetSelToleranceForText2d(SketcherPrs_Tools::getDefaultTextHeight());
 }
 
 
index 798b1700743a6be48e530fdd8aec98f09aa0502b..33a363a1b31e007fc8161234e5be3dd2780f77b0 100644 (file)
@@ -368,6 +368,9 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
   }
 
   aGroup->UserDraw(this, true);
+
+  // Disable frustum culling for this object by marking it as mutable
+  aGroup->Structure()->SetMutable(true);
   //aGroup->AddPrimitiveArray(myPntArray);
 }
 
index f8891b2253bdf2025369ea887e7c5e977ae99b4b..f2fbe2894153c2c835a64ac759e816cde7d304a2 100644 (file)
@@ -136,6 +136,22 @@ void setArrowSize(double theSize)
   MyArrowSize = theSize;
 }
 
+static double MyTextHeight = 20;
+double getTextHeight()
+{
+  return MyTextHeight;
+}
+
+void setTextHeight(double theHeight)
+{
+  MyTextHeight = theHeight;
+}
+
+double getDefaultTextHeight()
+{
+  return 30;
+}
+
 double getFlyoutDistance(const ModelAPI_Feature* theConstraint)
 {
   std::shared_ptr<GeomDataAPI_Point2D> aFlyoutPoint =
index b2ed89c5bdc56689593a691628fc3dc9603c2df8..ac014267e3f3f9b29bb2e44f7d223e4185902534 100644 (file)
@@ -17,7 +17,7 @@
 
 class GeomDataAPI_Point2D;
 
-#define MyTextHeight 20
+//#define MyTextHeight 20
 
 namespace SketcherPrs_Tools {
 
@@ -62,6 +62,12 @@ enum SelectionModes {
 
   SKETCHERPRS_EXPORT void setArrowSize(double theSize);
 
+  SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
+
+  SKETCHERPRS_EXPORT double getTextHeight();
+
+  SKETCHERPRS_EXPORT double getDefaultTextHeight();
+
   SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
 
   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(
index cf300615a91fcd56eec14c96019b28c163a98cdd..2011cf6b7bd10779d505ac0f78b3149ec4edfa83 100644 (file)
@@ -169,6 +169,8 @@ void XGUI_ViewerProxy::onTryCloseView(AppElements_ViewWindow* theWnd)
 
 void XGUI_ViewerProxy::onDeleteView(AppElements_ViewWindow* theWnd)
 {
+  if (myWindowScale.contains(theWnd->v3dView()))
+    myWindowScale.remove (theWnd->v3dView());
   emit deleteView(theWnd);
 }
 
@@ -176,6 +178,8 @@ void XGUI_ViewerProxy::onViewCreated(ModuleBase_IViewWindow* theWnd)
 {
   theWnd->viewPort()->installEventFilter(this);
 
+  myWindowScale.insert (theWnd->v3dView(), theWnd->v3dView()->Camera()->Scale());
+
   emit viewCreated(theWnd);
 }
 
@@ -186,6 +190,8 @@ void XGUI_ViewerProxy::onViewCreated(AppElements_ViewWindow* theWnd)
   connect(theWnd, SIGNAL(vpTransformationFinished(AppElements_ViewWindow::OperationType)),
     this, SLOT(onViewTransformed(AppElements_ViewWindow::OperationType)));
 
+  myWindowScale.insert (theWnd->v3dView(), theWnd->v3dView()->Camera()->Scale());
+
   emit viewCreated(theWnd);
 }