]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
GUI part for zones. Preview for zone is done in 2D view. (Feature #31)
authoradv <adv@opencascade.com>
Wed, 18 Sep 2013 11:38:17 +0000 (11:38 +0000)
committeradv <adv@opencascade.com>
Wed, 18 Sep 2013 11:38:17 +0000 (11:38 +0000)
25 files changed:
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/HYDROData_Zone.cxx
src/HYDROData/HYDROData_Zone.h
src/HYDROGUI/HYDROGUI.vcproj
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DataModel.h
src/HYDROGUI/HYDROGUI_DataObject.cxx
src/HYDROGUI/HYDROGUI_DataObject.h
src/HYDROGUI/HYDROGUI_Displayer.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_PrsZone.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_PrsZone.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_PrsZoneDriver.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_PrsZoneDriver.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_ZoneDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ZoneDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ZoneOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ZoneOp.h [new file with mode: 0644]
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 2a3d2a778723a4f06acd3517e852cdd762a2c1a4..401b54d40f10751a3c382aa1dbd36fb4d74df715 100644 (file)
@@ -5,6 +5,7 @@
 #include <HYDROData_VisualState.h>
 #include <HYDROData_Bathymetry.h>
 #include <HYDROData_Calculation.h>
+#include <HYDROData_Zone.h>
 
 #include <TDataStd_Name.hxx>
 #include <NCollection_DataMap.hxx>
@@ -72,6 +73,9 @@ Handle_HYDROData_Object HYDROData_Iterator::Object( const TDF_Label theLabel )
   case KIND_CALCULATION:
     aResult = new HYDROData_Calculation();
     break;
+  case KIND_ZONE:
+    aResult = new HYDROData_Zone();
+    break;
   }
 
   if ( !aResult.IsNull() )
index 1be3985a854702b26b2b9339a9e2dead81fe6972..062be0df68c1cdad67fe579dd4bd62ec48ac13a7 100644 (file)
@@ -14,6 +14,7 @@
 #include <TDF_CopyLabel.hxx>
 #include <TDF_ListIteratorOfLabelList.hxx>
 
+#include <QColor>
 #include <QString>
 #include <QStringList>
 #include <QVariant>
@@ -145,7 +146,10 @@ void HYDROData_Object::SetReferenceObject( const Handle_HYDROData_Object& theObj
                                            const int                      theIndex )
 {
   if ( theObj.IsNull() )
+  {
+    RemoveReferenceObject( theTag, theIndex );
     return;
+  }
 
   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
 
@@ -226,11 +230,15 @@ void HYDROData_Object::RemoveReferenceObject( const int theTag,
     return;
   }
 
-  Handle(HYDROData_Object) aRemovedObj = GetReferenceObject( theTag, theIndex );
-  if ( aRemovedObj.IsNull() )
+  int anIndex = 0;
+  TDF_ListIteratorOfLabelList anIter( aRefs->List() );
+  for ( ; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
+
+  if ( anIndex != theIndex )
     return;
 
-  aRefs->Remove( aRemovedObj->Label() );
+  const TDF_Label& aRefLabel = anIter.Value();
+  aRefs->Remove( aRefLabel );
 }
 
 void HYDROData_Object::ClearReferenceObjects( const int theTag )
@@ -250,3 +258,37 @@ Handle(TDataStd_ReferenceList) HYDROData_Object::getReferenceList( const int the
 
   return aRefs;
 }
+
+void HYDROData_Object::SetColor( const QColor& theColor,
+                                 const int     theTag )
+{
+  TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+
+  Handle(TDataStd_IntegerArray) aColorArray;
+  if ( !aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+    aColorArray = TDataStd_IntegerArray::Set( aLabel, 1, 4 );
+
+  aColorArray->SetValue( 1, theColor.red()   );
+  aColorArray->SetValue( 2, theColor.green() );
+  aColorArray->SetValue( 3, theColor.blue()  );
+  aColorArray->SetValue( 4, theColor.alpha() );
+}
+
+QColor HYDROData_Object::GetColor( const QColor& theDefColor,
+                                   const int     theTag ) const
+{
+  QColor aResColor = theDefColor;
+
+  TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+
+  Handle(TDataStd_IntegerArray) aColorArray;
+  if ( aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+  {
+    aResColor.setRed(   aColorArray->Value( 1 ) );
+    aResColor.setGreen( aColorArray->Value( 2 ) );
+    aResColor.setBlue(  aColorArray->Value( 3 ) );
+    aResColor.setAlpha( aColorArray->Value( 4 ) );
+  }
+
+  return aResColor;
+}
\ No newline at end of file
index 5d43cdde6d363b7400c151470928e791e5ad6aae..a44ffdb5affa77eee20a992de5b729a8ca50b1f8 100644 (file)
@@ -7,6 +7,7 @@
 #include <TDF_Label.hxx>
 #include <QMap>
 
+class QColor;
 class QString;
 class QVariant;
 class QStringList;
@@ -213,11 +214,26 @@ protected:
    */
   void ClearReferenceObjects( const int theTag = 0 );
 
+  /**
+   * Internal method that used to store the color attribute
+   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+   * \param theColor color to save
+   */
+  void SetColor( const QColor& theColor, const int theTag = 0 );
+
+  /**
+   * Internal method that used to retreive the color attribute
+   * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+   * \param theDefColor default color to return if attribute has not been set before
+   */
+  QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
+
 protected:
 
   Handle(TDataStd_ReferenceList) getReferenceList( const int  theTag,
                                                    const bool theIsCreate ) const;
 
+
 protected:
   /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
   TDF_Label myLab; ///< label of this object
index f87234534466247acc4ab6ad9db284cb10685dc4..fa2c0e16171b80e5c43c83c9cd4c0164c5e629ec 100644 (file)
@@ -35,32 +35,34 @@ QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects
   return aResList;
 }
 
-void HYDROData_Zone::SetColor( const QColor& theColor )
+QColor HYDROData_Zone::DefaultFillingColor()
 {
-  Handle(TDataStd_IntegerArray) aColorArray;
-  if ( !myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
-    aColorArray = TDataStd_IntegerArray::Set( myLab.FindChild( DataTag_Color ), 1, 4 );
+  return QColor( Qt::green );
+}
 
-  aColorArray->SetValue( 1, theColor.red()   );
-  aColorArray->SetValue( 2, theColor.green() );
-  aColorArray->SetValue( 3, theColor.blue()  );
-  aColorArray->SetValue( 4, theColor.alpha() );
+void HYDROData_Zone::SetFillingColor( const QColor& theColor )
+{
+  return SetColor( theColor, DataTag_FillingColor );
 }
 
-QColor HYDROData_Zone::GetColor() const
+QColor HYDROData_Zone::GetFillingColor() const
 {
-  QColor aResColor( Qt::green );
+  return GetColor( DefaultFillingColor(), DataTag_FillingColor );
+}
 
-  Handle(TDataStd_IntegerArray) aColorArray;
-  if ( myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
-  {
-    aResColor.setRed(   aColorArray->Value( 1 ) );
-    aResColor.setGreen( aColorArray->Value( 2 ) );
-    aResColor.setBlue(  aColorArray->Value( 3 ) );
-    aResColor.setAlpha( aColorArray->Value( 4 ) );
-  }
+QColor HYDROData_Zone::DefaultBorderColor()
+{
+  return QColor( Qt::transparent );
+}
 
-  return aResColor;
+void HYDROData_Zone::SetBorderColor( const QColor& theColor )
+{
+  return SetColor( theColor, DataTag_BorderColor );
+}
+
+QColor HYDROData_Zone::GetBorderColor() const
+{
+  return GetColor( DefaultBorderColor(), DataTag_BorderColor );
 }
 
 void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
index e9ad3ba9c976b0e972a97fe5f3676932cabbf3e0..5b277a13095b3474265b17b2176acffb320674d8 100644 (file)
@@ -27,9 +27,10 @@ protected:
   enum DataTag
   {
     DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
-    DataTag_Bathymetry, ///< reference bathymetries
-    DataTag_Polyline,   ///< reference polyline
-    DataTag_Color       ///< color of zone
+    DataTag_Bathymetry,   ///< reference bathymetries
+    DataTag_Polyline,     ///< reference polyline
+    DataTag_FillingColor, ///< filling color of zone
+    DataTag_BorderColor,  ///< border color of zone
   };
 
 public:
@@ -47,14 +48,35 @@ public:
 
 
   /**
-   * Sets color for zone.
+   * Returns default filling color for new zone.
    */
-  HYDRODATA_EXPORT virtual void SetColor( const QColor& theColor );
+  HYDRODATA_EXPORT static QColor DefaultFillingColor();
 
   /**
-   * Returns color of zone.
+   * Sets filling color for zone.
    */
-  HYDRODATA_EXPORT virtual QColor GetColor() const;
+  HYDRODATA_EXPORT virtual void SetFillingColor( const QColor& theColor );
+
+  /**
+   * Returns filling color of zone.
+   */
+  HYDRODATA_EXPORT virtual QColor GetFillingColor() const;
+
+
+  /**
+   * Returns default border color for new zone.
+   */
+  HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
+  /**
+   * Sets border color for zone.
+   */
+  HYDRODATA_EXPORT virtual void SetBorderColor( const QColor& theColor );
+
+  /**
+   * Returns border color of zone.
+   */
+  HYDRODATA_EXPORT virtual QColor GetBorderColor() const;
 
 
   /**
index 50be70bab5e39b486886bbaa6b9dc8383b929c4c..3a6362ad3d6fb187e1e186f8aaa6f1c90749d1db 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
        ProjectType="Visual C++"
-       Version="9,00"
+       Version="9.00"
        Name="HYDROGUI"
        ProjectGUID="{D11F0AD0-D002-4A22-A8E6-3F906379206F}"
        RootNamespace="HYDROGUI"
                                RelativePath=".\HYDROGUI_PrsPolylineDriver.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_PrsZone.cxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROGUI_PrsZoneDriver.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_ShowHideOp.cxx"
                                >
                                RelativePath=".\HYDROGUI_VisualStateOp.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ZoneDlg.cxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ZoneOp.cxx"
+                               >
+                       </File>
                        <Filter
                                Name="Link"
                                >
                                        <Tool
                                                Name="VCCustomBuildTool"
                                                Description="Generating moc_$(InputName).cxx"
-                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx&#x0D;&#x0A;"
                                                Outputs="moc/moc_$(InputName).cxx"
                                        />
                                </FileConfiguration>
                                RelativePath=".\HYDROGUI_PrsPolylineDriver.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_PrsZone.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROGUI_PrsZoneDriver.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_ShowHideOp.h"
                                >
                                        />
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ZoneDlg.h"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating moc_$(InputName).cxx"
+                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+                                               Outputs="moc/moc_$(InputName).cxx"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ZoneOp.h"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating moc_$(InputName).cxx"
+                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+                                               Outputs="moc/moc_$(InputName).cxx"
+                                       />
+                               </FileConfiguration>
+                       </File>
                </Filter>
                <Filter
                        Name="Resource Files"
                                RelativePath=".\moc\moc_HYDROGUI_VisualStateOp.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\moc\moc_HYDROGUI_ZoneDlg.cxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\moc\moc_HYDROGUI_ZoneOp.cxx"
+                               >
+                       </File>
                </Filter>
        </Files>
        <Globals>
index 392dfef5bd9b6d1262e77ccb1097ef0e28c8366d..c7b0cedf601912503409c9fac4586f03d84a0a79 100644 (file)
@@ -33,6 +33,7 @@
 #include <HYDROData_Iterator.h>
 #include <HYDROData_Polyline.h>
 #include <HYDROData_VisualState.h>
+#include <HYDROData_Zone.h>
 
 #include <CAM_Application.h>
 #include <CAM_DataObject.h>
@@ -227,17 +228,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
     Handle(HYDROData_Image) anImageObj =
       Handle(HYDROData_Image)::DownCast( anIterator.Current() );
     if( !anImageObj.IsNull() )
-    {
-      if( LightApp_DataObject* anImageDataObj = createObject( anImageRootObj, anImageObj ) )
-      {
-        for( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
-        {
-          Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
-          if( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
-            createObject( anImageDataObj, aRefObj, anImageDataObj->entry() );
-        }
-      }
-    }
+      createObject( anImageRootObj, anImageObj );
   }
 
   LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, partitionName( KIND_BATHYMETRY ) );
@@ -273,6 +264,17 @@ void HYDROGUI_DataModel::update( const int theStudyId )
       createObject( aPolylineRootObj, aPolylineObj );
   }
 
+  LightApp_DataObject* aZonesRootObj = createObject( aRootObj, partitionName( KIND_ZONE ) );
+
+  anIterator = HYDROData_Iterator( aDocument, KIND_ZONE );
+  for( ; anIterator.More(); anIterator.Next() )
+  {
+    Handle(HYDROData_Zone) aZoneObj =
+      Handle(HYDROData_Zone)::DownCast( anIterator.Current() );
+    if( !aZoneObj.IsNull() )
+      createObject( aZonesRootObj, aZoneObj );
+  }
+
   LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, partitionName( KIND_VISUAL_STATE ) );
 
   anIterator = HYDROData_Iterator( aDocument, KIND_VISUAL_STATE );
@@ -506,6 +508,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
     case KIND_VISUAL_STATE: return "VISUAL_STATES";
     case KIND_BATHYMETRY:   return "BATHYMETRIES";
     case KIND_CALCULATION:  return "CALCULATION_CASES";
+    case KIND_ZONE:         return "ZONES";
     default: break;
   }
   return QString();
@@ -517,17 +520,71 @@ Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
   return HYDROData_Document::Document( aStudyId );
 }
 
-LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
+LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*         theParent,
                                                        Handle(HYDROData_Object) theModelObject,
-                                                       const QString& theParentEntry )
+                                                       const QString&           theParentEntry )
 {
-  return new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
+  HYDROGUI_DataObject* aResObj = 
+    new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
+  buildObjectTree( theParent, aResObj, theParentEntry );
+  return aResObj;
 }
 
 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
-                                                       const QString& theName )
+                                                       const QString&   theName,
+                                                       const QString&   theParentEntry  )
+{
+  return new HYDROGUI_NamedObject( theParent, theName, theParentEntry );
+}
+
+void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
+                                          SUIT_DataObject* theObject,
+                                          const QString&   theParentEntry )
 {
-  return new HYDROGUI_NamedObject( theParent, theName );
+  HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>( theObject );
+  if ( !aGuiObj )
+    return;
+
+  Handle(HYDROData_Object) aDataObj = aGuiObj->modelObject();
+  if ( aDataObj.IsNull() )
+    return;
+
+  ObjectKind anObjectKind = aDataObj->GetKind();
+
+  if ( anObjectKind == KIND_IMAGE )
+  {
+    Handle(HYDROData_Image) anImageObj =
+      Handle(HYDROData_Image)::DownCast( aDataObj );
+    for ( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
+    {
+      Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
+      if ( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
+        createObject( aGuiObj, aRefObj, aGuiObj->entry() );
+    }
+  }
+  else if ( anObjectKind == KIND_ZONE )
+  {
+    Handle(HYDROData_Zone) aZoneObj =
+      Handle(HYDROData_Zone)::DownCast( aDataObj );
+
+    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() );
+
+    LightApp_DataObject* aBathsSect = createObject( aGuiObj, tr( "ZONE_BATHYMETRIES" ), aGuiObj->entry() );
+
+    HYDROData_SequenceOfObjects aZoneBaths = aZoneObj->GetBathymetries();
+    HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths );
+    for ( ; aBathsIter.More(); aBathsIter.Next() )
+    {
+      Handle(HYDROData_Bathymetry) aRefBath =
+        Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() );
+      if( !aRefBath.IsNull() && !aRefBath->IsRemoved() )
+        createObject( aBathsSect, aRefBath, aGuiObj->entry() );
+    }
+  }
 }
 
 void HYDROGUI_DataModel::removeChild( SUIT_DataObject* theParent,
index 3576a1a029bfad8e88c83e916855ad059802e347..a4216902d1e1ee45dac3a2e123fd92f43bf13e13 100644 (file)
@@ -231,19 +231,32 @@ protected:
   /**
    * Creates the GUI data object according to the model object.
    * \param theParent a created object will be appended as a child of this object
-   * \param theObject model object
+   * \param theModelObject model object
+   * \param theParentEntry entry of parent object
    */
-  LightApp_DataObject* createObject( SUIT_DataObject* theParent,
+  LightApp_DataObject* createObject( SUIT_DataObject*         theParent,
                                      Handle(HYDROData_Object) theModelObject,
-                                     const QString& theParentEntry = QString() );
+                                     const QString&           theParentEntry = QString() );
 
   /**
    * Creates the GUI data object without corresponding model object: just by name
    * \param theParent a created object will be appended as a child of this object
    * \param theName name of this object
+   * \param theParentEntry entry of parent object
    */
   LightApp_DataObject* createObject( SUIT_DataObject* theParent,
-                                     const QString& theName );
+                                     const QString&   theName,
+                                     const QString&   theParentEntry = QString() );
+
+  /**
+   * Build tree of model object.
+   * \param theParent a created object will be appended as a child of this object
+   * \param theObject gui object for which the tree will be build
+   * \param theParentEntry entry of parent object
+   */
+  void                 buildObjectTree( SUIT_DataObject* theParent,
+                                        SUIT_DataObject* theObject,
+                                        const QString&   theParentEntry = QString() );
 
   /**
    * Removes data object from the tree.
index bbd53f6b68e42d0484d48c6c10770242dad26829..f0b47e22b4beb40f0440981ae3271517a0b6a97f 100644 (file)
@@ -85,17 +85,21 @@ QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Object)& th
 }
 
 HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
-                                            const QString& theName )
+                                            const QString&   theName,
+                                            const QString&   theParentEntry  )
 : CAM_DataObject( theParent ),
   LightApp_DataObject( theParent ),
-  myName( theName )
+  myName( theName ),
+  myParentEntry( theParentEntry )
 {
 }
 
 QString HYDROGUI_NamedObject::entry() const
 {
-  //return LightApp_DataObject::entry();
-  return HYDROGUI_DataObject::entryPrefix() + name();
+  QString anEntry = HYDROGUI_DataObject::entryPrefix() + name();
+  if( !myParentEntry.isEmpty() )
+    anEntry.prepend( myParentEntry + "_" );
+  return anEntry;
 }
 
 QString HYDROGUI_NamedObject::name() const
index baa09573a5c73ed844deae9e444a4a736c996cc8..edb79f02e7006e87eea1ef74943fd9c5b18aa3c7 100644 (file)
@@ -116,7 +116,8 @@ public:
    * \param theName displayed name
    */
   HYDROGUI_NamedObject( SUIT_DataObject* theParent,
-                        const QString& theName );
+                        const QString& theName,
+                        const QString& theParentEntry  );
     
   /**
    * Returns the unique object identifier string.
@@ -130,6 +131,7 @@ public:
 
 private:
   QString myName; ///< name in the OB
+  QString myParentEntry;
 };
 
 #endif
index d979bfbea840e1bba3529214336400ff9f6c07f8..7f91a6a9afbbab095a16aa958099b0528bd331a4 100644 (file)
@@ -27,6 +27,7 @@
 #include "HYDROGUI_Prs.h"
 #include "HYDROGUI_PrsImageDriver.h"
 #include "HYDROGUI_PrsPolylineDriver.h"
+#include "HYDROGUI_PrsZoneDriver.h"
 #include "HYDROGUI_Tool.h"
 
 #include <GraphicsView_Viewer.h>
@@ -236,15 +237,20 @@ HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Object
     {
       case KIND_IMAGE:
         aDriver = new HYDROGUI_PrsImageDriver();
-        myPrsDriversMap[ aKind ] = aDriver;
         break;
       case KIND_POLYLINE:
         aDriver = new HYDROGUI_PrsPolylineDriver();
-        myPrsDriversMap[ aKind ] = aDriver;
+        break;
+      case KIND_ZONE:
+        aDriver = new HYDROGUI_PrsZoneDriver();
         break;
       default:
         break;
     }
+
+    if ( aDriver )
+      myPrsDriversMap[ aKind ] = aDriver;
   }
+
   return aDriver;
 }
index 6ce7fa531a283235f384068c464a8ef5f0a16bc3..b6d25267eb1bb6b8cabdad52163d8823a4499501 100644 (file)
@@ -193,6 +193,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsMustBeUpdatedImage = false;
   bool anIsPolyline = false;
   bool anIsCalculation = false;
+  bool anIsZone = false;
   bool anIsVisualState = false;
 
   // check the selected data model objects
@@ -236,6 +237,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsPolyline = true;
       else if( anObject->GetKind() == KIND_CALCULATION )
         anIsCalculation = true;
+      else if( anObject->GetKind() == KIND_ZONE )
+        anIsZone = true;
       else if( anObject->GetKind() == KIND_VISUAL_STATE )
         anIsVisualState = true;
     }
@@ -264,6 +267,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         case KIND_CALCULATION:
           theMenu->addAction( action( CreateCalculationId ) );
           break;
+        case KIND_ZONE:
+          theMenu->addAction( action( CreateZoneId ) );
+          break;
       }
       theMenu->addSeparator();
     }
@@ -310,6 +316,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       theMenu->addAction( action( EditCalculationId ) );
       theMenu->addSeparator();
     }
+    else if( anIsZone )
+    {
+      theMenu->addAction( action( EditZoneId ) );
+      theMenu->addSeparator();
+    }
     else if( anIsVisualState && anIsObjectBrowser )
     {
       theMenu->addAction( action( SaveVisualStateId ) );
@@ -324,7 +335,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addSeparator();
   }
 
-  if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline ) )
+  if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsZone ) )
   {
     if( anIsHiddenInSelection )
       theMenu->addAction( action( ShowId ) );
index 0e637e5fe9e27bc0dd485a9a96733b039f43902f..453b9e47e5156acc4a6dd537dc8e32b46ffaf103 100644 (file)
@@ -48,7 +48,10 @@ class HYDROGUI_Module : public LightApp_Module
   enum CustomEvent { NewViewEvent = QEvent::User + 100 };
 
 public:
-  enum ViewManagerRole { VMR_Unknown = 0, VMR_General, VMR_TransformImage, VMR_ObserveImage };
+  
+  enum ViewManagerRole { VMR_Unknown = 0, VMR_General, 
+                         VMR_TransformImage, VMR_ObserveImage, 
+                         VMR_PreviewZone };
   typedef QPair< SUIT_ViewManager*, ViewManagerRole > ViewManagerInfo;
 
   typedef QMap        < int, ViewManagerInfo > ViewManagerMap;
index 544d124dd0c9ab763561c30c1a5af40683afa8f9..87428aa30f7ff69a7c24ac9bc3abb7b97376f648 100644 (file)
@@ -37,6 +37,7 @@
 #include "HYDROGUI_UpdateFlags.h"
 #include "HYDROGUI_UpdateImageOp.h"
 #include "HYDROGUI_VisualStateOp.h"
+#include "HYDROGUI_ZoneOp.h"
 
 #include <CAM_Application.h>
 
@@ -86,6 +87,9 @@ void HYDROGUI_Module::createActions()
 
   createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::Key_B );
 
+  createAction( CreateZoneId, "CREATE_ZONE" );
+  createAction( EditZoneId, "EDIT_ZONE" );
+
   createAction( CreateCalculationId, "CREATE_CALCULATION" );
   createAction( EditCalculationId, "EDIT_CALCULATION" );
 
@@ -126,6 +130,7 @@ void HYDROGUI_Module::createMenus()
   createMenu( ImportImageId, aHydroId, -1, -1 );
   createMenu( ImportBathymetryId, aHydroId, -1, -1 );
   createMenu( CreatePolylineId, aHydroId, -1, -1 );
+  createMenu( CreateZoneId, aHydroId, -1, -1 );
   createMenu( CreateCalculationId, aHydroId, -1, -1 );
   createMenu( separator(), aHydroId );
   createMenu( FuseImagesId, aHydroId, -1, -1 );
@@ -271,6 +276,10 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case ImportBathymetryId:
     anOp = new HYDROGUI_ImportBathymetryOp( aModule );
     break;
+  case CreateZoneId:
+  case EditZoneId:
+    anOp = new HYDROGUI_ZoneOp( aModule, theId == EditZoneId );
+    break;
   case CreateCalculationId:
   case EditCalculationId:
     anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
index 92f9869fc2841b4be761e134551fe25aca6dd8f7..c8b8309f6829fdebf6b271bec7ed3e700a81a044 100644 (file)
@@ -48,6 +48,9 @@ enum OperationId
   ImportBathymetryId,
   EditImportedBathymetryId,
 
+  CreateZoneId,
+  EditZoneId,
+
   CreateCalculationId,
   EditCalculationId,
 
diff --git a/src/HYDROGUI/HYDROGUI_PrsZone.cxx b/src/HYDROGUI/HYDROGUI_PrsZone.cxx
new file mode 100644 (file)
index 0000000..3dafc9a
--- /dev/null
@@ -0,0 +1,166 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_PrsZone.h"
+
+#include <QBrush>
+#include <QPen>
+
+//=======================================================================
+// name    : HYDROGUI_PrsZone
+// Purpose : Constructor
+//=======================================================================
+HYDROGUI_PrsZone::HYDROGUI_PrsZone( const Handle(HYDROData_Object)& theObject )
+: HYDROGUI_Prs( theObject ),
+  myZoneItem( 0 ),
+  myFillingColor( Qt::transparent ),
+  myBorderColor( Qt::transparent )
+{
+}
+
+//=======================================================================
+// name    : HYDROGUI_PrsZone
+// Purpose : Destructor
+//=======================================================================
+HYDROGUI_PrsZone::~HYDROGUI_PrsZone()
+{
+}
+
+//================================================================
+// Function : setPath
+// Purpose  : 
+//================================================================
+void HYDROGUI_PrsZone::setPath( const QPainterPath& thePath )
+{
+  myPath = thePath;
+}
+
+//================================================================
+// Function : getPath
+// Purpose  : 
+//================================================================
+QPainterPath HYDROGUI_PrsZone::getPath() const
+{
+  return myPath;
+}
+
+//================================================================
+// Function : setFillingColor
+// Purpose  : 
+//================================================================
+void HYDROGUI_PrsZone::setFillingColor( const QColor& theColor )
+{
+  myFillingColor = theColor;
+}
+
+//================================================================
+// Function : getFillingColor
+// Purpose  : 
+//================================================================
+QColor HYDROGUI_PrsZone::getFillingColor() const
+{
+  return myFillingColor;
+}
+
+//================================================================
+// Function : setBorderColor
+// Purpose  : 
+//================================================================
+void HYDROGUI_PrsZone::setBorderColor( const QColor& theColor )
+{
+  myBorderColor = theColor;
+}
+
+//================================================================
+// Function : getBorderColor
+// Purpose  : 
+//================================================================
+QColor HYDROGUI_PrsZone::getBorderColor() const
+{
+  return myBorderColor;
+}
+
+//================================================================
+// Function : boundingRect
+// Purpose  : 
+//================================================================
+QRectF HYDROGUI_PrsZone::boundingRect() const
+{
+  return myZoneItem->boundingRect();
+}
+
+//================================================================
+// Function : compute
+// Purpose  : 
+//================================================================
+void HYDROGUI_PrsZone::compute()
+{
+  if( !myZoneItem )
+  {
+    myZoneItem = new QGraphicsPathItem( this );
+    addToGroup( myZoneItem );
+  }
+  
+  QPainterPath aPath( myPath );
+  aPath.setFillRule( Qt::WindingFill );
+
+  myZoneItem->setPath( aPath );
+  myZoneItem->setBrush( QBrush( myFillingColor ) );
+  myZoneItem->setPen( QPen( myBorderColor ) );
+}
+
+//================================================================
+// Function : checkHighlight
+// Purpose  : 
+//================================================================
+bool HYDROGUI_PrsZone::checkHighlight( double theX, double theY, QCursor& theCursor ) const
+{
+  // to do
+  return false;
+}
+
+//================================================================
+// Function : select
+// Purpose  : 
+//================================================================
+bool HYDROGUI_PrsZone::select( double theX, double theY, const QRectF& theRect )
+{
+  return GraphicsView_Object::select( theX, theY, theRect );
+}
+
+//================================================================
+// Function : unselect
+// Purpose  : 
+//================================================================
+void HYDROGUI_PrsZone::unselect()
+{
+  GraphicsView_Object::unselect();
+}
+
+//================================================================
+// Function : setSelected
+// Purpose  : 
+//================================================================
+void HYDROGUI_PrsZone::setSelected( bool theState )
+{
+  GraphicsView_Object::setSelected( theState );
+}
diff --git a/src/HYDROGUI/HYDROGUI_PrsZone.h b/src/HYDROGUI/HYDROGUI_PrsZone.h
new file mode 100644 (file)
index 0000000..3c21dc3
--- /dev/null
@@ -0,0 +1,71 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_PRSZONE_H
+#define HYDROGUI_PRSZONE_H
+
+#include "HYDROGUI_Prs.h"
+
+/*
+  Class       : HYDROGUI_PrsZone
+  Description : Presentation for zone object
+*/
+class HYDROGUI_PrsZone : public HYDROGUI_Prs
+{
+public:
+  HYDROGUI_PrsZone( const Handle(HYDROData_Object)& theObject );
+  virtual ~HYDROGUI_PrsZone();
+
+public:
+  void                            setPath( const QPainterPath& thePath );
+  QPainterPath                    getPath() const;
+
+  void                            setFillingColor( const QColor& theColor );
+  QColor                          getFillingColor() const;
+
+  void                            setBorderColor( const QColor& theColor );
+  QColor                          getBorderColor() const;
+
+public:
+  // from QGraphicsItem
+  virtual QRectF                  boundingRect() const;
+
+  // from GraphicsView_Object
+  virtual void                    compute();
+
+  virtual bool                    isMovable() const { return false; }
+
+  virtual bool                    checkHighlight( double theX, double theY, QCursor& theCursor ) const;
+
+  virtual bool                    select( double theX, double theY, const QRectF& theRect );
+  virtual void                    unselect();
+  virtual void                    setSelected( bool theState );
+
+protected:
+  QGraphicsPathItem*              myZoneItem;
+
+  QPainterPath                    myPath;
+  QColor                          myFillingColor;
+  QColor                          myBorderColor;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_PrsZoneDriver.cxx b/src/HYDROGUI/HYDROGUI_PrsZoneDriver.cxx
new file mode 100644 (file)
index 0000000..5edfaa1
--- /dev/null
@@ -0,0 +1,65 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_PrsZoneDriver.h"
+
+#include "HYDROGUI_PrsZone.h"
+
+#include <HYDROData_Zone.h>
+
+HYDROGUI_PrsZoneDriver::HYDROGUI_PrsZoneDriver()
+:HYDROGUI_PrsDriver()
+{
+}
+
+HYDROGUI_PrsZoneDriver::~HYDROGUI_PrsZoneDriver()
+{
+}
+
+bool HYDROGUI_PrsZoneDriver::Update( const Handle(HYDROData_Object)& theObj,
+                                     HYDROGUI_Prs*& thePrs )
+{
+  HYDROGUI_PrsDriver::Update( theObj, thePrs );
+
+  if ( theObj.IsNull() )
+    return false;
+
+  Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( theObj );
+  if ( aZone.IsNull() )
+    return false;
+
+  if ( !thePrs )
+    thePrs = new HYDROGUI_PrsZone( theObj );
+
+  HYDROGUI_PrsZone* aPrsZone = (HYDROGUI_PrsZone*)thePrs;
+
+  aPrsZone->setName( aZone->GetName() );
+  
+  aPrsZone->setFillingColor( aZone->GetFillingColor() );
+  aPrsZone->setBorderColor( aZone->GetBorderColor() );
+
+  aPrsZone->setPath( aZone->GetPainterPath() );
+
+  aPrsZone->compute();
+
+  return true;
+}
diff --git a/src/HYDROGUI/HYDROGUI_PrsZoneDriver.h b/src/HYDROGUI/HYDROGUI_PrsZoneDriver.h
new file mode 100644 (file)
index 0000000..0eb5dbc
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_PRSZONEDRIVER_H
+#define HYDROGUI_PRSZONEDRIVER_H
+
+#include <HYDROGUI_PrsDriver.h>
+
+/**
+ * \class HYDROGUI_PrsZoneDriver
+ * \brief Presentation driver for zone objects.
+ */
+class HYDROGUI_PrsZoneDriver : public HYDROGUI_PrsDriver
+{
+public:
+  /**
+   * \brief Constructor.
+   */
+  HYDROGUI_PrsZoneDriver();
+
+  /**
+   * \brief Destructor.
+   */
+  virtual ~HYDROGUI_PrsZoneDriver();
+
+public:
+  /**
+   * \brief Update or create the polyline presentation on a basis of data object.
+   * \param theObj data object
+   * \param thePrs presentation
+   * \return status of the operation
+   */
+  virtual bool Update( const Handle(HYDROData_Object)& theObj,
+                       HYDROGUI_Prs*& thePrs );
+};
+
+#endif
index e030e1db13e33016a05b5d17269e9143e0cb509e..3e11ed93c7fb9c6e41857d074af667362137a3ca 100644 (file)
@@ -194,6 +194,14 @@ void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
     if( !anObject.IsNull() )
       theSeq.Append( anObject );
   }
+
+  anIterator = HYDROData_Iterator( aDocument, KIND_ZONE );
+  for( ; anIterator.More(); anIterator.Next() )
+  {
+    Handle(HYDROData_Object) anObject = anIterator.Current();
+    if( !anObject.IsNull() )
+      theSeq.Append( anObject );
+  }
 }
 
 HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Object)& theObj,
diff --git a/src/HYDROGUI/HYDROGUI_ZoneDlg.cxx b/src/HYDROGUI/HYDROGUI_ZoneDlg.cxx
new file mode 100644 (file)
index 0000000..02e6a60
--- /dev/null
@@ -0,0 +1,297 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ZoneDlg.h"
+
+#include "HYDROGUI_ColorWidget.h"
+#include "HYDROGUI_Tool.h"
+
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QListWidget>
+#include <QRadioButton>
+
+HYDROGUI_ZoneDlg::HYDROGUI_ZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+  // Zone name
+  myObjectNameGroup = new QGroupBox( tr( "ZONE_NAME" ), mainFrame() );
+
+  myObjectName = new QLineEdit( myObjectNameGroup );
+
+  QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
+  aNameLayout->setMargin( 5 );
+  aNameLayout->setSpacing( 5 );
+  aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
+  aNameLayout->addWidget( myObjectName );
+
+
+  QGroupBox* aParamGroup = new QGroupBox( tr( "ZONE_PARAMETERS" ), mainFrame() );
+
+  QFrame* aPolylineFrame = new QFrame( aParamGroup );
+
+  myPolylines = new QComboBox( aPolylineFrame );
+  myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  QBoxLayout* aPolyLayout = new QHBoxLayout( aPolylineFrame );
+  aPolyLayout->setMargin( 0 );
+  aPolyLayout->setSpacing( 5 );
+  aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), aPolylineFrame ) );
+  aPolyLayout->addWidget( myPolylines );
+
+
+  QFrame* aFillingFrame = new QFrame( aParamGroup );
+  QLabel* aFillingLabel = new QLabel( tr( "FILLING_COLOR" ), aFillingFrame );
+  myFillingTransparent = new QRadioButton( tr( "TRANSPARENT" ), aFillingFrame );
+  myFillingTransparent->setChecked( true );
+  myFillingColor = new QRadioButton( tr( "COLOR" ), aFillingFrame );
+  myFillingColorBox = new HYDROGUI_ColorWidget( aFillingFrame );
+
+  QGridLayout* aFillingLayout = new QGridLayout( aFillingFrame );
+  aFillingLayout->setMargin( 0 );
+  aFillingLayout->setSpacing( 5 );
+  aFillingLayout->addWidget( aFillingLabel, 0, 0, 2, 1 );
+  aFillingLayout->addWidget( myFillingTransparent, 0, 1 );
+  aFillingLayout->addWidget( myFillingColor,       1, 1 );
+  aFillingLayout->addWidget( myFillingColorBox,    1, 2 );
+
+
+  myBorderColorGroup = new QGroupBox( tr( "BORDER_COLOR" ), mainFrame() );
+  myBorderColorGroup->setCheckable( true );
+
+  myBorderColorBox = new HYDROGUI_ColorWidget( myBorderColorGroup );
+
+  QBoxLayout* aBorderColorLayout = new QHBoxLayout( myBorderColorGroup );
+  aBorderColorLayout->setMargin( 5 );
+  aBorderColorLayout->setSpacing( 5 );
+  aBorderColorLayout->addWidget( new QLabel( tr( "COLOR" ), myBorderColorGroup ) );
+  aBorderColorLayout->addWidget( myBorderColorBox );
+
+
+  QBoxLayout* aParamLayout = new QVBoxLayout( aParamGroup );
+  aParamLayout->setMargin( 5 );
+  aParamLayout->setSpacing( 5 );
+  aParamLayout->addWidget( aPolylineFrame );
+  aParamLayout->addWidget( aFillingFrame );
+  aParamLayout->addWidget( myBorderColorGroup );
+
+
+  QGroupBox* aBathGroup = new QGroupBox( tr( "ZONE_BATHYMETRIES" ), mainFrame() );
+
+  myBathymetries = new QListWidget( aBathGroup );
+  myBathymetries->setSelectionMode( QListWidget::SingleSelection );
+  myBathymetries->setEditTriggers( QListWidget::NoEditTriggers );
+  myBathymetries->setViewMode( QListWidget::ListMode );
+
+  QBoxLayout* aBathLayout = new QHBoxLayout( aBathGroup );
+  aBathLayout->setMargin( 5 );
+  aBathLayout->setSpacing( 5 );
+  aBathLayout->addWidget( myBathymetries );
+
+
+  // Common
+  addWidget( myObjectNameGroup );
+  addWidget( aParamGroup );
+  addWidget( aBathGroup );
+
+  addStretch();
+
+
+  // Connect signals and slots
+  connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) );
+  connect( myFillingTransparent, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
+  connect( myFillingColor, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
+  connect( myFillingColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onFillingColorChanged() ) );
+  connect( myBorderColorGroup, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
+  connect( myBorderColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onZoneDefChanged() ) );
+}
+
+HYDROGUI_ZoneDlg::~HYDROGUI_ZoneDlg()
+{
+}
+
+void HYDROGUI_ZoneDlg::reset()
+{
+  bool isBlocked = blockSignals( true );
+
+  myObjectName->clear();
+
+  myPolylines->clear();
+  myBathymetries->clear();
+
+  myFillingTransparent->setChecked( true );
+  myFillingColorBox->resetColor();
+
+  myBorderColorGroup->setChecked( false );
+  myBorderColorBox->resetColor();
+
+  blockSignals( isBlocked );
+
+  onZoneDefChanged();
+}
+
+void HYDROGUI_ZoneDlg::setObjectName( const QString& theName )
+{
+  myObjectName->setText( theName );
+}
+
+QString HYDROGUI_ZoneDlg::getObjectName() const
+{
+  return myObjectName->text();
+}
+
+void HYDROGUI_ZoneDlg::setPolylineNames( const QStringList& thePolylines )
+{
+  bool isBlocked = blockSignals( true );
+
+  myPolylines->clear();
+  myPolylines->addItems( thePolylines );
+
+  blockSignals( isBlocked );
+}
+
+void HYDROGUI_ZoneDlg::setPolylineName( const QString& theName )
+{
+  myPolylines->setCurrentIndex( myPolylines->findText( theName ) );
+}
+
+QString HYDROGUI_ZoneDlg::getPolylineName() const
+{
+  return myPolylines->currentText();
+}
+
+void HYDROGUI_ZoneDlg::setBathymetries( const QStringList& theBathymetries )
+{
+  myBathymetries->clear();
+
+  for ( int i = 0, n = theBathymetries.length(); i < n; ++i )
+  {
+    QString aBathymetryName = theBathymetries.at( i );
+
+    QListWidgetItem* aListItem = new QListWidgetItem( aBathymetryName, myBathymetries );
+    aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable );
+    aListItem->setCheckState( Qt::Unchecked );
+  }
+}
+
+void HYDROGUI_ZoneDlg::setSelectedBathymetries( const QStringList& theBathymetries )
+{
+  for ( int i = 0, n = theBathymetries.length(); i < n; ++i )
+  {
+    QString aBathymetryName = theBathymetries.at( i );
+
+    QList<QListWidgetItem *> anItems = 
+      myBathymetries->findItems( aBathymetryName, Qt::MatchFixedString | Qt::MatchCaseSensitive );
+    if ( anItems.isEmpty() )
+      continue;
+
+    QListWidgetItem* aListItem = anItems.first();
+    if ( !aListItem )
+      continue;
+
+    aListItem->setCheckState( Qt::Checked );
+  }
+}
+
+QStringList HYDROGUI_ZoneDlg::getSelectedBathymetries() const
+{
+  QStringList aResList;
+
+  for ( int i = 0, n = myBathymetries->count(); i < n; ++i )
+  {
+    QListWidgetItem* aListItem = myBathymetries->item( i );
+    if ( !aListItem || aListItem->checkState() != Qt::Checked )
+      continue;
+
+    QString aSelBathName = aListItem->text();
+    aResList.append( aSelBathName );
+  }
+
+  return aResList;
+}
+
+void HYDROGUI_ZoneDlg::setFillingColor( const QColor& theColor )
+{
+  bool isBlocked = blockSignals( true );
+
+  if( theColor.alpha() == 0 ) // transparent
+    myFillingTransparent->setChecked( true );
+  else
+    myFillingColor->setChecked( true );
+
+  myFillingColorBox->setColor( theColor );
+
+  blockSignals( isBlocked );
+
+  onZoneDefChanged();
+}
+
+QColor HYDROGUI_ZoneDlg::getFillingColor() const
+{
+  QColor aColor( 255, 255, 255, 0 ); // transparent
+  if( myFillingColor->isChecked() )
+    aColor = myFillingColorBox->color();
+  return aColor;
+}
+
+void HYDROGUI_ZoneDlg::setBorderColor( const QColor& theColor )
+{
+  bool isBlocked = blockSignals( true );
+
+  bool isTransparent = theColor.alpha() == 0;
+  myBorderColorGroup->setChecked( !isTransparent );
+  myBorderColorBox->setColor( !isTransparent ? theColor : QColor( Qt::black ) );
+
+  blockSignals( isBlocked );
+
+  onZoneDefChanged();
+}
+
+QColor HYDROGUI_ZoneDlg::getBorderColor() const
+{
+  QColor aColor( Qt::transparent ); // transparent
+  if( myBorderColorGroup->isChecked() )
+    aColor = myBorderColorBox->color();
+  return aColor;
+}
+
+void HYDROGUI_ZoneDlg::onFillingColorChanged()
+{
+  if ( !myFillingColor->isChecked() )
+    return;
+
+  onZoneDefChanged();
+}
+
+void HYDROGUI_ZoneDlg::onZoneDefChanged()
+{
+  if ( signalsBlocked() )
+    return;
+
+  QString aPolylineName = getPolylineName();
+  emit CreatePreview( aPolylineName );
+}
+
+
diff --git a/src/HYDROGUI/HYDROGUI_ZoneDlg.h b/src/HYDROGUI/HYDROGUI_ZoneDlg.h
new file mode 100644 (file)
index 0000000..ad70cb5
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_ZONEDLG_H
+#define HYDROGUI_ZONEDLG_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class HYDROGUI_ColorWidget;
+class QComboBox;
+class QGroupBox;
+class QLineEdit;
+class QListWidget;
+class QRadioButton;
+
+class HYDROGUI_ZoneDlg : public HYDROGUI_InputPanel
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+  virtual ~HYDROGUI_ZoneDlg();
+
+  void                       reset();
+
+  void                       setObjectName( const QString& theName );
+  QString                    getObjectName() const;
+
+  void                       setPolylineNames( const QStringList& thePolylines );
+  void                       setPolylineName( const QString& thePolyline );
+  QString                    getPolylineName() const;
+
+  void                       setBathymetries( const QStringList& theBathymetries );
+  void                       setSelectedBathymetries( const QStringList& theBathymetries );
+  QStringList                getSelectedBathymetries() const;
+
+  void                       setFillingColor( const QColor& theColor );
+  QColor                     getFillingColor() const;
+
+  void                       setBorderColor( const QColor& theColor );
+  QColor                     getBorderColor() const;
+
+signals:
+  void                       CreatePreview( const QString& thePolylineName );
+
+private slots:
+  void                       onZoneDefChanged();
+  void                       onFillingColorChanged();
+
+private:
+
+  QGroupBox*                 myObjectNameGroup;
+  QLineEdit*                 myObjectName;
+
+  QComboBox*                 myPolylines;
+  QListWidget*               myBathymetries;
+
+  QRadioButton*              myFillingTransparent;
+  QRadioButton*              myFillingColor;
+  HYDROGUI_ColorWidget*      myFillingColorBox;
+
+  QGroupBox*                 myBorderColorGroup;
+  HYDROGUI_ColorWidget*      myBorderColorBox;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_ZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ZoneOp.cxx
new file mode 100644 (file)
index 0000000..88c5402
--- /dev/null
@@ -0,0 +1,350 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ZoneOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_ZoneDlg.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_PrsZone.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Bathymetry.h>
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Polyline.h>
+
+#include <GraphicsView_ViewManager.h>
+#include <GraphicsView_ViewPort.h>
+#include <GraphicsView_Viewer.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+HYDROGUI_ZoneOp::HYDROGUI_ZoneOp( HYDROGUI_Module* theModule,
+                                  const bool theIsEdit )
+: HYDROGUI_Operation( theModule ),
+  myIsEdit( theIsEdit ),
+  myActiveViewManager( 0 ),
+  myPreviewViewManager( 0 ),
+  myPreviewPrs( 0 )
+{
+  setName( theIsEdit ? tr( "EDIT_ZONE" ) : tr( "CREATE_ZONE" ) );
+}
+
+HYDROGUI_ZoneOp::~HYDROGUI_ZoneOp()
+{
+  closePreview();
+}
+
+void HYDROGUI_ZoneOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROGUI_ZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ZoneDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  aPanel->reset();
+
+  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Zone" );
+
+  QColor      aFillingColor( HYDROData_Zone::DefaultFillingColor() );
+  QColor      aBorderColor( HYDROData_Zone::DefaultBorderColor() );
+  QString     aSelectedPolyline;
+  QStringList aSelectedBathymetries;
+
+  if ( myIsEdit )
+  {
+    myEditedObject = Handle(HYDROData_Zone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+    if( !myEditedObject.IsNull() )
+    {
+      anObjectName = myEditedObject->GetName();
+
+      aFillingColor = myEditedObject->GetFillingColor();
+      aBorderColor = myEditedObject->GetBorderColor();
+
+      Handle(HYDROData_Polyline) aRefPolyline = myEditedObject->GetPolyline();
+      if ( !aRefPolyline.IsNull() )
+        aSelectedPolyline = aRefPolyline->GetName();
+
+      HYDROData_SequenceOfObjects aRefBathymetries = myEditedObject->GetBathymetries();
+      HYDROData_SequenceOfObjects::Iterator anIter( aRefBathymetries );
+      for ( ; anIter.More(); anIter.Next() )
+      {
+        Handle(HYDROData_Bathymetry) aRefBathymetry = 
+          Handle(HYDROData_Bathymetry)::DownCast( anIter.Value() );
+        if ( aRefBathymetry.IsNull() )
+          continue;
+
+        QString aRefBathymetryName = aRefBathymetry->GetName();
+        if ( aRefBathymetryName.isEmpty() )
+          continue;
+
+        aSelectedBathymetries.append( aRefBathymetryName );
+      }
+    }
+  }
+
+  // collect information about existing closed polylines
+  QStringList aPolylines;
+
+  HYDROData_Iterator anIter( doc(), KIND_POLYLINE );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Polyline) aPolylineObj = 
+      Handle(HYDROData_Polyline)::DownCast( anIter.Current() );
+    if ( aPolylineObj.IsNull() || !aPolylineObj->isClosed() )
+      continue;
+
+    QString aPolylineName = aPolylineObj->GetName();
+    if ( aPolylineName.isEmpty() )
+      continue;
+
+    aPolylines.append( aPolylineName );
+  }
+
+  // collect information about existing bathymetries
+  QStringList aBathymetries;
+
+  anIter = HYDROData_Iterator( doc(), KIND_BATHYMETRY );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Bathymetry) aBathymetryObj = 
+      Handle(HYDROData_Bathymetry)::DownCast( anIter.Current() );
+    if ( aBathymetryObj.IsNull() )
+      continue;
+
+    QString aBathymetryName = aBathymetryObj->GetName();
+    if ( aBathymetryName.isEmpty() )
+      continue;
+
+    aBathymetries.append( aBathymetryName );
+  }
+  
+  aPanel->setObjectName( anObjectName );
+  
+  aPanel->setFillingColor( aFillingColor );
+  aPanel->setBorderColor( aBorderColor );
+
+  aPanel->setPolylineNames( aPolylines );
+  aPanel->setPolylineName( aSelectedPolyline );
+
+  aPanel->setBathymetries( aBathymetries );
+  aPanel->setSelectedBathymetries( aSelectedBathymetries );
+
+}
+
+void HYDROGUI_ZoneOp::abortOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_ZoneOp::commitOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::commitOperation();
+}
+
+HYDROGUI_InputPanel* HYDROGUI_ZoneOp::createInputPanel() const
+{
+  HYDROGUI_ZoneDlg* aPanel = new HYDROGUI_ZoneDlg( module(), getName() );
+  connect( aPanel, SIGNAL( CreatePreview( const QString& ) ),
+           this,   SLOT( onCreatePreview( const QString& ) ) );
+  return aPanel;
+}
+
+bool HYDROGUI_ZoneOp::processApply( int& theUpdateFlags,
+                                    QString& theErrorMsg )
+{
+  HYDROGUI_ZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ZoneDlg*>( inputPanel() );
+  if ( !aPanel )
+    return false;
+
+  QString anObjectName = aPanel->getObjectName().simplified();
+  if ( anObjectName.isEmpty() )
+  {
+    theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+    return false;
+  }
+
+  if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
+  {
+    // check that there are no other objects with the same name in the document
+    Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+    if( !anObject.IsNull() )
+    {
+      theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
+      return false;
+    }
+  }
+
+  Handle(HYDROData_Zone) aZoneObj = myIsEdit ? myEditedObject :
+    Handle(HYDROData_Zone)::DownCast( doc()->CreateObject( KIND_ZONE ) );
+  if ( aZoneObj.IsNull() )
+    return false;
+
+  aZoneObj->SetName( anObjectName );
+
+  aZoneObj->SetFillingColor( aPanel->getFillingColor() );
+  aZoneObj->SetBorderColor( aPanel->getBorderColor() );
+
+  Handle(HYDROData_Polyline) aZonePolyline;
+
+  QString aPolylineName = aPanel->getPolylineName();
+  if ( !aPolylineName.isEmpty() )
+  {
+    aZonePolyline = Handle(HYDROData_Polyline)::DownCast(
+      HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) );
+  }
+
+  aZoneObj->SetPolyline( aZonePolyline );
+
+
+  aZoneObj->RemoveBathymetries();
+
+  QStringList aBathymetries = aPanel->getSelectedBathymetries();
+  for ( int i = 0; i < aBathymetries.length(); ++i )
+  {
+    const QString& aBathymetryName = aBathymetries.at( i );
+    if ( aBathymetryName.isEmpty() )
+      continue;
+
+    Handle(HYDROData_Bathymetry) aBathymetry = Handle(HYDROData_Bathymetry)::DownCast(
+        HYDROGUI_Tool::FindObjectByName( module(), aBathymetryName, KIND_BATHYMETRY ) );
+    if ( aBathymetry.IsNull() )
+      continue;
+
+    aZoneObj->AddBathymetry( aBathymetry );
+  }
+
+
+  theUpdateFlags = UF_Model;
+
+  return true;
+}
+
+void HYDROGUI_ZoneOp::onCreatePreview( const QString& thePolylineName )
+{
+  HYDROGUI_ZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ZoneDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  QPainterPath aPath;
+
+  Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast(
+    HYDROGUI_Tool::FindObjectByName( module(), thePolylineName, KIND_POLYLINE ) );
+  if ( !aPolyline.IsNull() )
+  {
+    aPath = aPolyline->painterPath();
+  }
+
+  LightApp_Application* anApp = module()->getApp();
+
+  if ( !myActiveViewManager )
+  {
+    myActiveViewManager = anApp->activeViewManager();
+  }
+
+  if ( !myPreviewPrs )
+  {
+    myPreviewPrs = new HYDROGUI_PrsZone( myIsEdit ? myEditedObject : 0 );
+  }
+
+  myPreviewPrs->setPath( aPath );
+  myPreviewPrs->setFillingColor( aPanel->getFillingColor() );
+  myPreviewPrs->setBorderColor( aPanel->getBorderColor() );
+  myPreviewPrs->compute();
+
+  if ( !myPreviewViewManager )
+  {
+    myPreviewViewManager = ::qobject_cast<GraphicsView_ViewManager*>( 
+      anApp->createViewManager( GraphicsView_Viewer::Type() ) );
+    if ( myPreviewViewManager )
+    {
+      connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+               this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+      module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_PreviewZone );
+      myPreviewViewManager->setTitle( tr( "PREVIEW_ZONE" ) );
+      if ( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
+      {
+        if ( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+        {
+          aViewPort->addItem( myPreviewPrs );
+        }
+      }
+    }
+  }
+
+  if ( myPreviewViewManager )
+  {
+    if ( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
+    {
+      if ( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+      {
+        aViewPort->update();
+        aViewPort->fitAll();
+      }
+    }
+  }
+}
+
+void HYDROGUI_ZoneOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
+{
+  closePreview();
+}
+
+void HYDROGUI_ZoneOp::closePreview()
+{
+  // It's very strange, but without calling this method (it's quite safe) a crash is stably reproduced.
+  // Scenario: create any non-Graphics view, activate import op, click apply.
+  // Result: a few SIGSEGVs coming from processEvents(), then crash.
+  if( myPreviewViewManager )
+    if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
+      if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+        aViewPort->onBoundingRectChanged();
+
+  if( myPreviewPrs )
+  {
+    delete myPreviewPrs;
+    myPreviewPrs = 0;
+  }
+
+  if( myPreviewViewManager )
+  {
+    disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+                this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+    module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here
+    myPreviewViewManager = 0;
+  }
+
+  if( myActiveViewManager )
+  {
+    HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager );
+    myActiveViewManager = 0;
+  }
+}
diff --git a/src/HYDROGUI/HYDROGUI_ZoneOp.h b/src/HYDROGUI/HYDROGUI_ZoneOp.h
new file mode 100644 (file)
index 0000000..9764d0f
--- /dev/null
@@ -0,0 +1,75 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_ZONEOP_H
+#define HYDROGUI_ZONEOP_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_Zone.h>
+
+#include <QPainterPath>
+
+class GraphicsView_ViewManager;
+
+class SUIT_ViewManager;
+
+class HYDROGUI_PrsZone;
+
+class HYDROGUI_ZoneOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ZoneOp( HYDROGUI_Module* theModule, const bool theIsEdit );
+  virtual ~HYDROGUI_ZoneOp();
+
+protected:
+  virtual void               startOperation();
+  virtual void               abortOperation();
+  virtual void               commitOperation();
+
+  virtual HYDROGUI_InputPanel* createInputPanel() const;
+
+  virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg );
+
+protected slots:
+  void                       onCreatePreview( const QString& thePolylineName );
+
+  void                       onLastViewClosed( SUIT_ViewManager* );
+
+private:
+  void                       closePreview();
+
+private:
+  bool                       myIsEdit;
+  Handle(HYDROData_Zone)     myEditedObject;
+
+  SUIT_ViewManager*          myActiveViewManager;
+
+  GraphicsView_ViewManager*  myPreviewViewManager;
+  HYDROGUI_PrsZone*          myPreviewPrs;
+
+  QPainterPath               myZonePath;
+};
+
+#endif
index 18d81f7f5f2cff3aa75e555e3453766ddebe45f2..10132b31d10d37b83f39f6c24dcc862c0c58dac6 100644 (file)
@@ -44,6 +44,14 @@ does not exist or you have not enough permissions to open it.</translation>
       <source>SAVE_ERROR</source>
       <translation>Study could not be saved</translation>
     </message>
+    <message>
+      <source>ZONE_POLYLINE</source>
+      <translation>Polyline</translation>
+    </message>
+    <message>
+      <source>ZONE_BATHYMETRIES</source>
+      <translation>Bathymetries</translation>
+    </message>
   </context>
 
   <context>
@@ -259,6 +267,14 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>DSK_CREATE_POLYLINE</source>
       <translation>Create polyline</translation>
     </message>
+    <message>
+      <source>DSK_CREATE_ZONE</source>
+      <translation>Create zone</translation>
+    </message>
+    <message>
+      <source>DSK_EDIT_ZONE</source>
+      <translation>Edit zone</translation>
+    </message>
     <message>
       <source>DSK_COPY</source>
       <translation>Copy</translation>
@@ -371,6 +387,14 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>MEN_CREATE_POLYLINE</source>
       <translation>Create polyline</translation>
     </message>
+    <message>
+      <source>MEN_CREATE_ZONE</source>
+      <translation>Create zone</translation>
+    </message>
+    <message>
+      <source>MEN_EDIT_ZONE</source>
+      <translation>Edit zone</translation>
+    </message>
     <message>
       <source>MEN_COPY</source>
       <translation>Copy</translation>
@@ -487,6 +511,14 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>STB_CREATE_POLYLINE</source>
       <translation>Create polyline</translation>
     </message>
+    <message>
+      <source>STB_CREATE_ZONE</source>
+      <translation>Create zone</translation>
+    </message>
+    <message>
+      <source>STB_EDIT_ZONE</source>
+      <translation>Edit zone</translation>
+    </message>
     <message>
       <source>STB_COPY</source>
       <translation>Copy</translation>
@@ -752,5 +784,61 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <translation>Save visual state</translation>
     </message>
   </context>
-  
+
+  <context>
+    <name>HYDROGUI_ZoneDlg</name>
+    <message>
+      <source>BORDER_COLOR</source>
+      <translation>Border</translation>
+    </message>
+    <message>
+      <source>COLOR</source>
+      <translation>Color</translation>
+    </message>
+    <message>
+      <source>FILLING_COLOR</source>
+      <translation>Filling color</translation>
+    </message>
+    <message>
+      <source>NAME</source>
+      <translation>Name</translation>
+    </message>
+    <message>
+      <source>TRANSPARENT</source>
+      <translation>Transparent</translation>
+    </message>
+    <message>
+      <source>ZONE_BATHYMETRIES</source>
+      <translation>Bathymetries</translation>
+    </message>
+    <message>
+      <source>ZONE_NAME</source>
+      <translation>Zone name</translation>
+    </message>
+    <message>
+      <source>ZONE_PARAMETERS</source>
+      <translation>Parameters</translation>
+    </message>
+    <message>
+      <source>ZONE_POLYLINE</source>
+      <translation>Polyline</translation>
+    </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_ZoneOp</name>
+    <message>
+      <source>CREATE_ZONE</source>
+      <translation>Create zone</translation>
+    </message>
+    <message>
+      <source>EDIT_ZONE</source>
+      <translation>Edit zone</translation>
+    </message>
+    <message>
+      <source>PREVIEW_ZONE</source>
+      <translation>Preview zone</translation>
+    </message>
+  </context>
+
 </TS>