Salome HOME
SALOME::GenericObj : Destroy() -> UnRegister()
[modules/visu.git] / src / VISUGUI / VisuGUI.cxx
index 8cc895f5d8cb8ee0ab04d03b63e14c920d3e0748..b09336a6b18503221f65d80e54a1816fcc737b60 100644 (file)
 //  File   : VisuGUI.cxx
 //  Author :
 //  Module : VISU
-//
+
+#include <Standard_math.hxx>  // E.A. must be included before Python.h to fix compilation on windows
+#include "Python.h"
+
 #include "VisuGUI.h"
 
 // STL Includes
@@ -926,6 +929,7 @@ VisuGUI
     case VISU::TCURVE:
     case VISU::TCONTAINER:
     case VISU::TTABLE:
+      getViewManager(SPlot2d_Viewer::Type(), true);
       displayer()->Display(anIO->getEntry());
       break;
     default: {
@@ -1454,6 +1458,7 @@ VisuGUI
       if( VISU::Prs3d_i* aPrs = aPrsList[i] )
       {
         VTKViewer_MarkerDlg* aDlg = new VTKViewer_MarkerDlg( GetDesktop( this ) );
+        aDlg->setHelpData( "VISU", "point_marker_page.html" );
 
         aDlg->setCustomMarkerMap( aMarkerMap[ aStudyId ] );
 
@@ -1929,6 +1934,7 @@ VisuGUI
     if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase)){
       if(aContainer && aContainer->GetNbCurves() > 0){
         aContainer->Clear();
+       VISU::updateContainerVisibility(aContainer);
         UpdateObjBrowser(this);
       }
     }
@@ -1958,8 +1964,9 @@ VisuGUI
   if (aDlg->exec()) {
     aDlg->storeToPrsObject(aContainer);
     UpdateObjBrowser(this, true);
+    delete aDlg;
+    VISU::updateContainerVisibility(aContainer);
   }
-  delete aDlg;
 }
 
 //----------------------------------------------------------------------------
@@ -3227,13 +3234,13 @@ VisuGUI
   QString aPrsInvisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})" + andInvisible + " and (not isPlot2dViewer))";
   QString aComponent = "( selcount=1 and canBeDisplayed and isVisuComponent )";
 
-  QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsVisible +
+  QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (" + aPrsVisible +
     " or (   (" + aTableOrContHide + orCurveVisible + "))) ) or " + aComponent;
 
-  QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsInvisible +
+  QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (" + aPrsInvisible +
     " or (   (" + aTableOrContShow + orCurveInvisible + "))) ) or " + aComponent;
 
-  QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed) and (($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})"
+  QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})"
     " or (   ((type='VISU::TTABLE' and nbChildren>0) or (type='VISU::TCONTAINER' and hasCurves) or"
     " (type='VISU::TCURVE')))) ) or" + aComponent;
 
@@ -3656,6 +3663,21 @@ VisuGUI
   setMenuShown( true );
   setToolShown( true );
 
+  // import Python module that manages VISU plugins (need to be here because SalomePyQt API uses active module)
+  PyGILState_STATE gstate = PyGILState_Ensure();
+  PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
+  if(pluginsmanager==NULL)
+    PyErr_Print();
+  else
+    {
+      PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"visu",tr("MEN_VISUALIZATION").toStdString().c_str(),tr("VISU_PLUGINS_OTHER").toStdString().c_str());
+      if(result==NULL)
+        PyErr_Print();
+      Py_XDECREF(result);
+    }
+  PyGILState_Release(gstate);
+  // end of GEOM plugins loading
+
   // Reset actions accelerator keys
   QList<QKeySequence> shortcuts;
   shortcuts.append( QKeySequence(Qt::CTRL + Qt::Key_I) );
@@ -3718,6 +3740,8 @@ extern "C" {
 
 void VisuGUI::createPreferences()
 {
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
   // TAB: General
   int genTab   = addPreference( tr( "VISU_PREF_GENERAL" ) );
   // Quantities with individual precision settings
@@ -3747,8 +3771,8 @@ void VisuGUI::createPreferences()
   
   // Set property for precision value for spinboxes
   for ( ii = 0; ii < nbQuantities; ii++ ){
-    setPreferenceProperty( precs[ii], "min", ii == 2 ? 0 : -10 );
-    setPreferenceProperty( precs[ii], "max", ii == 2 ? 3 : 10 );
+    setPreferenceProperty( precs[ii], "min", ii == 2 ? 0 : -14 );
+    setPreferenceProperty( precs[ii], "max", ii == 2 ? 3 : 14 );
     setPreferenceProperty( precs[ii], "precision", 2 );
   }   
 
@@ -3820,10 +3844,10 @@ void VisuGUI::createPreferences()
   int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), sbarTab );
   setPreferenceProperty( imposedGr, "columns", 4 );
 
-  int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
-  int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
-  setPreferenceProperty( min, "step", 0.1 );
-  setPreferenceProperty( max, "step", 0.1 );
+  int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::Double, "VISU", "scalar_range_min" );
+  int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::Double, "VISU", "scalar_range_max" );
+  setPreferenceProperty( min, "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) );
+  setPreferenceProperty( max, "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) );
 
   // group: "Font"
   int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
@@ -3998,6 +4022,18 @@ void VisuGUI::createPreferences()
   addPreference( tr( "Generate data table" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_data_table" );
   addPreference( tr( "Generate curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_curves" );
 
+  // TAB: "StreamLines"
+  int streamLinesTab = addPreference( tr( "VISU_STREAM_LINES" ) );
+
+  // group: "StreamLines preferences"
+  int streamLinesGr = addPreference( tr( "VISU_STREAM_LINES_PREF" ), streamLinesTab );
+  setPreferenceProperty( cutLineGr, "columns", 1 );
+  int usedPoints = addPreference( tr( "VISU_STREAM_LINES_USED_POINTS" ), streamLinesGr,
+                                  LightApp_Preferences::DblSpin, "VISU", "stream_lines_used_points" );
+  setPreferenceProperty( usedPoints, "min",  0 );
+  setPreferenceProperty( usedPoints, "max",  1 );
+  setPreferenceProperty( usedPoints, "step", 0.1 );
+
   // TAB: "Sweep, Animation, 3D Cache"
   int animationTab = addPreference( tr( "Sweep, Animation" ) );
   {
@@ -4245,8 +4281,6 @@ void VisuGUI::createPreferences()
   addPreference( tr( "VISU_EDGE_COLOR" ), representGr, LightApp_Preferences::Color, "VISU", "edge_color" );
   addPreference( "", representGr, LightApp_Preferences::Space );
 
-  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
-
   int typeOfMarker = addPreference( tr( "VISU_TYPE_OF_MARKER" ), representGr, LightApp_Preferences::Selector, "VISU", "type_of_marker" );
 
   QList<QVariant> aMarkerTypeIndicesList;
@@ -4393,6 +4427,15 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b)
       aResourceMgr->setValue("VISU", "scalar_bar_horizontal_height",sbH);
     }
   }
+  else if(b == "visual_data_precision") {
+    LightApp_Preferences* pref = preferences();
+    QtxPreferenceItem* min = pref->findItem( tr( "VISU_MIN" ), true );
+    QtxPreferenceItem* max = pref->findItem( tr( "VISU_MAX" ), true );
+    if ( min )
+      setPreferenceProperty( min->id(), "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) );
+    if ( max )
+      setPreferenceProperty( max->id(), "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) );
+  }
 
   if ( !aWarning.isEmpty() ){
     aWarning += "The default values are applied instead.";