]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Replace sclarmap to prsmerger
authorenk <enk@opencascade.com>
Wed, 18 Oct 2006 12:23:31 +0000 (12:23 +0000)
committerenk <enk@opencascade.com>
Wed, 18 Oct 2006 12:23:31 +0000 (12:23 +0000)
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_PopupTools.cxx
src/VISUGUI/VisuGUI_ScalarBarDlg.cxx
src/VISUGUI/VisuGUI_ScalarBarDlg.h
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_Tools.cxx

index aadd869dd0946964eb6998c711b2c7daffe5c8a2..c25658a035de4037789469d919c40257a22c326e 100644 (file)
 #include "VisuGUI_BuildProgressDlg.h"
 #include "VisuGUI_TransparencyDlg.h"
 
-#include "VISU_ScalarMap_i.hh"
+#include "VISU_PrsMerger_i.hh"
 #include "VisuGUI_ScalarBarDlg.h"
 
 #include "VISU_DeformedShape_i.hh"
@@ -545,7 +545,7 @@ void
 VisuGUI::
 OnCreateScalarMap()
 {
-  CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
+  CreatePrs3d<VISU::PrsMerger_i,VisuGUI_ScalarBarDlg,1>(this);
 }
 
 
@@ -751,7 +751,7 @@ OnEditScalarMap()
 {
   Handle(SALOME_InteractiveObject) anIO;
   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
-    EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg, 1>(this, anIO, aPrs3d);
+    EditPrs3d<VISU::PrsMerger_i, VisuGUI_ScalarBarDlg, 1>(this, anIO, aPrs3d);
 }
 
 void
@@ -1743,10 +1743,10 @@ OnCopyPresentation()
       aSameMesh->SameAs(aMeshPrs);
     }
     break;
-  case VISU::TSCALARMAP:
+  case VISU::TPRSMERGER:
     {
-      VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
-      VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
+      VISU::PrsMerger_i* aScalarPrs = dynamic_cast<VISU::PrsMerger_i*>(aPrsObject);
+      VISU::PrsMerger_i* aSameScalar = new VISU::PrsMerger_i(aScalarPrs->GetResult(),true);
       aSameScalar->SameAs(aScalarPrs);
     }
     break;
@@ -2473,7 +2473,7 @@ createPopupMenus()
 
   // Rules
 
-  QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
+  QString aPrsAll ("'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
                    "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'");
 
   // VISU root commands
@@ -2536,13 +2536,13 @@ createPopupMenus()
 
   // 3D presentations commands
   QString aPrsType    = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
-  QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
+  QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TPRSMERGER' 'VISU::TDEFORMEDSHAPE'}";
   QString aSurfFrameType   = " and $type in {'VISU::TMESH'}";
-  QString aSurfType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
+  QString aSurfType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
                         " 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
-  QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
+  QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' "
                         "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
-  QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
+  QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
                         "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' }";
 
   aRule = "selcount=1";
@@ -2596,7 +2596,7 @@ createPopupMenus()
   mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
 
   mgr->setRule( action( VISU_EDIT_SCALARMAP ),
-               "selcount=1 and type='VISU::TSCALARMAP'", true );
+               "selcount=1 and type='VISU::TPRSMERGER'", true );
   mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
                "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true );
   mgr->setRule( action( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE ),
@@ -2633,6 +2633,8 @@ createPopupMenus()
   aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
   mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
   mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
+  mgr->setRule( action( VISU_EDIT_PLOT3D ),
+               "selcount=1 and type='VISU::TPLOT3D'", true );
 
   //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
   //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
index 45d034d939acaee43cca21f06586e49fa9324069..a434301a58b8069bd743b811372745a13794c198 100644 (file)
@@ -93,7 +93,7 @@ QString VisuGUI_Selection::type( const int ind ) const
       ENUM2STRING( aResStr, VISU::TCURVE );
       ENUM2STRING( aResStr, VISU::TCONTAINER );
       ENUM2STRING( aResStr, VISU::TMESH );
-      ENUM2STRING( aResStr, VISU::TSCALARMAP );
+      ENUM2STRING( aResStr, VISU::TPRSMERGER );
       ENUM2STRING( aResStr, VISU::TISOSURFACE );
       ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPE );
       ENUM2STRING( aResStr, VISU::TSCALARMAPONDEFORMEDSHAPE );
index 45e47f88ce54d5d0ba08857be07a1b70bb2f982d..51a7ce4cdeb6d50945fbc6cef25d7de81cf0d7be 100644 (file)
@@ -41,6 +41,7 @@
 #include "VISU_ScalarMapPL.hxx"
 #include "VISU_ScalarMap_i.hh"
 #include "VISU_ScalarMapAct.h"
+#include "VISU_Result_i.hh"
 
 #include "LightApp_Application.h"
 
@@ -55,6 +56,7 @@
 
 #include <vtkTextProperty.h>
 
+using namespace VISU;
 using namespace std;
 
 
@@ -1082,6 +1084,9 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool Se
   TopLayout->setSpacing(6);
   TopLayout->setMargin(11);
 
+  myGroupPane = new VisuGUI_GroupSelectPane(this);
+  TopLayout->addWidget(myGroupPane);
+
   myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
   TopLayout->addWidget(myScalarPane);
 
@@ -1116,6 +1121,25 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool Se
   connect( buttonHelp,   SIGNAL( clicked() ), this, SLOT( onHelp() ) );
 }
 
+/*!
+  Set values in the dialog from the presentation
+*/
+void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::PrsMerger_i* thePrs)
+{
+  myScalarPane->initFromPrsObject(thePrs);
+  myGroupPane->initFromPrsObject(thePrs);
+}
+
+/*!
+  Set values to presentation from the dialog
+*/
+int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::PrsMerger_i* thePrs)
+{
+  bool res1 = myScalarPane->storeToPrsObject(thePrs);
+  bool res2 = myGroupPane->storeToPrsObject(thePrs);
+  return (res1&&res2);
+}
+
 /*!
   Called when <OK> button is clicked, validates data and closes dialog
 */
@@ -1297,3 +1321,199 @@ void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
       onHelp();
     }
 }
+
+/*!
+  Constructor
+*/
+VisuGUI_GroupSelectPane::VisuGUI_GroupSelectPane(QWidget * parent):
+  QVBox(parent)
+{
+  // Main groupbox
+  myMainGroupBox = new QGroupBox(tr(""), this, "myMainGroupBox");
+  myMainGroupBox->setColumnLayout(0, Qt::Vertical );                          
+  myMainGroupBox->layout()->setSpacing( 0 );
+  myMainGroupBox->layout()->setMargin( 0 );
+  QGridLayout* aMainGroupBoxLayout = new QGridLayout( myMainGroupBox->layout() );
+  myMainGroupBox->setAlignment( Qt::AlignTop );
+  aMainGroupBoxLayout->setSpacing( 6 );
+  aMainGroupBoxLayout->setMargin( 11 );
+  
+  myOnGroupsCB = new QCheckBox (tr("PRS_ON_GROUPS"), myMainGroupBox);
+  myOnGroupsCB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  
+  // Lists of groups and add/remove buttons
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+  QPixmap addImage    ( aResourceMgr->loadPixmap("VISU", tr("ICON_ADD")));
+  QPixmap removeImage ( aResourceMgr->loadPixmap("VISU", tr("ICON_REMOVE")));
+
+  myAllGroups = new VisuGUI_ListBox(myMainGroupBox, "myAllGroups");
+  myAllGroups->setSelectionMode(QListBox::Extended);
+  
+  myAddButton = new QToolButton(myMainGroupBox);
+  myAddButton->setPixmap( addImage );
+
+  myRemoveButton = new QToolButton(myMainGroupBox);
+  myRemoveButton->setPixmap( removeImage );
+  
+  mySelectedGroups = new VisuGUI_ListBox(myMainGroupBox, "mySelectedGroups");
+  mySelectedGroups->setSelectionMode(QListBox::Extended);
+  
+  // Layouting
+  QVBoxLayout* buttonsLayout = new QVBoxLayout();
+  buttonsLayout->addWidget(myAddButton);
+  buttonsLayout->addSpacing(6);
+  buttonsLayout->addWidget(myRemoveButton);
+  buttonsLayout->addStretch();
+  
+  aMainGroupBoxLayout->addMultiCellWidget( myOnGroupsCB, 0, 0, 0, 2);
+  aMainGroupBoxLayout->addWidget( myAllGroups, 1, 0 );
+  aMainGroupBoxLayout->addLayout( buttonsLayout, 1, 1 );
+  aMainGroupBoxLayout->addWidget( mySelectedGroups, 1, 2 );
+  aMainGroupBoxLayout->setRowStretch(1, 10);
+
+  // Connections
+  
+  connect( myOnGroupsCB, SIGNAL( toggled( bool ) ), this, SLOT( onTypeChanged() ) );
+  connect( myAllGroups,  SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) );
+  connect( mySelectedGroups,  SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) );
+  connect( myAddButton, SIGNAL(clicked()), this, SLOT(onAdd()));
+  connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
+  
+  mySelectedGroups->installEventFilter(this);
+  
+  onTypeChanged();
+}
+
+/*!
+  Called when the checkbox is toggled
+*/
+void VisuGUI_GroupSelectPane::onTypeChanged( )
+{
+  bool toEnable = myOnGroupsCB->isChecked();
+  if (!toEnable)
+    {
+      myAllGroups->clearSelection();
+      mySelectedGroups->clearSelection();
+    }
+  myAllGroups->setEnabled( toEnable );
+  mySelectedGroups->setEnabled( toEnable );
+  myAddButton->setEnabled( toEnable );
+  myRemoveButton->setEnabled( toEnable );
+}
+
+/*!
+  Initialise the pane from presentation object
+ */
+void VisuGUI_GroupSelectPane::initFromPrsObject(VISU::PrsMerger_i* thePrs)
+{
+  VISU::Result_i* theResult = thePrs->GetResult();
+  VISU_Convertor* aInput = theResult->GetInput();
+  
+  const VISU::TMeshMap& aMeshMap = aInput->GetMeshMap();
+  
+  VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(thePrs->GetMeshName());
+  if(aMeshIter!=aMeshMap.end()){
+    const PMesh& aMesh = aMeshIter->second;
+    const TGroupMap& aGroupMap = aMesh->myGroupMap;
+    TGroupMap::const_iterator aGroupIter = aGroupMap.begin();
+    for(;aGroupIter!=aGroupMap.end();aGroupIter++)
+      {
+       const string& aGroupName = aGroupIter->first;
+       myAllGroups->insertItem( QString(aGroupName) );
+      }
+  }
+
+  if (myAllGroups->count() < 1)
+    {
+      myAllGroups->insertItem( tr("NO_GROUPS") );
+      myMainGroupBox->setEnabled(false);
+    }
+  else
+    {
+      // Get names of the groups
+      string_array_var aGroupNames = thePrs->getGroupNames();
+      for(int i=0; i<aGroupNames->length(); i++)
+       mySelectedGroups->insertItem( QString(aGroupNames[i]) );
+      
+      if (mySelectedGroups->count() > 0)
+       myOnGroupsCB->setChecked(true);
+    }
+}
+
+/*!
+  Store values to presentation object
+ */
+int VisuGUI_GroupSelectPane::storeToPrsObject(VISU::PrsMerger_i* thePrs)
+{
+  thePrs->RemoveAllGeom();
+
+  if (myOnGroupsCB->isChecked())
+    {  
+      QString aMeshName = thePrs->GetMeshName();
+      for (int i = 0; i < mySelectedGroups->count(); i++)
+       thePrs->AddMeshOnGroup( aMeshName , mySelectedGroups->text(i) );
+    }
+  
+  return 1;
+}
+
+/*!
+  Called when add button is clicked, adds item to choosen groups
+*/
+void VisuGUI_GroupSelectPane::onAdd()
+{
+  QStringList aList;
+  
+  for (int i = 0; i < myAllGroups->count(); i++)
+    if (myAllGroups->isSelected(i))
+      aList.append(myAllGroups->text(i));
+
+  for (int i = 0; i < mySelectedGroups->count(); i++)
+    aList.remove(mySelectedGroups->text(i));
+    
+  mySelectedGroups->insertStringList(aList);
+}
+
+/*!
+  Called when remove button is clicked, remove selected items from choosen
+*/
+void VisuGUI_GroupSelectPane::onRemove()
+{
+  QPtrList<QListBoxItem> aList;
+  aList.setAutoDelete(false);
+  for (int i = 0; i < mySelectedGroups->count(); i++)
+    if (mySelectedGroups->isSelected(i))
+      aList.append(mySelectedGroups->item(i));
+  
+  for (int i = 0; i < aList.count(); i++)
+    delete aList.at(i);
+}
+
+/*!
+  Called when an item of listbox is double-clicked
+*/
+void VisuGUI_GroupSelectPane::onListDoubleClicked( QListBoxItem* theItem )
+{
+  QListBox* aListBox = theItem->listBox();
+
+  if (aListBox == myAllGroups)
+    {
+      if (!mySelectedGroups->findItem( theItem->text(), Qt::ExactMatch ))
+       mySelectedGroups->insertItem(theItem->text());
+    }
+  else if (aListBox == mySelectedGroups)
+    delete theItem;
+}
+
+/*!
+  Event filter
+*/
+bool VisuGUI_GroupSelectPane::eventFilter (QObject* object, QEvent* event)
+{
+  if (event->type() == QEvent::KeyPress) {
+    QKeyEvent* aKeyEvent = (QKeyEvent*)event;
+    if (object == mySelectedGroups && aKeyEvent->key() == Key_Delete)
+      onRemove();
+  }
+  return QObject::eventFilter(object, event);
+}
index d9d0f6f2e909adce0adecc8c64e1424d89b1c5bd..513e7b0af1c8973c81954920ff0dcd2dfae5e0db 100644 (file)
 #include <qtoolbutton.h>
 
 #include "QtxDblSpinBox.h"
+#include "QtxListBox.h"
 
 #include "VISU_ScalarMap_i.hh"
+#include "VISU_PrsMerger_i.hh"
 
 class QButtonGroup;
 class QGroupBox;
@@ -58,7 +60,7 @@ class QComboBox;
 class QVBox;
 class QToolButton;
 
-class QtxDblSpinBox;
+class QListBoxItem;
 class SalomeApp_Module;
 class SVTK_FontWidget;
 class VISU_ScalarMapAct;
@@ -190,6 +192,50 @@ class VisuGUI_ScalarBarPane : public QVBox
 };
 
 
+class VisuGUI_ListBox: public QtxListBox
+{
+  Q_OBJECT;
+  
+ public:
+  VisuGUI_ListBox( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )
+    : QtxListBox(parent, name, f) {};
+  ~VisuGUI_ListBox() {};
+
+  virtual QSize sizeHint() const { return minimumSizeHint(); };
+};
+
+class VisuGUI_GroupSelectPane : public QVBox
+{
+  Q_OBJECT;
+
+ public:
+  VisuGUI_GroupSelectPane(QWidget* parent);
+  ~VisuGUI_GroupSelectPane() {};
+  
+  void initFromPrsObject(VISU::PrsMerger_i* thePrs);
+  int storeToPrsObject(VISU::PrsMerger_i* thePrs);
+  
+  bool eventFilter (QObject* object, QEvent* event);
+  
+ private slots:
+  void onTypeChanged();
+  void onListDoubleClicked( QListBoxItem* theItem );
+  void onAdd();
+  void onRemove();
+   
+ private:
+  QGroupBox* myMainGroupBox;
+
+  QCheckBox* myOnGroupsCB;
+
+  VisuGUI_ListBox* myAllGroups;
+  VisuGUI_ListBox* mySelectedGroups;
+  
+  QToolButton* myAddButton;
+  QToolButton* myRemoveButton;
+};
+
+
 class VisuGUI_ScalarBarDlg : public QDialog
 {
   Q_OBJECT;
@@ -203,8 +249,8 @@ class VisuGUI_ScalarBarDlg : public QDialog
   void initFromResources() {myScalarPane->initFromResources();}
   void storeToResources() {myScalarPane->storeToResources();}
 
-  void initFromPrsObject(VISU::ScalarMap_i* thePrs) {myScalarPane->initFromPrsObject(thePrs);}
-  int storeToPrsObject(VISU::ScalarMap_i* thePrs) {return myScalarPane->storeToPrsObject(thePrs);}
+  void initFromPrsObject(VISU::PrsMerger_i* thePrs);
+  int storeToPrsObject(VISU::PrsMerger_i* thePrs);
 
  private:
   void keyPressEvent( QKeyEvent* e );
@@ -216,6 +262,7 @@ class VisuGUI_ScalarBarDlg : public QDialog
 
  protected:
   VisuGUI_ScalarBarPane* myScalarPane;
+  VisuGUI_GroupSelectPane* myGroupPane;
 };
 
 #endif // VISUGUI_SCALARBARDLG_H
index 91d6fd39fc44b869568fcf682dc213654a118dc1..46e66c08c01454352cbf9b05443d59ab827650c8 100644 (file)
@@ -649,7 +649,7 @@ void SetupDlg::onFieldChange (int theIndex)
   }
 
   switch (aData.myPrsType) {
-  case VISU::TSCALARMAP: //Scalar Map
+  case VISU::TPRSMERGER: //Scalar Map
     myTypeCombo->setCurrentItem(myTypeId2ComboId[TSCALARMAP_ITEM]);
     break;
   case VISU::TISOSURFACE: //Iso Surfaces
@@ -690,7 +690,7 @@ void SetupDlg::onTypeChanged (int theIndex)
   int aType = myComboId2TypeId[theIndex];
   switch (aType) {
   case TSCALARMAP_ITEM: //Scalar Map
-    aData.myPrsType = VISU::TSCALARMAP;
+    aData.myPrsType = VISU::TPRSMERGER;
     break;
   case TISOSURFACE_ITEM: //Iso Surfaces
     aData.myPrsType = VISU::TISOSURFACE;
@@ -764,7 +764,7 @@ void SetupDlg::onPreferencesDlg()
   switch (aType) {
   case TSCALARMAP_ITEM: //Scalar Map
     c.suspend();
-    EditPrs<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg>(myModule,aData);
+    EditPrs<VISU::PrsMerger_i,VisuGUI_ScalarBarDlg>(myModule,aData);
     break;
   case TISOSURFACE_ITEM: //Iso Surfaces
     c.suspend();
index 1ffbc39916aea7bce14049c3b466e95d033b0357..763de11a8b7f43d98bc3a680d253f866d512a306 100644 (file)
@@ -1156,7 +1156,7 @@ namespace VISU
       if (!CORBA::is_nil(aVisuObj)) {
         VISU::VISUType aType = aVisuObj->GetType();
         switch (aType) {
-        case VISU::TSCALARMAP:
+       case VISU::TPRSMERGER:
         case VISU::TISOSURFACE:
         case VISU::TDEFORMEDSHAPE:
         case VISU::TCUTPLANES: