Salome HOME
Implementation of the "21384: [CEA 508] Plot2d Allow user to rescale curve" isuue. V6_main_20111028 before_mergefrom_V6_3_BR_27Oct11
authorana <ana@opencascade.com>
Wed, 26 Oct 2011 12:24:32 +0000 (12:24 +0000)
committerana <ana@opencascade.com>
Wed, 26 Oct 2011 12:24:32 +0000 (12:24 +0000)
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h

index af51cd2172560b5115dbe82aebdc318aba8bdea3..09fd56e140344fe97b1c007836798d6aec0f983f 100644 (file)
@@ -739,6 +739,10 @@ Input value precision can be adjusted using
         <source>MEN_CURVE_PROPS</source>
         <translation>Properties...</translation>
     </message>
+    <message>
+        <source>MEN_CURVE_SCALE</source>
+        <translation>Scale...</translation>
+    </message>
     <message>
         <source>MEN_CUT_LINES</source>
         <translation>Cut Lines</translation>
index 2a9b3ebf8060d025e47e4193d2dad0ea687b87e6..c7a8b5763fad0ec4846687cea10d2d8169572c7a 100644 (file)
@@ -74,6 +74,7 @@
 #include "VisuGUI_SetupPlot2dDlg.h"
 #include "Plot2d_SetupCurveDlg.h"
 #include "Plot2d_ViewManager.h"
+#include "Plot2d_SetupCurveScaleDlg.h"
 
 #include "QtxPagePrefMgr.h"
 #include "OB_Browser.h"
@@ -1934,6 +1935,44 @@ VisuGUI
   }
 }
 
+//----------------------------------------------------------------------------
+void
+VisuGUI
+::OnCurveScale()
+{
+  if(IsStudyLocked(GetCStudy(GetAppStudy(this))))
+    return;
+
+  VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects( this );
+  int nbSel = aSelectionInfo.size();
+  QList<VISU::Curve_i*> curList;
+  bool isValuesEquals = true;                  
+  double value;
+
+  for (int i = 0; i < nbSel; i++ ) {
+    VISU::TSelectionItem aSelectionItem = aSelectionInfo[i];
+    VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+    if(!aBase)
+      continue;
+
+    if(aBase->GetType() == VISU::TCURVE) 
+      // Curve object
+      if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase)) {
+        curList.append(aCurve);
+        if( i>0 && isValuesEquals )
+          isValuesEquals = (value == aCurve->GetScale());
+         value = aCurve->GetScale();
+      }
+  }
+
+  Plot2d_SetupCurveScaleDlg aDlg(GetDesktop( this ));
+  if( isValuesEquals )
+     aDlg.setScale(value);
+
+  if( aDlg.exec() == QDialog::Accepted )
+       for ( int i = 0; i < curList.size(); ++i )
+         curList.at(i)->SetScale( aDlg.getScale() );
+}
 //----------------------------------------------------------------------------
 void
 VisuGUI
@@ -2624,6 +2663,10 @@ VisuGUI
                 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
                 this, SLOT(OnCurveProperties()));
 
+  createAction( VISU_CURVE_SCALE, tr("MEN_CURVE_SCALE"), QIcon(),
+                tr("MEN_CURVE_SCALE"), "", 0, aParent, false,
+                this, SLOT(OnCurveScale()));
+
   createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIcon(),
                 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
                 this, SLOT(OnEditContainer()));
@@ -3099,6 +3142,7 @@ VisuGUI
   mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
 
   mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
+  mgr->insert( action( VISU_CURVE_SCALE ), -1, -1, -1 ); // curve scale
 
   mgr->insert( action( VISU_MULTIPR_FULL_RES ), -1, -1, -1 );
   mgr->insert( action( VISU_MULTIPR_MED_RES ), -1, -1, -1 );
@@ -3262,6 +3306,7 @@ VisuGUI
   // Curve commands
   aRule = "selcount=1 and type='VISU::TCURVE'";
   mgr->setRule( action( VISU_CURVE_PROPS ), aRule );
+  mgr->setRule( action( VISU_CURVE_SCALE ), "selcount > 0 and type='VISU::TCURVE'");
 
   // Table Commands
   aRule = "selcount=1 and ( type='VISU::TPOINTMAP3D' or type='VISU::TTABLE')";
index b7b4b4fd8a8423bb6dcfb856ceb5bbb8697f5570..87967ffba72e0b64634e66c4fc82591948386733 100644 (file)
@@ -169,6 +169,7 @@ protected slots:
   void OnDeleteObjects();
   void OnPlotData();
   void OnCurveProperties();
+  void OnCurveScale();
   void OnClearContainer();
   void OnEditContainer();
 
index 972a922c4504c6b8df240f163de06b7760ab0831..2f854f15e245c36f62115d5fbc40789c2457ecef 100644 (file)
@@ -65,6 +65,7 @@
 
 #define VISU_COPY_PRS               4037
 #define VISU_CURVE_PROPS            4040
+#define VISU_CURVE_SCALE            4041
 #define VISU_EDIT_CONTAINER         4042
 #define VISU_CLEAR_CONTAINER        4043