Salome HOME
Allow only closed polylines for split images operation.
authormzn <mzn@opencascade.com>
Fri, 6 Dec 2013 12:05:48 +0000 (12:05 +0000)
committermzn <mzn@opencascade.com>
Fri, 6 Dec 2013 12:05:48 +0000 (12:05 +0000)
Bug #148: Split image works wrong.

src/HYDROGUI/HYDROGUI_ObjSelector.cxx
src/HYDROGUI/HYDROGUI_ObjSelector.h
src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx

index f3b0ae6992d5880c8b7742f0d54f0a457110343d..df700b220c674a83bfc3374e56fd55f9ef6f6120 100644 (file)
@@ -26,6 +26,8 @@
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_Tool.h"
 
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_Tool.h"
 
+#include <HYDROData_PolylineXY.h>
+
 #include <GraphicsView_Object.h>
 
 #include <LightApp_Application.h>
 #include <GraphicsView_Object.h>
 
 #include <LightApp_Application.h>
 
 HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule,
                                             const ObjectKind theObjectKind,
 
 HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule,
                                             const ObjectKind theObjectKind,
-                                            QWidget* theParent )
+                                            QWidget* theParent,
+                                            const int theObjectFlags)
 : QAbstractButton( theParent ),
   myObjectKind( theObjectKind ),
 : QAbstractButton( theParent ),
   myObjectKind( theObjectKind ),
-  myModule( theModule )
+  myModule( theModule ),
+  myObjectFlags( theObjectFlags )
 {
   QHBoxLayout* aLayout = new QHBoxLayout( this );
   aLayout->setMargin( 0 );
 {
   QHBoxLayout* aLayout = new QHBoxLayout( this );
   aLayout->setMargin( 0 );
@@ -103,7 +107,16 @@ void HYDROGUI_ObjSelector::OnSelectionChanged()
   if( !anObject.IsNull() )
     if( myObjectKind == KIND_UNKNOWN || myObjectKind == anObject->GetKind() )
     {
   if( !anObject.IsNull() )
     if( myObjectKind == KIND_UNKNOWN || myObjectKind == anObject->GetKind() )
     {
-      anObjName = anObject->GetName();
+      if ( myObjectKind == KIND_POLYLINEXY && ( myObjectFlags & ClosedPolyline ) ) {
+        // check if the polyline is closed
+        Handle(HYDROData_PolylineXY) aPolylineObj = 
+          Handle(HYDROData_PolylineXY)::DownCast( anObject );
+        if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed() ) {
+          anObjName = aPolylineObj->GetName();
+        }
+      } else {
+        anObjName = anObject->GetName();
+      }
 
       // Check if the same object has not been selected in other selectors of the same parent widget.
       if ( !anObjName.isEmpty() )
 
       // Check if the same object has not been selected in other selectors of the same parent widget.
       if ( !anObjName.isEmpty() )
index e44ba07a2e3faad9b78a7d76febb95941fb2e805..5846aed6bcd8dcefed318a484e290c39e98b07d2 100644 (file)
@@ -35,10 +35,17 @@ class HYDROGUI_ObjSelector : public QAbstractButton
 {
   Q_OBJECT
 
 {
   Q_OBJECT
 
+public:
+  enum ObjectFlags {
+    NoFlags        = 0x00000000,
+    ClosedPolyline = 0x00000001
+  };
+
 public:
   HYDROGUI_ObjSelector( HYDROGUI_Module* theModule,
                         const ObjectKind theObjectKind,
 public:
   HYDROGUI_ObjSelector( HYDROGUI_Module* theModule,
                         const ObjectKind theObjectKind,
-                        QWidget* theParent );
+                        QWidget* theParent, 
+                        const int theObjectFlags = NoFlags );
   virtual ~HYDROGUI_ObjSelector();
 
   void Clear();
   virtual ~HYDROGUI_ObjSelector();
 
   void Clear();
@@ -68,6 +75,8 @@ private:
 
   QToolButton* myBtn;
   QLineEdit* myObjName;
 
   QToolButton* myBtn;
   QLineEdit* myObjName;
+
+  int myObjectFlags;
 };
 
 #endif
 };
 
 #endif
index d8edd5962fc28c9536760a1db835484ffced4642..7ec78132a5c38f10e5f88cba4c5e8eac984442c0 100644 (file)
@@ -62,7 +62,8 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const
   myImage2 = new HYDROGUI_ObjSelector( theModule, KIND_IMAGE, aParamGroup );
 
   myPolylineLabel = new QLabel( tr( "POLYLINE" ), aParamGroup );
   myImage2 = new HYDROGUI_ObjSelector( theModule, KIND_IMAGE, aParamGroup );
 
   myPolylineLabel = new QLabel( tr( "POLYLINE" ), aParamGroup );
-  myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINEXY, aParamGroup );
+  myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINEXY, aParamGroup,
+    HYDROGUI_ObjSelector::ClosedPolyline);
 
   QFrame* aBackgroundFrame = new QFrame( aParamGroup );
   QLabel* aBackgroundLabel = new QLabel( tr( "BACKGROUND" ), aBackgroundFrame );
 
   QFrame* aBackgroundFrame = new QFrame( aParamGroup );
   QLabel* aBackgroundLabel = new QLabel( tr( "BACKGROUND" ), aBackgroundFrame );