From: isn Date: Thu, 9 Nov 2017 14:04:14 +0000 (+0300) Subject: refs #1334 debug X-Git-Tag: v2.1~43 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FBR_1334_MPROF;p=modules%2Fhydro.git refs #1334 debug --- diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index b59211f6..d8abe576 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -743,6 +743,20 @@ HYDROData_SequenceOfObjects HYDROData_Document::FindObjectsByNames( return aResSeq; } +HYDROData_SequenceOfObjects HYDROData_Document::CollectAllObjects( const ObjectKind theObjectKind ) const +{ + HYDROData_SequenceOfObjects aResSeq; + HYDROData_Iterator anIter( this, theObjectKind ); + for( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Entity) anObject = anIter.Current(); + if( anObject.IsNull() ) + continue; + aResSeq.Append( anObject ); + } + return aResSeq; +} + HYDROData_Document::HYDROData_Document() { HYDROData_Application::GetApplication()->NewDocument("BinOcaf", myDoc); diff --git a/src/HYDROData/HYDROData_Document.h b/src/HYDROData/HYDROData_Document.h index 4c0368f8..ce3bde51 100644 --- a/src/HYDROData/HYDROData_Document.h +++ b/src/HYDROData/HYDROData_Document.h @@ -210,6 +210,10 @@ public: const QStringList& theNames, const ObjectKind theObjectKind = KIND_UNKNOWN ) const; + //! Collect all data objects with given object type + HYDRODATA_EXPORT HYDROData_SequenceOfObjects CollectAllObjects( + const ObjectKind theObjectKind = KIND_UNKNOWN ) const; + public: //! Returns interpolator factory instance diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index 04d1d4ec..c20841a2 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -21,6 +21,7 @@ #include "HYDROGUI_Tool.h" #include "HYDROGUI_AISTrihedron.h" #ifndef TEST_MODE +#include #include "HYDROGUI_Tool2.h" #endif @@ -38,7 +39,7 @@ #ifndef TEST_MODE #include #endif - +#include #include #include @@ -51,7 +52,7 @@ #include #include #include - +#include const QString splitter_key = "HYDROGUI_ProfileDlg::splitter"; @@ -109,7 +110,7 @@ HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QStr connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) ); if (!mySingleProfileMode) { - //connect( myProfileNames, SIGNAL( currentTextChanged(QString)), SLOT(ProfileNameChanged(QString)) ); + connect( myProfileNames, SIGNAL( currentTextChanged(QString)), SLOT(ProfileNameChanged(QString)) ); connect( myProfileNames, SIGNAL( itemSelectionChanged()), this, SLOT( onProfileIndexChanged())); connect( myProfileNames, SIGNAL( itemChanged(QListWidgetItem*)), this, SLOT( onProfileNameChanged(QListWidgetItem*))); connect( myAddProfBtn, SIGNAL( clicked(bool)), this, SLOT( onAddBtnPressed(bool))); @@ -160,6 +161,8 @@ void HYDROGUI_ProfileDlg::setProfileName( const QString& theName ) void HYDROGUI_ProfileDlg::eraseProfile( int index ) { myProfileNames->takeItem(index); + if (myProfileNames->count() == 1) + myRemProfBtn->setEnabled(false); } void HYDROGUI_ProfileDlg::addProfileName( const QString& theName, const QColor& theColor ) @@ -178,6 +181,8 @@ void HYDROGUI_ProfileDlg::addProfileName( const QString& theName, const QColor& //anItem->setBackground(QBrush(theColor)); if (count == 1) anItem->setSelected(true); + if (count > 1) + myRemProfBtn->setEnabled(true); myProfileNames->blockSignals(false); } @@ -256,10 +261,10 @@ void HYDROGUI_ProfileDlg::processFinishedSubOperation( QWidget* theWidget ) myAddElementBox->hide(); } -//void HYDROGUI_ProfileDlg::ProfileNameChanged(QString theNewText) -//{ -// myProfileNames->setItemText( myProfileNames->currentIndex(), theNewText ); //TODO??? -//} +void HYDROGUI_ProfileDlg::ProfileNameChanged(QString text) +{ + myCurrentName = text; +} void HYDROGUI_ProfileDlg::onProfileIndexChanged() { @@ -326,9 +331,29 @@ void HYDROGUI_ProfileDlg::onRemoveBtnPressed(bool) void HYDROGUI_ProfileDlg::onProfileNameChanged(QListWidgetItem* item) { int ind = GetProfileSelectionIndex(); - //if (ind > -1) - //TODO - QString text = item->text(); + if (ind > -1) + { + int count = myProfileNames->count(); + QSet names; + for (int i = 0; i < count; i++) + { + QListWidgetItem* citem = myProfileNames->item(i); + if (item!=citem) + names << citem->text(); + } + QString curText = item->text(); + myProfileNames->blockSignals(true); + if (names.contains(curText)) + { + QString mes = tr( "PROFILE_ALREADY_EXISTS" ); + QString title = tr( "PROFILEOP_WARNING" ); +#ifndef TEST_MODE + SUIT_MessageBox::warning( module()->getApp()->desktop(), title, mes ); +#endif + item->setText(myCurrentName); + } + myProfileNames->blockSignals(false); + } } void HYDROGUI_ProfileDlg::SetSingleProfileMode(bool SingleMode) diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.h b/src/HYDROGUI/HYDROGUI_ProfileDlg.h index d8705434..36ad245d 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.h +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.h @@ -68,7 +68,7 @@ public: protected slots: void processStartedSubOperation( QWidget*, bool ); void processFinishedSubOperation( QWidget* ); - //void ProfileNameChanged(QString); + void ProfileNameChanged(QString); void onProfileIndexChanged(); void onAddBtnPressed(bool); void onRemoveBtnPressed(bool); @@ -97,6 +97,7 @@ public://temp TODO QGroupBox* myAddElementBox; std::vector* myProfilesPointer; bool mySingleProfileMode; + QString myCurrentName; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index 7bbae5ff..db19ae67 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -38,7 +38,8 @@ #include #include #include - +#include +#include #include #include @@ -339,7 +340,7 @@ HYDROGUI_InputPanel* HYDROGUI_ProfileOp::createInputPanel() const SLOT( onRemoveProfile(int) ) ); return aDlg; } - +#include bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ) @@ -351,23 +352,32 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, QStringList aProfileNames = aPanel->getProfileNames(); QVector aProfileNamesFiltered; int i = 0; + // QSet edObjStrMap = aProfileNames.toSet(); + QSet ObjStrMapNE ; + HYDROData_SequenceOfObjects allobj = doc()->CollectAllObjects(); + for (int i=1;i<=allobj.Size();i++ ) + ObjStrMapNE.insert(allobj(i)->GetName()); + for (int i=1; i<=myEditedObjects.Size();i++) + ObjStrMapNE.remove(myEditedObjects(i)->GetName()); + bool warn = false; + QString title = tr( "PROFILEOP_WARNING" ); + QString mes = tr("PROFILE_RENAMING_NOTIF") + "\n"; foreach (QString profName, aProfileNames) { i++; - if ( profName.isEmpty() ) - { - theErrorMsg = tr( "INCORRECT_OBJECT_NAME" ); //? - continue; - } - Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), profName ); - if( !myIsEdit || (!anObject.IsNull() && myEditedObjects(i)->GetName() != anObject->GetName() ) ) + if( !myIsEdit || ObjStrMapNE.contains(profName) || profName.isEmpty() ) { - profName = HYDROData_Tool::GenerateObjectName(doc(), "Profile"); - //theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( profName ); - continue; + QString newName = HYDROData_Tool::GenerateObjectName(doc(), "Profile"); + mes += profName + " => " + newName + "\n"; + profName = newName; + warn = true; } aProfileNamesFiltered.append(profName); } + if (warn) +#ifndef TEST_MODE + SUIT_MessageBox::warning( module()->getApp()->desktop(), title, mes ); +#endif // theUpdateFlags = UF_Model; if (myIsEdit) @@ -406,23 +416,7 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, return true; } -/*void HYDROGUI_ProfileOp::displayPreview() -{ - /* HYDROGUI_ProfileDlg* aPanel = dynamic_cast( inputPanel() ); - if( aPanel ) - { - Handle(AIS_InteractiveContext) aCtx = aPanel->getAISContext(); - if( !aCtx.IsNull() ) - { - CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx ); - myProfile->setDisplayer( aDisplayer ); - aDisplayer->display( myProfile->getAISObject( true ), true ); - } - } -}*/ - -void HYDROGUI_ProfileOp::displayPreviews( - const QMap& CurveToColor, +void HYDROGUI_ProfileOp::displayPreviews(const QMap& CurveToColor, int firstIndProf, int lastIndProf, bool createNewDisplayer, bool SwitchToFirstProf) { HYDROGUI_ProfileDlg* aPanel = dynamic_cast( inputPanel() ); @@ -452,7 +446,7 @@ void HYDROGUI_ProfileOp::displayPreviews( myDisplayer->display( CC->getAISObject( true ), true ); } } - if (SwitchToFirstProf && !myProfiles.empty()) + if (SwitchToFirstProf && myProfiles.size() > 1) aPanel->switchToFirstProfile(); } } diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index a6b85eb2..d44e0f0f 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2006,8 +2006,15 @@ Would you like to remove all references from the image? NUMBER_OF_PROFILE_POINTS_INCORRECT Number of profile points should not be less than 3. + + PROFILEOP_WARNING + Warning + + + PROFILE_RENAMING_NOTIF + The next profile(s) have been renamed: + - HYDROGUI_RemoveImageRefsOp @@ -2122,6 +2129,23 @@ Would you like to remove all references from the image? Z_TITLE Z + + ADD_PROFILE + Add Profile(s) + + + REMOVE_PROFILE + Remove Profile + + + PROFILE_ALREADY_EXISTS + Profile with this name is already exists + + + PROFILEDLG_WARNING + Warning + +