Salome HOME
bug #243: GUI for groups
authorasl <asl@opencascade.com>
Tue, 17 Dec 2013 06:45:45 +0000 (06:45 +0000)
committerasl <asl@opencascade.com>
Tue, 17 Dec 2013 06:45:45 +0000 (06:45 +0000)
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Shape.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 322fc12392efe8c04cd0d9f34b662aad65d01670..da21a508e0c96aa8c852785427bbde35c45bbb24 100644 (file)
@@ -64,6 +64,7 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
 : HYDROGUI_Wizard( theModule, theTitle )
 {
   addPage( createObjectsPage() );
+  addPage( createGroupsPage() );
   addPage( createZonesPage() );
 }
 
@@ -96,19 +97,19 @@ QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
     SIGNAL( boundarySelected( const QString & ) ) );
 
   myGeomObjects = new QListWidget( aPage );
-  myGeomObjects->setSelectionMode( QListWidget::SingleSelection );
+  myGeomObjects->setSelectionMode( QListWidget::ExtendedSelection );
   myGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
   myGeomObjects->setViewMode( QListWidget::ListMode );
   myGeomObjects->setSortingEnabled( true );
 
   myAvailableGeomObjects = new QListWidget( aPage );
-  myAvailableGeomObjects->setSelectionMode( QListWidget::SingleSelection );
+  myAvailableGeomObjects->setSelectionMode( QListWidget::ExtendedSelection );
   myAvailableGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
   myAvailableGeomObjects->setViewMode( QListWidget::ListMode );
   myAvailableGeomObjects->setSortingEnabled( true );
 
-  connect( myGeomObjects, SIGNAL( currentTextChanged( const QString & ) ), 
-    SIGNAL( objectSelected( const QString & ) ) );
+  connect( myGeomObjects, SIGNAL( itemSelectionChanged() ), 
+    SIGNAL( objectsSelected() ) );
 
   QFrame* anObjectsFrame = new QFrame( aPage );
   QGridLayout* anObjsLayout = new QGridLayout( anObjectsFrame );
@@ -162,6 +163,69 @@ QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
   return aPage;
 }
 
+QWizardPage* HYDROGUI_CalculationDlg::createGroupsPage() {
+  QWizardPage* aPage = new QWizardPage( mainFrame() );
+  QFrame* aFrame = new QFrame( aPage );
+
+  myGroups = new QListWidget( aPage );
+  myGroups->setSelectionMode( QListWidget::ExtendedSelection );
+  myGroups->setEditTriggers( QListWidget::NoEditTriggers );
+  myGroups->setViewMode( QListWidget::ListMode );
+  myGroups->setSortingEnabled( true );
+
+  myAvailableGroups = new QListWidget( aPage );
+  myAvailableGroups->setSelectionMode( QListWidget::ExtendedSelection );
+  myAvailableGroups->setEditTriggers( QListWidget::NoEditTriggers );
+  myAvailableGroups->setViewMode( QListWidget::ListMode );
+  myAvailableGroups->setSortingEnabled( true );
+
+  connect( myGroups, SIGNAL( itemSelectionChanged() ), 
+    SIGNAL( groupsSelected() ) );
+
+  QFrame* aGroupsFrame = new QFrame( aPage );
+  QGridLayout* aGroupsLayout = new QGridLayout( aGroupsFrame );
+  aGroupsLayout->setMargin( 5 );
+  aGroupsLayout->setSpacing( 5 );
+  aGroupsFrame->setLayout( aGroupsLayout );
+
+  QFrame* aBtnsFrame = new QFrame( aGroupsFrame );
+  QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
+  aBtnsLayout->setMargin( 5 );
+  aBtnsLayout->setSpacing( 5 );
+  aBtnsFrame->setLayout( aBtnsLayout );
+  QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
+  QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
+
+  // Fill the butons frame with two buttons
+  aBtnsLayout->addWidget( anAddBtn );
+  aBtnsLayout->addWidget( aRemoveBtn );
+  aBtnsLayout->addStretch( 1 );
+
+  QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_GROUPS" ), aGroupsFrame );
+  QLabel* anAvailableLabel = new QLabel( tr( "AVAILABLE_GROUPS" ), aGroupsFrame );
+
+  // Fill the objects frame with two lists, two labels and with buttons frame
+  aGroupsLayout->addWidget( anAvailableLabel, 0, 0, Qt::AlignHCenter );
+  aGroupsLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
+  aGroupsLayout->addWidget( myAvailableGroups, 1, 0, Qt::AlignHCenter );
+  aGroupsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
+  aGroupsLayout->addWidget( myGroups, 1, 2, Qt::AlignHCenter );
+
+  // Fill the page
+  QGridLayout* aPageLayout = new QGridLayout( aPage );
+  aPageLayout->setMargin( 5 );
+  aPageLayout->setSpacing( 5 );
+  aPageLayout->setVerticalSpacing( 10 );
+  aPageLayout->addWidget( aGroupsFrame, 0, 0, Qt::AlignHCenter );
+
+  aPage->setLayout( aPageLayout );
+
+  connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addGroups() ) );
+  connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeGroups() ) );
+
+  return aPage;
+}
+
 QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
   QWizardPage* aPage = new QWizardPage( mainFrame() );
   QFrame* aFrame = new QFrame( aPage );
index 43770dc28722b39a09f254d4d925e361dc19e66d..414d4af6be52fa68bad4bf80cc6cd0bc8bea1914 100644 (file)
@@ -84,7 +84,12 @@ public slots:
 signals:
   void                       addObjects();
   void                       removeObjects();
-  void                       objectSelected( const QString & theObjName );
+  void                       objectsSelected();
+
+  void                       addGroups();
+  void                       removeGroups();
+  void                       groupsSelected();
+
   void                       boundarySelected( const QString & theObjName );
   void                       setMergeType( int theMergeType, QString& theBathymetryName );
   void                       createRegion( const QList<SUIT_DataObject*>& theZonesList );
@@ -98,6 +103,7 @@ protected:
 private:
 
   QWizardPage*               createObjectsPage();
+  QWizardPage*               createGroupsPage();
   QWizardPage*               createZonesPage();
 
   QGroupBox*                 myObjectNameGroup;
@@ -109,6 +115,9 @@ private:
   QListWidget*               myAvailableGeomObjects;
   QListWidget*               myGeomObjects;
 
+  QListWidget*               myAvailableGroups;
+  QListWidget*               myGroups;
+
   HYDROGUI_DataBrowser*      myBrowser;
   Handle(HYDROData_CalculationCase) myEditedObject;
   QComboBox*                 myBathymetryChoice;
index 2dabc9fa9714a77fdf10a696578d8754300225c3..91cbb27e626219cebc7b0c45ea94b9dbed0cece9 100644 (file)
@@ -204,7 +204,7 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
   // Connect signals and slots
   connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
   connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
-  connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onSplitZones() ) );
+  connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
   connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones() ) );
   //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
   connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
@@ -214,8 +214,8 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
     SLOT( onCreateRegion( const QList<SUIT_DataObject*>& ) ) );
   connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ),
     SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) );
-  connect( aPanel, SIGNAL( objectSelected( const QString & ) ), 
-    SLOT( onObjectSelected( const QString & ) ) );
+  connect( aPanel, SIGNAL( objectsSelected() ), 
+           SLOT( onObjectsSelected() ) );
   connect( aPanel, SIGNAL( boundarySelected( const QString & ) ), 
     SLOT( onBoundarySelected( const QString & ) ) );
 
@@ -261,14 +261,22 @@ void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
   }
 }
 
-void HYDROGUI_CalculationOp::onObjectSelected ( const QString & theObjName )
+void HYDROGUI_CalculationOp::onObjectsSelected()
 {
+  HYDROGUI_CalculationDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+
+  QStringList aSelectedObjs = aPanel->getSelectedGeomObjects();
+  QMap<QString, bool> aSelectedObjsMap;
+  foreach( QString aName, aSelectedObjs )
+    aSelectedObjsMap[aName] = true;
+
+
   // Select the appropriate geometry object shape in the viewer
   selectionMgr()->clearSelected();
 
   // Unhighlight all objects except selected
-  HYDROGUI_Shape* aShape;
-  HYDROGUI_Shape* aSelectedShape = 0;
+  HYDROGUI_Shape* aShape = 0, *aLastShape = 0;
   Handle(HYDROData_Entity) anEntity;
   HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
   HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
@@ -283,27 +291,15 @@ void HYDROGUI_CalculationOp::onObjectSelected ( const QString & theObjName )
       if ( aShape )
       {
         aName = anEntity->GetName();
-        isSelected = ( aName == theObjName );
-        if ( isSelected )
-        {
-          aSelectedShape = aShape;
-        }
-        if ( aShape->isHighlighted() != isSelected )
-        {
-          if ( !isSelected )
-          {
-            aShape->highlight( isSelected );
-            aShape->update();
-          }
-        }
+        isSelected = aSelectedObjsMap.contains( aName );
+        aShape->highlight( isSelected, false );
+        aShape->update( false );
+        aLastShape = aShape;
       }
     }
   }
-  if ( aSelectedShape )
-  {
-    aSelectedShape->highlight( true );
-    aSelectedShape->update();
-  }
+  if( aLastShape )
+    aLastShape->update( true );
 }
 
 void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem )
@@ -553,43 +549,50 @@ void HYDROGUI_CalculationOp::onApply()
   }
 }
 
-void HYDROGUI_CalculationOp::onSplitZones()
+void HYDROGUI_CalculationOp::onNext( const int theIndex )
 {
-  HYDROGUI_CalculationDlg* aPanel = 
-    ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
-  if ( !aPanel )
-    return;
-
-  QApplication::setOverrideCursor( Qt::WaitCursor );
-
-  QString aNewCaseName = aPanel->getObjectName();
-  QString anOldCaseName = myEditedObject->GetName();
+  if( theIndex==1 )
+  {
+    setAvailableGroups();
+  }
+  else if( theIndex==2 )
+  {
+    HYDROGUI_CalculationDlg* aPanel = 
+      ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+    if ( !aPanel )
+      return;
 
-  bool anIsToUpdateOb = myIsEdit && anOldCaseName != aNewCaseName;
+    QApplication::setOverrideCursor( Qt::WaitCursor );
   
-  // At first we must to update the case name because of 
-  // automatic names generation for regions and zones
-  myEditedObject->SetName( aNewCaseName );
+    QString aNewCaseName = aPanel->getObjectName();
+    QString anOldCaseName = myEditedObject->GetName();
   
-  if ( myEditedObject->IsMustBeUpdated() )
-  {
-    myShowZones = true;
-    myEditedObject->Update();
+    bool anIsToUpdateOb = myIsEdit && anOldCaseName != aNewCaseName;
+  
+    // At first we must to update the case name because of 
+    // automatic names generation for regions and zones
+    myEditedObject->SetName( aNewCaseName );
+  
+    if ( myEditedObject->IsMustBeUpdated() )
+    {
+      myShowZones = true;
+      myEditedObject->Update();
 
-    //aPanel->setEditedObject( myEditedObject );
-    aPanel->refreshZonesBrowser();
+      //aPanel->setEditedObject( myEditedObject );
+      aPanel->refreshZonesBrowser();
 
-    createPreview();
-  }
-  else
-  {
-    setZonesVisible( true );
-  }
+      createPreview();
+    }
+    else
+    {
+      setZonesVisible( true );
+    }
 
-  if ( anIsToUpdateOb )
-    module()->getApp()->updateObjectBrowser( false );
+    if ( anIsToUpdateOb )
+      module()->getApp()->updateObjectBrowser( false );
 
-  QApplication::restoreOverrideCursor();
+    QApplication::restoreOverrideCursor();
+  }
 }
 
 void HYDROGUI_CalculationOp::onHideZones()
@@ -768,4 +771,15 @@ void HYDROGUI_CalculationOp::closePreview()
   }
 }
 
+void HYDROGUI_CalculationOp::setAvailableGroups()
+{
+  HYDROGUI_CalculationDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
 
+  HYDROData_SequenceOfObjects anObjs = myEditedObject->GetGeometryObjects();
+  for( int anIndex = 1, aLength = anObjs.Length(); anIndex <= aLength; anIndex++ )
+  {
+    Handle_HYDROData_Object anObj = Handle_HYDROData_Object::DownCast( anObjs.Value( anIndex ) );
+    //TODO: anObj->GetGroups();
+  }
+}
index 1ede7ff639838b5b6a25b44ea29e029526590e15..d60637c5ab74d68246199aa78d7e08461d7568d6 100644 (file)
@@ -54,6 +54,8 @@ protected:
   virtual void                    onApply();
   virtual bool                    processApply( int& theUpdateFlags, QString& theErrorMsg );
 
+  void setAvailableGroups();
+
 protected slots:
   /**
    * Add geometry objects selected in the module browser to the calculation case.
@@ -79,7 +81,7 @@ protected slots:
   /**
    * Case objects must be splitted to zones if the case has been modified or new.
    */
-  void                            onSplitZones();
+  void                            onNext( const int );
   void                            onLastViewClosed( SUIT_ViewManager* );
   /**
    * The zone is selected in the browser on the second page of the wizard.
@@ -92,7 +94,7 @@ protected slots:
   /** 
    * Geometry object is selected in the list on the first wizard page
    */
-  void                            onObjectSelected ( const QString & theObjName );
+  void                            onObjectsSelected();
   /** 
    * Boundary polyline is selected in the list on the first wizard page
    */
index 8ff001e2183bdd3fea701e2a4ef2ddb89eb86672..ceafe1eb669f408b4fbcfe5fc72bcbec1cf95f31 100644 (file)
@@ -377,7 +377,7 @@ void HYDROGUI_Shape::setVisible( const bool theState,
     myContext->Erase( myShape, theIsUpdateViewer );
 }
 
-void HYDROGUI_Shape::highlight( bool theIsHighlight )
+void HYDROGUI_Shape::highlight( bool theIsHighlight, bool isUpdateViewer )
 {
   if ( myIsHighlight == theIsHighlight )
     return;
@@ -388,7 +388,7 @@ void HYDROGUI_Shape::highlight( bool theIsHighlight )
     return;
 
   colorShapeBorder( getActiveColor() );
-  myContext->Display( myShape );
+  myContext->Display( myShape, isUpdateViewer );
 }
 
 bool HYDROGUI_Shape::isHighlighted() const
index 31966461ae710c1d07aec6cb4955f9acffe6eb62..a1af4dbb7390e8041fe874daa7c01864d6f95ff4 100644 (file)
@@ -46,7 +46,7 @@ public:
   virtual void               display( const bool theIsUpdateViewer = true );
   virtual void               erase( const bool theIsUpdateViewer = true );
 
-  virtual void               highlight( bool theIsHighlight );
+  virtual void               highlight( bool theIsHighlight, bool isUpdateViewer );
   virtual bool               isHighlighted() const;
 
   Handle(HYDROData_Entity)   getObject() const { return myObject; }
index 7267eefba9ae300e4a9129891377ad685c052a59..08ae62f6adb97a33fa7ba125363e32873d168989 100644 (file)
@@ -201,6 +201,14 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>INCLUDED_OBJECTS</source>
       <translation>Included objects</translation>
     </message>
+    <message>
+      <source>AVAILABLE_GROUPS</source>
+      <translation>Available groups</translation>
+    </message>
+    <message>
+      <source>INCLUDED_GROUPS</source>
+      <translation>Included groups</translation>
+    </message>
     <message>
       <source>LIMITS</source>
       <translation>Limits</translation>