]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Splitting of czlculztion zones.
authoradv <adv@opencascade.com>
Thu, 19 Sep 2013 15:04:12 +0000 (15:04 +0000)
committeradv <adv@opencascade.com>
Thu, 19 Sep 2013 15:04:12 +0000 (15:04 +0000)
16 files changed:
src/HYDROData/HYDROData_Calculation.cxx
src/HYDROData/HYDROData_Calculation.h
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DataModel.h
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_SplitZonesTool.cxx
src/HYDROGUI/HYDROGUI_SplitZonesTool.h
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_Tool.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index c836f54882b85ee58a9a883cc39e917d1b6a6e31..8b9c94d7bd051a384b9fc6244a04367d7e791ff4 100644 (file)
@@ -4,6 +4,7 @@
 #include "HYDROData_Document.h"
 #include "HYDROData_Iterator.h"
 #include "HYDROData_Polyline.h"
+#include "HYDROData_Zone.h"
 
 #include <TDataStd_ReferenceList.hxx>
 
@@ -53,3 +54,83 @@ Handle(HYDROData_Polyline) HYDROData_Calculation::GetBoundaryPolyline() const
   return Handle(HYDROData_Polyline)::DownCast( 
            GetReferenceObject( DataTag_BoundaryPolyline ) );
 }
+
+void HYDROData_Calculation::RemoveBoundaryPolyline()
+{
+  ClearReferenceObjects( DataTag_BoundaryPolyline );
+}
+
+int HYDROData_Calculation::NbZones() const
+{
+  return NbReferenceObjects( DataTag_Zone );
+}
+
+void HYDROData_Calculation::AddZone( const Handle(HYDROData_Zone)& theZone )
+{
+  AddReferenceObject( theZone, DataTag_Zone );
+}
+
+void HYDROData_Calculation::SetZone( const int                     theIndex,
+                                     const Handle(HYDROData_Zone)& theZone )
+{
+  SetReferenceObject( theZone, DataTag_Zone, theIndex );
+}
+
+void HYDROData_Calculation::SetZones( const HYDROData_SequenceOfObjects& theZones )
+{
+  SetReferenceObjects( theZones, DataTag_Zone );
+}
+
+Handle(HYDROData_Zone) HYDROData_Calculation::GetZone( const int theIndex ) const
+{
+  return Handle(HYDROData_Zone)::DownCast( 
+           GetReferenceObject( DataTag_Zone, theIndex ) );
+}
+
+HYDROData_SequenceOfObjects HYDROData_Calculation::GetZones() const
+{
+  return GetReferenceObjects( DataTag_Zone );
+}
+
+void HYDROData_Calculation::RemoveZones()
+{
+  ClearReferenceObjects( DataTag_Zone );
+}
+
+int HYDROData_Calculation::NbSplittedZones() const
+{
+  return NbReferenceObjects( DataTag_SplittedZone );
+}
+
+void HYDROData_Calculation::AddSplittedZone( const Handle(HYDROData_Zone)& theZone )
+{
+  AddReferenceObject( theZone, DataTag_SplittedZone );
+}
+
+void HYDROData_Calculation::SetSplittedZone( const int                     theIndex,
+                                             const Handle(HYDROData_Zone)& theZone )
+{
+  SetReferenceObject( theZone, DataTag_SplittedZone, theIndex );
+}
+
+void HYDROData_Calculation::SetSplittedZones( const HYDROData_SequenceOfObjects& theZones )
+{
+  SetReferenceObjects( theZones, DataTag_SplittedZone );
+}
+
+Handle(HYDROData_Zone) HYDROData_Calculation::GetSplittedZone( const int theIndex ) const
+{
+  return Handle(HYDROData_Zone)::DownCast( 
+           GetReferenceObject( DataTag_SplittedZone, theIndex ) );
+}
+
+HYDROData_SequenceOfObjects HYDROData_Calculation::GetSplittedZones() const
+{
+  return GetReferenceObjects( DataTag_SplittedZone );
+}
+
+void HYDROData_Calculation::RemoveSplittedZones()
+{
+  ClearReferenceObjects( DataTag_SplittedZone );
+}
+  
index cee923cecc6ca48b4206d7630844bf4771bff632..64de389ef9fb2ba4488e217b34493f30b5505e57 100644 (file)
@@ -10,6 +10,7 @@ class QPointF;
 class QFile;
 
 class Handle(HYDROData_Polyline);
+class Handle(HYDROData_Zone);
 
 DEFINE_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object)
 
@@ -31,6 +32,8 @@ protected:
   {
     DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
     DataTag_BoundaryPolyline,    ///< reference boundary polyline
+    DataTag_Zone,                ///< reference zones
+    DataTag_SplittedZone         ///< reference splitted zones
   };
 
 public:
@@ -51,10 +54,95 @@ public:
 public:      
   // Public methods to work with Calculation
 
+  /**
+   * Sets boundary polyline for calculation case.
+   */
   HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline );
 
+  /**
+   * Returns boundary polyline of calculation case.
+   */
   HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline) GetBoundaryPolyline() const;
 
+  /**
+   * Removes boundary polyline of calculation case.
+   */
+  HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
+
+
+  /**
+   * Returns number of refrence zones for calculation case.
+   */
+  HYDRODATA_EXPORT virtual int NbZones() const;
+
+  /**
+   * Add new one refrence zone for calculation case.
+   */
+  HYDRODATA_EXPORT virtual void AddZone( const Handle(HYDROData_Zone)& theZone );
+
+  /**
+   * Replace the refrence zone for calculation case.
+   */
+  HYDRODATA_EXPORT virtual void SetZone( const int                     theIndex,
+                                         const Handle(HYDROData_Zone)& theBathymetry );
+
+  /**
+   * Sets the refrence zones for calculation case.
+   */
+  HYDRODATA_EXPORT virtual void SetZones( const HYDROData_SequenceOfObjects& theZones );
+
+  /**
+   * Returns refrence zone of calculation case by index.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZone( const int theIndex ) const;
+
+  /**
+   * Returns all refrence zone of calculation case.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetZones() const;
+
+  /**
+   * Removes all refrence zone of calculation case.
+   */
+  HYDRODATA_EXPORT virtual void RemoveZones();
+
+
+  /**
+   * Returns number of splitted zones for calculation case.
+   */
+  HYDRODATA_EXPORT virtual int NbSplittedZones() const;
+
+  /**
+   * Add new one splitted zone for calculation case.
+   */
+  HYDRODATA_EXPORT virtual void AddSplittedZone( const Handle(HYDROData_Zone)& theZone );
+
+  /**
+   * Replace the splitted zone for calculation case.
+   */
+  HYDRODATA_EXPORT virtual void SetSplittedZone( const int                     theIndex,
+                                                 const Handle(HYDROData_Zone)& theBathymetry );
+
+  /**
+   * Sets the refrence zones for calculation case.
+   */
+  HYDRODATA_EXPORT virtual void SetSplittedZones( const HYDROData_SequenceOfObjects& theZones );
+
+  /**
+   * Returns splitted zone of calculation case by index.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetSplittedZone( const int theIndex ) const;
+
+  /**
+   * Returns all splitted zone of calculation case.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedZones() const;
+
+  /**
+   * Removes all splitted refrence zone of calculation case.
+   */
+  HYDRODATA_EXPORT virtual void RemoveSplittedZones();
+
 protected:
 
   friend class HYDROData_Iterator;
index 062be0df68c1cdad67fe579dd4bd62ec48ac13a7..9a971a75a61172f187e110cf429866fbcc6a8e1c 100644 (file)
@@ -175,6 +175,18 @@ void HYDROData_Object::SetReferenceObject( const Handle_HYDROData_Object& theObj
   }
 }
 
+void HYDROData_Object::SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
+                                            const int                          theTag )
+{
+  ClearReferenceObjects( theTag );
+  if ( theObjects.IsEmpty() )
+    return;
+
+  HYDROData_SequenceOfObjects::Iterator anIter( theObjects );
+  for ( ; anIter.More(); anIter.Next() )
+    AddReferenceObject( anIter.Value(), theTag );
+}
+
 Handle(HYDROData_Object) HYDROData_Object::GetReferenceObject( const int theTag,
                                                                const int theIndex ) const
 {
index a44ffdb5affa77eee20a992de5b729a8ca50b1f8..caa0b29ce5c14dd65c1c910ee594e04875b39df1 100644 (file)
@@ -188,6 +188,14 @@ protected:
                            const int                      theTag = 0,
                            const int                      theIndex = 0 );
 
+  /**
+   * Internal method that used to store the reference object label attribute
+   * \param theObjects sequence with pointers to reference objects
+   * \param theTag tag of a label to store attribute (for 0 this is myLab)
+   */
+  void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
+                            const int                          theTag = 0 );
+
   /**
    * Internal method that used to retreive the reference object(s) attribute
    * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
index b1f888174f1366048fa16c431475e8e73912ea78..90869a487212396dfde99d19883baa2bdc5f00e5 100644 (file)
@@ -33,7 +33,9 @@
 #include <QLabel>
 #include <QLayout>
 #include <QLineEdit>
+#include <QListWidget>
 #include <QPicture>
+#include <QPushButton>
 #include <QToolButton>
 
 HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle )
@@ -50,6 +52,8 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
   aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
   aNameLayout->addWidget( myObjectName );
 
+  
+  // Calculation boundary line
   QGroupBox* aBndGroup = new QGroupBox( tr( "CALCULATION_BOUNDARY" ), mainFrame() );
 
   myBndPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINE, aBndGroup );
@@ -60,10 +64,44 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
   aBndLayout->addWidget( new QLabel( tr( "BOUNDARY_POLYLINE" ), aBndGroup ) );
   aBndLayout->addWidget( myBndPolyline );
 
+
+  // Calculation zones
+  QGroupBox* aZonesGroup = new QGroupBox( tr( "CALCULATION_ZONES" ), mainFrame() );
+
+  myZones = new QListWidget( aZonesGroup );
+  myZones->setSelectionMode( QListWidget::SingleSelection );
+  myZones->setEditTriggers( QListWidget::NoEditTriggers );
+  myZones->setViewMode( QListWidget::ListMode );
+
+  mySplittedZones = new QListWidget( aZonesGroup );
+  mySplittedZones->setSelectionMode( QListWidget::SingleSelection );
+  mySplittedZones->setEditTriggers( QListWidget::NoEditTriggers );
+  mySplittedZones->setViewMode( QListWidget::ListMode );
+
+  mySplittedZonesPrefix = new QLineEdit( aZonesGroup );
+
+  QPushButton* aSplitBtn = new QPushButton( tr( "SPLIT_REFERENCE_ZONES" ), aZonesGroup );
+
+  QGridLayout* aZonesLayout = new QGridLayout( aZonesGroup );
+  aZonesLayout->setMargin( 5 );
+  aZonesLayout->setSpacing( 5 );
+  aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_REFERENCE_ZONES" ), aZonesGroup ), 0, 0, 1, 2 );
+  aZonesLayout->addWidget( myZones, 1, 0, 1, 2 );
+  aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_SPLITTED_ZONES" ), aZonesGroup ), 2, 0, 1, 2 );
+  aZonesLayout->addWidget( mySplittedZones, 3, 0, 1, 2 );
+  aZonesLayout->addWidget( new QLabel( tr( "PREFIX_SPLITTED_ZONES" ), aZonesGroup ), 4, 0 );
+  aZonesLayout->addWidget( mySplittedZonesPrefix, 4, 1 );
+  aZonesLayout->addWidget( aSplitBtn, 5, 0, 1, 2 );
+
   // Common
   addWidget( myObjectNameGroup );
   addWidget( aBndGroup );
+  addWidget( aZonesGroup );
   addStretch();
+
+
+  // Connect signals and slots
+  connect( aSplitBtn, SIGNAL( clicked( bool ) ), this, SIGNAL( SplitZones() ) );
 }
 
 HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
@@ -75,6 +113,11 @@ void HYDROGUI_CalculationDlg::reset()
   myObjectName->clear();
 
   myBndPolyline->Clear();
+
+  myZones->clear();
+  mySplittedZones->clear();
+
+  setSplitZonesPrefix( tr( "DEFAULT_PREFIX_SPLITTED_ZONES" ) );
 }
 
 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
@@ -97,5 +140,96 @@ QString HYDROGUI_CalculationDlg::getPolylineName() const
   return myBndPolyline->GetName();
 }
 
+void HYDROGUI_CalculationDlg::setZones( const QStringList& theZones )
+{
+  myZones->clear();
+
+  for ( int i = 0, n = theZones.length(); i < n; ++i )
+  {
+    QString aZoneName = theZones.at( i );
+
+    QListWidgetItem* aListItem = new QListWidgetItem( aZoneName, myZones );
+    aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable );
+    aListItem->setCheckState( Qt::Unchecked );
+  }
+}
+
+void HYDROGUI_CalculationDlg::setSelectedZones( const QStringList& theZones )
+{
+  for ( int i = 0, n = theZones.length(); i < n; ++i )
+  {
+    QString aZoneName = theZones.at( i );
 
+    QList<QListWidgetItem *> anItems = 
+      myZones->findItems( aZoneName, Qt::MatchFixedString | Qt::MatchCaseSensitive );
+    if ( anItems.isEmpty() )
+      continue;
+
+    QListWidgetItem* aListItem = anItems.first();
+    if ( !aListItem )
+      continue;
+
+    aListItem->setCheckState( Qt::Checked );
+  }
+}
+
+QStringList HYDROGUI_CalculationDlg::getSelectedZones() const
+{
+  QStringList aResList;
+
+  for ( int i = 0, n = myZones->count(); i < n; ++i )
+  {
+    QListWidgetItem* aListItem = myZones->item( i );
+    if ( !aListItem || aListItem->checkState() != Qt::Checked )
+      continue;
+
+    QString aSelZoneName = aListItem->text();
+    aResList.append( aSelZoneName );
+  }
+
+  return aResList;
+}
+
+void HYDROGUI_CalculationDlg::setSplittedZones( const QStringList& theZones )
+{
+  mySplittedZones->clear();
+
+  for ( int i = 0, n = theZones.length(); i < n; ++i )
+  {
+    QString aZoneName = theZones.at( i );
+
+    QListWidgetItem* aListItem = new QListWidgetItem( aZoneName, mySplittedZones );
+    aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
+  }
+}
+
+QStringList HYDROGUI_CalculationDlg::getSplittedZones() const
+{
+  QStringList aResList;
+
+  for ( int i = 0, n = mySplittedZones->count(); i < n; ++i )
+  {
+    QListWidgetItem* aListItem = mySplittedZones->item( i );
+    if ( !aListItem )
+      continue;
+
+    QString aSplittedZoneName = aListItem->text();
+    aResList.append( aSplittedZoneName );
+  }
+
+  return aResList;
+}
+
+void HYDROGUI_CalculationDlg::setSplitZonesPrefix( const QString& theName )
+{
+  mySplittedZonesPrefix->setText( theName );
+}
+
+QString HYDROGUI_CalculationDlg::getSplitZonesPrefix() const
+{
+  QString aPrefix = mySplittedZonesPrefix->text();
+  if ( aPrefix.isEmpty() )
+    aPrefix = tr( "DEFAULT_PREFIX_SPLITTED_ZONES" );
+  return aPrefix;
+}
 
index b9a0395cf63895e660dc5b420fbb003836e137f7..742bbca9ca5817184b8cbd73aa0646ddd45bc218 100644 (file)
@@ -28,6 +28,7 @@
 class HYDROGUI_ObjSelector;
 class QGroupBox;
 class QLineEdit;
+class QListWidget;
 
 class HYDROGUI_CalculationDlg : public HYDROGUI_InputPanel
 {
@@ -45,11 +46,28 @@ public:
   void                       setPolylineName( const QString& theName );
   QString                    getPolylineName() const;
 
+  void                       setZones( const QStringList& theZones );
+  void                       setSelectedZones( const QStringList& theZones );
+  QStringList                getSelectedZones() const;
+
+  void                       setSplittedZones( const QStringList& theZones );
+  QStringList                getSplittedZones() const;
+
+  void                       setSplitZonesPrefix( const QString& theName );
+  QString                    getSplitZonesPrefix() const;
+
+signals:
+  void                       SplitZones();
+
 private:
   QGroupBox*                 myObjectNameGroup;
   QLineEdit*                 myObjectName;
 
   HYDROGUI_ObjSelector*      myBndPolyline;
+
+  QListWidget*               myZones;
+  QListWidget*               mySplittedZones;
+  QLineEdit*                 mySplittedZonesPrefix;
 };
 
 #endif
index 492b381fb9cac2a88a5fd3085ce7616363a825b6..5d4a465b695d194b9e13b965bfebd34e515d6ae5 100644 (file)
 #include "HYDROGUI_UpdateFlags.h"
 
 #include <HYDROData_Polyline.h>
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Zone.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
 
 #include <LightApp_Application.h>
 #include <LightApp_UpdateFlags.h>
 
+#include <QApplication>
+
 HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit )
 : HYDROGUI_Operation( theModule ),
-  myIsEdit( theIsEdit )
+  myIsEdit( theIsEdit ),
+  myActiveViewManager( NULL ),
+  myPreviewViewManager( NULL )
 {
   setName( myIsEdit ? tr( "EDIT_CALCULATION" ) : tr( "CREATE_CALCULATION" ) );
 }
 
 HYDROGUI_CalculationOp::~HYDROGUI_CalculationOp()
 {
+  closePreview();
 }
 
 void HYDROGUI_CalculationOp::startOperation()
@@ -53,10 +63,13 @@ void HYDROGUI_CalculationOp::startOperation()
   if ( !aPanel )
     return;
 
+  mySplittedZones.clear();
   aPanel->reset();
 
   QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" );
 
+  QStringList aSelectedZones, aSplittedZones;
+
   myEditedObject.Nullify();
   if ( myIsEdit )
   {
@@ -71,25 +84,87 @@ void HYDROGUI_CalculationOp::startOperation()
         QString aPolylineName = aBoundaryPolyline->GetName();
         aPanel->setPolylineName( aPolylineName );
       }
+
+      HYDROData_SequenceOfObjects aRefZones = myEditedObject->GetZones();
+      HYDROData_SequenceOfObjects::Iterator anIter( aRefZones );
+      for ( ; anIter.More(); anIter.Next() )
+      {
+        Handle(HYDROData_Zone) aRefZone = 
+          Handle(HYDROData_Zone)::DownCast( anIter.Value() );
+        if ( aRefZone.IsNull() )
+          continue;
+
+        QString aRefZoneName = aRefZone->GetName();
+        if ( aRefZoneName.isEmpty() )
+          continue;
+
+        aSelectedZones.append( aRefZoneName );
+      }
+
+      HYDROData_SequenceOfObjects aSplitZones = myEditedObject->GetSplittedZones();
+      anIter.Init( aSplitZones );
+      for ( ; anIter.More(); anIter.Next() )
+      {
+        Handle(HYDROData_Zone) aSplitZone = 
+          Handle(HYDROData_Zone)::DownCast( anIter.Value() );
+        if ( aSplitZone.IsNull() )
+          continue;
+
+        QString aSplitZoneName = aSplitZone->GetName();
+        if ( aSplitZoneName.isEmpty() )
+          continue;
+
+        aSplittedZones.append( aSplitZoneName );
+      }
     }
   }
 
+  // collect information about existing zones
+  QStringList aZones;
+
+  HYDROData_Iterator anIter( doc(), KIND_ZONE );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Zone) aZoneObj = 
+      Handle(HYDROData_Zone)::DownCast( anIter.Current() );
+    if ( aZoneObj.IsNull() )
+      continue;
+
+    QString aZoneName = aZoneObj->GetName();
+    if ( aZoneName.isEmpty() )
+      continue;
+
+    aZones.append( aZoneName );
+  }
+
   aPanel->setObjectName( anObjectName );
+
+  aPanel->setZones( aZones );
+  aPanel->setSelectedZones( aSelectedZones );
+  aPanel->setSplittedZones( aSplittedZones );
 }
 
 void HYDROGUI_CalculationOp::abortOperation()
 {
+  closePreview();
+
   HYDROGUI_Operation::abortOperation();
 }
 
 void HYDROGUI_CalculationOp::commitOperation()
 {
+  closePreview();
+
   HYDROGUI_Operation::commitOperation();
 }
 
 HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
 {
   HYDROGUI_CalculationDlg* aPanel = new HYDROGUI_CalculationDlg( module(), getName() );
+
+  // Connect signals and slots
+  connect( aPanel, SIGNAL( SplitZones() ), this, SLOT( onSplitZones() ) );
+
   return aPanel;
 }
 
@@ -119,27 +194,220 @@ bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
     }
   }
 
+  Handle(HYDROData_Document) aDocument = doc();
+
   Handle(HYDROData_Calculation) aCalculObj = myIsEdit ? myEditedObject :
-    Handle(HYDROData_Calculation)::DownCast( doc()->CreateObject( KIND_CALCULATION ) );
+    Handle(HYDROData_Calculation)::DownCast( aDocument->CreateObject( KIND_CALCULATION ) );
   if ( aCalculObj.IsNull() )
     return false;
 
   aCalculObj->SetName( anObjectName );
 
-  Handle(HYDROData_Polyline) aBndPolyline;
-
   QString aPolylineName = aPanel->getPolylineName();
-  if ( !aPolylineName.isEmpty() )
-  {
-    aBndPolyline = Handle(HYDROData_Polyline)::DownCast(
+  Handle(HYDROData_Polyline) aBndPolyline = Handle(HYDROData_Polyline)::DownCast(
       HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) );
-  }
 
   aCalculObj->SetBoundaryPolyline( aBndPolyline );
 
+  QStringList aRefZoneNames = aPanel->getSelectedZones();
+  HYDROData_SequenceOfObjects aRefZones = 
+    HYDROGUI_Tool::FindObjectsByNames( module(), aRefZoneNames, KIND_ZONE );
+
+  aCalculObj->SetZones( aRefZones );
+
+  HYDROData_SequenceOfObjects aSplittedZones;
+
+  SplittedZonesList::iterator anIter = mySplittedZones.begin();
+  for ( ; anIter != mySplittedZones.end(); ++anIter )
+  {
+    const SplittedZone& aSplittedZone = *anIter;
+
+    Handle(HYDROData_Polyline) aPolyline =
+      Handle(HYDROData_Polyline)::DownCast( aDocument->CreateObject( KIND_POLYLINE ) );
+    Handle(HYDROData_Zone) aDtaZone =
+      Handle(HYDROData_Zone)::DownCast( aDocument->CreateObject( KIND_ZONE ) );
+
+    if( aPolyline.IsNull() || aDtaZone.IsNull() )
+      continue;
+
+    // Fill the polyline data
+    aPolyline->SetName( aSplittedZone.PolylineName );
+    aPolyline->setDimension( 2 );
+
+    QList<PolylineSection> aPolylineData;
+    for( int i = 0, n = aSplittedZone.SplitData.Path.elementCount(); i < n; i++ )
+    {
+      const QPainterPath::Element anElement = aSplittedZone.SplitData.Path.elementAt( i );
+      switch( anElement.type )
+      {
+        case QPainterPath::MoveToElement:
+          aPolylineData.append( PolylineSection() );
+          break;
+        case QPainterPath::LineToElement:
+          if( !aPolylineData.isEmpty() )
+          {
+            PolylineSection& aSection = aPolylineData.last();
+            aSection.myCoords << anElement.x;
+            aSection.myCoords << anElement.y;
+          }
+          break;
+        case QPainterPath::CurveToElement: // currently not supported
+        default:
+          break;
+      }
+    }
+    aPolyline->setPolylineData( aPolylineData );
+
+    // Fill the zone data
+    aDtaZone->SetName( aSplittedZone.ZoneName );
+    aDtaZone->SetPolyline( aPolyline );
+    aDtaZone->SetBorderColor( aSplittedZone.BorderColor );
+    aDtaZone->SetFillingColor( aSplittedZone.FillingColor );
+
+    aSplittedZones.Append( aDtaZone );
+  }
+
+  aCalculObj->SetSplittedZones( aSplittedZones );
+
   theUpdateFlags = UF_Model;
 
   return true;
 }
 
+void HYDROGUI_CalculationOp::onSplitZones()
+{
+  mySplittedZones.clear();
+
+  HYDROGUI_CalculationDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  QApplication::setOverrideCursor( Qt::WaitCursor );
+
+  QString aPolylineName = aPanel->getPolylineName();
+  Handle(HYDROData_Polyline) aBndPolyline = Handle(HYDROData_Polyline)::DownCast(
+      HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) );
+
+  QStringList aZoneNames = aPanel->getSelectedZones();
+  HYDROData_SequenceOfObjects aZones = 
+    HYDROGUI_Tool::FindObjectsByNames( module(), aZoneNames, KIND_ZONE );
+
+  QStringList aResSplittedZones;
+
+  HYDROGUI_SplitZonesTool::SplitDataList aSplittedZones =
+    HYDROGUI_SplitZonesTool::SplitZones( aZones, aBndPolyline );
+
+  QString aSplitZonesPrefix = aPanel->getSplitZonesPrefix();
+  QStringList aUsedNames;
+
+  HYDROGUI_SplitZonesTool::SplitDataListIterator anIter( aSplittedZones );
+  while( anIter.hasNext() )
+  {
+    SplittedZone aSplittedZone;
+    aSplittedZone.SplitData = anIter.next();
+
+    aSplittedZone.FillingColor = HYDROGUI_Tool::GenerateFillingColor( module(), aSplittedZone.SplitData.ZoneNames );
+    aSplittedZone.BorderColor  = QColor( HYDROData_Zone::DefaultBorderColor() );
+
+    aSplittedZone.ZoneName = HYDROGUI_Tool::GenerateObjectName( module(), aSplitZonesPrefix + "Zone", aUsedNames );
+    aSplittedZone.PolylineName = HYDROGUI_Tool::GenerateObjectName( module(), aSplitZonesPrefix + "Poly", aUsedNames );
+
+    aUsedNames.append( aSplittedZone.ZoneName );
+    aUsedNames.append( aSplittedZone.PolylineName );
+
+    aResSplittedZones.append( aSplittedZone.ZoneName );
+
+    mySplittedZones.append( aSplittedZone );
+  }
+
+  aPanel->setSplittedZones( aResSplittedZones );
+  
+  createPreview();
+
+  QApplication::restoreOverrideCursor();
+}
+
+void HYDROGUI_CalculationOp::createPreview()
+{
+  LightApp_Application* anApp = module()->getApp();
+
+  if ( !myActiveViewManager )
+  {
+    myActiveViewManager = anApp->activeViewManager();
+  }
+
+  if ( !myPreviewViewManager )
+  {
+    myPreviewViewManager = ::qobject_cast<OCCViewer_ViewManager*>( 
+      anApp->createViewManager( OCCViewer_Viewer::Type() ) );
+    if ( myPreviewViewManager )
+    {
+      connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+               this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+      module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_PreviewCaseZones );
+      myPreviewViewManager->setTitle( tr( "PREVIEW_CASE_ZONES" ) );
+    }
+  }
+
+  if ( !myPreviewViewManager )
+    return;
+
+  if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
+  {
+    Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+    if ( !aCtx.IsNull() )
+    {
+      SplittedZonesList::iterator anIter = mySplittedZones.begin();
+      for ( ; anIter != mySplittedZones.end(); ++anIter )
+      {
+        SplittedZone& aSplittedZone = *anIter;
+        if ( aSplittedZone.Shape )
+          delete aSplittedZone.Shape;
+
+        aSplittedZone.Shape = new HYDROGUI_Shape( aCtx );
+
+        aSplittedZone.Shape->setFillingColor( aSplittedZone.FillingColor, false );
+        aSplittedZone.Shape->setBorderColor( aSplittedZone.BorderColor, false );
+        aSplittedZone.Shape->setPath( aSplittedZone.SplitData.Path, true );
+      }
+    }
+  }
+}
+
+void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
+{
+  closePreview();
+}
+
+void HYDROGUI_CalculationOp::closePreview()
+{
+  SplittedZonesList::iterator anIter= mySplittedZones.begin();
+  for ( ; anIter != mySplittedZones.end(); ++anIter )
+  {
+    SplittedZone& aSplittedZone = *anIter;
+    if ( aSplittedZone.Shape )
+    {
+      delete aSplittedZone.Shape;
+      aSplittedZone.Shape = NULL;
+    }
+  }
+
+  if( myPreviewViewManager )
+  {
+    disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+                this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+    module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here
+    myPreviewViewManager = NULL;
+  }
+
+  if( myActiveViewManager )
+  {
+    HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager );
+    myActiveViewManager = NULL;
+  }
+}
+
 
index 0ca60d2ffeb791d7a7ea5b3a4552729a1af35b36..46ab3bf0da50860ddc8d57352ec38722f37c5bd3 100644 (file)
 
 #include "HYDROGUI_Operation.h"
 
+#include "HYDROGUI_SplitZonesTool.h"
+#include "HYDROGUI_Shape.h"
+
 #include <HYDROData_Calculation.h>
 
+class SUIT_ViewManager;
+class OCCViewer_ViewManager;
+
 class HYDROGUI_CalculationOp : public HYDROGUI_Operation
 {
   Q_OBJECT
 
+  struct SplittedZone
+  {
+    QString                            ZoneName;
+    QString                            PolylineName;
+    QColor                             FillingColor;
+    QColor                             BorderColor;
+    HYDROGUI_SplitZonesTool::SplitData SplitData;
+    HYDROGUI_Shape*                    Shape;
+
+    SplittedZone()
+    : Shape( NULL ),
+      FillingColor( Qt::green ),
+      BorderColor( Qt::transparent )
+    { }
+
+    ~SplittedZone()
+    {
+      if ( Shape )
+      {
+        delete Shape;
+        Shape = NULL;
+      }
+    }
+  };
+
+  typedef QList<SplittedZone>         SplittedZonesList;
+
 public:
   HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit );
   virtual ~HYDROGUI_CalculationOp();
@@ -44,10 +77,22 @@ protected:
 
   virtual bool                    processApply( int& theUpdateFlags, QString& theErrorMsg );
 
+protected slots:
+  void                            onSplitZones();
+  void                            onLastViewClosed( SUIT_ViewManager* );
+
+private:
+  void                            createPreview();
+  void                            closePreview();
+
 private:
   bool                            myIsEdit;
   Handle(HYDROData_Calculation)   myEditedObject;
 
+  SUIT_ViewManager*               myActiveViewManager;
+
+  OCCViewer_ViewManager*          myPreviewViewManager;
+  SplittedZonesList               mySplittedZones;
 };
 
 #endif
index c7b0cedf601912503409c9fac4586f03d84a0a79..ef136fff2abb773ad85c7f2b61fa748dfcc680d1 100644 (file)
@@ -522,17 +522,23 @@ Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
 
 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*         theParent,
                                                        Handle(HYDROData_Object) theModelObject,
-                                                       const QString&           theParentEntry )
+                                                       const QString&           theParentEntry,
+                                                       const bool               theIsBuildTree )
 {
   HYDROGUI_DataObject* aResObj = 
     new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
-  buildObjectTree( theParent, aResObj, theParentEntry );
+  
+  if ( theIsBuildTree )
+  {
+    buildObjectTree( theParent, aResObj, theParentEntry );
+  }
+
   return aResObj;
 }
 
 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
                                                        const QString&   theName,
-                                                       const QString&   theParentEntry  )
+                                                       const QString&   theParentEntry )
 {
   return new HYDROGUI_NamedObject( theParent, theName, theParentEntry );
 }
@@ -559,7 +565,7 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
     {
       Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
       if ( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
-        createObject( aGuiObj, aRefObj, aGuiObj->entry() );
+        createObject( aGuiObj, aRefObj, aGuiObj->entry(), false );
     }
   }
   else if ( anObjectKind == KIND_ZONE )
@@ -567,13 +573,15 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
     Handle(HYDROData_Zone) aZoneObj =
       Handle(HYDROData_Zone)::DownCast( aDataObj );
 
-    LightApp_DataObject* aPolylineSect = createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() );
+    LightApp_DataObject* aPolylineSect = 
+      createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() );
 
     Handle(HYDROData_Polyline) aPolyline = aZoneObj->GetPolyline();
     if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
-      createObject( aPolylineSect, aPolyline, aGuiObj->entry() );
+      createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
 
-    LightApp_DataObject* aBathsSect = createObject( aGuiObj, tr( "ZONE_BATHYMETRIES" ), aGuiObj->entry() );
+    LightApp_DataObject* aBathsSect = 
+      createObject( aGuiObj, tr( "ZONE_BATHYMETRIES" ), aGuiObj->entry() );
 
     HYDROData_SequenceOfObjects aZoneBaths = aZoneObj->GetBathymetries();
     HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths );
@@ -582,7 +590,45 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
       Handle(HYDROData_Bathymetry) aRefBath =
         Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() );
       if( !aRefBath.IsNull() && !aRefBath->IsRemoved() )
-        createObject( aBathsSect, aRefBath, aGuiObj->entry() );
+        createObject( aBathsSect, aRefBath, aGuiObj->entry(), false );
+    }
+  }
+  else if ( anObjectKind == KIND_CALCULATION )
+  {
+    Handle(HYDROData_Calculation) aCaseObj =
+      Handle(HYDROData_Calculation)::DownCast( aDataObj );
+
+    LightApp_DataObject* aPolylineSect = 
+      createObject( aGuiObj, tr( "CASE_BND_POLYLINE" ), aGuiObj->entry() );
+
+    Handle(HYDROData_Polyline) aPolyline = aCaseObj->GetBoundaryPolyline();
+    if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
+      createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
+
+    LightApp_DataObject* aRefZonesSect = 
+      createObject( aGuiObj, tr( "CASE_REFERENCE_ZONES" ), aGuiObj->entry() );
+
+    HYDROData_SequenceOfObjects aRefZones = aCaseObj->GetZones();
+    HYDROData_SequenceOfObjects::Iterator anIter( aRefZones );
+    for ( ; anIter.More(); anIter.Next() )
+    {
+      Handle(HYDROData_Zone) aRefZone =
+        Handle(HYDROData_Zone)::DownCast( anIter.Value() );
+      if( !aRefZone.IsNull() && !aRefZone->IsRemoved() )
+        createObject( aRefZonesSect, aRefZone, aGuiObj->entry(), false );
+    }
+
+    LightApp_DataObject* aSplittedZonesSect = 
+      createObject( aGuiObj, tr( "CASE_SPLITTED_ZONES" ), aGuiObj->entry() );
+
+    HYDROData_SequenceOfObjects aSplittedZones = aCaseObj->GetSplittedZones();
+    anIter.Init( aSplittedZones );
+    for ( ; anIter.More(); anIter.Next() )
+    {
+      Handle(HYDROData_Zone) aSplittedZone =
+        Handle(HYDROData_Zone)::DownCast( anIter.Value() );
+      if( !aSplittedZone.IsNull() && !aSplittedZone->IsRemoved() )
+        createObject( aSplittedZonesSect, aSplittedZone, aGuiObj->entry(), false );
     }
   }
 }
index a4216902d1e1ee45dac3a2e123fd92f43bf13e13..1f2f3fb23f1a472254eb4afd28109ae29ddb7247 100644 (file)
@@ -236,7 +236,8 @@ protected:
    */
   LightApp_DataObject* createObject( SUIT_DataObject*         theParent,
                                      Handle(HYDROData_Object) theModelObject,
-                                     const QString&           theParentEntry = QString() );
+                                     const QString&           theParentEntry = QString(),
+                                     const bool               theIsBuildTree = true );
 
   /**
    * Creates the GUI data object without corresponding model object: just by name
index 2950a9fc8158c63ef50a8dcce94214dbb73ef8b5..fde4689ca17800b10f6e423c097ad92693c91890 100644 (file)
@@ -51,7 +51,7 @@ public:
   
   enum ViewManagerRole { VMR_Unknown = 0, VMR_General, 
                          VMR_TransformImage, VMR_ObserveImage, 
-                         VMR_PreviewZone };
+                         VMR_PreviewZone,    VMR_PreviewCaseZones };
   typedef QPair< SUIT_ViewManager*, ViewManagerRole > ViewManagerInfo;
 
   typedef QMap        < int, ViewManagerInfo > ViewManagerMap;
index 590f6877a590857ecda4c8023e5f1d3d1d327527..d570f46c50288b83dff9e5d4449d241d90e98c17 100644 (file)
 
 #include <HYDROData_Zone.h>
 
+void printPath( const QString& thePrefix, const QPainterPath& thePath )
+{
+  printf( "%s (n=%d) :", qPrintable( thePrefix ), thePath.elementCount() );
+  for( int i = 0, n = thePath.elementCount(); i < n; i++ )
+  {
+    const QPainterPath::Element anElement = thePath.elementAt( i );
+    switch( anElement.type )
+    {
+      case QPainterPath::MoveToElement:
+        printf( " M(%.0f,%.0f)", anElement.x, anElement.y );
+        break;
+      case QPainterPath::LineToElement:
+        printf( " L(%.0f,%.0f)", anElement.x, anElement.y );
+        break;
+      default:
+        break;
+    }
+  }
+  printf( "\n" );
+}
+
 HYDROGUI_SplitZonesTool::SplitDataList
 HYDROGUI_SplitZonesTool::SplitZones( const HYDROData_SequenceOfObjects& theZoneList,
                                      const Handle(HYDROData_Polyline)&  thePolylie )
@@ -86,25 +107,32 @@ HYDROGUI_SplitZonesTool::SplitTwoData( const SplitData& theData1,
 
   const QPainterPath& aPath1 = theData1.Path;
   const QPainterPath& aPath2 = theData2.Path;
+  printPath( "aPath1", aPath1 );
+  printPath( "aPath2", aPath2 );
 
   const QStringList& aZoneNames1 = theData1.ZoneNames;
   const QStringList& aZoneNames2 = theData2.ZoneNames;
 
   QPainterPath anIntersection = aPath1.intersected( aPath2 );
+  printPath( "anIntersection", anIntersection );
+  anIntersection.closeSubpath();
+  printPath( "anIntersection after closing", anIntersection );
   if( anIntersection.isEmpty() )
   {
     aSplitDataList.append( theData1 );
-    aSplitDataList.append( theData2 );
+    //aSplitDataList.append( theData2 );
   }
   else
   {
     aSplitDataList.append( SplitData( anIntersection, aZoneNames1 + aZoneNames2 ) );
 
     QPainterPath aPath1Sub = aPath1.subtracted( aPath2 );
+    printPath( "aPath1Sub", aPath1Sub );
     if( !aPath1Sub.isEmpty() )
       aSplitDataList.append( ExtractSeparateData( SplitData( aPath1Sub, aZoneNames1 ) ) );
 
     QPainterPath aPath2Sub = aPath2.subtracted( aPath1 );
+    printPath( "aPath2Sub", aPath2Sub );
     if( !aPath2Sub.isEmpty() )
       aSplitDataList.append( ExtractSeparateData( SplitData( aPath2Sub, aZoneNames2 ) ) );
   }
@@ -147,6 +175,7 @@ HYDROGUI_SplitZonesTool::ExtractSeparateData( const SplitData& theData )
     const QPainterPath& aPath2 = aPathList.last();
     if( aPath1.contains( aPath2 ) || aPath2.contains( aPath1 ) )
     {
+      printf( "HOLE CASE!\n" );
       aSplitDataList.append( theData );
       return aSplitDataList;
     }
@@ -156,6 +185,7 @@ HYDROGUI_SplitZonesTool::ExtractSeparateData( const SplitData& theData )
   while( anIter.hasNext() )
   {
     const QPainterPath& aPath = anIter.next();
+    printPath( "aPath", aPath );
     aSplitDataList.append( SplitData( aPath, aBaseZoneNames ) );
   }
   return aSplitDataList;
index 03aa538192545b1b772fdb5f52e027cf5fce4c12..7a1b3c21458b6b3f544a676a1a8d4ee8e65fad90 100644 (file)
@@ -43,6 +43,8 @@ public:
     QPainterPath Path;
     QStringList  ZoneNames;
 
+    SplitData() {}
+    
     SplitData( const QPainterPath& thePath,
                const QStringList& theZoneNames ) :
       Path( thePath ), ZoneNames( theZoneNames ) {}
index 3e11ed93c7fb9c6e41857d074af667362137a3ca..4650f24e36a5c2bd2115d005c9576c8ea7762f70 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Iterator.h>
+#include <HYDROData_Zone.h>
 
 #include <GraphicsView_Viewer.h>
 
@@ -301,30 +302,62 @@ ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule )
 }
 
 Handle(HYDROData_Object) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theModule,
-                                                          const QString& theName,
+                                                          const QString&   theName,
                                                           const ObjectKind theObjectKind )
 {
   Handle(HYDROData_Object) anObject;
+  if ( theName.isEmpty() )
+    return anObject;
+
+  QStringList aNamesList;
+  aNamesList << theName;
+
+  HYDROData_SequenceOfObjects aSeqOfObjs = FindObjectsByNames( theModule, aNamesList, theObjectKind );
+  if( aSeqOfObjs.IsEmpty() )
+    return anObject;
+  
+  anObject = aSeqOfObjs.First();
+  return anObject;
+}
+
+HYDROData_SequenceOfObjects HYDROGUI_Tool::FindObjectsByNames( HYDROGUI_Module*   theModule,
+                                                               const QStringList& theNames,
+                                                               const ObjectKind   theObjectKind )
+{
+  HYDROData_SequenceOfObjects aResSeq;
+  if ( theNames.isEmpty() )
+    return aResSeq;
 
   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
   if( aDocument.IsNull() )
-    return anObject;
+    return aResSeq;
+
+  QStringList aNamesList = theNames;
 
   HYDROData_Iterator anIter( aDocument, theObjectKind );
   for( ; anIter.More(); anIter.Next() )
   {
     Handle(HYDROData_Object) anObjectRef = anIter.Current();
-    if( !anObjectRef.IsNull() && anObjectRef->GetName() == theName )
-    {
-      anObject = anObjectRef;
+    if( anObjectRef.IsNull() )
+      continue;
+
+    QString anObjName = anObjectRef->GetName();
+    if ( anObjName.isEmpty() || !aNamesList.contains( anObjName ) )
+      continue;
+
+    aResSeq.Append( anObjectRef );
+
+    aNamesList.removeAll( anObjName );
+    if ( aNamesList.isEmpty() )
       break;
-    }
   }
-  return anObject;
+
+  return aResSeq;
 }
 
-QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module* theModule,
-                                           const QString& thePrefix )
+QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module*   theModule,
+                                           const QString&     thePrefix,
+                                           const QStringList& theUsedNames )
 {
   QString aName;
   int anId = 1;
@@ -332,6 +365,9 @@ QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module* theModule,
   {
     aName = QString( "%1_%2" ).arg( thePrefix ).arg( QString::number( anId++ ) );
 
+    if ( theUsedNames.contains( aName ) )
+      continue;
+
     // check that there are no other objects with the same name in the document
     Handle(HYDROData_Object) anObject = FindObjectByName( theModule, aName, KIND_UNKNOWN );
     if( anObject.IsNull() )
@@ -444,3 +480,35 @@ QDockWidget* HYDROGUI_Tool::WindowDock( QWidget* wid )
   }
   return dock;
 }
+
+QColor HYDROGUI_Tool::GenerateFillingColor( HYDROGUI_Module*   theModule,
+                                            const QStringList& theZoneNames )
+{
+  QColor aFillingColor( HYDROData_Zone::DefaultFillingColor() );
+
+  int aCounter = 0;
+  int aR = 0, aG = 0, aB = 0;
+  QStringListIterator aZoneNameIter( theZoneNames );
+  while( aZoneNameIter.hasNext() )
+  {
+    const QString& aZoneName = aZoneNameIter.next();
+    Handle(HYDROData_Zone) aRefZone = Handle(HYDROData_Zone)::DownCast(
+      FindObjectByName( theModule, aZoneName, KIND_ZONE ) );
+    if( !aRefZone.IsNull() )
+    {
+      QColor aRefColor = aRefZone->GetFillingColor();
+      aR += aRefColor.red();
+      aG += aRefColor.green();
+      aB += aRefColor.blue();
+      aCounter++;
+    }
+  }
+  
+  if( aCounter > 0 )
+  {
+    aFillingColor = QColor( aR / aCounter, aG / aCounter, aB / aCounter );
+  }
+
+  return aFillingColor;
+}
+
index c2552ddca66bb25f52a349b624cf21660bbe676c..264adbd58535eb9546090a3bb73d27c51f0543f0 100644 (file)
@@ -176,14 +176,27 @@ public:
                                                     const QString& theName,
                                                     const ObjectKind theObjectKind = KIND_UNKNOWN );
 
+  /**
+   * \brief Find the data objects with the specified names.
+   * \param theModule module
+   * \param theNames list of names
+   * \param theObjectKind kind of object
+   * \return list of data objects
+   */
+  static HYDROData_SequenceOfObjects FindObjectsByNames( HYDROGUI_Module*   theModule,
+                                                         const QStringList& theNames,
+                                                         const ObjectKind   theObjectKind = KIND_UNKNOWN );
+
   /**
    * \brief Generate name for new object.
    * \param theModule module
    * \param thePrefix name prefix
+   * \param theUsedNames list of already used names
    * \return generated name
    */
-  static QString                  GenerateObjectName( HYDROGUI_Module* theModule,
-                                                      const QString& thePrefix );
+  static QString                  GenerateObjectName( HYDROGUI_Module*   theModule,
+                                                      const QString&     thePrefix,
+                                                      const QStringList& theUsedNames = QStringList() );
 
   /**
    * \brief Get id of the active GraphicsView view.
@@ -228,6 +241,15 @@ public:
    */
   static QDockWidget*             WindowDock( QWidget* wid );
 
+  /**
+   * \brief Generates the filling color for intersected zone
+   * \param theModule module
+   * \param theZoneNames list of intersected zones
+   * \return result color
+   */
+  static QColor                   GenerateFillingColor( HYDROGUI_Module*   theModule,
+                                                        const QStringList& theZoneNames );
+
 };
 
 #endif
index 10132b31d10d37b83f39f6c24dcc862c0c58dac6..e006fe795775f6a50aef433265385db9a5456145 100644 (file)
@@ -7,6 +7,18 @@
       <source>BATHYMETRY_FILTER</source>
       <translation>Bathymetry files (*.xyz);;All files (*.* *)</translation>
     </message>
+    <message>
+      <source>CASE_BND_POLYLINE</source>
+      <translation>Boundary polyline</translation>
+    </message>
+    <message>
+      <source>CASE_REFERENCE_ZONES</source>
+      <translation>Reference zones</translation>
+    </message>
+    <message>
+      <source>CASE_SPLITTED_ZONES</source>
+      <translation>Splitted zones</translation>
+    </message>
     <message>
       <source>FILE_NOT_EXISTS_OR_CANT_BE_READ</source>
       <translation>The file '%1'
@@ -68,10 +80,34 @@ does not exist or you have not enough permissions to open it.</translation>
       <source>CALCULATION_NAME</source>
       <translation>Calculation case name</translation>
     </message>
+    <message>
+      <source>CALCULATION_REFERENCE_ZONES</source>
+      <translation>Reference zones</translation>
+    </message>
+    <message>
+      <source>CALCULATION_SPLITTED_ZONES</source>
+      <translation>Splitted zones</translation>
+    </message>
+    <message>
+      <source>PREFIX_SPLITTED_ZONES</source>
+      <translation>Prefix of splitted zones</translation>
+    </message>
+    <message>
+      <source>CALCULATION_ZONES</source>
+      <translation>Case zones</translation>
+    </message>
+    <message>
+      <source>DEFAULT_PREFIX_SPLITTED_ZONES</source>
+      <translation>Splitt</translation>
+    </message>
     <message>
       <source>NAME</source>
       <translation>Name</translation>
     </message>
+    <message>
+      <source>SPLIT_REFERENCE_ZONES</source>
+      <translation>Split zones</translation>
+    </message>
   </context>
 
   <context>
@@ -84,6 +120,10 @@ does not exist or you have not enough permissions to open it.</translation>
       <source>EDIT_CALCULATION</source>
       <translation>Edit calculation case</translation>
     </message>
+    <message>
+      <source>PREVIEW_CASE_ZONES</source>
+      <translation>Preview case zones</translation>
+    </message>
   </context>
 
   <context>