X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FVISUGUI%2FVisuGUI.cxx;h=a8c76b6b0a0274cb4f605f20199ee5464551464c;hb=8a7496cff86f3bf3ce0c5a32181836a26a0b89fc;hp=8cc895f5d8cb8ee0ab04d03b63e14c920d3e0748;hpb=43ac4bca0b3831bed6ba417dba4ee14e6d99680b;p=modules%2Fvisu.git diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 8cc895f5..a8c76b6b 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1,30 +1,36 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // VISU VISUGUI : GUI of VISU component // File : VisuGUI.cxx // Author : // Module : VISU -// + +#include // E.A. must be included before Python.h to fix compilation on windows +#ifdef HAVE_FINITE +#undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined +#endif +#include "Python.h" + #include "VisuGUI.h" // STL Includes @@ -71,6 +77,7 @@ #include "VisuGUI_SetupPlot2dDlg.h" #include "Plot2d_SetupCurveDlg.h" #include "Plot2d_ViewManager.h" +#include "Plot2d_SetupCurveScaleDlg.h" #include "QtxPagePrefMgr.h" #include "OB_Browser.h" @@ -80,6 +87,7 @@ #include "SalomeApp_Application.h" #include "SalomeApp_DataModel.h" #include "SalomeApp_Study.h" +#include "SalomeApp_DataObject.h" #include "SalomeApp_CheckFileDlg.h" #include "LightApp_SelectionMgr.h" @@ -217,6 +225,118 @@ VisuGUI } } +void +VisuGUI +::OnImportFromSauvFile() +{ + if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromSauvFile()"); + + if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) ) + return; + + SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); + + // Get file name(s) + QStringList aFilter; + aFilter.append( tr( "FLT_SAUV_FILES" ) ); + aFilter.append( tr( "FLT_ALL_FILES" ) ); + + bool toUseBuildProgress = aResourceMgr->booleanValue("VISU", "use_build_progress", false); + + SalomeApp_CheckFileDlg fd( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") ); + fd.setWindowTitle( tr( "IMPORT_FROM_FILE" ) ); + fd.setFileMode( SalomeApp_CheckFileDlg::ExistingFiles ); + fd.setFilters( aFilter ); + fd.SetChecked( toUseBuildProgress ); + if ( SalomeApp_CheckFileDlg::getLastVisitedPath().isEmpty() ) + fd.setDirectory( QDir::currentPath() ); + + QStringList fileNames; + if ( !fd.exec() ) + return; // cancelled, return + + fileNames = fd.selectedFiles(); + toUseBuildProgress = fd.IsChecked(); + + if ( fileNames.count() == 0 ) + return; // nothing selected, return + + SUIT_OverrideCursor wc; + QStringList errors; + + for ( QStringList::ConstIterator it = fileNames.begin(); it != fileNames.end(); ++it ) { + QFileInfo aFileInfo( *it ); + + if ( !aFileInfo.exists() ) { + // file not exist + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_FILE_NOT_EXISTS" ) ) ); + } + else { + std::string file_in = aFileInfo.filePath().toLatin1().constData(); + std::string file_tmp = file_in + ".med"; +#ifdef WNT + std::string cmd = "%PYTHONBIN% "; +#else + std::string cmd = "python "; +#endif + cmd += "-c \""; + cmd += "from medutilities import convert ; convert(r'" + file_in + "', 'GIBI', 'MED', 1, r'" + file_tmp + "')"; + cmd += "\""; + system(cmd.c_str()); + QString fff(file_tmp.c_str()); + aFileInfo = fff; + try { + if ( !toUseBuildProgress ) { + // build progress is not used, use build flags from settings + bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true ); + bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true ); + bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true ); + bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false ); + bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false ); + + QString anInfo( tr( "IMPORT_FROM_FILE" ) + " " + aFileInfo.filePath() + " ... " ); + application()->putInfo( anInfo ); + + VISU::Result_var aResult = GetVisuGen( this )->CreateResult( aFileInfo.filePath().toLatin1().constData() ); + + if ( CORBA::is_nil( aResult.in() ) ) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); + } + else { + aResult->SetBuildFields( toBuildFields, toBuildMinMax ); + aResult->SetBuildGroups( toBuildGroups ); + aResult->Build( toBuildAll, toBuildAtOnce ); + application()->putInfo( anInfo + tr("INF_DONE") ); + } + } // if ( !toUseBuildProgress ) + else { + // use build progress + wc.suspend(); + VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) ); + aBuildProgressDlg->setFileName( aFileInfo.filePath() ); + aBuildProgressDlg->setGenerator( GetVisuGen(this) ); + aBuildProgressDlg->exec(); + wc.resume(); + } + } // try + catch(...) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); + } + } // else // if ( !aFileInfo.exists() ) + } // for (...) + + if ( errors.count() > 0 ) { + SUIT_MessageBox::critical( GetDesktop(this), + tr("ERR_ERROR"), + tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + } + else { + UpdateObjBrowser(this); + } +} + void VisuGUI ::OnImportFromFile() @@ -256,6 +376,7 @@ VisuGUI SUIT_OverrideCursor wc; QStringList errors; + QStringList anEntryList; for ( QStringList::ConstIterator it = fileNames.begin(); it != fileNames.end(); ++it ) { QFileInfo aFileInfo( *it ); @@ -288,6 +409,8 @@ VisuGUI aResult->SetBuildFields( toBuildFields, toBuildMinMax ); aResult->SetBuildGroups( toBuildGroups ); aResult->Build( toBuildAll, toBuildAtOnce ); + if( VISU::Result_i* aCResult = dynamic_cast( VISU::GetServant( aResult ).in() ) ) + anEntryList.append( aCResult->GetEntry().c_str() ); application()->putInfo( anInfo + tr("INF_DONE") ); } } // if ( !toUseBuildProgress ) @@ -314,6 +437,8 @@ VisuGUI } else { UpdateObjBrowser(this); + if( getApp() ) + getApp()->browseObjects( anEntryList ); } } @@ -359,6 +484,7 @@ VisuGUI return; // nothing selected QStringList errors; + QStringList anEntryList; for ( QStringList::ConstIterator it = aFiles.begin(); it != aFiles.end(); ++it ) { QFileInfo aFileInfo( *it ); @@ -371,7 +497,7 @@ VisuGUI QString anInfo( tr("TLT_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." ); application()->putInfo( anInfo ); - CORBA::Object_var anObject = + SALOMEDS::SObject_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath().toLatin1().constData(), aFirstStrAsTitle); @@ -380,11 +506,12 @@ VisuGUI arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); } else { + anEntryList.append( anObject->GetID() ); application()->putInfo( anInfo + tr("INF_DONE") ); } } catch(...) { - errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNSUPPORTED_FILE_FORMAT" ) ) ); } } } @@ -396,6 +523,8 @@ VisuGUI } else { UpdateObjBrowser(this); + if( getApp() ) + getApp()->browseObjects( anEntryList ); } } @@ -516,6 +645,7 @@ VisuGUI SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); + QStringList anEntryList; SALOME_ListIteratorOfListIO It (aListIO); QApplication::setOverrideCursor(Qt::WaitCursor); for (; It.More(); It.Next()) { @@ -555,14 +685,15 @@ VisuGUI } } + VISU::Result_var aResult; CORBA::Object_var anObject = VISU::SObjectToObject(aSObject); if (!CORBA::is_nil(anObject)) { SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject); if (!CORBA::is_nil(aMED.in())) - GetVisuGen(this)->ImportMed(aSObject); + aResult = GetVisuGen(this)->ImportMed(aSObject); SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); if (!CORBA::is_nil(aField.in())) - GetVisuGen(this)->ImportMedField(aField); + aResult = GetVisuGen(this)->ImportMedField(aField); } else { SALOMEDS::SObject_var aSFather = aSObject->GetFather(); SALOMEDS::GenericAttribute_var anAttr; @@ -570,11 +701,17 @@ VisuGUI SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); CORBA::String_var aValue = aName->Value(); if (strcmp(aValue.in(), "MEDFIELD") == 0) - GetVisuGen(this)->ImportMed(aSObject); + aResult = GetVisuGen(this)->ImportMed(aSObject); } + + if( !CORBA::is_nil( aResult ) ) + if( VISU::Result_i* aCResult = dynamic_cast( VISU::GetServant( aResult ).in() ) ) + anEntryList.append( aCResult->GetEntry().c_str() ); } } UpdateObjBrowser(this, true); + if( getApp() ) + getApp()->browseObjects( anEntryList ); QApplication::restoreOverrideCursor(); } @@ -752,8 +889,7 @@ VisuGUI // create mesh presentation and display it in aViewWindow VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow); aViewWindow->highlight(anIO, 1); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -780,8 +916,7 @@ VisuGUI // create mesh presentation and display it in aViewWindow VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow); aViewWindow->highlight(anIO, 1); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } } @@ -790,8 +925,7 @@ VisuGUI ::OnCreateScalarMap() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } @@ -800,8 +934,7 @@ VisuGUI ::OnCreateDeformedShape() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -809,8 +942,7 @@ VisuGUI ::OnCreateDeformedShapeAndScalarMap() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -818,8 +950,7 @@ VisuGUI ::OnCreateVectors() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -827,8 +958,7 @@ VisuGUI ::OnCreateIsoSurfaces() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -836,8 +966,7 @@ VisuGUI ::OnCreateCutPlanes() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -845,8 +974,7 @@ VisuGUI ::OnCreateCutLines() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -854,8 +982,7 @@ VisuGUI ::OnCreateCutSegment() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -863,8 +990,7 @@ VisuGUI ::OnCreateStreamLines() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -872,8 +998,7 @@ VisuGUI ::OnCreatePlot3D() { Prs3d_i* aPrs = CreatePrs3d(this); - if (aPrs) - emit presentationCreated(aPrs); + processPresentationCreated(aPrs); } void @@ -881,8 +1006,17 @@ VisuGUI ::OnCreatePlot2dView() { CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)); - GetVisuGen( this )->CreateContainer(); + VISU::Container_var aContainer = GetVisuGen( this )->CreateContainer(); UpdateObjBrowser(this); + + if( !CORBA::is_nil( aContainer.in() ) ) { + if( VISU::Container_i* aCContainer = dynamic_cast( VISU::GetServant( aContainer ).in() ) ) { + QStringList anEntryList; + anEntryList.append( aCContainer->GetEntry().c_str() ); + if( getApp() ) + getApp()->browseObjects( anEntryList ); + } + } } void @@ -926,7 +1060,9 @@ VisuGUI case VISU::TCURVE: case VISU::TCONTAINER: case VISU::TTABLE: + getViewManager(SPlot2d_Viewer::Type(), true); displayer()->Display(anIO->getEntry()); + aSelectionMgr->setSelectedObjects(aList); break; default: { VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(aBase); @@ -1290,6 +1426,7 @@ VisuGUI break; case VISU::WIREFRAME : case VISU::INSIDEFRAME : + case VISU::FEATURE_EDGES : anOldColor = aMesh->GetLinkColor(); break; case VISU::SHADED : @@ -1322,6 +1459,7 @@ VisuGUI break; case VISU::SHADED : case VISU::SURFACEFRAME : + case VISU::FEATURE_EDGES : aMesh->SetCellColor(aNewColor); break; } @@ -1444,6 +1582,10 @@ VisuGUI _PTR(Study) aCStudy = GetCStudy( GetAppStudy( this ) ); int aStudyId = aCStudy->StudyId(); + QPixmap aPointSpritePixmap; + if( SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr() ) + aPointSpritePixmap = aResourceMgr->loadPixmap( "VISU", tr( "ICON_POINT_SPRITE" ) ); + bool update = false; for( SALOME_ListIteratorOfListIO It( aListIO ); It.More(); It.Next() ) { @@ -1454,9 +1596,12 @@ VisuGUI if( VISU::Prs3d_i* aPrs = aPrsList[i] ) { VTKViewer_MarkerDlg* aDlg = new VTKViewer_MarkerDlg( GetDesktop( this ) ); + aDlg->setHelpData( "VISU", "point_marker_page.html" ); aDlg->setCustomMarkerMap( aMarkerMap[ aStudyId ] ); + aDlg->addExtraStdMarker( VTK::MT_POINT_SPRITE, aPointSpritePixmap ); + VISU::MarkerType aMarkerTypeCurrent = aPrs->GetMarkerType(); VISU::MarkerScale aMarkerScaleCurrent = aPrs->GetMarkerScale(); int aMarkerTextureCurrent = aPrs->GetMarkerTexture(); @@ -1739,7 +1884,7 @@ VisuGUI _PTR(Study) aStudy = GetCStudy(GetAppStudy(this)); _PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() ); if(IsSObjectTable(aSObject)){ - VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this)); + VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, aTable ,GetDesktop(this)); if(aDlg->exec() == QDialog::Accepted){ if(!IsStudyLocked(aStudy)){ // if study is not locked - create new container, create curves and insert them @@ -1754,7 +1899,10 @@ VisuGUI for( int i = 0; i < verIndices.count(); i++ ){ bool isV2 = ver2Indices.contains(verIndices[i]); VISU::Curve_var aCurveObject = - GetVisuGen(this)->CreateCurveWithZExt(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1, isV2 ); + GetVisuGen(this)->CreateCurveWithZExt(aTable->_this(), + aDlg->idx(horIndex)+1, + aDlg->idx(verIndices[i])+1, + aDlg->idx(zIndices[i])+1, isV2 ); if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCurveObject).in())){ bool isAuto; int marker, line, lineWidth; @@ -1803,7 +1951,7 @@ VisuGUI // check if Table SObject is selected _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; if(IsSObjectTable(aSObject)){ - VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this)); + VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, NULL, GetDesktop(this)); if(aDlg->exec() == QDialog::Accepted){ _PTR(Study) aStudy = GetCStudy(GetAppStudy(this)); if(!IsStudyLocked(aStudy)){ @@ -1906,6 +2054,44 @@ VisuGUI } } +//---------------------------------------------------------------------------- +void +VisuGUI +::OnCurveScale() +{ + if(IsStudyLocked(GetCStudy(GetAppStudy(this)))) + return; + + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects( this ); + int nbSel = aSelectionInfo.size(); + QList curList; + bool isValuesEquals = true; + double value; + + for (int i = 0; i < nbSel; i++ ) { + VISU::TSelectionItem aSelectionItem = aSelectionInfo[i]; + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + if(!aBase) + continue; + + if(aBase->GetType() == VISU::TCURVE) + // Curve object + if(VISU::Curve_i* aCurve = dynamic_cast(aBase)) { + curList.append(aCurve); + if( i>0 && isValuesEquals ) + isValuesEquals = (value == aCurve->GetScale()); + value = aCurve->GetScale(); + } + } + + Plot2d_SetupCurveScaleDlg aDlg(GetDesktop( this )); + if( isValuesEquals ) + aDlg.setScale(value); + + if( aDlg.exec() == QDialog::Accepted ) + for ( int i = 0; i < curList.size(); ++i ) + curList.at(i)->SetScale( aDlg.getScale() ); +} //---------------------------------------------------------------------------- void VisuGUI @@ -1929,6 +2115,7 @@ VisuGUI if(VISU::Container_i* aContainer = dynamic_cast(aBase)){ if(aContainer && aContainer->GetNbCurves() > 0){ aContainer->Clear(); + VISU::updateContainerVisibility(aContainer); UpdateObjBrowser(this); } } @@ -1958,8 +2145,9 @@ VisuGUI if (aDlg->exec()) { aDlg->storeToPrsObject(aContainer); UpdateObjBrowser(this, true); + delete aDlg; + VISU::updateContainerVisibility(aContainer); } - delete aDlg; } //---------------------------------------------------------------------------- @@ -2013,109 +2201,6 @@ VisuGUI 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(aBase)) - aCurve->SetName(Name.toLatin1().constData(), true); - break; - } - case VISU::TTABLE: { // Table object - if (VISU::Table_i* aTable = dynamic_cast(aBase)) - aTable->SetName(Name.toLatin1().constData(), true); - break; - } - case VISU::TPOINTMAP3D: { // Table object - if (VISU::PointMap3d_i* aTable3d = dynamic_cast(aBase)) { - aTable3d->SetTitle(Name.toLatin1().constData()); - aTable3d->UpdateActors(); - } - break; - } - case VISU::TCONTAINER: { // Container object - if (VISU::Container_i* aContainer = dynamic_cast(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(aViewManager)) { - if (SPlot2d_Viewer* aViewer = dynamic_cast(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 @@ -2554,6 +2639,10 @@ VisuGUI tr("MEN_IMPORT_FROM_FILE"), "", (Qt::CTRL + Qt::Key_I), aParent, false, this, SLOT(OnImportFromFile())); + createAction( VISU_IMPORT_SAUV, "", QIcon(), + tr("MEN_IMPORT_SAUV"), "", 0, aParent, false, + this, SLOT(OnImportFromSauvFile())); + createAction( VISU_IMPORT_TABLE, "", QIcon(), tr("MEN_IMPORT_TABLE"), "", 0, aParent, false, this, SLOT(OnImportTableFromFile())); @@ -2697,9 +2786,9 @@ 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_CURVE_SCALE, tr("MEN_CURVE_SCALE"), QIcon(), + tr("MEN_CURVE_SCALE"), "", 0, aParent, false, + this, SLOT(OnCurveScale())); createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIcon(), tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false, @@ -2783,8 +2872,8 @@ VisuGUI tr("MEN_EDGE_COLOR"), "", 0, aParent, false, this, SLOT(OnChangeWireframeColor())); - createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIcon(), - tr("MEN_OPACITY"), "", 0, aParent, false, + createAction( VISU_OPACITY, tr("MEN_TRANSPARENCY"), QIcon(), + tr("MEN_TRANSPARENCY"), "", 0, aParent, false, this, SLOT(OnChangeOpacity())); createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIcon(), @@ -2966,6 +3055,10 @@ VisuGUI tr("MEN_VISU_LINEQUAD_MODE"), "",0, aParent, true, this, SLOT(OnLineQuadMode())); + createAction(VISU_SHOW_DEVIATION, tr("MEN_VISU_SHOW_DEVIATION"),QIcon(), + tr("MEN_VISU_SHOW_DEVIATION"), "",0, aParent, true, + this, SLOT(OnShowDeviation())); + } void @@ -2979,6 +3072,7 @@ VisuGUI int anImportId = createMenu( tr( "MEN_IMPORT" ), aMenuId, -1, 10 ); createMenu( VISU_IMPORT_FROM_FILE, anImportId ); // import from file + createMenu( VISU_IMPORT_SAUV, anImportId ); // import sauv file createMenu( VISU_IMPORT_TABLE, anImportId ); // import table aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 ); @@ -3055,6 +3149,7 @@ VisuGUI // VISU root commands mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file + mgr->insert( action( VISU_IMPORT_SAUV ), -1, -1, -1 ); // import SAUV file mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View @@ -3093,9 +3188,6 @@ VisuGUI 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 ); @@ -3179,6 +3271,9 @@ VisuGUI mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties + mgr->insert( action( VISU_CURVE_SCALE ), -1, -1, -1 ); // curve scale + //Show deviation command on curve + mgr->insert( action( VISU_SHOW_DEVIATION ), -1, -1, -1 ); // deviation mgr->insert( action( VISU_MULTIPR_FULL_RES ), -1, -1, -1 ); mgr->insert( action( VISU_MULTIPR_MED_RES ), -1, -1, -1 ); @@ -3200,6 +3295,7 @@ VisuGUI // VISU root commands QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'"; mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule ); + mgr->setRule( action( VISU_IMPORT_SAUV ), aRule ); mgr->setRule( action( VISU_IMPORT_TABLE ), aRule ); mgr->setRule( action( VISU_PLOT2D ), aRule ); @@ -3227,13 +3323,13 @@ VisuGUI QString aPrsInvisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})" + andInvisible + " and (not isPlot2dViewer))"; QString aComponent = "( selcount=1 and canBeDisplayed and isVisuComponent )"; - QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsVisible + + QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (" + aPrsVisible + " or ( (" + aTableOrContHide + orCurveVisible + "))) ) or " + aComponent; - QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsInvisible + + QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (" + aPrsInvisible + " or ( (" + aTableOrContShow + orCurveInvisible + "))) ) or " + aComponent; - QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed) and (($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})" + QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})" " or ( ((type='VISU::TTABLE' and nbChildren>0) or (type='VISU::TCONTAINER' and hasCurves) or" " (type='VISU::TCURVE')))) ) or" + aComponent; @@ -3326,19 +3422,15 @@ VisuGUI mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'" ); mgr->setRule( action( VISU_EDGE_COLOR ), aRule + aSurfFrameType + " and representation='VISU::SURFACEFRAME'" ); mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'" - " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) " + " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::FEATURE_EDGES'}) " "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))" ); mgr->setRule( action( VISU_OPACITY ), aRule + " and hasActor=1" ); - mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1" ); + mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1 and representation!='VISU::POINT'" ); 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 ); @@ -3346,6 +3438,7 @@ VisuGUI // Curve commands aRule = "selcount=1 and type='VISU::TCURVE'"; mgr->setRule( action( VISU_CURVE_PROPS ), aRule ); + mgr->setRule( action( VISU_CURVE_SCALE ), "selcount > 0 and type='VISU::TCURVE'"); // Table Commands aRule = "selcount=1 and ( type='VISU::TPOINTMAP3D' or type='VISU::TTABLE')"; @@ -3434,6 +3527,11 @@ VisuGUI mgr->setRule( action( VISU_FILE_INFO ), "selcount=1 and type in {'VISU::TRESULT'}" ); mgr->setRule( action( VISU_EXPORT_MED ), "selcount=1 and type in {'VISU::TRESULT'}" ); + + aRule = "isPlot2dViewer and isVisible and selcount > 0 and type='VISU::TCURVE' and hasDeviation"; + mgr->setRule (action(VISU_SHOW_DEVIATION), aRule , QtxPopupMgr::VisibleRule); + aRule = "isPlot2dViewer and isVisible and selcount > 0 and type='VISU::TCURVE' and hasDeviation and isDeviationDisplayed"; + mgr->setRule (action(VISU_SHOW_DEVIATION), aRule , QtxPopupMgr::ToggleRule); } void VisuGUI::createPanels() @@ -3656,16 +3754,30 @@ VisuGUI setMenuShown( true ); setToolShown( true ); + // import Python module that manages VISU plugins (need to be here because SalomePyQt API uses active module) + PyGILState_STATE gstate = PyGILState_Ensure(); + PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager"); + if(pluginsmanager==NULL) + PyErr_Print(); + else + { + PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"visu",tr("MEN_VISUALIZATION").toStdString().c_str(),tr("VISU_PLUGINS_OTHER").toStdString().c_str()); + if(result==NULL) + PyErr_Print(); + Py_XDECREF(result); + } + PyGILState_Release(gstate); + // end of GEOM plugins loading + // Reset actions accelerator keys QList shortcuts; shortcuts.append( QKeySequence(Qt::CTRL + Qt::Key_I) ); 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(theStudy)),true); emit moduleActivated(); return aResult; @@ -3683,7 +3795,6 @@ VisuGUI 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 ); @@ -3699,6 +3810,25 @@ VisuGUI return new VisuGUI_Selection( (SalomeApp_Module*)this ); } +void +VisuGUI +::processPresentationCreated( VISU::Prs3d_i* thePrs ) +{ + if( thePrs ) + { + QString anEntry = thePrs->GetEntry().c_str(); + if( anEntry.isEmpty() ) + if( VISU::ColoredPrs3d_i* aColoredPrs = dynamic_cast( thePrs ) ) + anEntry = aColoredPrs->GetHolderEntry().c_str(); + + QStringList anEntryList( anEntry ); + if( getApp() ) + getApp()->browseObjects( anEntryList ); + + emit presentationCreated( thePrs ); + } +} + //****************************************************************** void VisuGUI::studyActivated() { @@ -3718,6 +3848,8 @@ extern "C" { void VisuGUI::createPreferences() { + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + // TAB: General int genTab = addPreference( tr( "VISU_PREF_GENERAL" ) ); // Quantities with individual precision settings @@ -3747,8 +3879,8 @@ void VisuGUI::createPreferences() // Set property for precision value for spinboxes for ( ii = 0; ii < nbQuantities; ii++ ){ - setPreferenceProperty( precs[ii], "min", ii == 2 ? 0 : -10 ); - setPreferenceProperty( precs[ii], "max", ii == 2 ? 3 : 10 ); + setPreferenceProperty( precs[ii], "min", ii == 2 ? 0 : -14 ); + setPreferenceProperty( precs[ii], "max", ii == 2 ? 3 : 14 ); setPreferenceProperty( precs[ii], "precision", 2 ); } @@ -3820,10 +3952,10 @@ void VisuGUI::createPreferences() int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), sbarTab ); setPreferenceProperty( imposedGr, "columns", 4 ); - int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_min" ); - int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_max" ); - setPreferenceProperty( min, "step", 0.1 ); - setPreferenceProperty( max, "step", 0.1 ); + int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::Double, "VISU", "scalar_range_min" ); + int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::Double, "VISU", "scalar_range_max" ); + setPreferenceProperty( min, "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) ); + setPreferenceProperty( max, "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) ); // group: "Font" int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab ); @@ -3998,6 +4130,18 @@ void VisuGUI::createPreferences() addPreference( tr( "Generate data table" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_data_table" ); addPreference( tr( "Generate curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_curves" ); + // TAB: "StreamLines" + int streamLinesTab = addPreference( tr( "VISU_STREAM_LINES" ) ); + + // group: "StreamLines preferences" + int streamLinesGr = addPreference( tr( "VISU_STREAM_LINES_PREF" ), streamLinesTab ); + setPreferenceProperty( cutLineGr, "columns", 1 ); + int usedPoints = addPreference( tr( "VISU_STREAM_LINES_USED_POINTS" ), streamLinesGr, + LightApp_Preferences::DblSpin, "VISU", "stream_lines_used_points" ); + setPreferenceProperty( usedPoints, "min", 0 ); + setPreferenceProperty( usedPoints, "max", 1 ); + setPreferenceProperty( usedPoints, "step", 0.1 ); + // TAB: "Sweep, Animation, 3D Cache" int animationTab = addPreference( tr( "Sweep, Animation" ) ); { @@ -4113,12 +4257,12 @@ void VisuGUI::createPreferences() setPreferenceProperty( representGr, "columns", 2 ); QStringList mesh_modes; - mesh_modes.append( "Points" ); - mesh_modes.append( "Wireframe" ); - mesh_modes.append( "Insideframe" ); - mesh_modes.append( "Surfaceframe" ); - mesh_modes.append( "Surface" ); - mesh_modes.append( "Feature edges" ); + mesh_modes.append( tr("MEN_POINTS") ); + mesh_modes.append( tr("MEN_WIREFRAME") ); + mesh_modes.append( tr("MEN_INSIDEFRAME") ); + mesh_modes.append( tr("MEN_SURFACEFRAME") ); + mesh_modes.append( tr("MEN_SURFACE") ); + mesh_modes.append( tr("VISU_FEATURE_EDGES") ); QList mesh_indices; mesh_indices.append( 0 ); mesh_indices.append( 1 ); @@ -4245,8 +4389,6 @@ void VisuGUI::createPreferences() addPreference( tr( "VISU_EDGE_COLOR" ), representGr, LightApp_Preferences::Color, "VISU", "edge_color" ); addPreference( "", representGr, LightApp_Preferences::Space ); - SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - int typeOfMarker = addPreference( tr( "VISU_TYPE_OF_MARKER" ), representGr, LightApp_Preferences::Selector, "VISU", "type_of_marker" ); QList aMarkerTypeIndicesList; @@ -4257,6 +4399,8 @@ void VisuGUI::createPreferences() aMarkerTypeIndicesList << i; aMarkerTypeIconsList << pixmap; } + aMarkerTypeIndicesList << VTK::MT_POINT_SPRITE; + aMarkerTypeIconsList << aResourceMgr->loadPixmap( "VISU", tr( "ICON_POINT_SPRITE" ) ); setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList ); setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList ); @@ -4393,6 +4537,15 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) aResourceMgr->setValue("VISU", "scalar_bar_horizontal_height",sbH); } } + else if(b == "visual_data_precision") { + LightApp_Preferences* pref = preferences(); + QtxPreferenceItem* min = pref->findItem( tr( "VISU_MIN" ), true ); + QtxPreferenceItem* max = pref->findItem( tr( "VISU_MAX" ), true ); + if ( min ) + setPreferenceProperty( min->id(), "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) ); + if ( max ) + setPreferenceProperty( max->id(), "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) ); + } if ( !aWarning.isEmpty() ){ aWarning += "The default values are applied instead."; @@ -4523,8 +4676,7 @@ void VisuGUI::OnPlot3dFromCutPlane() AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos); } - if (aPrs3d) - emit presentationCreated(aPrs3d); + processPresentationCreated(aPrs3d); } } application()->putInfo(QObject::tr("INF_DONE")); @@ -4782,3 +4934,195 @@ void VisuGUI::OnArcQuadMode(){ void VisuGUI::OnLineQuadMode(){ ChangeQuadratic2DRepresentation(this,VISU::LINES); } + +/*! + \brief Return \c true if object can be renamed +*/ +bool VisuGUI::renameAllowed( const QString& entry) const { + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* appStudy = app ? dynamic_cast( app->activeStudy() ) : 0; + SalomeApp_DataObject* obj = appStudy ? dynamic_cast(appStudy->findObjectByEntry(entry)) : 0; + + if(!app || !appStudy || !obj) + return false; + + if(appStudy->isComponent(entry) || obj->isReference()) + 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; + } else { + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + bool anIsExist; + QString aVal = VISU::Storable::FindValue(aMap, "myComment", &anIsExist); + return anIsExist && "VIEW3D" == aVal; + } + return false; +} + +void VisuGUI::OnShowDeviation() { + + if(IsStudyLocked(GetCStudy(GetAppStudy(this)))) + return; + + QAction* anAction = action(VISU_SHOW_DEVIATION); + if(!anAction) + return; + + bool anIsShow = anAction->isChecked(); + + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + TSelectionInfo::iterator anIter = aSelectionInfo.begin(); + for( ; anIter != aSelectionInfo.end(); anIter++ ) + { + VISU::TSelectionItem aSelectionItem = *anIter; + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + if(aBase && aBase->GetType() == VISU::TCURVE) { + // Curve object + if(VISU::Curve_i* aCurve = dynamic_cast(aBase)) { + aCurve->ShowDeviation(anIsShow); + if( displayer()->IsDisplayed( anIO->getEntry() ) ) + PlotCurve(this, aCurve, VISU::eDisplay); + } + } + } +} + +/*! + 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) { + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication()); + SalomeApp_Study* appStudy = app ? dynamic_cast( app->activeStudy() ) : 0; + + if(!appStudy) + return false; + + _PTR(Study) aStudy = appStudy->studyDS(); + + if(!aStudy) + return false; + + bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked(); + if ( aLocked ) { + SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") ); + return false; + } + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this) , qPrintable(entry) ); + + _PTR(SObject) aSObject = anObjectInfo.mySObject; + if (aSObject) { + VISU::Base_i* aBase = anObjectInfo.myBase; + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + 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(aBase)) + aCurve->SetName(qPrintable(name), true); + break; + } + case VISU::TTABLE: { // Table object + if (VISU::Table_i* aTable = dynamic_cast(aBase)) + aTable->SetName(qPrintable(name), true); + break; + } + case VISU::TPOINTMAP3D: { // Table object + if (VISU::PointMap3d_i* aTable3d = dynamic_cast(aBase)) { + aTable3d->SetTitle(qPrintable(name)); + aTable3d->UpdateActors(); + } + break; + } + case VISU::TCONTAINER: { // Container object + if (VISU::Container_i* aContainer = dynamic_cast(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(aViewManager)) { + if (SPlot2d_Viewer* aViewer = dynamic_cast(aManager->getViewModel())) + aViewer->renameAll( anIO, qPrintable(name) ); + } + } + QApplication::restoreOverrideCursor(); + return true; + } + } + //Rename visual params + } + } else { + bool anIsExist; + QString aVal = VISU::Storable::FindValue(aMap, "myComment", &anIsExist); + if(anIsExist && "VIEW3D" == aVal) { + _PTR(GenericAttribute) anAttr; + if (aSObject->FindAttribute(anAttr, "AttributeName")) { + _PTR(AttributeName) aName (anAttr); + if (!name.isEmpty()) { + aName->SetValue(qPrintable(name)); + } + } + } + } + } + return false; +}