VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
}
-//----------------------------------------------------------------------------
-void
-VisuGUI
-::OnRename()
-{
- _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
- if (CheckLock(aCStudy,GetDesktop(this)))
- return;
-
- VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
- if (aSelectionInfo.empty())
- return;
-
- VisuGUI_Selection aSel (this);
- aSel.init("", getApp()->selectionMgr());
- if (aSel.count() < 1) return;
-
- bool isAny = false; // is there any appropriate object selected
- for (int i = 0; i < aSelectionInfo.size(); i++) {
- VISU::TSelectionItem aSelectionItem = aSelectionInfo[i];
- VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
-
- _PTR(SObject) aSObject = anObjectInfo.mySObject;
- if (!aSObject)
- continue;
-
- // Check, if the selected object can be renamed
- QString aStr = aSel.parameter(i, "type" ).toString();
- if (aStr == "VISU::TSCALARMAP" || aStr == "VISU::TISOSURFACES" ||
- aStr == "VISU::TDEFORMEDSHAPE" || aStr == "VISU::TCUTPLANES" ||
- aStr == "VISU::TCUTLINES" || aStr == "VISU::TCUTSEGMENT" || aStr == "VISU::TVECTORS" ||
- aStr == "VISU::TSTREAMLINES" || aStr == "VISU::TPLOT3D" ||
- aStr == "VISU::TSCALARMAPONDEFORMEDSHAPE" || aStr == "VISU::TCOLOREDPRS3DHOLDER" ||
- aStr == "VISU::TTABLE" || aStr == "VISU::TCURVE" || aStr == "VISU::TCONTAINER" ||
- aStr == "VISU::POINTMAP3D" || aStr == "VISU::TVIEW3D" ||
- aStr == "VISU::TPOINTMAP3D" || aStr == "VISU::TGAUSSPOINTS")
- {
- _PTR(GenericAttribute) anAttr;
- if (aSObject->FindAttribute(anAttr, "AttributeName")) {
- isAny = true;
- _PTR(AttributeName) aName (anAttr);
- QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
- if (!Name.isEmpty()) {
- QApplication::setOverrideCursor(Qt::WaitCursor);
-
- // rename specific objects
- if (VISU::Base_i* aBase = anObjectInfo.myBase) {
- switch (aBase->GetType()) {
- case VISU::TCURVE: { // Curve object
- if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase))
- aCurve->SetName(Name.toLatin1().constData(), true);
- break;
- }
- case VISU::TTABLE: { // Table object
- if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
- aTable->SetName(Name.toLatin1().constData(), true);
- break;
- }
- case VISU::TPOINTMAP3D: { // Table object
- if (VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
- aTable3d->SetTitle(Name.toLatin1().constData());
- aTable3d->UpdateActors();
- }
- break;
- }
- case VISU::TCONTAINER: { // Container object
- if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
- aContainer->SetName(Name.toLatin1().constData(), true);
- break;
- }
- default: {
- }}
- }
-
- // rename the study object
- Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
- aName->SetValue(Name.toLatin1().constData()); // rename the SObject
- anIO->setName(Name.toLatin1().constData()); // rename the InteractiveObject
-
- ViewManagerList aViewManagerList;
- getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
- SUIT_ViewManager* aViewManager;
- foreach( aViewManager, aViewManagerList ) {
- if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
- if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
- aViewer->renameAll( anIO, Name.toLatin1().constData() );
- }
- }
-
- UpdateObjBrowser(this, false);
- QApplication::restoreOverrideCursor();
- }
- }
- }
- } // for
-
- if (!isAny) {
- SUIT_MessageBox::warning(GetDesktop(this),
- QObject::tr("WRN_VISU"),
- QObject::tr("WRN_NO_APPROPRIATE_SELECTION"));
- }
-}
-
//----------------------------------------------------------------------------
void
VisuGUI
tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
this, SLOT(OnCurveProperties()));
- createAction( VISU_RENAME, tr("MEN_RENAME"), QIcon(),
- tr("MEN_RENAME"), "", Qt::Key_F2, aParent, false,
- this, SLOT(OnRename()));
-
createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIcon(),
tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
this, SLOT(OnEditContainer()));
mgr->insert( action( VISU_FILTERSCALARS ), -1, -1, -1 );
- // rename
- mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
-
// copy
mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
mgr->setRule( action( VISU_POINT_MARKER ), aRule + aLineType + " and hasActor=1 and representation='VISU::POINT'" );
mgr->setRule( action( VISU_SHRINK_FACTOR ), aRule + aShrinkType + " and isShrunk=1" );
- // rename command
QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER' 'VISU::POINTMAP3D'";
- aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TPOINTMAP3D' " + aCurveAll + " " + aPrsAll + "})";
- mgr->setRule( action( VISU_RENAME ), aRule );
-
// copy presentation command
aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
mgr->setRule( action( VISU_COPY_PRS ), aRule );
action(VISU_IMPORT_FROM_FILE)->setShortcuts(shortcuts);
action(VISU_DELETE_OBJS)->setEnabled(true); // Delete: Key_Delete
- action(VISU_RENAME )->setEnabled(true); // Rename: Key_F2
((VisuGUI_ClippingPanel*) myPanels[ClippingPlanesPanelId])->init();
GetVisuGen( this )->GetClippingPlaneMgr().SetStudy(GetCStudy(dynamic_cast<SalomeApp_Study*>(theStudy)),true);
action(VISU_IMPORT_FROM_FILE)->setShortcuts(QKeySequence::UnknownKey); // Import: CTRL + Key_I
action(VISU_DELETE_OBJS)->setEnabled(false); // Delete: Key_Delete
- action(VISU_RENAME )->setEnabled(false); // Rename: Key_F2
bool aResult = SalomeApp_Module::deactivateModule( theStudy );
void VisuGUI::OnLineQuadMode(){
ChangeQuadratic2DRepresentation(this,VISU::LINES);
}
+
+/*!
+ \brief Return \c true if object can be renamed
+*/
+bool VisuGUI::renameAllowed( const QString& entry) const {
+ bool appRes = SalomeApp_Module::renameAllowed(entry);
+ if( !appRes )
+ return false;
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry( GetAppStudy(this), qPrintable(entry) );
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ if(aBase){
+ VISU::VISUType aType = aBase->GetType();
+ if( aType == VISU::TCOLOREDPRS3DHOLDER ) {
+ CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject);
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+ aType = aHolder->GetPrsType();
+ }
+ if (aType == VISU::TSCALARMAP || aType == VISU::TISOSURFACES ||
+ aType == VISU::TDEFORMEDSHAPE || aType == VISU::TCUTPLANES ||
+ aType == VISU::TCUTLINES || aType == VISU::TCUTSEGMENT || aType == VISU::TVECTORS ||
+ aType == VISU::TSTREAMLINES || aType == VISU::TPLOT3D ||
+ aType == VISU::TSCALARMAPONDEFORMEDSHAPE || aType == VISU::TCOLOREDPRS3DHOLDER ||
+ aType == VISU::TTABLE || aType == VISU::TCURVE || aType == VISU::TCONTAINER ||
+ aType == VISU::TPOINTMAP3D || aType == VISU::TVIEW3D ||
+ aType == VISU::TPOINTMAP3D || aType == VISU::TGAUSSPOINTS)
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Rename object by entry.
+ \param entry entry of the object
+ \param name new name of the object
+ \brief Return \c true if rename operation finished successfully, \c false otherwise.
+*/
+bool VisuGUI::renameObject( const QString& entry, const QString& name) {
+ bool appRes = SalomeApp_Module::renameObject(entry, name);
+ if( !appRes )
+ return false;
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this) , qPrintable(entry) );
+
+ _PTR(SObject) aSObject = anObjectInfo.mySObject;
+ if (aSObject) {
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ if(aBase){
+ VISU::VISUType aType = aBase->GetType();
+ if( aType == VISU::TCOLOREDPRS3DHOLDER ) {
+ CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject);
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+ aType = aHolder->GetPrsType();
+ }
+ if (aType == VISU::TSCALARMAP || aType == VISU::TISOSURFACES ||
+ aType == VISU::TDEFORMEDSHAPE || aType == VISU::TCUTPLANES ||
+ aType == VISU::TCUTLINES || aType == VISU::TCUTSEGMENT || aType == VISU::TVECTORS ||
+ aType == VISU::TSTREAMLINES || aType == VISU::TPLOT3D ||
+ aType == VISU::TSCALARMAPONDEFORMEDSHAPE || aType == VISU::TCOLOREDPRS3DHOLDER ||
+ aType == VISU::TTABLE || aType == VISU::TCURVE || aType == VISU::TCONTAINER ||
+ aType == VISU::TPOINTMAP3D || aType == VISU::TVIEW3D ||
+ aType == VISU::TPOINTMAP3D || aType == VISU::TGAUSSPOINTS) {
+ _PTR(GenericAttribute) anAttr;
+ if (aSObject->FindAttribute(anAttr, "AttributeName")) {
+ _PTR(AttributeName) aName (anAttr);
+ if (!name.isEmpty()) {
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ // rename specific objects
+ if (VISU::Base_i* aBase = anObjectInfo.myBase) {
+ switch (aBase->GetType()) {
+ case VISU::TCURVE: { // Curve object
+ if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase))
+ aCurve->SetName(qPrintable(name), true);
+ break;
+ }
+ case VISU::TTABLE: { // Table object
+ if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+ aTable->SetName(qPrintable(name), true);
+ break;
+ }
+ case VISU::TPOINTMAP3D: { // Table object
+ if (VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
+ aTable3d->SetTitle(qPrintable(name));
+ aTable3d->UpdateActors();
+ }
+ break;
+ }
+ case VISU::TCONTAINER: { // Container object
+ if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
+ aContainer->SetName(qPrintable(name), true);
+ break;
+ }
+ default: {
+ }}
+ }
+
+ // rename the study object
+ aName->SetValue( qPrintable(name) ); // rename the SObject
+
+ ViewManagerList aViewManagerList;
+ getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
+ SUIT_ViewManager* aViewManager;
+ Handle(SALOME_InteractiveObject) anIO =
+ new SALOME_InteractiveObject ( qPrintable(entry), "VISU", qPrintable(name) );
+ foreach( aViewManager, aViewManagerList ) {
+ if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
+ if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
+ aViewer->renameAll( anIO, qPrintable(name) );
+ }
+ }
+ QApplication::restoreOverrideCursor();
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
#define GAUSS_DISPLAY_PRS 5500
#define GAUSS_DISPLAY_ONLY_PRS 5600
-#define GAUSS_SAVE_CONFIGURATION 5700
-#define GAUSS_OVERWRITE_CONFIGURATION 5701
-#define GAUSS_RESTORE_CONFIGURATION 5702
-#define GAUSS_RENAME_CONFIGURATION 5703
+//#define GAUSS_SAVE_CONFIGURATION 5700
+//#define GAUSS_OVERWRITE_CONFIGURATION 5701
+//#define GAUSS_RESTORE_CONFIGURATION 5702
+//#define GAUSS_RENAME_CONFIGURATION 5703
using namespace std;
createMenu( action( GAUSS_CREATE_PRS ), createMenu( tr( "MEN_VISUALISATION" ), -1 ), -1 );
createTool( GAUSS_CREATE_PRS, createTool( tr( "TOOL_VISUALISATION" ) ), -1 );
- createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIcon(),
+ /*
+ createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIcon(),
VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
this, SLOT(OnRename()));
- mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 );
- mgr->setRule( action( GAUSS_RENAME ),
- "selcount=1 and type='VISU::TGAUSSPOINTS'" );
-
+ mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 );
+ mgr->setRule( action( GAUSS_RENAME ),
+ "selcount=1 and type='VISU::TGAUSSPOINTS'" );
+ */
+
createAction( GAUSS_EDIT_PRS, VisuGUI::tr("MEN_EDIT_PRS"), QIcon(),
VisuGUI::tr("MEN_EDIT_PRS"), "", 0, this, false,
this, SLOT(OnEditGaussPoints()));
"selcount=1 and type='VISU::TGAUSSPOINTS'" );
action( GAUSS_COPY_PRS )->setEnabled(false);
-
+
QStringList viewers;
#ifndef DISABLE_OCCVIEWER
mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only
mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ),
aRule + " and ({true} in $canBeDisplayed)" );*/
-
+/*
createAction( GAUSS_RENAME_CONFIGURATION, VisuGUI::tr("MEN_RENAME"), QIcon(),
VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
this, SLOT(OnRename()));
mgr->insert( action( GAUSS_RESTORE_CONFIGURATION ), -1, -1, -1 );
mgr->setRule( action( GAUSS_RESTORE_CONFIGURATION ),
"selcount=1 and type='VISU::TGAUSSVIEW'" );
+*/
}
// //---------------------------------------------------------------