Salome HOME
refs #1508
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ProfileOp.cxx
index c51ed3861cb1e8466b373924dc8ee4efacadbea6..a7ae37ffb0e6844fe49b7f21c24e654074d6784c 100644 (file)
@@ -128,7 +128,7 @@ static int CurveCrProfileToHProfile(const HYDROGUI_CurveCreatorProfile* outProfi
 
 HYDROGUI_ProfileOp::HYDROGUI_ProfileOp( HYDROGUI_Module* theModule, bool theIsEdit )
 : HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), 
-   myDisplayer (NULL), mySingleProfileMode (false)
+   myDisplayer (NULL)
 {
   setName( theIsEdit ? tr( "EDIT_PROFILE" ) : tr( "CREATE_PROFILE" ) );
 }
@@ -183,7 +183,7 @@ void HYDROGUI_ProfileOp::startOperation()
   for (int i = 0; i < myProfiles.size(); i++)
     myProfiles[i] = new HYDROGUI_CurveCreatorProfile();
 
-  mySingleProfileMode = myEditedObjects.IsEmpty() || lenP == 1;  
+  //mySingleProfileMode = myEditedObjects.IsEmpty();  
   HYDROGUI_Operation::startOperation();
 
   HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel();
@@ -192,7 +192,7 @@ void HYDROGUI_ProfileOp::startOperation()
   setPreviewManager( aPanel->viewManager() );
   setCursor();
 
-  aPanel->SetSingleProfileMode(mySingleProfileMode); 
+  //aPanel->SetSingleProfileMode(mySingleProfileMode); 
   QMap<HYDROGUI_CurveCreatorProfile*, QColor> CurveToColor;
   if( lenP )
   {
@@ -214,7 +214,7 @@ void HYDROGUI_ProfileOp::startOperation()
     }
     int ext = myCurveToProfile.Extent(); //ext should be equal to lenP
     QVector<QColor> PColors;
-    if (!mySingleProfileMode)
+    if (myIsEdit)
       HYDROData_Tool::GenerateRepeatableRandColors(ext, PColors);
     else
       PColors << QColor(0,0,255); //default color
@@ -227,7 +227,7 @@ void HYDROGUI_ProfileOp::startOperation()
       CurveToColor[CC] = CurCol;
       const QString& profName = CP->GetName();
       const QColor& PColor = CurCol;
-      if (!mySingleProfileMode)
+      if (myIsEdit)
         aPanel->addProfileName(profName, PColor);
       else
         aPanel->setProfileName(profName);
@@ -269,13 +269,24 @@ void HYDROGUI_ProfileOp::onAddProfiles()
   }
 
   int NewLen = myEditedObjects.Length();
+  bool IsNewPoly = NewLen - ExistingProfLen;
+  if (aSelectedObj.IsEmpty())
+  {
+    SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "PROFILEOP_WARNING" ), tr ("PROFILES_ARE_NOT_SELECTED") );
+    return;
+  }
+  if (!IsNewPoly)
+  {
+    SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "PROFILEOP_WARNING" ), tr ("PROFILES_ALREADY_PRESENT") );
+    return;
+  }
   myProfiles.resize(myEditedObjects.Length());
   for (int i = myProfiles.size() - 1; i < myEditedObjects.Length(); i++)
     myProfiles[i] = new HYDROGUI_CurveCreatorProfile();
     
   HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel();  
   QMap<HYDROGUI_CurveCreatorProfile*, QColor> CurveToColor;
-  if( NewLen - ExistingProfLen )
+  if( IsNewPoly )
   {
     //TODO move to ext func!
     for (int i = ExistingProfLen + 1; i <= NewLen; i++)
@@ -306,7 +317,7 @@ void HYDROGUI_ProfileOp::onAddProfiles()
       CurveToColor[CC] = CurCol;
       const QString& profName = CP->GetName();
       const QColor& PColor = CurCol;
-      if (!mySingleProfileMode)
+      if (myIsEdit)
         aPanel->addProfileName(profName, PColor);
       else
         aPanel->setProfileName(profName);
@@ -333,7 +344,7 @@ void HYDROGUI_ProfileOp::commitOperation()
 
 HYDROGUI_InputPanel* HYDROGUI_ProfileOp::createInputPanel() const
 {
-  HYDROGUI_ProfileDlg* aDlg = new HYDROGUI_ProfileDlg( module(), getName(), mySingleProfileMode );
+  HYDROGUI_ProfileDlg* aDlg = new HYDROGUI_ProfileDlg( module(), getName(), myIsEdit );
   connect( aDlg, SIGNAL( AddProfiles() ), this, 
     SLOT( onAddProfiles() ) );
   connect( aDlg, SIGNAL( RemoveProfile(int) ), this,