]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Merge remote-tracking branch 'origin/BR_LAND_COVER' into BR_v14_rc
authorasl <asl@opencascade.com>
Mon, 15 Jun 2015 07:57:19 +0000 (10:57 +0300)
committerasl <asl@opencascade.com>
Mon, 15 Jun 2015 07:57:19 +0000 (10:57 +0300)
Conflicts:
src/HYDROData/HYDROData_CalculationCase.cxx

29 files changed:
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_GeomTool.cxx
src/HYDROData/HYDROData_GeomTool.h
src/HYDROData/HYDROData_PolylineXY.cxx
src/HYDROData/HYDROData_PolylineXY.h
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DataModel.h
src/HYDROGUI/HYDROGUI_DataOwner.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_DataOwner.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_OCCSelector.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_RecognizeContoursOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_Tool.h
src/HYDROGUI/HYDROGUI_ZLayers.cxx
src/HYDROGUI/HYDROGUI_ZLayers2.cxx
src/HYDROGUI/resources/HYDROGUI_images.ts
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROGUI/resources/icon_recognize_contours.png [new file with mode: 0644]

index bfed4f10d357b74e775bfd9e9ad784c5cef330eb..5ab5b3093d38276baaeb547b4f72d018c2645984 100644 (file)
@@ -1095,7 +1095,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var
   // Publish the sewed shape
   QString aName = EXPORT_NAME;
   GEOM::GEOM_Object_ptr aMainShape = 
-    publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName, theGeomObjEntry );
+    HYDROData_GeomTool::publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName, theGeomObjEntry );
 
   if ( aMainShape->_is_nil() )  
     return false;
@@ -1192,52 +1192,6 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var
   return true;
 }
 
-GEOM::GEOM_Object_ptr HYDROData_CalculationCase::publishShapeInGEOM( 
-  GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy,
-  const TopoDS_Shape& theShape, const QString& theName,
-  QString& theGeomObjEntry ) const
-{
-  theGeomObjEntry = "";
-  GEOM::GEOM_Object_var aGeomObj;
-
-  if ( theGeomEngine->_is_nil() || theStudy->_is_nil() ||
-       theShape.IsNull() ) {
-    return aGeomObj._retn();
-  }
-
-  std::ostringstream aStreamShape;
-  // Write TopoDS_Shape in ASCII format to the stream
-  BRepTools::Write( theShape, aStreamShape );
-  // Returns the number of bytes that have been stored in the stream's buffer.
-  int aSize = aStreamShape.str().size();
-  // Allocate octect buffer of required size
-  CORBA::Octet* anOctetBuf = SALOMEDS::TMPFile::allocbuf( aSize );
-  // Copy ostrstream content to the octect buffer
-  memcpy( anOctetBuf, aStreamShape.str().c_str(), aSize );
-  // Create TMPFile
-  SALOMEDS::TMPFile_var aSeqFile = new SALOMEDS::TMPFile( aSize, aSize, anOctetBuf, 1 );
-
-  // Restore shape from the stream and get the GEOM object
-  GEOM::GEOM_IInsertOperations_var anInsOp = theGeomEngine->GetIInsertOperations( theStudy->StudyId() );
-  aGeomObj = anInsOp->RestoreShape( aSeqFile );
-  
-  // Puplish the GEOM object
-  if ( !aGeomObj->_is_nil() ) {
-    QString aName = HYDROData_GeomTool::GetFreeName( theStudy, theName );
-
-    SALOMEDS::SObject_var aResultSO = 
-      theGeomEngine->PublishInStudy( theStudy, SALOMEDS::SObject::_nil(), 
-                                     aGeomObj, qPrintable( aName ) );
-    if ( aResultSO->_is_nil() ) {
-      aGeomObj = GEOM::GEOM_Object::_nil();
-    }
-    else
-      theGeomObjEntry = aResultSO->GetID();
-  }
-
-  return aGeomObj._retn();
-}
-
 void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
                                             const bool theIsSetToUpdate )
 {
index b40503ba9f2c42e33b41d3f1cc072e6e1f4f5ebe..a54800f13544cbadbfe469cfdfa3d46cf2c9108a 100644 (file)
@@ -407,21 +407,7 @@ private:
                const TopTools_ListOfShape&                   theFaces,
                const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
                QString& theGeomObjEntry ) const;
-
-  /**
-   * Publish the given shape in GEOM as a GEOM object.
-   * \param theGeomEngine GEOM module engine
-   * \param theStudy SALOMEDS study, used for publishing of the shape
-   * \param theShape the shape to publish as a GEOM object
-   * \param theName the name of the published object
-   * \return the published GEOM object
-   */
-  GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var  theGeomEngine,
-                                            SALOMEDS::Study_ptr theStudy,
-                                            const TopoDS_Shape& theShape, 
-                                            const QString&      theName,
-                                            QString& theGeomObjEntry ) const;
-
+  
   void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
                          const HYDROData_SplitToZonesTool::SplitDataList& theZones );
   void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
index 10c0bf4ca90b029ea409f5201125a0c3b8199ae6..a83258e61f7bff4b896da5ca198a886e923faee6 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <TopoDS_Shape.hxx>
 
+#include <BRepTools.hxx>
+
 #include <SALOME_NamingService.hxx>
 #include <SALOME_LifeCycleCORBA.hxx>
 
@@ -106,4 +108,90 @@ QString HYDROData_GeomTool::GetFreeName( SALOMEDS::Study_ptr theStudy, const QSt
   }
 
   return aName;
-}
\ No newline at end of file
+}
+
+GEOM::GEOM_Object_ptr HYDROData_GeomTool::publishShapeInGEOM( 
+  GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy,
+  const TopoDS_Shape& theShape, const QString& theName,
+  QString& theGeomObjEntry )
+{
+  theGeomObjEntry = "";
+  GEOM::GEOM_Object_var aGeomObj;
+
+  if ( theGeomEngine->_is_nil() || theStudy->_is_nil() ||
+       theShape.IsNull() ) {
+    return aGeomObj._retn();
+  }
+
+  std::ostringstream aStreamShape;
+  // Write TopoDS_Shape in ASCII format to the stream
+  BRepTools::Write( theShape, aStreamShape );
+  // Returns the number of bytes that have been stored in the stream's buffer.
+  int aSize = aStreamShape.str().size();
+  // Allocate octect buffer of required size
+  CORBA::Octet* anOctetBuf = SALOMEDS::TMPFile::allocbuf( aSize );
+  // Copy ostrstream content to the octect buffer
+  memcpy( anOctetBuf, aStreamShape.str().c_str(), aSize );
+  // Create TMPFile
+  SALOMEDS::TMPFile_var aSeqFile = new SALOMEDS::TMPFile( aSize, aSize, anOctetBuf, 1 );
+
+  // Restore shape from the stream and get the GEOM object
+  GEOM::GEOM_IInsertOperations_var anInsOp = theGeomEngine->GetIInsertOperations( theStudy->StudyId() );
+  aGeomObj = anInsOp->RestoreShape( aSeqFile );
+  
+  // Publish the GEOM object
+  theGeomObjEntry = publishGEOMObject( theGeomEngine, theStudy, aGeomObj, theName );
+  
+  return aGeomObj._retn();
+}
+
+ GEOM::GEOM_Object_ptr HYDROData_GeomTool::createFaceInGEOM( GEOM::GEOM_Gen_var theGeomEngine,
+                                                             SALOMEDS::Study_ptr theStudy,
+                                                             const int theWidth,
+                                                             const int theHeight,
+                                                             const QString& theName,
+                                                             QString& theFaceEntry )
+{
+  theFaceEntry = "";
+  GEOM::GEOM_Object_var aGeomObj;
+
+  if ( theGeomEngine->_is_nil() || theStudy->_is_nil() ) {
+    return aGeomObj._retn();
+  }
+
+  GEOM::GEOM_IBasicOperations_var aBasicOperations = theGeomEngine->GetIBasicOperations( theStudy->StudyId() );
+  GEOM::GEOM_IBlocksOperations_var aBlocksOperations = theGeomEngine->GetIBlocksOperations( theStudy->StudyId() );
+         
+  GEOM::GEOM_Object_var P1 = aBasicOperations->MakePointXYZ( -0.5 * theWidth, -0.5 * theHeight, 0 );
+  GEOM::GEOM_Object_var P2 = aBasicOperations->MakePointXYZ(  0.5 * theWidth, -0.5 * theHeight, 0 );
+  GEOM::GEOM_Object_var P3 = aBasicOperations->MakePointXYZ(  0.5 * theWidth,  0.5 * theHeight, 0 );
+  GEOM::GEOM_Object_var P4 = aBasicOperations->MakePointXYZ( -0.5 * theWidth,  0.5 * theHeight, 0 );
+  
+  GEOM::GEOM_Object_var aFace = aBlocksOperations->MakeQuad4Vertices( P1, P2 ,P3, P4 );
+    
+  // Publish the face
+  theFaceEntry = publishGEOMObject( theGeomEngine, theStudy, aFace, theName );
+
+  return aFace._retn();
+}
+
+QString HYDROData_GeomTool::publishGEOMObject( GEOM::GEOM_Gen_var theGeomEngine,
+                                               SALOMEDS::Study_ptr theStudy,
+                                               GEOM::GEOM_Object_ptr theGeomObj,
+                                               const QString& theName )
+{
+  QString anEntry;
+
+  if ( !theGeomObj->_is_nil() ) {
+    QString aName = HYDROData_GeomTool::GetFreeName( theStudy, theName );
+
+    SALOMEDS::SObject_var aResultSO = 
+      theGeomEngine->PublishInStudy( theStudy, SALOMEDS::SObject::_nil(), 
+                                     theGeomObj, qPrintable( aName ) );
+    if ( !aResultSO->_is_nil() ) {
+      anEntry = aResultSO->GetID();
+    }
+  }
+
+  return anEntry;
+}
index ea4cb95d39dad7d48fbecb721958a8cbc6418aea..554aede3c7e5b6209191433586af4deb31a66b5c 100644 (file)
@@ -58,6 +58,52 @@ public:
    * \return the default name
    */
   static QString GetFreeName( SALOMEDS::Study_ptr theStudy, const QString& theBaseName );
+
+  /**
+   * Publish the given shape in GEOM as a GEOM object.
+   * \param theGeomEngine GEOM module engine
+   * \param theStudy SALOMEDS study, used for publishing of the shape
+   * \param theShape the shape to publish as a GEOM object
+   * \param theName the name of the published object
+   * \param theGeomObjEntry the entry of the published object
+   * \return the published GEOM object
+   */
+  static GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var  theGeomEngine,
+                                                   SALOMEDS::Study_ptr theStudy,
+                                                   const TopoDS_Shape& theShape, 
+                                                   const QString&      theName,
+                                                   QString& theGeomObjEntry );
+
+  /**
+   * Create and publish face in GEOM as a GEOM object.
+   * \param theGeomEngine GEOM module engine
+   * \param theStudy SALOMEDS study, used for publishing of the face
+   * \param theWidth the face width
+   * \param theHeight the face height
+   * \param theName the name of the published face
+   * \param theFaceEntry the entry of the published face
+   * \return the published GEOM object
+   */
+  static GEOM::GEOM_Object_ptr createFaceInGEOM( GEOM::GEOM_Gen_var theGeomEngine,
+                                                 SALOMEDS::Study_ptr theStudy,
+                                                 const int theWidth,
+                                                 const int theHeight,
+                                                 const QString& theName,
+                                                 QString& theFaceEntry );
+
+  /**
+   * Publish the given GEOM object in the study.
+   * \param theGeomEngine GEOM module engine
+   * \param theStudy SALOMEDS study, used for publishing of the object
+   * \param theGeomObj the GEOM object
+   * \param theName the object name
+   * \return the entry of the published object (empty string in case of fail)
+   */
+  static QString publishGEOMObject( GEOM::GEOM_Gen_var theGeomEngine,
+                                    SALOMEDS::Study_ptr theStudy,
+                                    GEOM::GEOM_Object_ptr theGeomObj,
+                                    const QString& theName );
+
 };
 
 #endif
index 6c188ac6b727552cd756e33ade5c3dd3a20f5a83..32f2ddabdc1d7a21e19920f2f29c3dbb76db9f6f 100755 (executable)
@@ -1142,5 +1142,26 @@ void HYDROData_PolylineXY::UpdateLocalCS( double theDx, double theDy )
   SetToUpdate( true );
 }
 
+void HYDROData_PolylineXY::Transform( const QTransform& theTrsf )
+{
+  NCollection_Sequence<TCollection_AsciiString>           aSectNames;
+  NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
+  NCollection_Sequence<bool>                              aSectClosures;
+  GetSections( aSectNames, aSectTypes, aSectClosures );
+
+  for ( int i = 0, aNbSects = aSectNames.Size(); i < aNbSects; i++ ) {
+    PointsList aPoints = GetPoints( i );
+    for( int j = 1, n = aPoints.Size(); j <= n; ++j ) {
+      Point& aPoint = aPoints.ChangeValue( j );
+
+      QPointF aTrsfPoint = theTrsf.map( QPointF( aPoint.X(), aPoint.Y() ) );
 
+      aPoint.SetX( aTrsfPoint.x() );
+      aPoint.SetY( aTrsfPoint.y() );
+    }
+    SetPoints( i, aPoints );
+  }
+
+  Update();
+}
 
index fa764067ac0a874b5f4c349370266042f5298684..ef7101048ef76aa9f003a624c8a0eb7d01908c3b 100644 (file)
@@ -24,6 +24,7 @@
 DEFINE_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
 
 class QPainterPath;
+class QTransform;
 class TopoDS_Wire;
 class gp_XYZ;
 
@@ -286,6 +287,11 @@ public:
    */
   HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
 
+  /**
+   * Transform the polyline points.
+   * @param theTrsf the transformation
+   */
+  HYDRODATA_EXPORT void Transform( const QTransform& theTrsf );
 
 protected:
 
index 684e5634e628121f82ed146c86e44f22468b3924..fcf27039dc084145804a692022c594181c4887b9 100644 (file)
@@ -18,6 +18,7 @@ set(PROJECT_HEADERS
     HYDROGUI_DataModel.h
     HYDROGUI_DataModelSync.h
     HYDROGUI_DataObject.h
+       HYDROGUI_DataOwner.h
     HYDROGUI_DeleteDlg.h
     HYDROGUI_DeleteOp.h
     HYDROGUI_DigueDlg.h
@@ -119,6 +120,8 @@ set(PROJECT_HEADERS
     HYDROGUI_RiverBottomOp.h
     HYDROGUI_ViewerDlg.h
     HYDROGUI_ObjComboBox.h
+    HYDROGUI_RecognizeContoursDlg.h
+    HYDROGUI_RecognizeContoursOp.h
 )
 
 QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -139,6 +142,7 @@ set(PROJECT_SOURCES
     HYDROGUI_DataModel.cxx
     HYDROGUI_DataModelSync.cxx
     HYDROGUI_DataObject.cxx
+       HYDROGUI_DataOwner.cxx
     HYDROGUI_DeleteDlg.cxx
     HYDROGUI_DeleteOp.cxx
     HYDROGUI_DigueDlg.cxx
@@ -241,6 +245,8 @@ set(PROJECT_SOURCES
     HYDROGUI_RiverBottomOp.cxx
     HYDROGUI_ViewerDlg.cxx
     HYDROGUI_ObjComboBox.cxx
+    HYDROGUI_RecognizeContoursDlg.cxx
+    HYDROGUI_RecognizeContoursOp.cxx
 )
 
 add_definitions(
index f8311d5a4f90c45bb0ef1dfa8626dd9995559e35..be424729bcabfd453be0b79ac0b5de76b01d7074 100644 (file)
@@ -55,7 +55,9 @@ HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool
 : HYDROGUI_Operation( theModule ),
   myIsEdit( theIsEdit ),
   myActiveViewManager( NULL ),
-  myPreviewViewManager( NULL )
+  myPreviewViewManager( NULL ),
+  myShowGeomObjects( true ),
+  myShowZones( false )
 {
   setName( myIsEdit ? tr( "EDIT_CALCULATION" ) : tr( "CREATE_CALCULATION" ) );
 }
@@ -220,7 +222,7 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
   connect( aPanel, SIGNAL( orderLandCoverChanged( bool& ) ), SLOT( onOrderLandCoverChanged( bool& ) ) );
     
   connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
-  connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones() ) );
+  connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onBack( const int ) ) );
   //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
   connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
   connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ),
@@ -924,6 +926,8 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
       return;
 
     QApplication::setOverrideCursor( Qt::WaitCursor );
+
+    setGeomObjectsVisible( false );
   
     QString aNewCaseName = aPanel->getObjectName();
     QString anOldCaseName = myEditedObject->GetName();
@@ -1049,8 +1053,9 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
   }
 }
 
-void HYDROGUI_CalculationOp::onHideZones()
+void HYDROGUI_CalculationOp::onBack( const int theIndex )
 {
+  setGeomObjectsVisible( theIndex != 2 );
   setZonesVisible( false );
 }
 
@@ -1088,6 +1093,18 @@ void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
   }
 }
 
+void HYDROGUI_CalculationOp::setGeomObjectsVisible( bool theIsVisible )
+{
+  myShowGeomObjects = theIsVisible;
+
+  HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
+
+  HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+  for ( ; anIter.More(); anIter.Next() ) {
+    setObjectVisibility( anIter.Value(), theIsVisible );
+  }
+}
+
 void HYDROGUI_CalculationOp::AssignDefaultZonesColors()
 {
   HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
@@ -1195,7 +1212,10 @@ void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDat
 void HYDROGUI_CalculationOp::createPreview()
 {
   LightApp_Application* anApp = module()->getApp();
-  HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
+  HYDROData_SequenceOfObjects aSeq;
+  if ( myShowGeomObjects ) {
+    aSeq.Append( myEditedObject->GetGeometryObjects() );
+  }
   Handle(HYDROData_Entity) anEntity;
 
   if ( myShowZones )
index 4966ee3cde0e3152a198dea7285e69dc59a822e4..b4961a357602834508caf5b5bc35d7c9de151037 100644 (file)
@@ -118,9 +118,9 @@ protected slots:
    */
   void                            onClickedInZonesBrowser( SUIT_DataObject* theItem );
   /**
-   * Hide zones in the viewer.
+   * Slot called on back button click.
    */
-  void                            onHideZones();
+  void                            onBack( const int );
   /** 
    * Geometry object is selected in the list on the first wizard page
    */
@@ -146,6 +146,7 @@ private:
   void                            closePreview();
   void                            setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
   void                            setZonesVisible( bool theIsVisible );
+  void                            setGeomObjectsVisible( bool theIsVisible );
   void                            getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, 
                                                       QStringList& theNames, QStringList& theEntries ) const;
 
@@ -182,6 +183,7 @@ private:
 private:
   bool                            myIsEdit;
   bool                            myShowZones;
+  bool                            myShowGeomObjects;
   Handle(HYDROData_CalculationCase) myEditedObject;
 
   SUIT_ViewManager*               myActiveViewManager;
index 06a0ab41c2da1dcd98b9dd276a91b111a720b5c9..61f5453c82b9af3f3f129c9bab390edfee3fbbde 100644 (file)
@@ -735,18 +735,7 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*
 
   if ( visibility )
   {
-    SUIT_AbstractModel* treeModel = 0;
-    LightApp_Application* app = dynamic_cast<LightApp_Application*>( module()->application() );
-    if ( app )
-        treeModel = dynamic_cast<SUIT_AbstractModel*>( app->objectBrowser()->model() );
-
-    if ( treeModel )
-    {
-      HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
-      bool isVisible = aModule->isObjectVisible( -1, theModelObject );
-      Qtx::VisibilityState aVisState = isVisible ? Qtx::ShownState : Qtx::HiddenState;
-      treeModel->setVisibilityState( aResObj->text( aResObj->customData( Qtx::IdType ).toInt() ), aVisState, false );
-    }
+    setObjectVisibilityState( theModelObject, aResObj );
   }
 
   if ( theIsBuildTree )
@@ -776,8 +765,12 @@ LightApp_DataObject* HYDROGUI_DataModel::createZone( SUIT_DataObject*       theP
                                                      const bool             theIsBuildTree,
                                                      const bool             theIsInOperation )
 {
-  return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry, theIsInOperation ), 
-    theParentEntry, theIsBuildTree, theIsInOperation );
+  HYDROGUI_Zone* aZone = new HYDROGUI_Zone( theParent, theModelObject, theParentEntry, theIsInOperation );
+  LightApp_DataObject* aDataObj = buildObject( theParent, aZone, theParentEntry, theIsBuildTree, theIsInOperation );
+
+  setObjectVisibilityState( theModelObject, aZone );
+
+  return aDataObj;
 }
 
 LightApp_DataObject* HYDROGUI_DataModel::createRegion( SUIT_DataObject*         theParent,
@@ -1203,3 +1196,20 @@ bool HYDROGUI_DataModel::rename( Handle(HYDROData_Entity) theEntity, const QStri
   }
   return true;
 }
+
+void HYDROGUI_DataModel::setObjectVisibilityState( Handle(HYDROData_Entity) theModelObject,
+                                                   HYDROGUI_DataObject* theObject )
+{
+  SUIT_AbstractModel* treeModel = 0;
+  LightApp_Application* app = dynamic_cast<LightApp_Application*>( module()->application() );
+  if ( app )
+    treeModel = dynamic_cast<SUIT_AbstractModel*>( app->objectBrowser()->model() );
+
+  if ( treeModel )
+  {
+    HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
+    bool isVisible = aModule->isObjectVisible( -1, theModelObject );
+    Qtx::VisibilityState aVisState = isVisible ? Qtx::ShownState : Qtx::HiddenState;
+    treeModel->setVisibilityState( theObject->text( theObject->customData( Qtx::IdType ).toInt() ), aVisState, false );
+  }
+}
index f8b4a7018c426ec2ba4fe8e71ad03ed2e4f6ed74..671a6969a86dc361ad8ae20ef602b06196a7f71d 100644 (file)
@@ -365,6 +365,15 @@ protected:
   static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
                                            const QString& theName );
 
+  /**
+   * Set object visibility state.
+   * \param theModelObject the data model object
+   * \param theDataObject the GUI object
+   */
+  void setObjectVisibilityState( Handle(HYDROData_Entity) theModelObject,
+                                 HYDROGUI_DataObject* theObject );
+                                 
+
 protected:
   QString myStudyURL; ///< the saved/opened document URL
   QByteArray myStates;
diff --git a/src/HYDROGUI/HYDROGUI_DataOwner.cxx b/src/HYDROGUI/HYDROGUI_DataOwner.cxx
new file mode 100644 (file)
index 0000000..040085b
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_DataOwner.h"
+
+
+HYDROGUI_DataOwner::HYDROGUI_DataOwner()
+{
+}
+
+HYDROGUI_DataOwner::HYDROGUI_DataOwner( const Handle(AIS_InteractiveObject)& theIO ):
+  myIO(theIO)
+{
+}
+
+HYDROGUI_DataOwner::~HYDROGUI_DataOwner()
+{
+}
+
+QString HYDROGUI_DataOwner::keyString() const
+{
+  QString aKey;
+
+  if ( !myIO.IsNull() ) {
+    aKey = QString().sprintf( "%08p", myIO.operator->() );
+  }
+
+  return aKey;
+}
+
+const Handle(AIS_InteractiveObject)& HYDROGUI_DataOwner::IO() const
+{
+  return myIO;
+}
diff --git a/src/HYDROGUI/HYDROGUI_DataOwner.h b/src/HYDROGUI/HYDROGUI_DataOwner.h
new file mode 100644 (file)
index 0000000..f955cbb
--- /dev/null
@@ -0,0 +1,66 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_DATAOWNER_H
+#define HYDROGUI_DATAOWNER_H
+
+#include <SUIT_DataOwner.h>
+
+#include <AIS_InteractiveObject.hxx>
+
+
+/*!
+  This class provide data owner objects.
+*/
+class HYDROGUI_DataOwner : public SUIT_DataOwner
+{
+public:
+    /**
+     * Constructor. Initialize by \a AIS_InteractiveObject.
+     */
+    HYDROGUI_DataOwner( const Handle(AIS_InteractiveObject)& theIO );
+
+    /**
+     * Constructor.
+     */
+    HYDROGUI_DataOwner();
+
+    /**
+     * Destructor.
+     */
+    virtual ~HYDROGUI_DataOwner();
+
+    /**
+     * Gets key string, used for data owners comparison.
+     * \return the empty string
+     */
+    virtual QString keyString() const;
+
+    /**
+     * Gets SALOME_InteractiveObject.
+     * \return the SALOME interactive object
+     */
+    const Handle(AIS_InteractiveObject)& IO() const;
+
+private:
+    Handle(AIS_InteractiveObject) myIO; ///< the AIS interactive object
+};
+
+typedef SMART(HYDROGUI_DataOwner) HYDROGUI_DataOwnerPtr;
+
+#endif
index f84dcebf8d79af10b4d97c896f4ad2ec7b0e8421..9127cb74a747cd7926b26e0583279c62fbf4f614 100644 (file)
@@ -585,6 +585,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( CutImagesId ) );
         theMenu->addAction( action( SplitImageId ) );
         theMenu->addSeparator();
+        theMenu->addAction( action( RecognizeContoursId ) );
+        theMenu->addSeparator();
       }
       else if( anIsBathymetry )
       {
index eebfdf3575b8dba74f9c0cbd283dcf59b57294b6..432306627ff08164ce644a83d348cb9dca394d77 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "HYDROGUI_DataModel.h"
 #include "HYDROGUI_DataObject.h"
+#include "HYDROGUI_DataOwner.h"
 #include "HYDROGUI_Module.h"
 
 #include <AIS_ListOfInteractive.hxx>
@@ -53,8 +54,14 @@ void HYDROGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
   for ( AIS_ListIteratorOfListOfInteractive anIt( aSelList ); anIt.More(); anIt.Next() )
     if ( !anIt.Value().IsNull() )
     {
-      if ( !isLocalContext )
-        aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( entry( anIt.Value() ) ) ) );
+      if ( !isLocalContext ) {
+        QString anEntry = entry( anIt.Value() );
+        if ( !anEntry.isEmpty() ) {
+          aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( entry( anIt.Value() ) ) ) );
+        } else {
+          aList.append( SUIT_DataOwnerPtr( new HYDROGUI_DataOwner( anIt.Value() ) ) );
+        }
+      }
     }
   // add externally selected objects
   SUIT_DataOwnerPtrList::const_iterator anExtIter;
@@ -70,11 +77,39 @@ void HYDROGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
     return;
 
   Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext();
-  if ( aContext->HasOpenedContext() ) {
+  if ( aContext.IsNull() || aContext->HasOpenedContext() ) {
     return;
   }
 
-  LightApp_OCCSelector::setSelection( aList );
+  QMap<QString, Handle(AIS_InteractiveObject)> aDisplayed;
+  AIS_ListOfInteractive aDispList, aSelList;
+  aContext->DisplayedObjects( aDispList );
+
+  for ( AIS_ListIteratorOfListOfInteractive it( aDispList ); it.More(); it.Next() )
+  {
+    QString entryStr = entry( it.Value() );
+    if ( !entryStr.isEmpty() )
+      aDisplayed.insert( entryStr, it.Value() );
+  }
+  
+  mySelectedExternals.clear();
+
+  for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
+  {
+    const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
+    if ( owner && aDisplayed.contains( owner->entry() ) )
+      aSelList.Append( aDisplayed[owner->entry()] );
+    else {
+      const HYDROGUI_DataOwner* hydroOwner = dynamic_cast<const HYDROGUI_DataOwner*>( (*itr).operator->() );
+      if ( hydroOwner && !hydroOwner->IO().IsNull() ) {
+        aSelList.Append( hydroOwner->IO() );
+      } else
+        mySelectedExternals.append(*itr);
+    }
+  }
+  aViewer->unHighlightAll( false );
+  aViewer->setObjectsSelected( aSelList );
 }
 
 QString HYDROGUI_OCCSelector::entry( const Handle(AIS_InteractiveObject)& anAIS ) const
index 0a96e7986f8f9afffa28f14b8c0a29c913bfe757..3ebae5722f6977aa998ab7459a26809c074aa901 100644 (file)
@@ -57,6 +57,7 @@
 #include "HYDROGUI_LocalCSOp.h"
 #include "HYDROGUI_RiverBottomOp.h"
 #include "HYDROGUI_ProfileInterpolateOp.h"
+#include "HYDROGUI_RecognizeContoursOp.h"
 #include "HYDROGUI_SubmersibleOp.h"
 #include "HYDROGUI_StricklerTableOp.h"
 #include "HYDROGUI_DuplicateOp.h"
@@ -180,6 +181,8 @@ void HYDROGUI_Module::createActions()
   createAction( SplitImageId, "SPLIT_IMAGE", "SPLIT_IMAGE_ICO" );
   createAction( EditSplittedImageId, "EDIT_SPLITTED_IMAGE", "EDIT_SPLITTED_IMAGE_ICO" );
 
+  createAction( RecognizeContoursId, "RECOGNIZE_CONTOURS", "RECOGNIZE_CONTOURS_ICO" );
+
   createAction( CopyViewerPositionId, "COPY_VIEWER_POSITION", "" );
 
   createAction( DeleteId, "DELETE", "", Qt::Key_Delete, false,
@@ -563,6 +566,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case RiverBottomContextId:
     anOp = new HYDROGUI_RiverBottomOp( aModule );
     break;
+  case RecognizeContoursId:
+    anOp = new HYDROGUI_RecognizeContoursOp( aModule );
+    break;
   case ShowId:
   case ShowOnlyId:
   case ShowAllId:
index e9d10c02a64d6113ea30002b101de3dde8bfdd95..2669cae2c688749c6f47b0a557f1826a75a454cb 100644 (file)
@@ -107,6 +107,7 @@ enum OperationId
   RiverBottomContextId,
   ProfileInterpolateId,
 
+  RecognizeContoursId,
   SubmersibleId,
   ImportPolylineId,
   ExportPolylineId,
diff --git a/src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.cxx b/src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.cxx
new file mode 100644 (file)
index 0000000..6840e2d
--- /dev/null
@@ -0,0 +1,156 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_RecognizeContoursDlg.h"
+
+#include <QGroupBox>
+#include <QLabel>
+#include <QLineEdit>
+#include <QListWidget>
+#include <QVBoxLayout>
+
+/**
+ * Constructor.
+ * \param theModule the module
+ * \param theTitle the panel title
+ */
+HYDROGUI_RecognizeContoursDlg::HYDROGUI_RecognizeContoursDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+  // Original image
+  QGroupBox* anImageGroup = new QGroupBox( tr( "ORIGINAL_IMAGE" ), mainFrame() );
+  QLabel* aNameLabel = new QLabel( tr("NAME") );
+  myImageName = new QLineEdit;
+  myImageName->setReadOnly( true );
+
+  QHBoxLayout* anImageLayout = new QHBoxLayout();
+  anImageLayout->addWidget( aNameLabel );
+  anImageLayout->addWidget( myImageName );
+  anImageGroup->setLayout( anImageLayout );
+
+  // List of recognized polylines
+  QGroupBox* aPolylinesGroup = new QGroupBox( tr( "RECOGNIZED_POLYLINES" ), mainFrame() );
+  myPolylines = new QListWidget( aPolylinesGroup );
+  myPolylines->setSelectionMode( QListWidget::ExtendedSelection );
+  myPolylines->setEditTriggers( QListWidget::NoEditTriggers );
+  myPolylines->setViewMode( QListWidget::ListMode );
+  myPolylines->setSortingEnabled( false );
+
+  QBoxLayout* aPolylinesLayout = new QVBoxLayout;
+  aPolylinesLayout->addWidget( myPolylines );
+  aPolylinesGroup->setLayout( aPolylinesLayout );
+
+  // Layout
+  addWidget( anImageGroup );
+  addWidget( aPolylinesGroup );
+
+  // Conections
+  connect( myPolylines, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
+}
+
+/**
+ * Destructor.
+ */
+HYDROGUI_RecognizeContoursDlg::~HYDROGUI_RecognizeContoursDlg()
+{
+}
+
+/**
+ * Set the image name.
+ * \param theName the name
+ */
+void HYDROGUI_RecognizeContoursDlg::setImageName( const QString& theName )
+{
+  myImageName->setText( theName );
+}
+
+/**
+ * Reset the panel.
+ */
+void HYDROGUI_RecognizeContoursDlg::reset()
+{
+  myImageName->clear();
+  myPolylines->clear();
+}
+
+/**
+ * Refill the list of polylines names.
+ * \param theNames the list of names
+ */
+void HYDROGUI_RecognizeContoursDlg::setPolylineNames( const QStringList& theNames )
+{
+  myPolylines->clear();
+  myPolylines->addItems( theNames );
+}
+
+/**
+ * Remove the given polyline names from the list.
+ * \param theNames the list of names
+ */
+void HYDROGUI_RecognizeContoursDlg::removePolylineNames( const QStringList& theNames )
+{
+  QList<QListWidgetItem*> aFoundItems;
+
+  foreach ( const QString& aName, theNames ) {
+    aFoundItems = myPolylines->findItems( aName, Qt::MatchExactly );
+    foreach ( QListWidgetItem* anItem, aFoundItems ) {
+      anItem = myPolylines->takeItem( myPolylines->row( anItem ) );
+      delete anItem;
+    }
+  }
+}
+
+/**
+ * Select the given polyline names in the list.
+ * \param theNames the list of names
+ */
+void HYDROGUI_RecognizeContoursDlg::setSelectedPolylineNames( const QStringList& theNames )
+{
+  myPolylines->clearSelection();
+
+  foreach( const QString aName, theNames ) {
+    QList<QListWidgetItem*> anItems = myPolylines->findItems( aName, Qt::MatchExactly );
+    if ( anItems.count() == 1 ) {
+      anItems.first()->setSelected( true );
+    }
+  }
+}
+
+/**
+ * Slot called when polyline names selection changed.
+ */
+void HYDROGUI_RecognizeContoursDlg::onItemSelectionChanged()
+{
+  emit selectionChanged( getSelectedtPolylineNames() );
+}
+
+/**
+ * Get the list of selected polyline names.
+ * \return the list of names
+ */ 
+QStringList HYDROGUI_RecognizeContoursDlg::getSelectedtPolylineNames() const
+{
+  QStringList aSelectedNames;
+
+  QList<QListWidgetItem*> aSelectedItems = myPolylines->selectedItems();
+  foreach( const QListWidgetItem* anItem, aSelectedItems ) {
+    aSelectedNames << anItem->text();
+  }
+
+  return aSelectedNames;
+}
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.h b/src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.h
new file mode 100644 (file)
index 0000000..f30d7db
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_RecognizeContoursDlg_H
+#define HYDROGUI_RecognizeContoursDlg_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class QListWidget;
+class QLineEdit;
+
+class HYDROGUI_RecognizeContoursDlg : public HYDROGUI_InputPanel
+{
+  Q_OBJECT
+
+  enum CreationMode { CreateNewId, ModifyExistentId };
+
+public:
+  HYDROGUI_RecognizeContoursDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+  virtual ~HYDROGUI_RecognizeContoursDlg();
+
+  void setImageName( const QString& theName );
+
+  void reset();
+
+  void setPolylineNames( const QStringList& theNames );
+  void removePolylineNames( const QStringList& theNames );
+
+  void setSelectedPolylineNames( const QStringList& theNames );
+
+  QStringList getSelectedtPolylineNames() const;
+  
+signals:
+  void selectionChanged( const QStringList& );
+
+public slots:
+  void onItemSelectionChanged();
+
+private:
+  QLineEdit*   myImageName;
+  QListWidget* myPolylines;    
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx b/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx
new file mode 100644 (file)
index 0000000..2bee9b7
--- /dev/null
@@ -0,0 +1,516 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_RecognizeContoursOp.h"
+
+#include "HYDROGUI_RecognizeContoursDlg.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Shape.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_OCCSelector.h"
+#include "HYDROGUI_ZLayers.h"
+
+#include <HYDROData_Document.h>
+#include <HYDROData_GeomTool.h>
+#include <HYDROData_ShapesTool.h>
+#include <HYDROData_PolylineXY.h>
+
+#include <GeometryGUI.h>
+#include <GeometryGUI_Operations.h>
+#include <GEOM_Constants.h>
+#include <GEOMBase.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <SalomeApp_Study.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_DataOwner.h>
+#include <LightApp_Displayer.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
+
+#include <BRepBuilderAPI_GTransform.hxx>
+#include <gp_GTrsf.hxx>
+
+#include <QDialog>
+#include <QTemporaryFile>
+
+/**
+  Constructor.
+*/
+HYDROGUI_RecognizeContoursOp::HYDROGUI_RecognizeContoursOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule ),
+  myGEOMOpName( "" )
+{
+  setName( tr( "CONTOURS_RECOGNITION" ) );
+}
+
+/**
+  Destructor.
+*/
+HYDROGUI_RecognizeContoursOp::~HYDROGUI_RecognizeContoursOp()
+{
+  cleanup();
+}
+
+/**
+*/
+void HYDROGUI_RecognizeContoursOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+  
+  // Set preview view manager
+  if ( !getPreviewManager() ) {
+    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( 
+                       module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
+  }
+
+  if ( !isApplyAndClose() ) {
+    return;
+  }
+
+  // Get the selected image
+  myImage = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+  if ( myImage.IsNull() ) {
+    abort();
+    return;
+  }
+  QString anImageName = myImage->GetName();
+
+  // Create temporary graphics file
+  QImage aQImage = myImage->Image();
+  myTmpImageFile = new QTemporaryFile( anImageName );
+  if ( !myTmpImageFile->open() || 
+       !aQImage.save( myTmpImageFile->fileName(), "PNG", 100 ) ) {
+    abort();
+    return;
+  }
+
+  // Create the input panel
+  HYDROGUI_RecognizeContoursDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_RecognizeContoursDlg*>( inputPanel() );
+  if ( !aPanel ) {
+    return;
+  }
+
+  // Reset the panel
+  aPanel->reset();
+  aPanel->setImageName( anImageName );
+
+  // Get active study
+  SalomeApp_Study* aStudy = 
+    dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
+
+  // Get active view manager
+  SUIT_ViewManager* aViewMgr = module()->getApp()->activeViewManager();
+
+  // Export the selected image to GEOM module
+  if ( aStudy && aViewMgr ) {
+    SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
+    GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
+
+    QString aGeomPictureEntry;
+
+    HYDROData_GeomTool::createFaceInGEOM( aGeomEngine, aDSStudy, aQImage.width(), aQImage.height(), 
+                                          anImageName, aGeomPictureEntry );
+    
+    if ( !aGeomPictureEntry.isEmpty() ) {
+      aStudy->setObjectProperty( aViewMgr->getGlobalId(), aGeomPictureEntry, 
+                                 GEOM::propertyName( GEOM::Texture ), myTmpImageFile->fileName() );
+    
+      // update the object browser
+      module()->getApp()->updateObjectBrowser( true );
+
+      // select the picture
+      SUIT_DataOwnerPtrList aList( true );
+      aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aGeomPictureEntry ) ) );
+      selectionMgr()->setSelected(aList );
+
+      // Add GEOM picture object entry to the list of temporary geom objects
+      myTmpGeomObjects << aGeomPictureEntry;
+    }
+  }
+
+  // Activate GEOM module operation
+  LightApp_Application* anApp = module()->getApp();
+  if ( anApp ) {
+    connect( anApp, SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ), 
+             this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
+
+    module()->getApp()->activateOperation( "Geometry", GEOMOp::OpFeatureDetect );
+  }
+}
+
+/**
+*/
+void HYDROGUI_RecognizeContoursOp::abortOperation()
+{
+  LightApp_Application* anApp = module()->getApp();
+  if ( anApp ) {
+    anApp->disconnect( this );
+  }
+
+  cleanup();
+
+  HYDROGUI_Operation::abortOperation();
+}
+
+/**
+*/
+void HYDROGUI_RecognizeContoursOp::commitOperation()
+{
+  if ( isApplyAndClose() ) {
+    cleanup();
+  }
+
+  HYDROGUI_Operation::commitOperation();
+}
+
+/**
+*/
+bool HYDROGUI_RecognizeContoursOp::processApply( int& theUpdateFlags,
+                                                QString& theErrorMsg,
+                                                QStringList& theBrowseObjectsEntries )
+{
+  // Check the original image
+  if ( myImage.IsNull() ) {
+    return false;
+  }
+
+  // Get panel
+  HYDROGUI_RecognizeContoursDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_RecognizeContoursDlg*>( inputPanel() );
+  if ( !aPanel ) {
+    return false;
+  }
+  
+  // Check if contour GEOM object exists
+  if ( myGeomContourEntry.isEmpty() ) {
+    theErrorMsg = tr( "NO_DETECTED_CONTOURS" );
+    return false;
+  }
+
+  // Get selected polylines
+  QStringList aSelectedtPolylines = aPanel->getSelectedtPolylineNames();
+  // Remove the selected polylines from the panel
+  aPanel->removePolylineNames( aSelectedtPolylines );
+
+  // Create polylines
+  foreach ( QString aName, aSelectedtPolylines ) {
+    TopoDS_Shape aShape = myPolylineShapes.value( aName )->getTopoShape();
+    if ( aShape.IsNull() ) {
+      continue;
+    }
+
+    Handle(HYDROData_PolylineXY) aPolylineObj =
+      Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) );
+
+    if( !aPolylineObj.IsNull() ) {
+      aPolylineObj->SetName( aName );
+      aPolylineObj->ImportShape( aShape );
+      aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() );
+
+      aPolylineObj->Update();
+      module()->setIsToUpdate( aPolylineObj );
+    }
+
+    // Remove the shape from the map
+    HYDROGUI_Shape* aShapeToDelete = myPolylineShapes.take( aName );
+    delete aShapeToDelete;
+  }
+  theUpdateFlags = UF_Model;
+
+  return true;
+}
+
+/**
+*/
+HYDROGUI_InputPanel* HYDROGUI_RecognizeContoursOp::createInputPanel() const
+{
+  HYDROGUI_InputPanel* aPanel = new HYDROGUI_RecognizeContoursDlg( module(), getName() );
+
+  connect( aPanel, SIGNAL( selectionChanged( const QStringList& ) ), this, SLOT( onSelectionChanged( const QStringList& ) ) );
+
+  return aPanel;
+}
+
+/**
+ * Called when the operation perfomed by another module is finished.
+ * \param theModuleName the name of the module which perfomed the operation
+ * \param theOperationName the operation name
+ * \param theEntryList the list of the created objects entries
+ */
+void HYDROGUI_RecognizeContoursOp::onExternalOperationFinished( 
+  const QString& theModuleName, const QString& theOperationName,
+  const QStringList& theEntryList )
+{
+  // Process "Geometry" module operations only
+  if ( theModuleName != "Geometry" ) {
+    return;
+  }
+    
+  // Store the operation name
+  myGEOMOpName = theOperationName;
+
+  // Close the dialog corresponding to the external operation
+  closeExternalOperationDlg();
+  
+  // Erase the GEOM objects
+  LightApp_Displayer().Erase( theEntryList );
+
+  // Add GEOM object entries to the list of temporary GEOM objects
+  myTmpGeomObjects << theEntryList;
+
+  if ( theEntryList.count() == 1 ) {
+    myGeomContourEntry = theEntryList.first();
+
+    // Update the list of polylines
+    updateRecognizedPolylines();
+  }
+}
+
+/**
+  Close the GEOM contours detection dialog.
+*/
+void HYDROGUI_RecognizeContoursOp::closeExternalOperationDlg()
+{
+  if ( myGEOMOpName.isEmpty() ) {
+    return;
+  }
+
+  SUIT_Desktop* aDesktop = module()->getApp()->desktop();
+  if ( aDesktop ) {
+    QList<QDialog*> aDialogs = aDesktop->findChildren<QDialog*>();
+    foreach ( QDialog* aDlg, aDialogs ) {
+      if ( typeid(*aDlg).name() == myGEOMOpName ) {
+        aDlg->close();
+        break;
+      }
+    }
+  }
+}
+
+/**
+  Update the list of recognized polylines by exploding the GEOM contour object.
+*/
+void HYDROGUI_RecognizeContoursOp::updateRecognizedPolylines()
+{
+  // Erase the preview
+  erasePreview();
+
+  // Get active study
+  SalomeApp_Study* aStudy = 
+    dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
+  if ( !aStudy ) {
+    return;
+  }
+
+  // Explode the compound
+  _PTR(SObject) aSObject( aStudy->studyDS()->FindObjectID( qPrintable( myGeomContourEntry ) ) );
+  if ( aSObject ) {
+    TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( aSObject->GetIOR().c_str() );
+
+    TopTools_SequenceOfShape aSubShapes;
+    HYDROData_ShapesTool::ExploreShapeToShapes( aShape, TopAbs_WIRE, aSubShapes );
+    if ( aSubShapes.Length() < 1 ) {
+      HYDROData_ShapesTool::ExploreShapeToShapes( aShape, TopAbs_EDGE, aSubShapes );
+    }
+
+    Handle(AIS_InteractiveContext) aCtx = NULL;
+
+    // Display preview
+    OCCViewer_ViewManager* aViewManager = getPreviewManager();
+    if ( aViewManager ) {
+      if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+        // aViewer->enablePreselection( true );
+        // aViewer->enableSelection( true );
+        aCtx = aViewer->getAISContext();
+        connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) );
+      }
+    }
+
+    QTransform aTrsf = myImage->Trsf();
+    QImage anImage = myImage->Image();
+    QRectF aRect( QPointF( 0, 0 ), QPointF( anImage.width(), anImage.height() ) );
+    aRect = aTrsf.mapRect( aRect );
+    aTrsf.setMatrix( aTrsf.m11(), aTrsf.m12(),  aTrsf.m13(),
+                     aTrsf.m21(), -aTrsf.m22(), aTrsf.m23(),
+                     aTrsf.m31() + aRect.width() * 0.5, aTrsf.m32 () - aRect.height() * 0.5, aTrsf.m33() );
+
+    /*
+    QTransform aTrsf = myImage->Trsf();
+    gp_Mat aMat( aTrsf.m11(), aTrsf.m21(), 0, 
+                 aTrsf.m12(), -aTrsf.m22(), 0, 
+                 0,           0,           1 );
+    QImage anImage = myImage->Image();
+    QRectF aRect( QPointF( 0, 0 ), QPointF( anImage.width(), anImage.height() ) );
+    aRect = aTrsf.mapRect( aRect );
+    gp_XYZ aVec( aTrsf.m31() + aRect.width() * 0.5, 
+                 aTrsf.m32() - aRect.height() * 0.5, 0 );
+
+    BRepBuilderAPI_GTransform aBuilder( gp_GTrsf( aMat, aVec ) );
+    */
+
+    Handle(HYDROData_PolylineXY) aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) );
+    QStringList aNamesList;
+    for ( int i = 1; i <= aSubShapes.Length(); i++ ) {
+      TopoDS_Shape aSubShape = aSubShapes.Value( i );
+
+      // Transform the sub-shape
+      aPolylineObj->ImportShape( aSubShape );
+      aPolylineObj->Transform( aTrsf );
+
+      /*
+      aBuilder.Perform( aSubShape, Standard_True );
+      if ( aBuilder.IsDone() ) {
+        aSubShape = aBuilder.Shape();
+      }*/
+      
+      HYDROGUI_Shape* aShape = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
+      aShape->setShape( aPolylineObj->GetShape(), true, false );
+      aShape->setBorderColor( HYDROData_PolylineXY::DefaultWireColor(), false, false );
+      
+      QString aPrefix = QString("%1_%2_%3").arg( myImage->GetName(), "Contour", QString::number( i ) );
+      QString aName = HYDROGUI_Tool::GenerateObjectName( module(), aPrefix, QStringList(), true );
+      myPolylineShapes.insert( aName, aShape);
+      aNamesList << aName;
+    }
+
+    aPolylineObj->Remove();
+
+    if ( !aCtx.IsNull() ) {
+      UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, Graphic3d_ZLayerId_TopOSD );
+      aCtx->UpdateCurrentViewer();
+    }
+
+    // Get panel
+    HYDROGUI_RecognizeContoursDlg* aPanel = 
+      ::qobject_cast<HYDROGUI_RecognizeContoursDlg*>( inputPanel() );
+    if ( aPanel ) {
+      aPanel->setPolylineNames( aNamesList );
+    }
+  }
+}
+
+/**
+  Erase the preview.
+*/
+void HYDROGUI_RecognizeContoursOp::erasePreview()
+{
+  foreach ( HYDROGUI_Shape* aShape, myPolylineShapes ) {
+    delete aShape;
+  }
+
+  myPolylineShapes.clear();
+}
+
+/**
+  Called when selection of the recognized polylines is changed.
+*/
+void HYDROGUI_RecognizeContoursOp::onSelectionChanged( const QStringList& theSelectedNames )
+{
+  Handle(AIS_InteractiveContext) aCtx = NULL;
+
+  OCCViewer_ViewManager* aViewManager = getPreviewManager();
+  if ( aViewManager ) {
+    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+      aCtx = aViewer->getAISContext();
+    }
+  }
+
+  if ( !aCtx.IsNull() ) {
+    foreach ( QString aName, myPolylineShapes.keys() ) {
+      Handle(AIS_InteractiveObject) anObject = 
+        myPolylineShapes.value(aName)->getAISObject();
+
+      bool isSelected = theSelectedNames.contains( aName );
+      if ( ( isSelected && !aCtx->IsSelected( anObject) ) ||
+           ( !isSelected && aCtx->IsSelected( anObject) ) ) {
+        aCtx->AddOrRemoveSelected( anObject, Standard_False );
+      }
+      // myPolylineShapes[aName]->highlight( isSelected, true );
+    }
+    aCtx->UpdateCurrentViewer();
+  }
+}
+
+/**
+  Called when selection in the viewer is changed.
+*/
+void HYDROGUI_RecognizeContoursOp::onViewerSelectionChanged()
+{
+  // Get panel
+  HYDROGUI_RecognizeContoursDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_RecognizeContoursDlg*>( inputPanel() );
+  if ( !aPanel ) {
+    return;
+  }
+
+  Handle(AIS_InteractiveContext) aCtx = NULL;
+
+  OCCViewer_ViewManager* aViewManager = getPreviewManager();
+  if ( aViewManager ) {
+    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+      aCtx = aViewer->getAISContext();
+    }
+  }
+  
+  if ( !aCtx.IsNull() ) {
+    QStringList aSelectedNames;
+
+    foreach ( QString aName, myPolylineShapes.keys() ) {
+      bool isSelected = aCtx->IsSelected( myPolylineShapes.value(aName)->getAISObject() );
+      if ( isSelected ) {
+        aSelectedNames << aName;
+      }
+    }
+
+    aPanel->setSelectedPolylineNames( aSelectedNames );
+  }
+}
+
+/**
+  Do the operation data cleanup.
+*/
+void HYDROGUI_RecognizeContoursOp::cleanup()
+{
+  // Close the external operation dialog
+  closeExternalOperationDlg();
+
+  // Erase the preview 
+  erasePreview();
+
+  // Delete temporary image file
+  if ( myTmpImageFile ) {
+    delete myTmpImageFile;
+    myTmpImageFile = NULL;
+  }
+
+  // Delete temporary GEOM objects
+  if ( !myTmpGeomObjects.isEmpty() ) {
+    HYDROGUI_Tool::DeleteGeomObjects( module(), myTmpGeomObjects );
+    // update the object browser
+    module()->getApp()->updateObjectBrowser( true );
+  }
+}
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.h b/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.h
new file mode 100644 (file)
index 0000000..dfe7b98
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// 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, or (at your option) any later version.
+//
+// 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_RecognizeContoursOp_H
+#define HYDROGUI_RecognizeContoursOp_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_Image.h>
+
+#include <QMap>
+#include <QStringList>
+
+class QTemporaryFile;
+
+
+class HYDROGUI_RecognizeContoursOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_RecognizeContoursOp( HYDROGUI_Module* theModule );
+  virtual ~HYDROGUI_RecognizeContoursOp();
+
+protected:
+  virtual void startOperation();
+  virtual void abortOperation();
+  virtual void commitOperation();
+
+  virtual HYDROGUI_InputPanel* createInputPanel() const;
+
+  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+                             QStringList& theBrowseObjectsEntries );
+
+protected slots:
+  void onExternalOperationFinished( const QString&, const QString&, 
+                                    const QStringList& );
+
+  void onSelectionChanged( const QStringList& theSelectedNames );
+  void onViewerSelectionChanged();
+
+private:
+  void closeExternalOperationDlg();
+
+  void updateRecognizedPolylines();
+
+  void erasePreview();
+
+  void cleanup();
+
+private:
+  Handle(HYDROData_Image) myImage; ///< the image used for contours detection
+
+  QTemporaryFile* myTmpImageFile;  ///< the temporary graphics file
+
+  QStringList myTmpGeomObjects;    ///< the list of temporary GEOM objects entries
+  QString myGeomContourEntry;      ///< the GEOM contour object entry
+  QString myGEOMOpName;            ///< the name of the called GEOM module operation
+  
+  QMap<QString, HYDROGUI_Shape*> myPolylineShapes; ///< the detected polylines shapes map (key: name, value: shape)
+};
+
+#endif
\ No newline at end of file
index 339f9453e054787e8a4f54925a84b2563de992f3..4d015a5c52035044665c62b4f321b1088ce480fe 100644 (file)
@@ -462,7 +462,7 @@ QColor HYDROGUI_Shape::getFillingColor() const
 void HYDROGUI_Shape::setBorderColor( const QColor& theColor,
                                      const bool    theToDisplay,
                                      const bool    theIsUpdateViewer )
-{
+{ 
   myBorderColor = theColor;
   updateShape( theToDisplay, theIsUpdateViewer );
 }
@@ -494,11 +494,22 @@ void HYDROGUI_Shape::setZLayer( const int theZLayer )
 
 Handle_AIS_InteractiveObject HYDROGUI_Shape::createShape() const
 {
-  if( myTopoShape.IsNull() )
+  if( myTopoShape.IsNull() ) {
     return Handle_AIS_InteractiveObject();
-  
+  }
+
   TopAbs_ShapeEnum aShapeType = myTopoShape.ShapeType();
-  if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE ) {
+  bool IsWireEdgeCompound = aShapeType==TopAbs_COMPOUND;
+  if (IsWireEdgeCompound) {
+    TopoDS_Iterator itr(myTopoShape);
+    while (itr.More() && IsWireEdgeCompound) {
+      if (itr.Value().ShapeType() != TopAbs_WIRE && itr.Value().ShapeType() != TopAbs_EDGE)
+        IsWireEdgeCompound = false;
+      itr.Next();
+    }
+  }
+
+  if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound) {
     return new HYDROGUI_Polyline( myTopoShape );
   } else {
     return new AIS_Shape( myTopoShape );
@@ -605,7 +616,9 @@ void HYDROGUI_Shape::displayShape( const bool theIsUpdateViewer )
   if ( myZLayer >= 0 )
     myContext->SetZLayer( myShape, myZLayer );
 
-  myContext->UpdateCurrentViewer();
+  if ( theIsUpdateViewer ) {
+    myContext->UpdateCurrentViewer();
+  }
 }
 
 QColor HYDROGUI_Shape::getActiveColor() const
index 45e356eba33aecb89808930ffa822a9753b8dbb1..c4e6b90b58cd43a80c3ec6fd3cc517c42edf1da4 100644 (file)
@@ -30,6 +30,7 @@
 #include <HYDROData_Profile.h>
 #include <HYDROData_LandCover.h>
 
+#include <GeometryGUI.h>
 #include <GEOMBase.h>
 
 #include <GraphicsView_Viewer.h>
@@ -791,3 +792,39 @@ Handle(Image_PixMap) HYDROGUI_Tool::Pixmap( const QImage& theImage )
 
     return pix;
 }
+
+void HYDROGUI_Tool::DeleteGeomObjects( HYDROGUI_Module* theModule, const QStringList& theEntries )
+{
+  QStringList anEntryList;
+
+  // Get active SalomeApp_Study
+  SalomeApp_Study* aStudy = NULL;
+  if ( theModule && theModule->getApp() ) {
+    aStudy = dynamic_cast<SalomeApp_Study*>( theModule->getApp()->activeStudy() );
+  }
+  if ( !aStudy ) {
+    return;
+  }
+  // Get GEOM engine
+  GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
+  if ( aGeomEngine->_is_nil() ) {
+    return;
+  }
+  
+  // Delete GEOM objects
+  _PTR(StudyBuilder) aStudyBuilder( aStudy->studyDS()->NewBuilder() );
+  foreach ( const QString anEntry, theEntries ) {
+    _PTR(SObject) aSObject( aStudy->studyDS()->FindObjectID( qPrintable(anEntry) ) );
+    if ( aSObject ) {
+      GEOM::GEOM_Object_var aGeomObj = 
+        GEOMBase::GetObjectFromIOR( aSObject->GetIOR().c_str() );
+
+      if ( !aGeomObj->_is_nil() ) {
+        aGeomEngine->RemoveObject( aGeomObj );
+      }
+
+      aStudyBuilder->RemoveObject( aSObject );
+    }
+  }
+}
index fada415c5233880283e5493d286456419e6587d7..3231d00b1ec4281fa091263068044feadb7ac818 100644 (file)
@@ -179,16 +179,7 @@ public:
    * \return object kind
    */
   static ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule );
-
-  /**
-   * \brief Get the selected GEOM objects.
-   * \param theModule module
-   * \param theTypes the acceptable GEOM object types
-   * \return list of GEOM objects entries
-   */
-  static QStringList GetSelectedGeomObjects( HYDROGUI_Module* theModule,
-                                             QList<GEOM::shape_type> theTypes );
-
+  
   /**
    * \brief Find the data object with the specified name.
    * \param theModule module
@@ -356,6 +347,22 @@ public:
    * \return Image_PixMap object
    */
   static Handle(Image_PixMap)     Pixmap( const QImage& theImage );
+
+  /**
+   * \brief Get the selected GEOM objects.
+   * \param theModule the module
+   * \param theTypes the acceptable GEOM object types
+   * \return list of GEOM objects entries
+   */
+  static QStringList GetSelectedGeomObjects( HYDROGUI_Module* theModule,
+                                             QList<GEOM::shape_type> theTypes );
+
+  /**
+   * \brief Delete the GEOM objects.
+   * \param theModule the module
+   * \param theEntries the GEOM objects entries
+   */
+  static void DeleteGeomObjects( HYDROGUI_Module* theModule, const QStringList& theEntries );
 };
 
 #endif
index ac479434cafb04f231eb35d9a8c9053b4cedfd39..0fe911d488f0c16f487867dbcf95a4674bd53326 100644 (file)
@@ -93,9 +93,12 @@ void HYDROGUI_ZLayersIterator::Init( const Handle_V3d_Viewer& theViewer )
   theViewer->GetAllZLayers( anExistingZLayers );
   
   int n = anExistingZLayers.Length();
-  myZLayers.resize( n );
-  for( int i=1; i<=n; i++ )
-    myZLayers[i-1] = anExistingZLayers( i );
+  for( int i=1; i<=n; i++ ) {
+    int aLayerId = anExistingZLayers( i );
+    if ( aLayerId >= 0 ) {
+      myZLayers.push_back( aLayerId );
+    }
+  }
 
   myIndex = 0;
 }
index 1d59e75b274ac62d033273e8b9789b817e0ac4e8..76bd41b06414b7c0802b1b98727aaf4775d4a6a0 100644 (file)
@@ -21,6 +21,7 @@
 #include <AIS_InteractiveObject.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Trihedron.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
 
 void UpdateZLayersOfHilightPresentationsOfDisplayedObjects( const Handle_AIS_InteractiveContext& theContext,
@@ -33,7 +34,7 @@ void UpdateZLayersOfHilightPresentationsOfDisplayedObjects( const Handle_AIS_Int
   for ( ; aListIter.More(); aListIter.Next() )
   {
     Handle(AIS_InteractiveObject) aPrsObj = aListIter.Value();
-    if( !aPrsObj.IsNull() )
+    if( !aPrsObj.IsNull() && !aPrsObj->IsKind( STANDARD_TYPE(AIS_Trihedron) ) )
     {
       int aMode = aPrsObj->HasHilightMode() ? aPrsObj->HilightMode() : 0;
       theContext->MainPrsMgr()->Color( aPrsObj, Quantity_NOC_YELLOW, aMode );
index 5015949557913659c7b5099804db161e67b1ddf6..882b6e57ce1bed3893912ebe42a68263109cc267 100644 (file)
       <translation>icon_edit_splitted_image.png</translation>
     </message>
 
+    <message>
+      <source>RECOGNIZE_CONTOURS_ICO</source>
+      <translation>icon_recognize_contours.png</translation>
+    </message>
+
     <message>
       <source>CREATE_STREAM_BOTTOM_ICO</source>
       <translation>icon_stream_bottom_image.png</translation>
index 998b0f0137aeb1c5769e5ac868a88f95043ef542..a69f3b62c2946b1cbe62da51d0f772df1f1283e2 100644 (file)
@@ -1583,6 +1583,19 @@ Would you like to remove all references from the image?</translation>
       <translation>Creates the new stream profiles using interpolation of selected ones</translation>
     </message>
 
+    <message>
+      <source>MEN_RECOGNIZE_CONTOURS</source>
+      <translation>Recognize contours</translation>
+    </message>
+    <message>
+      <source>DSK_RECOGNIZE_CONTOURS</source>
+      <translation>Recognize contours</translation>
+    </message>
+    <message>
+      <source>STB_RECOGNIZE_CONTOURS</source>
+      <translation>Recognize contours</translation>
+    </message>
+
   </context>
   
   <context>
@@ -2696,5 +2709,33 @@ Polyline should consist from one not closed curve.</translation>
       <translation>Can't obtain stream oject \"%1\"</translation>
     </message>
   </context>
+  
+  <context>
+    <name>HYDROGUI_RecognizeContoursDlg</name>
+    <message>
+      <source>NAME</source>
+      <translation>Name</translation>
+    </message>
+    <message>
+      <source>ORIGINAL_IMAGE</source>
+      <translation>Original image</translation>
+    </message>
+    <message>
+      <source>RECOGNIZED_POLYLINES</source>
+      <translation>Polylines</translation>
+    </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_RecognizeContoursOp</name>
+    <message>
+      <source>CONTOURS_RECOGNITION</source>
+      <translation>Contours recognition</translation>
+    </message>
+    <message>
+      <source>NO_DETECTED_CONTOURS</source>
+      <translation>No contours were detected.</translation>
+    </message>
+  </context>
 
 </TS>
diff --git a/src/HYDROGUI/resources/icon_recognize_contours.png b/src/HYDROGUI/resources/icon_recognize_contours.png
new file mode 100644 (file)
index 0000000..ea1e154
Binary files /dev/null and b/src/HYDROGUI/resources/icon_recognize_contours.png differ