]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authornds <natalia.donis@opencascade.com>
Tue, 31 Mar 2015 09:35:19 +0000 (12:35 +0300)
committernds <natalia.donis@opencascade.com>
Tue, 31 Mar 2015 09:35:19 +0000 (12:35 +0300)
1  2 
src/PartSet/PartSet_Module.cpp

index da5860f6ccebf198f1d2f87093f708acd1160416,00b6e321ffb4ee6dddae30efbbf1da9dee9cad0c..3603d3cd09a53c98ba45dc0944647cc225f0dd7b
@@@ -57,7 -57,9 +57,9 @@@
  #include <SketchPlugin_ConstraintParallel.h>
  #include <SketchPlugin_ConstraintPerpendicular.h>
  #include <SketchPlugin_ConstraintRadius.h>
- //#include <SketchPlugin_ConstraintRigid.h>
+ #include <SketcherPrs_SymbolPrs.h>
+ #include <SketcherPrs_Tools.h>
  
  #include <Events_Loop.h>
  #include <Config_PropManager.h>
@@@ -94,7 -96,6 +96,6 @@@ PartSet_Module::PartSet_Module(ModuleBa
    : ModuleBase_IModule(theWshop), 
    myRestartingMode(RM_None), myVisualLayerId(0)
  {
-   //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
    mySketchMgr = new PartSet_SketcherMgr(this);
  
    XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
    ModuleBase_IViewer* aViewer = theWshop->viewer();
    connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
            this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
+   connect(aViewer, SIGNAL(viewTransformed(int)),
+           SLOT(onViewTransformed(int)));
  
    createActions();
  }
@@@ -275,12 -278,36 +278,12 @@@ bool PartSet_Module::canRedo() cons
  
  bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
  {
 -  bool aCanDisplay = false;
 -  if (!mySketchMgr->canDisplayObject())
 -    return aCanDisplay;
 -  CompositeFeaturePtr aSketchFeature = mySketchMgr->activeSketch();
 -  if (aSketchFeature.get() != NULL) {
 -    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
 -
 -    // MPV: the second and third conditions to avoid crash on exit for application
 -    if (aFeature.get() != NULL && aFeature->data().get() && aFeature->data()->isValid()) {
 -      if (aFeature == aSketchFeature) {
 -        aCanDisplay = false;
 -      }
 -      else if (aSketchFeature.get() && aSketchFeature->data().get() &&
 -               aSketchFeature->data()->isValid()) {
 -        for (int i = 0; i < aSketchFeature->numberOfSubs() && !aCanDisplay; i++) {
 -          FeaturePtr aSubFeature = aSketchFeature->subFeature(i);
 -          std::list<ResultPtr> aResults = aSubFeature->results();
 -          std::list<ResultPtr>::const_iterator aIt;
 -          for (aIt = aResults.begin(); aIt != aResults.end() && !aCanDisplay; ++aIt) {
 -            if (theObject == (*aIt))
 -              aCanDisplay = true;
 -          }
 -          if (aSubFeature == theObject)
 -            aCanDisplay = true;
 -        }
 -      }
 -    }
 -  }
 -  else {
 -    aCanDisplay = ModuleBase_IModule::canDisplayObject(theObject);
 +  // the display should be possible almost always, with exception of some specific cases
 +
 +  bool aCanDisplay = true;
 +
 +  if (mySketchMgr->activeSketch()) {
 +    aCanDisplay = mySketchMgr->canDisplayObject(theObject);
    }
    return aCanDisplay;
  }
@@@ -642,11 -669,48 +645,48 @@@ void PartSet_Module::onObjectDisplayed(
  {
    Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
    if (!anAIS.IsNull()) {
+     Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
      Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAIS);
      if (!aDim.IsNull()) {
-       Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
        aCtx->SetZLayer(aDim, myVisualLayerId);
+     } else {
+       Handle(SketcherPrs_SymbolPrs) aCons = Handle(SketcherPrs_SymbolPrs)::DownCast(anAIS);
+       if (!aCons.IsNull())
+         aCtx->SetZLayer(aCons, myVisualLayerId);
      }
    }
  }
  
+ void PartSet_Module::onViewTransformed(int theTrsfType)
+ {
+   // Set length of arrows constant in pixel size
+   // if the operation is panning or rotate or panglobal then do nothing
+   if ((theTrsfType == 1) || (theTrsfType == 3) || (theTrsfType == 4))
+     return;
+   ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+   Handle(V3d_View) aView = aViewer->activeView();
+   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+   XGUI_Workshop* aWorkshop = aConnector->workshop();
+   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+   double aLen = aView->Convert(25);
+   SketcherPrs_Tools::setArrowSize(aLen);
+   bool isModified = false;
+   QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
+   foreach (AISObjectPtr aAIS, aPrsList) {
+     Handle(AIS_InteractiveObject) aAisObj = aAIS->impl<Handle(AIS_InteractiveObject)>();
+     Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
+     if (!aDim.IsNull()) {
+       aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen);
+       aContext->Redisplay(aDim, false);
+       isModified = true;
+     }
+   }
+   if (isModified)
+     aDisplayer->updateViewer();
+ }