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);
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
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_AISTrihedron.h"
#ifndef TEST_MODE
+#include <HYDROGUI_Module.h>
#include "HYDROGUI_Tool2.h"
#endif
#ifndef TEST_MODE
#include <LightApp_Application.h>
#endif
-
+#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <QSettings>
#include <QListWidget>
#include <QPushButton>
-
+#include <SUIT_MessageBox.h>
const QString splitter_key = "HYDROGUI_ProfileDlg::splitter";
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)));
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 )
//anItem->setBackground(QBrush(theColor));
if (count == 1)
anItem->setSelected(true);
+ if (count > 1)
+ myRemProfBtn->setEnabled(true);
myProfileNames->blockSignals(false);
}
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()
{
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<QString> 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)
protected slots:
void processStartedSubOperation( QWidget*, bool );
void processFinishedSubOperation( QWidget* );
- //void ProfileNameChanged(QString);
+ void ProfileNameChanged(QString);
void onProfileIndexChanged();
void onAddBtnPressed(bool);
void onRemoveBtnPressed(bool);
QGroupBox* myAddElementBox;
std::vector<HYDROGUI_CurveCreatorProfile*>* myProfilesPointer;
bool mySingleProfileMode;
+ QString myCurrentName;
};
#endif
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
#include <OCCViewer_ViewWindow.h>
-
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
#include <OCCViewer_AISSelector.h>
#include <Precision.hxx>
SLOT( onRemoveProfile(int) ) );
return aDlg;
}
-
+#include <set>
bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags,
QString& theErrorMsg,
QStringList& theBrowseObjectsEntries )
QStringList aProfileNames = aPanel->getProfileNames();
QVector<QString> aProfileNamesFiltered;
int i = 0;
+ // QSet<QString> edObjStrMap = aProfileNames.toSet();
+ QSet<QString> 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)
return true;
}
-/*void HYDROGUI_ProfileOp::displayPreview()
-{
- /* HYDROGUI_ProfileDlg* aPanel = dynamic_cast<HYDROGUI_ProfileDlg*>( 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<HYDROGUI_CurveCreatorProfile*, QColor>& CurveToColor,
+void HYDROGUI_ProfileOp::displayPreviews(const QMap<HYDROGUI_CurveCreatorProfile*, QColor>& CurveToColor,
int firstIndProf, int lastIndProf, bool createNewDisplayer, bool SwitchToFirstProf)
{
HYDROGUI_ProfileDlg* aPanel = dynamic_cast<HYDROGUI_ProfileDlg*>( inputPanel() );
myDisplayer->display( CC->getAISObject( true ), true );
}
}
- if (SwitchToFirstProf && !myProfiles.empty())
+ if (SwitchToFirstProf && myProfiles.size() > 1)
aPanel->switchToFirstProfile();
}
}
<source>NUMBER_OF_PROFILE_POINTS_INCORRECT</source>
<translation>Number of profile points should not be less than 3.</translation>
</message>
+ <message>
+ <source>PROFILEOP_WARNING</source>
+ <translation>Warning</translation>
+ </message>
+ <message>
+ <source>PROFILE_RENAMING_NOTIF</source>
+ <translation>The next profile(s) have been renamed:</translation>
+ </message>
</context>
-
<context>
<name>HYDROGUI_RemoveImageRefsOp</name>
<message>
<source>Z_TITLE</source>
<translation>Z</translation>
</message>
+ <message>
+ <source>ADD_PROFILE</source>
+ <translation>Add Profile(s)</translation>
+ </message>
+ <message>
+ <source>REMOVE_PROFILE</source>
+ <translation>Remove Profile</translation>
+ </message>
+ <message>
+ <source>PROFILE_ALREADY_EXISTS</source>
+ <translation>Profile with this name is already exists</translation>
+ </message>
+ <message>
+ <source>PROFILEDLG_WARNING</source>
+ <translation>Warning</translation>
+ </message>
+
</context>
<context>