-using namespace std;
-// File : VisuGUI.cxx
-// Created : Wed Aug 01 10:20:18 2001
-// Author : Laurent CORNABE
-// Project : SALOME
-// Module : VISUGUI
-// Copyright : PRINCIPIA
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2003 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VisuGUI.cxx
+// Author : Laurent CORNABE
+// Module : VISU
// $Header$
#include "VisuGUI.h"
-#include "VisuGUI_PhaseDlg.h"
-#include "VisuGUI_MagnitudeDlg.h"
-#include "VisuGUI_PhaseMagnitudeDlg.h"
-#include "VisuGUI_PartialScaDlg.h"
-#include "VisuGUI_CursorDlg.h"
-#include "VisuGUI_ScalarBarDlg.h"
-#include "VisuGUI_SweepPrefDlg.h"
-#include "VisuGUI_CutPlanesDlg.h"
-#include "VisuGUI_VectorsDlg.h"
-#include "VisuGUI_IsoSurfacesDlg.h"
-#include "VisuGUI_StreamLinesDlg.h"
-#include "VisuGUI_TimeAnimation.h"
-#include "VisuGUI_Selection.h"
-#include "VisuGUI_VisuAsDlg.h"
-#include "VisuGUI_SelVectCompDlg.h"
-#include "VisuGUI_NonIsometricDlg.h"
+// STL Includes
+#include <exception>
+#include <typeinfo>
+#include <vector>
-#include "VISU_Gen_i.hh"
-#include "VISU_Result_i.hh"
-#include "VISU_Extractor.hxx"
-#include "VISU_Table_i.hh"
-#include "VISU_ViewManager_i.hh"
-#include "VISU_LookupTable.hxx"
-#include "VISU_ScalarBarActor.hxx"
+// QT Includes
+#include <qptrlist.h>
+#include <qptrvector.h>
+#include <qcolordialog.h>
-#include "SALOMEGUI_ImportOperation.h"
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
-#include "utilities.h"
+// VTK Includes
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkActorCollection.h>
-#include "QAD_Config.h"
-
-#include "QAD_Settings.h"
-#include "QAD_Tools.h"
-#include "QAD_LeftFrame.h"
-#include "QAD_RightFrame.h"
-#include "QAD_MessageBox.h"
-#include "QAD_ObjectBrowser.h"
-#include "QAD_ObjectBrowserItem.h"
-#include "QAD_Menus.h"
-#include "QAD_Resource.h"
-#include "QAD_ResourceMgr.h"
-#include "QAD_FileDlg.h"
-#include "SALOME_Selection.h"
-#include "SALOMEGUI_NameDlg.h"
-#include "SALOMEGUI_TableDlg.h"
-#include "SALOMEGUI_SetupCurveDlg.h"
-#include "SALOMEGUI_SetValueDlg.h"
-#include "Plot2d_SetupPlot2dDlg.h"
-#include "Plot2d_ViewFrame.h"
-#include "VTKViewer_ViewFrame.h"
+// SALOME Includes
+#include "SALOME_LifeCycleCORBA.hxx"
-// QT Includes
-#define INCLUDE_MENUITEM_DEF
-#include <qpopupmenu.h>
-#include <qfont.h>
-#include <qpainter.h>
-#include <qstring.h>
-#include <qapplication.h>
-#include <qinputdialog.h>
-#include <qcolordialog.h>
-#include <qlabel.h>
-#include <qspinbox.h>
-#include <qradiobutton.h>
-#include <qthread.h>
-#include <qlistbox.h>
-#include <qcombobox.h>
-
-//VRV: porting on Qt 3.0.5
-#if QT_VERSION >= 0x030005
-#include <qlistview.h>
-#endif
-//VRV: porting on Qt 3.0.5
-#include <qmessagebox.h>
-
-#include <med.h>
-#include CORBA_CLIENT_HEADER(Med_Gen)
-
-#include <vtkActor.h>
-#include <vtkCellCenters.h>
-//#include <vtkOutlineFilter.h>
-#include <vtkDataSetMapper.h>
-#include <vtkWarpVector.h>
-#include <vtkContourFilter.h>
-#include <vtkCellDataToPointData.h>
-#include <vtkShrinkFilter.h>
-
-// Open CASCADE Include
-#include <TCollection_AsciiString.hxx>
-
-//#define CHECKTIME
-#ifdef CHECKTIME
-#include <OSD_Timer.hxx>
-#endif
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_MessageBox.h"
-#ifdef DEBUG
-static int MYDEBUG = 1;
-static int MYDEBUGWITHFILES = 0;
-#else
-static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
-#endif
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
-// unique name visu entity
-//static bool localContext = false;
-static VisuGUI_Selection *Selection;
-static int VISU_POINT_SIZE = 5;
+#include "CAM_Module.h"
-QAD_Study* VisuGUI::myActiveStudy = NULL;
-VISU::VISU_Gen_var VisuGUI::myComponent = VISU::VISU_Gen::_nil();
-SALOMEDS::Study_var VisuGUI::myStudy = SALOMEDS::Study::_nil();
-SALOMEDS::StudyBuilder_var VisuGUI::myStudyBuilder = SALOMEDS::StudyBuilder::_nil();
-QAD_Desktop* VisuGUI::myDesktop = NULL;
+#include "SVTK_RenderWindow.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_Functor.h"
-QAD_Study* MYActiveStudy = NULL;
-SALOMEDS::StudyBuilder_var MYStudyBuilder = SALOMEDS::StudyBuilder::_nil();
-SALOMEDS::Study_var MYStudyDocument = SALOMEDS::Study::_nil();
+#include "SPlot2d_ViewModel.h"
+#include "SPlot2d_SetupPlot2dDlg.h"
+#include "Plot2d_SetupCurveDlg.h"
-const QString ObjectTypes("FIELD VIEW3D MESH TIMESTAMP ENTITY FAMILY GROUP");
+#include "OB_Browser.h"
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
-class CustomItem : public QCustomMenuItem
-{
-public:
- CustomItem( const QString& s, const QFont& f )
- : string( s ), font( f ){};
- ~CustomItem(){}
-
- void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
- {
- p->setFont ( font );
- p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
- }
-
- QSize sizeHint()
- {
- return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
- }
-private:
- QString string;
- QFont font;
-};
+#include "SalomeApp_Application.h"
+#include "SalomeApp_DataModel.h"
+#include "SalomeApp_Study.h"
+#include "SalomeApp_SelectionMgr.h"
+#include "SalomeApp_Selection.h"
+#include "SalomeApp_Preferences.h"
-static VisuGUI *visuGUI = 0;
-static QString PREFIX = QString(getenv("USER")) + "-VISU-";
+#include "VISUConfig.hh"
+#include "VISU_Gen_i.hh"
+#include "VISU_Mesh_i.hh"
+#include "VISU_Table_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_View_i.hh"
+#include "VISU_ViewManager_i.hh"
+#include "VISU_Plot3D_i.hh"
+#include "VISU_Actor.h"
+#include "VisuGUI_Prs3dTools.h"
+#include "VisuGUI_Tools.h"
-vtkRenderer* VisuGUI::GetRenderer(QAD_Study* theStudy){
- if (theStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
- return NULL;
+#include "VisuGUI_PopupTools.h"
+#include "VisuGUI_NameDlg.h"
+#include "VisuGUI_FileDlg.h"
+#include "VisuGUI_CursorDlg.h"
+#include "VisuGUI_Selection.h"
+#include "VisuGUI_TimeAnimation.h"
+#include "VisuGUI_EditContainerDlg.h"
+#include "VisuGUI_NonIsometricDlg.h"
+#include "VisuGUI_ClippingDlg.h"
+#include "VisuGUI_Plot3DDlg.h"
+#include "VisuGUI_CubeAxesDlg.h"
+#include "VisuGUI_OffsetDlg.h"
- return ((VTKViewer_ViewFrame*)theStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
-}
+#include "VISU_ScalarMap_i.hh"
+#include "VisuGUI_ScalarBarDlg.h"
+#include "VISU_DeformedShape_i.hh"
+#include "VisuGUI_DeformedShapeDlg.h"
-/**
- * Finds value by given key
- */
+#include "VISU_IsoSurfaces_i.hh"
+#include "VisuGUI_IsoSurfacesDlg.h"
-VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
- VISU::Storable::TRestoringMap aMap;
- if(!theSObject->_is_nil()){
- SALOMEDS::GenericAttribute_var anAttr;
- if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
- SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
- CORBA::String_var aString = aComment->Value();
- QString strIn(aString.in());
- VISU::Storable::StrToMap(strIn,aMap);
- }
- }
- return aMap;
-}
-
-QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
- QString aStr("");
- VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
- if(!aMap.empty())
- aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
- return aStr;
-}
-
-
-CORBA::Object_var GetSelectedObj(string& theComment, Handle(SALOME_InteractiveObject)& theIO, QAD_Study* theStudy){
- SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection());
- if( Sel->IObjectCount() > 0 ) {
- theIO = Sel->firstIObject();
- if (theIO->hasEntry()){
- SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(theIO->getEntry());
- if(!aSObject->_is_nil()){
- SALOMEDS::GenericAttribute_var anAttr;
- if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
- SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
- theComment = aComment->Value();
- QString strIn(theComment.c_str());
- VISU::Storable::TRestoringMap aMap;
- VISU::Storable::StrToMap(strIn,aMap);
- bool isExist;
- theComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
- if(!isExist) theComment = "NONE";
- } else {
- theComment = "NONE";
- }
- aSObject->FindAttribute(anAttr, "AttributeIOR");
- if(!anAttr->_is_nil()){
- SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- if(!anIOR->_is_nil()){
- CORBA::String_var aValue = anIOR->Value();
- if(strcmp(aValue,"") != 0){
- CORBA::ORB_var anORB = VISU::GetORB();
- CORBA::Object_var anObject = anORB->string_to_object(aValue);
- return anObject;
- }
- }
- }
- }
- }
- }
- return CORBA::Object::_nil();
-}
-
-CORBA::Object_var GetSelectedObj(QAD_Study* theStudy, Handle(SALOME_InteractiveObject)* pIO = NULL,
- VISU::Storable::TRestoringMap* pMap = NULL)
-{
- SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection());
- if( Sel->IObjectCount() > 0 ) {
- Handle(SALOME_InteractiveObject)& anIO = (*pIO) = Sel->firstIObject();
- if (anIO->hasEntry()){
- SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
- SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
- if(!aSObject->_is_nil()){
- SALOMEDS::GenericAttribute_var anAttr;
- if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
- SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
- string aComm = aComment->Value();
- QString strIn(aComm.c_str());
- VISU::Storable::StrToMap(strIn,*pMap);
- }
- return VISU::SObjectToObject(aSObject);
- }
- }
- }
- return CORBA::Object::_nil();
-}
+#include "VISU_CutPlanes_i.hh"
+#include "VisuGUI_CutPlanesDlg.h"
-int IsTrihedronDisplayed(){
- QAD_ViewFrame* aViewFrame = MYActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- VTKViewer_ViewFrame* aVTKViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
- return aVTKViewFrame->isTrihedronDisplayed();
-}
+#include "VISU_CutLines_i.hh"
+#include "VisuGUI_CutLinesDlg.h"
+#include "VISU_StreamLines_i.hh"
+#include "VisuGUI_StreamLinesDlg.h"
-VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
- QAD_ViewFrame* aViewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
-}
+#include "VISU_Vectors_i.hh"
+#include "VisuGUI_VectorsDlg.h"
+#include "VisuGUI_TableDlg.h"
-void RepaintCurrentView(){
- VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
- if (vf)
- vf->Repaint();
-}
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(MED_Gen)
+#include "utilities.h"
-VISU_Actor* GetActorByIO(const Handle(SALOME_InteractiveObject)& theIO, vtkRenderer* theRen) {
- vtkActorCollection* aActors = theRen->GetActors();
- vtkActor* anActor;
- VISU_Actor* aVisuActor;
- for (aActors->InitTraversal(); (anActor = aActors->GetNextActor())!=NULL;) {
- if (anActor->IsA("VISU_Actor")) {
- aVisuActor = VISU_Actor::SafeDownCast(anActor);
- if (aVisuActor->hasIO()) {
- if (theIO->isSame(aVisuActor->getIO()))
- return aVisuActor;
- }
- }
- }
- return 0;
-}
+#include "VisuGUI_ActionsDef.h"
-VISU::Base_i* GetSelectedVisuObj(){
- SALOME_Selection* Sel = SALOME_Selection::Selection(MYActiveStudy->getSelection());
- SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
- if(It.More()){
- Handle(SALOME_InteractiveObject) IObject = It.Value();
- if (IObject->hasEntry()){
- SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(IObject->getEntry());
- if(!aSObject->_is_nil()){
- CORBA::Object_var aObject = VISU::SObjectToObject(aSObject);
- if(!CORBA::is_nil(aObject))
- return dynamic_cast<VISU::Base_i*>(VISU::GetServant(aObject));
- }
- }
- }
- return NULL;
-}
-
-/**
- * Returns selected sclalar mode or -1 if it was cancelled
- */
-int GetScalarMode(VISU::Result_i* theResult, const char* theFieldName){
- int aScalarMode = 0;
-// const VISU::TField* aField = theResult->GetInput()->GetField(theFieldName);
-// if(aField->myNbComp > 1){
-// VisuGUI_SelVectCompDlg* SelCompDlg = new VisuGUI_SelVectCompDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
-// if(SelCompDlg->exec()){
-// aScalarMode = SelCompDlg->whatIsChecked();
-// } else {
-// aScalarMode = -1;
-// }
-// delete SelCompDlg;
-// }
- return aScalarMode;
-}
-
-
-VisuGUI::VisuGUI(){
-}
-
-
-VisuGUI* VisuGUI::GetOrCreateVisuGUI( QAD_Desktop* desktop ){
- if(!visuGUI){
- static VisuGUI VISUGUI;
- visuGUI = &VISUGUI;
- Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "VISU");
- myComponent = VISU::VISU_Gen::_narrow(comp);
- }
- /* study may have changed */
- myDesktop = desktop;
- myActiveStudy = myDesktop->getActiveStudy();
- myStudy = myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active
- myComponent->SetCurrentStudy(myStudy);
- myStudyBuilder = myStudy->NewBuilder();
+using namespace VISU;
- MYActiveStudy = myActiveStudy;
- MYStudyDocument = myStudy;
- MYStudyBuilder = myStudyBuilder;
- return visuGUI;
-}
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//////////////////////////////////////////////////
+// Class: VisuGUI
+//////////////////////////////////////////////////
-/* ********************************************************************************* */
-/* Function to return VisuGUI object */
-/* ********************************************************************************* */
-VisuGUI* VisuGUI::GetVisuGUI( )
+VisuGUI::VisuGUI():
+ SalomeApp_Module( "VISU" )
{
- return VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
}
-/* ==================================================================================== */
-/* ==================================================================================== */
-/* ONGUI EVENT */
-/* ==================================================================================== */
-/* ==================================================================================== */
-static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
- return theStudy->GetProperties()->IsLocked();
+VisuGUI::~VisuGUI()
+{
}
-static int checkLock(const SALOMEDS::Study_var& theStudy) {
- if (isStudyLocked(theStudy)) {
- QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
- QObject::tr("WARNING"),
- QObject::tr("WRN_STUDY_LOCKED"),
- QObject::tr("BUT_OK") );
- return true;
+
+void
+VisuGUI::
+OnImportFromFile()
+{
+ if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
+ CheckLock(GetCStudy(GetAppStudy(this)));
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ QStringList aFilter;
+ aFilter.append( tr("FLT_MED_FILES") );
+ aFilter.append( tr("FLT_ALL_FILES") );
+
+ QFileInfo aFileInfo =
+ SUIT_FileDlg::getFileName(GetDesktop(this),
+ "",
+ aFilter,
+ tr("MEN_IMPORT_FROM_FILE"),
+ true);
+ if(aFileInfo.exists()) {
+ application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
+
+ VISU::Result_var aResult;
+ bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
+ if (VisuGUI_FileDlg::IsBuild) {
+ aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
+ if (!CORBA::is_nil(aResult.in()))
+ if (Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())) {
+ if (!aRes->IsPossible())
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ tr("WRN_VISU"),
+ tr("ERR_CANT_BUILD_PRESENTATION"),
+ tr("BUT_OK"));
+ else
+ aRes->BuildAll();
+ }
+ } else {
+ aResourceMgr->setValue("VISU", "full_med_loading", false);
+ aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
+ aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
+ }
+
+ if (CORBA::is_nil(aResult.in())) {
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ tr("WRN_VISU"),
+ tr("ERR_ERROR_IN_THE_FILE"),
+ tr("BUT_OK"));
+ }else{
+ application()->putInfo(aFileInfo.filePath() + tr("INF_DONE"));
+ UpdateObjBrowser(this);
+ }
}
- return false;
}
-
-bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
+void
+VisuGUI::
+OnExploreMEDFile()
{
- try{
- VisuGUI::GetOrCreateVisuGUI(parent);
-// get Visu directories from configuration file. Default values are enabled.
-/* if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) { // BugID: SAL931
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("Not available in Non-VTK viewers"),
- tr ("VISU_BUT_OK") );
- }*/
- QString VisuInputDir = getVisuInputDir();
- QString VisuOutputDir = getVisuOutputDir();
- vtkRenderer *theRenderer = GetRenderer(visuGUI->myActiveStudy);
+ if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+ CheckLock(aStudy);
+
+ SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
+
+ QStringList aFilter;
+ aFilter.append( tr("FLT_MED_FILES") );
+ aFilter.append( tr("FLT_ALL_FILES") );
+
+ QFileInfo aFileInfo =
+ SUIT_FileDlg::getFileName(GetDesktop(this),
+ "",
+ aFilter,
+ tr("MEN_EXPLORE_MED_FILE"),
+ true);
+ if(aFileInfo.exists()){
+ application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
+ std::string aStudyName = aStudy->Name();
+ try
+ {
+ aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
+ }
+ catch(...)
+ {
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ tr("WRN_VISU"),
+ tr("ERR_ERROR_IN_THE_FILE"),
+ tr("BUT_OK"));
+ }
+ application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
+ getApp()->updateObjectBrowser(true); // as need to update MED tree
+ getApp()->updateActions();
+ }
+}
- //vtkActorCollection* aActors = theRenderer->GetActors();
- //cout<<"### Actors Nb="<<aActors->GetNumberOfItems()<<endl;
- SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- SALOMEDS::AttributeIOR_var anIOR;
+void
+VisuGUI::
+OnImportTableFromFile()
+{
+ if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
+ CheckLock(GetCStudy(GetAppStudy(this)));
+
+ QStringList aFilter;
+ aFilter.append( tr("FLT_TABLE_FILES") );
+ aFilter.append( tr("FLT_ALL_FILES") );
+
+ QFileInfo aFileInfo =
+ SUIT_FileDlg::getFileName(GetDesktop(this),
+ "",
+ aFilter,
+ tr("MEN_IMPORT_TABLE"),
+ true);
+ if (aFileInfo.exists()) {
+ application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
+
+ CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
+
+ if (CORBA::is_nil(anObject.in())) {
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ tr("WRN_VISU"),
+ tr("ERR_ERROR_IN_THE_FILE"),
+ tr("BUT_OK"));
+ } else {
+ application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
+ UpdateObjBrowser(this);
+ }
+ }
+}
- switch (theCommandID)
- {
- /* ======================================================================================== */
- /* Define Selection Mode */
- /* ======================================================================================== */
- case 101:
- case 102:
- case 103:
- case 104:
- {
- QApplication::setOverrideCursor( Qt::waitCursor );
- int mode = theCommandID - 100; // Point, Edge, Cell, Actor
- parent->SetSelectionMode( mode );
- QApplication::restoreOverrideCursor();
- }
- break;
-
- /* ======================================================================================== */
- /* Import Table from file */
- /* ======================================================================================== */
-
- case 199:
- {
- if(checkLock(aStudy)) break;
- visuGUI->ImportTablesFromFile();
- break;
+void
+VisuGUI::
+OnExportTableToFile()
+{
+ if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
+
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+
+ if (aListIO.Extent() > 0) {
+ const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+ if (anIO->hasEntry()) {
+ _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
+ if (!aSObj) return;
+
+ // find table attribute
+ bool isTOR = true;
+ _PTR(GenericAttribute) anAttr;
+
+ if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
+ isTOR = false;
+ if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
+ // if the current SObject is a table title
+ // we take a father contaning the table
+ aSObj = aSObj->GetFather();
+
+ if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
+ isTOR = true;
+ } else {
+ if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
+ return;
+ }
+ }
+ }
}
- /* ======================================================================================== */
- /* Import Mesh from MED, DAT file */
- /* ======================================================================================== */
-
- case 112:
- {
- visuGUI->ImportFromFile();
- break;
+ // get table title in order to have default name of the file
+ QString aTitle;
+ if (isTOR) {
+ _PTR(AttributeTableOfReal) aTabAttr (anAttr);
+ if (!aTabAttr) return;
+ aTitle = aTabAttr->GetTitle().c_str();
+ } else {
+ _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
+ if (!aTabAttr) return;
+ aTitle = aTabAttr->GetTitle().c_str();
}
-
- /* ======================================================================================== */
- /* Export results and mesh into a file format */
- /* ======================================================================================== */
-
- case 122:
- {
- visuGUI->ExportToFile();
- break;
+ aTitle.simplifyWhiteSpace();
+ aTitle = aTitle.replace(QRegExp(" "), "_");
+
+ // get default path for the file
+ SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
+ QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
+ if (aDir.isEmpty()) {
+ aDir = aResourceMgr->stringValue("VISU","InputDir","");
+ if (aDir.isEmpty()) {
+ aDir = getenv("CSF_PATHData");
+ }
}
-
- /* ========================================================================================================================= */
- /* Print to printer (132) or in file (131) */
- /* ========================================================================================================================= */
-
- case 131 :
- case 132 :
- {
- QString prFile;
- if (theCommandID == 131) { // save the file
- prFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
- VisuOutputDir,
- filters[9],
- tr("TIFF File"),
- false);
- if ( prFile.isEmpty() )
- break;
-
- VisuOutputDir = QAD_Tools::getDirFromPath(prFile); // set VisuOutputDir
- QAD_CONFIG->addSetting("Visu:OutputDir",VisuOutputDir);
-
- visuGUI->PrintRW(prFile, false);
- } else {
- prFile=VisuOutputDir+"SalomeVisu.tif";
- visuGUI->PrintRW(prFile, true);
+ QString aPath = Qtx::addSlash(aDir) + aTitle;
+
+ // get name for the file
+ QStringList aFilter;
+ aFilter.append("Table Files (*.xls)");
+
+ QFileInfo aFileInfo =
+ SUIT_FileDlg::getFileName(GetDesktop(this),
+ aPath,
+ aFilter,
+ tr("MEN_EXPORT_TABLE"), // "Export Table To File"
+ false);
+
+ // export
+ QString aFile = aFileInfo.filePath();
+ if (!aFile.isEmpty()) {
+ application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
+ aDir = Qtx::dir(aFile, true);
+ aResourceMgr->setValue("VISU", "OutputDir", aDir);
+
+ try {
+ GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), aFile.latin1());
+ application()->putInfo(aFile + " " + tr("INF_DONE"));
+ } catch(std::exception& ex) {
+ INFOS(ex.what());
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ tr("WRN_VISU"),
+ tr("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
+ tr("BUT_OK"));
+ } catch(...) {
+ INFOS(tr("ERR_ERROR_DURING_EXPORT"));
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ tr("WRN_VISU"),
+ tr("ERR_ERROR_DURING_EXPORT"),
+ tr("BUT_OK") );
}
- break;
}
-
- /* ========================================================================== */
- /* Visualization of Results : */
- /* 4011 : Scalar Map */
- /* 4012 : Deformed Shape */
- /* 4013 : Vectors */
- /* 4014 : Iso-Surfaces */
- /* 4015 : Cut Planes */
- /* 4016 : Stream Lines */
- /* ========================================================================== */
-
- case 4011 :
- visuGUI->CreateScalarMap();
- break;
- case 4012 :
- visuGUI->CreateDeformedShape();
- break;
- case 4013 :
- visuGUI->CreateVectors();
- break;
- case 4014 :
- visuGUI->CreateIsoSurfaces();
- break;
- case 4015 :
- visuGUI->CreateCutPlanes();
- break;
- case 4016 :
- visuGUI->CreateStreamLines();
- break;
-
- /* ======================================================================================================================= */
- /* View Scalar Animation (Animation/scalar) */
- /* With Phase */
- /* ======================================================================================================================= */
-
- //case 4021 :
- //case 4022 :
- //case 4023 :
-
- /* ========================================================================================================================= */
- /* Selection - Cell by number */
- /* ========================================================================================================================= */
-
- case 4111 :
- {
- visuGUI->SelectCell();
- break;
-/* VSR 12/03/03: see VisuGUI::SelectCell()
- int TypeMode;
- VISU_Actor *ActorTmp;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy);
- //srn: Added check if anObject is Null, then break
-// if(CORBA::is_nil(anObject)) break;
-
- VISU::ScalarMap_i* aPrsObject = NULL;
- if(!CORBA::is_nil(anObject))
- aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(VISU::GetServant(anObject));
- if(aPrsObject){
- //aPrsObject->SetIO(anIO);
- //ActorTmp = aPrsObject->GetActor();
- //UpdateViewer(ActorTmp);
- ActorTmp = visuGUI->UpdateViewer(aPrsObject);
- } else {
- ActorTmp = ActorSelected(parent,true,&TypeMode);
- }
- if (ActorTmp==NULL)
- break;
-
- bool ok=FALSE;
- vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
- Mapper->SetInput(ActorTmp->DataSource);
- vtkDataSet *Data=Mapper->GetInput();
- int nbCells=Data->GetNumberOfCells();
- int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,"");
- if (ok && theRenderer)
- Selection->HighlightCell(selectedCell , ActorTmp , theRenderer);
- break;
-*/
- }
-
- /* ========================================================================================================================= */
- /* Selection - Cell - information attribute */
- /* ========================================================================================================================= */
-
- case 4112 :
- {
- visuGUI->InfoOnCell();
- break;
-/* VSR 12/03/03: see VisuGUI::InfoOnCell()
- int TypeMode;
- VISU_Actor *ActorTmp;
- ActorTmp = ActorSelected(parent,true,&TypeMode);
- if (ActorTmp==NULL)
- break;
-
- if ((TypeMode == SelectionCell) || (TypeMode == SelectionEdge))
- Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp);
- else
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"),
- tr ("Not Selected View - Cell Selection Mode"),
- tr ("VISU_BUT_OK") );
- break;
-*/
- }
-
- /* ========================================================================================================================= */
- /* Selection - Point - information number */
- /* ========================================================================================================================= */
-
- case 4121 :
- {
- visuGUI->SelectPoint();
- break;
-/* VSR 12/03/03: see VisuGUI::SelectPoint()
- int TypeMode;
- VISU_Actor *ActorTmp;
- ActorTmp = ActorSelected(parent,true,&TypeMode);
- if (ActorTmp==NULL)
- break;
-
- bool ok=FALSE;
- vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
- Mapper->SetInput(ActorTmp->DataSource);
- vtkDataSet *Data=Mapper->GetInput();
- int nbPoints=Data->GetNumberOfPoints();
- int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,"");
- if (ok && theRenderer)
- Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer);
- break;
-*/
- }
-
- /* ========================================================================================================================= */
- /* Selection - Point - information attribute */
- /* ========================================================================================================================= */
-
- case 4122 :
- {
- visuGUI->InfoOnPoint();
- break;
-/* VSR 12/03/03: see VisuGUI::InfoOnPoint()
- int TypeMode;
- VISU_Actor *ActorTmp;
- ActorTmp = ActorSelected(parent,true,&TypeMode);
- if (ActorTmp==NULL)
- break;
-
- if (TypeMode == SelectionPoint)
- Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp);
- else
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"),
- tr ("Not Selected View - Point Selection Mode"),
- tr ("VISU_BUT_OK") );
- break;
-*/
- }
+ }
+ }
+}
- /* ========================================================================================================================= */
- /* Selection - Shape */
- /* ========================================================================================================================= */
-
- //case 413 :
-
- /* ========================================================================================================================= */
- /* Visualization - Wireframe */
- /* ========================================================================================================================= */
-
- case 4211 :
- ChangeViewer(parent, theRenderer, true, 1);
- break;
-
- /* ========================================================================================================================= */
- /* Visualization - Surface */
- /* ========================================================================================================================= */
-
- case 4212 :
- ChangeViewer(parent, theRenderer, true, 2);
- break;
-
- /* ========================================================================================================================= */
- /* Visualization - Points */
- /* ========================================================================================================================= */
-
- case 4213 :
- ChangeViewer(parent, theRenderer, true, 0);
- break;
-
- /* ========================================================================================================================= */
- /* Visualization - Erase */
- /* ========================================================================================================================= */
-
- case 422 :
- if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
- ClearViewer(parent, theRenderer, -1);
- break;
-
- /* ========================================================================================================================= */
- /* Visualization - Global */
- /* ========================================================================================================================= */
-
- //case 423 :
-
- /* ========================================================================================================================= */
- /* Visualization - Partial */
- /* ========================================================================================================================= */
-
- //case 424 :
-
- case 430 :
- {
- //Show dialog that allows to select scale function and corresponding scale factor
- VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
- FALSE, Qt::WDestructiveClose );
- m_NonIsoDlg->show();
- break;
- }
-
- /* ============================ */
- /* POP-UP OBJECTS BROWSER */
- /* ============================ */
-
- case 900 : // Rename object
- visuGUI->Rename();
- break;
-
- // ---------------- For Popup in Viewer
- case 802 : // Erase
- case 902 : // Erase
- visuGUI->ErasePrs();
- break;
-
- case 803 : // Display only
- case 903 : // Display only
- visuGUI->DisplayOnlyPrs();
- break;
-
- case 901 : // Display
- visuGUI->DisplayPrs();
- break;
-
- case 8041 : // Object representation : Wireframe
- case 9041 : // Object representation : Wireframe
- visuGUI->ChangeRepresentation(WIREFRAME);
- break;
-
- case 8042 : // Object representation : Surface
- case 9042 : // Object representation : Surface
- visuGUI->ChangeRepresentation(SURFACE);
- break;
-
- case 8043 : // Object representation : Points
- case 9043 : // Object representation : Points
- visuGUI->ChangeRepresentation(POINTS);
- break;
-
- case 8044 : // Object representation : Shrink/Unshrink
- case 9044 : // Object representation : Shrink/Unshrink
- visuGUI->ChangeRepresentation(SHRINK);
- break;
-
- case 8051 : // Change object color
- case 9051 : // Change object color
- visuGUI->ChageColor();
- break;
-
- case 8052 : // Change object opacity
- case 9052 : // Change object opacity
- visuGUI->ChangeOpacity();
- break;
-
- case 8053 : // Change object line width
- case 9053 : // Change object line width
- visuGUI->ChangeLines();
- break;
-
- case 808 : // Sweep IsoSurfaces or Cutplanes
- case 908 : // Sweep IsoSurfaces or Cutplanes
- visuGUI->Sweep();
- break;
-
- case 807 : // Modify visualization
- case 809 : // Return Cell Id
- case 810 : // Highlight Cell parameter
- // ---------------- For Popup in ObjectBrowser
- case 907 : // Modify visualization
-
- {
- int TypeMode;
- bool InViewer;
- VISU_Actor *ActorTmp;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy);
- VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(VISU::GetServant(anObject));
- if(aPrsObject){
- ActorTmp = visuGUI->UpdateViewer(aPrsObject);
- } else {
- if ( ((theCommandID >= 801) && (theCommandID <= 809)) || ((theCommandID >= 8041) && (theCommandID <= 8059)) )
- InViewer= true;
- else if ( ((theCommandID >= 901) && (theCommandID <= 909)) || ((theCommandID >= 9041) && (theCommandID <= 9059)) )
- InViewer = false;
-
- ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
- }
- if (ActorTmp==NULL)
- break;
-
-
- if (theCommandID == 809) // return results of object picked, in the message box
- {
- Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp);
- MESSAGE("Valeur : " << Selection->getId())
- }
+void
+VisuGUI::
+OnImportMedField()
+{
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aCStudy))
+ return;
+ SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
- if (theCommandID == 810) // Highlight Cell or point with parameter
- {
- bool ok=FALSE;
- vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
- Mapper->SetInput(ActorTmp->DataSource);
- vtkDataSet *Data=Mapper->GetInput();
- if (TypeMode == SelectionPoint)
- {
- int nbPoints=Data->GetNumberOfPoints();
- int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,"");
- if (ok)
- Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer);
- }
- if ( (TypeMode == SelectionCell) || (TypeMode == SelectionEdge) )
- {
- int nbCells=Data->GetNumberOfCells()-1;
- int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,"");
- if (ok)
- Selection->HighlightCell(selectedCell , ActorTmp , theRenderer);
- }
- }
-
- break;
- }
-
-/* ======================================================================================== */
-/* Preferences for Scalar Bar */
-/* ======================================================================================== */
- case 51:
- {
- ChangeScalarBar();
-
- break;
- }
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
-/* ======================================================================================== */
-/* Preferences for Sweeping */
-/* ======================================================================================== */
- case 52:
- {
- SetSweepingPreferences();
- }
- break;
-
-
- case 113: // Load MED using MED component
- {
- if (checkLock(myStudy)) break;
-
- Engines::Component_var aMedComp = myDesktop->getEngine("FactoryServer", "MED");
- if (CORBA::is_nil(aMedComp)) return false;
- Engines::Med_Gen_var aMedGen = Engines::Med_Gen::_narrow(aMedComp);
- if (CORBA::is_nil(aMedGen)) return false;
-
- QStringList filtersList ;
-
- filtersList.append( tr("MED_MEN_IMPORT_MED") );
- filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
- QString aFileName = QAD_FileDlg::getFileName(myDesktop,
- "",
- filtersList,
- tr("MED_MEN_IMPORT"),
- true);
- if (!aFileName.isEmpty()) {
- QApplication::setOverrideCursor( Qt::waitCursor );
- aMedGen->readStructFileWithFieldType(aFileName.latin1(), myActiveStudy->getTitle());
- myActiveStudy->updateObjBrowser();
- QApplication::restoreOverrideCursor();
- }
+ SALOME_ListIteratorOfListIO It (aListIO);
+ QApplication::setOverrideCursor(Qt::waitCursor);
+ for (; It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject) anIO = It.Value();
+ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
+ if (!aSObject->_is_nil()) {
+ 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);
+ SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
+ if (!CORBA::is_nil(aField.in()))
+ GetVisuGen(this)->ImportMedField(aField);
+ } else {
+ SALOMEDS::SObject_var aSFather = aSObject->GetFather();
+ SALOMEDS::GenericAttribute_var anAttr;
+ aSFather->FindAttribute(anAttr, "AttributeName");
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ CORBA::String_var aValue = aName->Value();
+ if (strcmp(aValue.in(), "MEDFIELD") == 0)
+ GetVisuGen(this)->ImportMed(aSObject);
}
- break;
-
- default:
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("Not Yet Implemented"),
- tr ("VISU_BUT_OK") );
- break;
}
}
-/*
- catch(SALOMEDS::GenericAttribute::LockProtection&) {
- QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
- QObject::tr("WARNING"),
- QObject::tr("WRN_STUDY_LOCKED"),
- QObject::tr("BUT_OK") );
- return false;
- }
-*/
- catch (const SALOME::SALOME_Exception& S_ex) {
- QtCatchCorbaException(S_ex);
- return false;
- }
- catch(...) {
- QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr("Unknown exception was caught in VISU module"),
- tr("VISU_BUT_OK") );
- return false;
- }
- return true;
+ UpdateObjBrowser(this, true);
+ QApplication::restoreOverrideCursor();
}
+void
+CreateCurves( SalomeApp_Module* theModule,
+ VISU::CutLines_i* thePrs,
+ QDialog* theDlg,
+ const bool theCreate = true )
+{
+ if ( !thePrs )
+ return;
+ VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
+ if ( !aCutDlg )
+ return;
-/* ********************************************************************************* */
-/* Function to find Actor in ObjectBrowser */
-/* ********************************************************************************* */
-
-VISU_Actor *VisuGUI::GetActorObjBrowser(SALOMEDS::SObject_var objVisu, vtkRenderer *ren)
-{
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- if ( objVisu->FindAttribute(anAttr, "AttributeName") ) {
- aName = SALOMEDS::AttributeName::_narrow(anAttr);
-
- MESSAGE("GetActor == > Name : " << aName->Value());
-
- vtkActorCollection *ac;
- vtkActor *actor;
- ac = ren->GetActors();
-
- for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) {
- if (actor->IsA("VISU_Actor")) {
- VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(actor);
- if (strcmp(VISUActor->getName(), aName->Value()) == 0)
- return VISUActor;
+ _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
+ _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
+
+ if ( !theCreate && aSObject ) {
+ // Remove old Table
+ _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+ _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
+ for (; aIter->More(); aIter->Next()) {
+ _PTR(SObject) aTblObj = aIter->Value();
+ if ( aTblObj ) {
+ _PTR(GenericAttribute) anAttr;
+ if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
+ aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
+ break;
+ }
}
}
}
- return NULL;
-}
-
-
-/* ********************************************************************************* */
-/* Function to find Actor in Viewer */
-/* ********************************************************************************* */
-
-
-VISU_Actor *VisuGUI::GetActor(QAD_Desktop* parent, Handle_SALOME_InteractiveObject IO, vtkRenderer *ren)
-{
- VisuGUI::GetOrCreateVisuGUI(parent);
-
- QString theEntry = IO->getEntry();
- Standard_CString aComment;
- Standard_CString Persistent;
- //Standard_CString aName = IO->getName();
- VISU_Actor *anActor;
- result Test;
-
- SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument();
-
- SALOMEDS::SObject_var objlocal = aStudy->FindObjectID(theEntry.latin1());
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeComment_var aCmnt;
- SALOMEDS::AttributePersistentRef_var aPRef;
-
- if (objlocal->FindAttribute(anAttr, "AttributeComment")) {
- aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
- aComment = aCmnt->Value();
- }
- if (objlocal->FindAttribute(anAttr, "AttributePersistentRef")) {
- aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
- Persistent = aPRef->Value();
- }
-
- vtkActorCollection *aclocal;
- vtkActor *actorlocal;
- aclocal = ren->GetActors();
-
- // =============================================================================
- // Test if Actor exists in theRenderer
- for (aclocal->InitTraversal();(actorlocal = aclocal->GetNextActor())!=NULL;)
- {
- if (actorlocal->IsA("VISU_Actor"))
- {
- anActor = VISU_Actor::SafeDownCast(actorlocal);
- MESSAGE(" getIO de anActor : " << anActor->getIO())
- if (anActor->hasIO())
- {
- if (IO->isSame(anActor->getIO()))
- {
- MESSAGE("isSame IO")
- return anActor;
- }
- }
- }
- }
- // =============================================================================
- // If Actor doesn't exist in theRenderer => create same actor in new renderer
- /* int nbSf = visuGUI->myActiveStudy->getStudyFramesCount();
- SALOMEDS::SObject_var TheMeshObject= objlocal->GetFather();
- for ( int i = 0; i < nbSf; i++ )
- {
- QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i);
- if ( sf->getTypeView() == VIEW_VTK )
- {
- vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
- vtkActorCollection* ac = aRenderer->GetActors();
- vtkActor *actor;
- for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;)
- {
- if (actor->IsA("VISU_Actor"))
- {
- anActor = VISU_Actor::SafeDownCast(actor);
- if (anActor->hasIO())
- {
- if (IO->isSame(anActor->getIO()))
- {
- if (aRenderer != ren)
- {
- return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment));
- }
- }
- }
- }
- }
- }
- }*/
- return NULL;
- //return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment));
-}
-
-/* ********************************************************************************** */
-/* Function ActorSelected */
-/* To return the Actor selected in Viewer or in ObjectBrowser */
-/* ********************************************************************************** */
-
-VISU_Actor *VisuGUI::ActorSelected(QAD_Desktop* parent, bool InViewer, int *Mode)
-{
- VisuGUI::GetOrCreateVisuGUI(parent);
- SALOME_Selection *Sel;
- QAD_ObjectBrowserItem* item;
- VISU_Actor *ActorTmp;
- Standard_CString PersRef = "";
- Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection());
- vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
-
-
-
- *Mode=Sel->SelectionMode();
-
- SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- //SALOMEDS::SComponent_var father = aStudy->FindComponent("VISU");
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- SALOMEDS::AttributePersistentRef_var aPRef;
- if ( InViewer )
- {
- if (Sel->IObjectCount()==0)
- return NULL;
- SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
- Handle(SALOME_InteractiveObject) IObject = It.Value();
- ActorTmp=GetActor(parent,IObject,theRenderer);
+ if ( aCutDlg->isGenerateTable() ) {
+ GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
+ if ( aCutDlg->isGenerateCurves() ) {
+ if ( aSObject ) {
+ _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+ _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
+ for (; aIter->More(); aIter->Next()) {
+ _PTR(SObject) aTblObj = aIter->Value();
+ if ( aTblObj ) {
+ _PTR(GenericAttribute) anAttr;
+ if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
+ CreatePlot( theModule, aTblObj );
+ }
+ }
+ }
+ }
+ }
}
- else
- {
- item = (QAD_ObjectBrowserItem*)(visuGUI->myActiveStudy->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser()->getListView()->currentItem());
- if ( item != NULL )
- {
- // Test if a selected visu object
- QString theEntry = item->getEntry();
-
- MESSAGE("==================== TheEntry : " << theEntry)
- if ( theEntry.isEmpty() )
- {
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("Bad Type for Selected Item in Popup Menu"),
- tr ("VISU_BUT_OK") );
- return NULL;
- }
-
- SALOMEDS::SObject_var objVisu = aStudy->FindObjectID(theEntry.latin1());
- if (objVisu->FindAttribute(anAttr, "AttributePersistentRef")) {
- aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
- PersRef = aPRef->Value();
- }
-
- if ( objVisu->_is_nil() )
- {
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("nil object"),
- tr ("VISU_BUT_OK") );
- return NULL;
- }
- ActorTmp=GetActorObjBrowser(objVisu,theRenderer);
- }
- else
- return NULL;
+
+ if (!theCreate && aSObject) {
+ UpdateObjBrowser(theModule);
}
- return (ActorTmp);
}
-/* ********************************************************************************** */
-/* Function ClearViewer - Erase the actors displayed on the viewer */
-/* ********************************************************************************** */
+void
+VisuGUI::
+OnCreateMesh()
+{
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aStudy))
+ return;
-void VisuGUI::ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor)
+ // Get selected SObject
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ if (anIO.IsNull() || !anIO->hasEntry())
+ return;
+
+ // create a VTK view window if it does not exist
+ GetViewWindow( this, /*create=*/true );
+
+ CreateMesh(this, anIO);
+}
+
+void
+VisuGUI::
+OnCreateManyMesh()
{
- // TypeOfActor = -1 : All
- // = 1 : VisuActor
- // = 2 : ScalarBarActor
- // = 4 : Other Actor2D
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aStudy))
+ return;
- vtkActorCollection *ac;
- vtkActor2DCollection *ac2D;
- vtkActor *actor;
- vtkActor2D *actor2D;
- ac = ren->GetActors();
- ac2D = ren->GetActors2D();
+ // create a VTK view window if it does not exist
+ GetViewWindow( this, /*create=*/true );
+
+ // Get selected SObject
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+ SALOME_ListIteratorOfListIO anIter (aListIO);
+ for (; anIter.More(); anIter.Next()) {
+ Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+ if (anIO.IsNull() || !anIO->hasEntry())
+ return;
- if(TypeOfActor == -1 || TypeOfActor == 1) {
- bool TrhVisible = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->
- getActiveStudyFrame()->getRightFrame()->getViewFrame())->isTrihedronDisplayed();
- for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) {
- if (actor->IsA("VISU_Actor") || actor->IsA("vtkActor") )
- actor->VisibilityOff();
- }
- if (TrhVisible) ShowTrihedron(false);
- }
-
- if(TypeOfActor == -1 || TypeOfActor == 2) {
- for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;)
- if (actor2D->IsA("vtkScalarBarActor"))
- actor2D->VisibilityOff();
- }
-
- if(TypeOfActor == -1 || TypeOfActor == 4) {
- for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;)
- if (!(actor2D->IsA("vtkScalarBarActor"))) // it's a plot2d
- {
- actor2D->VisibilityOff();
- //actor2D->Delete();
- }
+ CreateMesh(this, anIO);
}
}
-/* ********************************************************************************** */
-/* Function ShowTrihedron */
-/* ********************************************************************************** */
-
-void VisuGUI::ShowTrihedron(bool ShowThd){
- bool ThdIsVisible = true;
- if( ShowThd && !ThdIsVisible)
- ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
- if( !ShowThd && ThdIsVisible)
- ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
+void
+VisuGUI::
+OnCreateScalarMap()
+{
+ CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
}
-/* ********************************************************************************** */
-/* Destructor */
-/* Clear all tmp files used in VISU */
-/* ********************************************************************************** */
-VisuGUI::~VisuGUI(){
- MESSAGE("VisuGUI::~VisuGUI");
+void
+VisuGUI::
+OnCreateDeformedShape()
+{
+ CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
}
-
-/* ********************************************************************************** */
-/* Function ChangeViewer */
-/* Change representation of all actors */
-/* ********************************************************************************** */
-void VisuGUI::ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type)
+void
+VisuGUI::
+OnCreateVectors()
{
- if (!ren) return;
- VisuGUI::GetOrCreateVisuGUI(parent);
- vtkActorCollection *ac;
- vtkActor *actor;
- ac = ren->GetActors();
-
- for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;)
- actor->GetProperty()->SetRepresentation(Type);
+ CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
}
+void
+VisuGUI::
+OnCreateIsoSurfaces()
+{
+ CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
+}
-// -----------------------------------------------------------------------------------------
-// EVENTS
-// -----------------------------------------------------------------------------------------
+void
+VisuGUI::
+OnCreateCutPlanes()
+{
+ CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
+}
-bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+void
+VisuGUI::
+OnCreateCutLines()
{
- VisuGUI::GetOrCreateVisuGUI(parent);
- return true;
+ CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
}
-// ====================================================================================================================
+void
+VisuGUI::
+OnCreateStreamLines()
+{
+ CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
+}
-bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+void
+VisuGUI::
+OnCreatePlot3D()
{
- VisuGUI::GetOrCreateVisuGUI(parent);
- return true;
+ CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
}
-// ===================================================================================================================
+void
+VisuGUI::
+OnCreatePlot2dView()
+{
+ CheckLock(GetCStudy(GetAppStudy(this)));
+ GetVisuGen( this )->CreateContainer();
+ UpdateObjBrowser(this);
+}
-bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+void
+VisuGUI::
+OnDisplayPrs()
{
- VisuGUI::GetOrCreateVisuGUI(parent);
- if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
- return false;
+ if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
- MESSAGE ( "VisuGUI::onKeyPress : " << pe->key() )
+ SVTK_ViewWindow* vw = GetViewWindow( this, /*create=*/true );
- switch ( pe->key() )
- {
- case Key_Escape :
- {
- MESSAGE("--> Key : Escape")
- return true;
+ QApplication::setOverrideCursor(Qt::waitCursor);
+ SALOME_ListIO aList;
+ SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
+ mgr->selectedObjects(aList);
+
+ Handle(SALOME_InteractiveObject) anIO;
+ for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
+ anIO = it.Value();
+ CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
+ if ( !CORBA::is_nil( anObject ) ) {
+ // is it Prs3d object ?
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
+ if(aPrsObject){
+ if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
+ UpdateViewer( this, aPrsObject );
+ if ( vw ) {
+ vw->highlight(anIO, 1);
+ }
+ continue;
+ }
+ // is it Curve ?
+ VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
+ if(aCurve){
+ if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
+ PlotCurve( this, aCurve, VISU::eDisplay );
+ continue;
}
- default :
- return true;
- break;
- }
- return true;
+ // is it Container ?
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
+ if(aContainer){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
+ PlotContainer( this, aContainer, VISU::eDisplay );
+ continue;
+ }
+ // is it Table ?
+ VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
+ if(aTable){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
+ PlotTable( this, aTable, VISU::eDisplay );
+ continue;
+ }
+ }
+ }
+ if ( vw ) {
+ vw->getRenderer()->ResetCameraClippingRange();
+ vw->Repaint();
+ }
+ QApplication::restoreOverrideCursor();
}
+void
+VisuGUI::
+OnDisplayOnlyPrs()
+{
+ OnEraseAll();
+ OnDisplayPrs();
+}
+void
+VisuGUI::
+OnErasePrs()
+{
+ if(MYDEBUG) MESSAGE("OnErasePrs");
-//=====================================================================================
-// Slot-functions for presentations creation
-//=====================================================================================
-
+ QApplication::setOverrideCursor(Qt::waitCursor);
-#define CREATEPRESENTATION(FunctionName) \
- void FunctionName() { \
- if (checkLock(myStudy)) return; \
- SALOMEDS::SObject_var objVisu; \
- if (!TestObjectBrowser(&objVisu)) return; \
- if(!FunctionName(objVisu)) return; \
- visuGUI->myActiveStudy->updateObjBrowser(); \
- myDesktop->putInfo("Ready"); \
- VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
- if (vf) { \
- /*vf->getRenderer()->ResetCameraClippingRange();*/ \
- vf->onViewFitAll(); \
- } \
- }
+ SVTK_ViewWindow* vw = GetViewWindow( this );
+ if (vw)
+ vw->unHighlightAll();
+ SALOME_ListIO aList;
+ SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
+ mgr->selectedObjects(aList);
-CREATEPRESENTATION(VisuGUI::CreateScalarMap);
-CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
-CREATEPRESENTATION(VisuGUI::CreateVectors);
-CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
-CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
-CREATEPRESENTATION(VisuGUI::CreateStreamLines);
+ Handle(SALOME_InteractiveObject) anIO;
+ for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
+ anIO = it.Value();
+ CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
+ ErasePrs( this, anObject, false );
+ }
+ if (vw)
+ vw->Repaint();
+ QApplication::restoreOverrideCursor();
+}
-//=====================================================================================
-// function : setSettings()
-// purpose :
-//=====================================================================================
-bool VisuGUI::setSettings(QAD_Desktop* parent)
+void
+VisuGUI::
+OnEditScalarMap()
{
- VisuGUI::GetOrCreateVisuGUI(parent);
- return true;
-}
-
-//=====================================================================================
-// function : DisplayPrs()
-// purpose :
-//=====================================================================================
-void VisuGUI::DisplayPrs() {
- MESSAGE("VisuGUI::DisplayPrs");
- string aComment;
Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
- if ( !CORBA::is_nil( anObject ) ) {
- // is it Prs3d object ?
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
- if(aPrsObject){
- MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
- UpdateViewer(aPrsObject);
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf) {
- vf->getRenderer()->ResetCameraClippingRange();
-#ifdef CHECKTIME
- OSD_Timer timer;
- timer.Start();
-#endif
- vf->Repaint();
- vf->highlight(anIO, 1);
-#ifdef CHECKTIME
- timer.Stop();
- MESSAGE("Check time on VisuGUI::DisplayPrs - vf->Repaint + vf->highlight");
- timer.Show();
-#endif
- }
- return;
- }
- // is it Curve ?
- VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
- if(aCurve){
- MESSAGE("VisuGUI::DisplayPrs : Curve object");
- PlotCurve(aCurve, VISU::eDisplay );
- return;
- }
- // is it Container ?
- VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
- if(aContainer){
- MESSAGE("VisuGUI::DisplayPrs : Container object");
- PlotContainer(aContainer, VISU::eDisplay );
- return;
- }
- // is it Table ?
- VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
- if(aTable){
- MESSAGE("VisuGUI::DisplayPrs : Table object");
- PlotTable(aTable, VISU::eDisplay );
- return;
+ if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
+ EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg,1>(this, aPrs3d);
+ if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
+ aViewWindow->highlight(anIO, 1);
}
}
}
-//=====================================================================================
-// function : DisplayOnlyPrs()
-// purpose :
-//=====================================================================================
-void VisuGUI::DisplayOnlyPrs() {
- MESSAGE("VisuGUI::DisplayOnlyPrs");
- string aComment;
+
+void
+VisuGUI::
+OnEditDeformedShape()
+{
Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
- if ( !CORBA::is_nil( anObject ) ) {
- // is it Prs3d object ?
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
- if(aPrsObject){
- MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
- UpdateViewer(aPrsObject, true);
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf) {
- vf->getRenderer()->ResetCameraClippingRange();
- vf->Repaint();
- }
- return;
- }
- // is it Curve ?
- VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
- if(aCurve){
- MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
- PlotCurve(aCurve, VISU::eDisplayOnly );
- return;
- }
- // is it Container ?
- VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
- if(aContainer){
- MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
- PlotContainer(aContainer, VISU::eDisplayOnly );
- return;
- }
- // is it Table ?
- VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
- if(aTable){
- MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
- PlotTable(aTable, VISU::eDisplayOnly );
- return;
+ if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
+ EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg,1>(this, aPrs3d);
+ if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
+ aViewWindow->highlight(anIO, 1);
}
}
}
-//=====================================================================================
-// function : ErasePrs()
-// purpose :
-//=====================================================================================
-void VisuGUI::ErasePrs() {
- MESSAGE("VisuGUI::ErasePrs");
- string aComment;
+
+void
+VisuGUI::
+OnEditCutPlanes()
+{
Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
- if ( !CORBA::is_nil( anObject ) ) {
- // is it Prs3d object ?
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
- if(aPrsObject){
- MESSAGE("VisuGUI::ErasePrs : Prs3d object");
- ErasePrs(aPrsObject);
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf) {
- vf->Repaint();
- }
- }
- // is it Curve ?
- VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
- if(aCurve){
- MESSAGE("VisuGUI::ErasePrs : Curve object");
- PlotCurve(aCurve, VISU::eErase );
- }
- // is it Container ?
- VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
- if(aContainer){
- MESSAGE("VisuGUI::ErasePrs : Container object");
- PlotContainer(aContainer, VISU::eErase );
- }
- // is it Table ?
- VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
- if(aTable){
- MESSAGE("VisuGUI::ErasePrs : Table object");
- PlotTable(aTable, VISU::eErase );
+ if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
+ EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg,0>(this, aPrs3d);
+ if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
+ aViewWindow->highlight(anIO, 1);
}
}
}
-//=====================================================================================
-// function : RecreateActor()
-// purpose :
-//=====================================================================================
-void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
- /* BEGIN_OF("VisuGUI::RecreateActor");
-
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (!vf) return;
- QApplication::setOverrideCursor( Qt::waitCursor );
- vtkRenderer *aRen = vf->getRenderer();
- VISU_Actor* anVISUActor = GetActor(thePrs);
-
- if(anVISUActor == NULL){
- anVISUActor= thePrs->CreateActor();
- anVISUActor->SetVisibility(true);
- vf->AddActor(anVISUActor);
- if (anVISUActor->HasScalarBar()) {
- anVISUActor->getScalarBar()->SetVisibility(true);
- aRen->AddActor2D(anVISUActor->getScalarBar());
+void
+VisuGUI::
+OnEditCutLines()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
+ EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg,0>(this, aPrs3d);
+ if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
+ aViewWindow->highlight(anIO, 1);
}
}
- vf->Repaint();
+}
- QApplication::restoreOverrideCursor();
- END_OF("VisuGUI::RecreateActor") */
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (!vf) return;
-
- VISU_Actor* anVISUActor = GetActor(thePrs);
- int isVisible = false;
-
- QApplication::setOverrideCursor( Qt::waitCursor );
- vtkRenderer *aRen = vf->getRenderer();
- if (anVISUActor) {
- isVisible = anVISUActor->GetVisibility();
- Handle(SALOME_InteractiveObject) anIO = anVISUActor->getIO();
- if (anVISUActor->HasScalarBar())
- aRen->RemoveActor(anVISUActor->getScalarBar());
- aRen->RemoveActor(anVISUActor);
- anVISUActor->Delete();
- anVISUActor = thePrs->CreateActor(anIO);
- } else
- anVISUActor = thePrs->CreateActor();
- QApplication::restoreOverrideCursor();
-
- if (!anVISUActor) return;
- anVISUActor->SetVisibility(isVisible);
- aRen->AddActor(anVISUActor);
- if (anVISUActor->HasScalarBar()) {
- anVISUActor->getScalarBar()->SetVisibility(isVisible);
- aRen->AddActor2D(anVISUActor->getScalarBar());
+void
+VisuGUI::
+OnEditIsoSurfaces()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
+ EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg,1>(this, aPrs3d);
+ if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
+ aViewWindow->highlight(anIO, 1);
+ }
}
}
-//=====================================================================================
-// function : EditPrs()
-// purpose :
-//=====================================================================================
-#define EDITPRS(PrsName, DlgName) \
- { \
- PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
- if (aPrsObject) { \
- DlgName* aDlg = new DlgName(); \
- aDlg->initFromPrsObject(aPrsObject); \
- if ( aDlg->exec() ) { \
- aDlg->storeToPrsObject(aPrsObject); \
- RecreateActor(aPrsObject); \
- /*RepaintCurrentView();*/ \
- VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
- if (vf) { \
- if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
- vf->getRenderer()->ResetCameraClippingRange(); \
- vf->onViewFitAll(); \
- }\
- } \
- } \
- delete aDlg; \
- } \
+void
+VisuGUI::
+OnEditVectors()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
+ EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg,1>(this, aPrs3d);
+ if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
+ aViewWindow->highlight(anIO, 1);
}
+ }
+}
-void VisuGUI::EditPrs() {
- VISU::Prs3d_i* aPrs3d = GetSelectedPrs();
-
- switch (aPrs3d->GetType()) {
- case VISU::TMESH: // Mesh 13
- break;
-
- case VISU::TSCALARMAP: // ScalarMap 18
- EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
- break;
-
- case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
- EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
- break;
-
- case VISU::TCUTPLANES: // Cut planes 42
- EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
- break;
-
- case VISU::TISOSURFACE: // Iso surfaces
- EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
- break;
- case VISU::TVECTORS: // Vectors 64
- EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
- break;
-
- case VISU::TSTREAMLINES:
- EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
+void
+VisuGUI::
+OnEditStreamLines()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
+ EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg,1>(this, aPrs3d);
+ if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
+ aViewWindow->highlight(anIO, 1);
+ }
}
}
-//=====================================================================================
-// function : EditScalarBar()
-// purpose :
-//=====================================================================================
-void VisuGUI::EditScalarBar() {
- VISU::Prs3d_i* aPrs3d = GetSelectedPrs();
- VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
- if (aPrsObject) {
- VisuGUI_ScalarBarDlg* aDlg = new VisuGUI_ScalarBarDlg(false);
- aDlg->initFromPrsObject(aPrsObject);
- if ( aDlg->exec() ) {
- aDlg->storeToPrsObject(aPrsObject);
- RecreateActor(aPrsObject);
-
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf)
- vf->Repaint();
-
- if (aDlg->isToSave())
- aDlg->storeToResources();
+void
+VisuGUI::
+OnEditPlot3D()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
+ EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg,0>(this, aPrs3d);
+ if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
+ aViewWindow->highlight(anIO, 1);
}
- delete aDlg;
- }
-
-}
-
-
-//=====================================================================================
-// function : CreateMesh()
-// purpose :
-//=====================================================================================
-void VisuGUI::CreateMesh() {
-
- //string aComment;
- //Handle(SALOME_InteractiveObject) anIO;
- //CORBA::Object_var anObject = GetSelectedObj(aComment,anIO, VisuGUI::myActiveStudy);
- SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SALOMEDS::SObject_var aSObject = myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
-
- if (checkLock(myStudy)) return;
-
- SALOMEDS::SObject_var aSObj = aSObject->GetFather();
- aSObj = aSObj->GetFather();
- aSObj = aSObj->GetFather();
- CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
- if(CORBA::is_nil(anObject)) {
- aSObj = aSObj->GetFather();
- anObject = VISU::SObjectToObject(aSObj);
- if(CORBA::is_nil(anObject)) return;
}
- VISU::Result_var aResult = VISU::Result::_narrow(anObject);
- if(CORBA::is_nil(aResult)) return;
+}
- VISU::Storable::TRestoringMap aMap;
- SALOMEDS::GenericAttribute_var anAttr;
- if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
- SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
- string aComm = aComment->Value();
- QString strIn(aComm.c_str());
- VISU::Storable::StrToMap(strIn,aMap);
- }
- bool isExist;
- string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
- if(!isExist) return;
- CORBA::Object_var aMesh;
- string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
- if(aComment == "ENTITY"){
- VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
- aMesh = myComponent->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
- }else if(aComment == "FAMILY"){
- VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
- string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
- aMesh = myComponent->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
- }else if(aComment == "GROUP"){
- string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
- aMesh = myComponent->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
- }
- QApplication::restoreOverrideCursor();
- if(CORBA::is_nil(aMesh)) return;
- VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh));
-#ifdef CHECKTIME
- OSD_Timer timer;
- timer.Start();
-#endif
- VISU_Actor *anActor = pPresent->CreateActor();
- if (! anActor ) return;
-#ifdef CHECKTIME
- timer.Stop();
- MESSAGE("Check time on VisuGUI::CreateMesh - pPresent->CreateActor");
- timer.Show();
-#endif
- if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
- vtkRenderer *aRenderer = vf->getRenderer();
- //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1);
- //visuGUI->ShowTrihedron(true);
-#ifdef CHECKTIME
- OSD_Timer timer;
- timer.Start();
-#endif
- vf->AddActor(anActor);
- vf->getRenderer()->AddActor(anActor->EdgeDevice);
- vf->getRenderer()->ResetCameraClippingRange();
- vf->onViewFitAll();
-#ifdef CHECKTIME
- timer.Stop();
- MESSAGE("Check time on VisuGUI::CreateMesh - vf->AddActor + vf->onViewFitAll");
- timer.Show();
-#endif
- }
- myActiveStudy->updateObjBrowser(); //update Object browser
- myDesktop->putInfo("Ready");
-}
-
-
-//=====================================================================================
-// function : ChangeRepresentation()
-// purpose :
-//=====================================================================================
-
-static void ShrinkMesh(VISU_Actor *Actor){
- if (!(Actor->IsShrunk)){
- vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper());
- vtkShrinkFilter *shrink = vtkShrinkFilter::New();
- shrink->SetInput(mapper->GetInput());
- shrink->SetShrinkFactor(0.8);
- mapper->SetInput(shrink->GetOutput());
- Actor->IsShrunk = true;
- shrink->Delete();
- Actor->EdgeDevice->VisibilityOff();
- }else{
- vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper());
- // mpv: we wish to remove shrink filter only instead of all filters ignore
-// mapper->SetInput(Actor->DataSource);
- vtkDataObject* anObject = mapper->GetInput();
- vtkSource* aPrevSource = (vtkSource*)mapper;
- while(anObject != Actor->DataSource) {
- vtkShrinkFilter* aShrink = vtkShrinkFilter::SafeDownCast(anObject->GetSource());
- if (aShrink) {
- vtkSource* aSource = aShrink->GetInput()->GetSource();
- vtkDataObject** Inputs = aPrevSource->GetInputs();
- vtkDataObject** Outputs = aSource->GetOutputs();
- Outputs[0]->UnRegister(aShrink);
- Inputs[0]->UnRegister(aShrink);
- Outputs[0]->Register(aPrevSource);
- Inputs[0]->Register(aSource);
- Inputs[0] = aSource->GetOutputs()[0];
- aSource->Modified();
- aSource->Update();
-
- mapper->Update();
- break;
+void
+VisuGUI::
+OnEraseAll()
+{
+ if (SVTK_ViewWindow* vw = GetViewWindow()) {
+ vw->unHighlightAll();
+ if (vtkRenderer *aRen = vw->getRenderer()) {
+ vtkActor *anActor;
+ vtkActorCollection *anActColl = aRen->GetActors();
+ for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
+ if (anActor->GetVisibility() > 0)
+ if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
+ anVISUActor = anVISUActor->GetParent();
+ anVISUActor->VisibilityOff();
+ }
}
- aPrevSource = anObject->GetSource();
- anObject = aPrevSource->GetInputs()[0];
+ vw->Repaint();
}
-
-
- Actor->IsShrunk = false;
- if ( Actor->GetProperty()->GetRepresentation() == 2 )
- Actor->EdgeDevice->VisibilityOn();
+ } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
+ aPlot2d->EraseAll();
}
}
-void VisuGUI::ChangeRepresentation(RepresentType theType) {
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
- if(!aPrsObject) return;
-
-#ifdef CHECKTIME
- OSD_Timer timer;
- timer.Start();
-#endif
- VISU_Actor* anActor = GetActor(aPrsObject);
- if (!anActor) return;
- switch (theType) {
- case POINTS:
- anActor->EdgeDevice->VisibilityOff();
- anActor->GetProperty()->SetRepresentation(0);
- anActor->GetProperty()->SetPointSize(VISU_POINT_SIZE);
- break;
- case WIREFRAME:
- anActor->EdgeDevice->VisibilityOff();
- anActor->GetProperty()->SetRepresentation(1);
- break;
- case SURFACE:
- if ( !anActor->IsShrunk )
- anActor->EdgeDevice->VisibilityOn();
- anActor->GetProperty()->SetRepresentation(2);
- break;
- case SHRINK:
- ShrinkMesh(anActor);
- break;
- }
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf)
- vf->Repaint();
-#ifdef CHECKTIME
- timer.Stop();
- MESSAGE("Cheking time in VisuGUI::ChangeRepresentation - anActor->GetProperty()->SetRepresentation + vf->Repaint");
- timer.Show();
-#endif
+void
+VisuGUI::
+OnMakeSurfaceframe()
+{
+ ChangeRepresentation(this, VISU::SURFACEFRAME);
}
-void VisuGUI::MakeWireframe() {
- ChangeRepresentation(WIREFRAME);
+void
+VisuGUI::
+OnMakeInsideframe()
+{
+ ChangeRepresentation(this, VISU::INSIDEFRAME);
}
+void
+VisuGUI::
+OnMakeWireframe()
+{
+ ChangeRepresentation(this, VISU::WIREFRAME);
+}
-void VisuGUI::MakeSurface() {
- ChangeRepresentation(SURFACE);
+void
+VisuGUI::
+OnMakeSurface()
+{
+ ChangeRepresentation(this, VISU::SHADED);
}
+void
+VisuGUI::
+OnMakePoints()
+{
+ ChangeRepresentation(this, VISU::POINT);
+}
-void VisuGUI::MakePoints() {
- ChangeRepresentation(POINTS);
+void
+VisuGUI::
+OnMakeShrink()
+{
+ ChangeRepresentation(this, VISU::SHRINK);
}
+void
+VisuGUI::
+OnChangeColor()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ if (CORBA::is_nil(anObject)) return;
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+ if (!aServant.in()) return;
-void VisuGUI::MakeShrink() {
- ChangeRepresentation(SHRINK);
-}
+ VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+ if (!aPrs3d) return;
+ SVTK_ViewWindow* vw = GetViewWindow();
+ if (!vw) return;
+ VISU_Actor* anActor = GetActor(aPrs3d, vw);
+ if (!anActor) return;
-//=====================================================================================
-// functions : Change Propertise
-// purpose :
-//=====================================================================================
-VISU::Prs3d_i* VisuGUI::GetSelectedPrs() {
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
- return dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
+ VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
+ VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
+ SALOMEDS::Color anOldColor, aNewColor;
+ int aRepresent = anActor->GetRepresentation();
+ if (aMesh) {
+ switch (aRepresent) {
+ case VISU::POINT :
+ anOldColor = aMesh->GetNodeColor();
+ break;
+ case VISU::WIREFRAME :
+ case VISU::INSIDEFRAME :
+ anOldColor = aMesh->GetLinkColor();
+ break;
+ case VISU::SHADED :
+ case VISU::SURFACEFRAME :
+ anOldColor = aMesh->GetCellColor();
+ break;
+ }
+ } else if (aDeformedShape) {
+ anOldColor = aDeformedShape->GetColor();
+ } else {
+ return;
+ }
+
+ QColor aColor (int(255*anOldColor.R),
+ int(255*anOldColor.G),
+ int(255*anOldColor.B));
+ QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
+ if (aColorNew.isValid()) {
+ aNewColor.R = aColorNew.red()/255.;
+ aNewColor.G = aColorNew.green()/255.;
+ aNewColor.B = aColorNew.blue()/255.;
+ if (aMesh) {
+ switch (aRepresent) {
+ case VISU::POINT :
+ aMesh->SetNodeColor(aNewColor);
+ break;
+ case VISU::WIREFRAME :
+ case VISU::INSIDEFRAME :
+ aMesh->SetLinkColor(aNewColor);
+ break;
+ case VISU::SHADED :
+ case VISU::SURFACEFRAME :
+ aMesh->SetCellColor(aNewColor);
+ break;
+ }
+ } else {
+ aDeformedShape->SetColor(aNewColor);
+ }
+ RecreateActor(this, aPrs3d);
+ }
}
-void VisuGUI::ChageColor() {
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
- if(!aPrsObject) return;
+void
+VisuGUI::
+OnChangeWireframeColor()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ if (CORBA::is_nil(anObject)) return;
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+ if (!aServant.in()) return;
- VISU_Actor* anActor = GetActor(aPrsObject);
- if (!anActor) return;
- NewColor(anActor);
-}
+ VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+ if (!aPrs3d) return;
-void VisuGUI::ChangeOutlineColor() {
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
- if(!aPrsObject) return;
+ SVTK_ViewWindow* vw = GetViewWindow();
+ if (!vw) return;
- VISU_Actor* anActor = GetActor(aPrsObject);
+ VISU_Actor* anActor = GetActor(aPrs3d, vw);
if (!anActor) return;
- NewOutlineColor(anActor);
+
+ if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
+ SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
+ QColor aColor (int(255*anOldColor.R),
+ int(255*anOldColor.G),
+ int(255*anOldColor.B));
+ QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
+ if (aColorNew.isValid()) {
+ aNewColor.R = aColorNew.red()/255.;
+ aNewColor.G = aColorNew.green()/255.;
+ aNewColor.B = aColorNew.blue()/255.;
+ aMesh->SetLinkColor(aNewColor);
+ RecreateActor(this, aMesh);
+ }
+ }
}
+void
+VisuGUI::
+OnChangeOpacity()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ if (CORBA::is_nil(anObject)) return;
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+ if (!aServant.in()) return;
-void VisuGUI::ChangeOpacity() {
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
- if(!aPrsObject) return;
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+ if (!aPrsObject) return;
+
+ SVTK_ViewWindow* vw = GetViewWindow();
+ if (!vw) return;
- VISU_Actor* anActor = GetActor(aPrsObject);
+ VISU_Actor* anActor = GetActor(aPrsObject, vw);
if (!anActor) return;
- NewOpacity(anActor);
-}
+ VisuGUI_CursorDlg* CursorDlg =
+ new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
-void VisuGUI::ChangeLines() {
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
- if(!aPrsObject) return;
+ CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
+ CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
+ CursorDlg->SpinBox1->setMinValue(0);
+ CursorDlg->SpinBox1->setMaxValue(100);
- VISU_Actor* anActor = GetActor(aPrsObject);
- if (!anActor) return;
- NewLinewidth(anActor);
-}
-void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
-{
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- if ( table && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
- Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- if ( theDisplaying == VISU::eDisplayOnly )
- aPlot->EraseAll();
- QList<Plot2d_Curve> clist;
- aPlot->getCurves( clist );
- SALOMEDS::SObject_var TableSO = visuGUI->myActiveStudy->getStudyDocument()->FindObjectID( table->GetEntry() );
- if ( !TableSO->_is_nil() ) {
- SALOMEDS::ChildIterator_var Iter = visuGUI->myActiveStudy->getStudyDocument()->NewChildIterator( TableSO );
- for ( ; Iter->More(); Iter->Next() ) {
- CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
- if( !CORBA::is_nil( childObject ) ) {
- CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
- if( !CORBA::is_nil( aCurve ) ) {
- VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
- Plot2d_Curve* plotCurve = 0;
- for ( int i = 0; i < clist.count(); i++ ) {
- if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
- plotCurve = clist.at( i );
- break;
- }
- }
- if ( theDisplaying == VISU::eErase ) {
- if ( plotCurve ) {
- aPlot->eraseCurve( plotCurve, false );
- clist.remove( plotCurve );
- }
- }
- else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
- if ( plotCurve ) {
- plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
- //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
- plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
- plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
- plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
- /* - DATA NOT UPDATED */
- if ( !plotCurve->isAutoAssign() ) {
- plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
- plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
- SALOMEDS::Color color = theCurve->GetColor();
- plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
- plotCurve->setAutoAssign( theCurve->IsAuto() );
- }
- aPlot->displayCurve( plotCurve, false );
- }
- else {
- Plot2d_Curve* crv = theCurve->CreatePresentation();
- if ( crv )
- aPlot->displayCurve( crv, false );
- }
- }
- }
- }
- }
- aPlot->Repaint();
- }
- }
-}
-void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
-{
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- if ( theCurve && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
- Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
-// if ( theDisplaying == VISU::eDisplayOnly )
-// aPlot->EraseAll();
- QList<Plot2d_Curve> clist;
- aPlot->getCurves( clist );
- Plot2d_Curve* plotCurve = 0;
- for ( int i = 0; i < clist.count(); i++ ) {
- if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
- plotCurve = clist.at( i );
- }
- else if ( theDisplaying == VISU::eDisplayOnly ) {
- aPlot->eraseCurve( clist.at( i ) );
- }
- }
- if ( theDisplaying == VISU::eErase ) {
- if ( plotCurve )
- aPlot->eraseCurve( plotCurve, false );
- }
- else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
- if ( plotCurve ) {
- plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
- //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
- plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
- plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
- plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
- /* DATA NOT UPDATED */
- if ( !plotCurve->isAutoAssign() ) {
- plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
- plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
- SALOMEDS::Color color = theCurve->GetColor();
- plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
- plotCurve->setAutoAssign( theCurve->IsAuto() );
- }
- aPlot->displayCurve( plotCurve, false );
- }
- else {
- Plot2d_Curve* crv = theCurve->CreatePresentation();
- if ( crv ) {
- aPlot->displayCurve( crv, false );
- }
- }
- }
- aPlot->Repaint();
+ float oldopac = anActor->GetOpacity();
+ int intopac = int(oldopac*100. + 0.5);
+ CursorDlg->SpinBox1->setValue(intopac);
+
+ int ret = CursorDlg->exec();
+ if (ret == 1) {
+ intopac = CursorDlg->SpinBox1->value();
+ float newopac = intopac/100.;
+ anActor->SetOpacity(newopac);
}
+ delete CursorDlg;
}
-void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
-{
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- if ( container && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
- Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- if ( theDisplaying == VISU::eDisplayOnly )
- aPlot->EraseAll();
- QList<Plot2d_Curve> clist;
- aPlot->getCurves( clist );
- if ( container->GetNbCurves() > 0 ) {
- int nbCurves = container->GetNbCurves();
- for ( int k = 1; k <= nbCurves; k++ ) {
- VISU::Curve_i* theCurve = container->GetCurve( k );
- if ( theCurve && theCurve->IsValid() ) {
- Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( strdup(theCurve->GetEntry()), "", "" ) );
-// for ( int i = 0; i < clist.count(); i++ ) {
-// if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
-// plotCurve = clist.at( i );
-// break;
-// }
-// }
- if ( theDisplaying == VISU::eErase ) {
- if ( plotCurve ) {
- aPlot->eraseCurve( plotCurve, false );
- clist.remove( plotCurve );
- }
- }
- else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
- if ( plotCurve ) {
- plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
- //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
- plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
- plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
- plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
- /* - DATA NOT UPDATED */
- if ( !plotCurve->isAutoAssign() ) {
- plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
- plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
- SALOMEDS::Color color = theCurve->GetColor();
- plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
- plotCurve->setAutoAssign( theCurve->IsAuto() );
- }
- aPlot->displayCurve( plotCurve, false );
- }
- else {
- Plot2d_Curve* crv = theCurve->CreatePresentation();
- if ( crv )
- aPlot->displayCurve( crv, false );
- }
- }
- }
- }
- }
- aPlot->Repaint();
+
+void
+VisuGUI::
+OnChangeLines()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ if (CORBA::is_nil(anObject)) return;
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+ if (!aServant.in()) return;
+
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+ if (!aPrsObject) return;
+
+ SVTK_ViewWindow* vw = GetViewWindow();
+ if (!vw) return;
+
+ VISU_Actor* anActor = GetActor(aPrsObject, vw);
+ if (!anActor) return;
+
+ VisuGUI_CursorDlg* CursorDlg =
+ new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
+
+ CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
+ CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
+ CursorDlg->SpinBox1->setMinValue(1);
+ CursorDlg->SpinBox1->setMaxValue(10);
+
+ float oldlwid = anActor->GetLineWidth();
+ int intlwid = int(oldlwid);
+ CursorDlg->SpinBox1->setValue(intlwid);
+
+ int ret = CursorDlg->exec();
+ if (ret == 1) {
+ intlwid = CursorDlg->SpinBox1->value();
+ float newlwid = intlwid;
+ anActor->SetLineWidth(newlwid);
}
+ delete CursorDlg;
}
-/*!
- Slot : opens Table view : for Table object or SObject with table attribute selected
-*/
-void VisuGUI::ShowTable() {
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
- if( Sel->IObjectCount() !=1 )
- return;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
- SALOMEDS::SObject_var SO;
+
+void
+VisuGUI::
+OnShowTable()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
+ _PTR(SObject) SO;
if ( !CORBA::is_nil( anObject ) ) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
+ VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
if( !CORBA::is_nil( aTable ) ) {
- VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
- if ( table ) {
- SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
- }
+ VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
+ if ( table ) {
+ SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
+ }
}
- }
+ }
} else {
// possibly this is Table SObject
- SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( anIO->getEntry() );
+ SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
}
- SALOMEDS::GenericAttribute_var anAttr;
- if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" )
- && !SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) )
+
+ if( !IsSObjectTable( SO ) )
return;
- SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
- SO,
- false );
+
+ VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
+ SO,
+ false,
+ //SAL2670 Orientation of show tables
+ VisuGUI_TableDlg::ttAuto,
+ Qt::Vertical );
dlg->show();
}
-/*!
- Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
-*/
-void VisuGUI::PlotData() {
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
- if( Sel->IObjectCount() !=1 )
+
+void
+VisuGUI::
+OnCreateTable()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
+ _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
+ _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
+ VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
+ if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
+ GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
+ UpdateObjBrowser(this);
+ }
+}
+
+void
+VisuGUI::
+OnDeleteObjects()
+{
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aCStudy))
return;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
- SALOMEDS::SObject_var SO;
+
+ SALOME_ListIO aList;
+ SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
+ mgr->selectedObjects(aList);
+ int i = 0, nbSelected = aList.Extent();
+ if (nbSelected < 1) return;
+
+ const char* entries [nbSelected];
+ Handle(SALOME_InteractiveObject) anIO;
+ for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
+ anIO = it.Value();
+ if (anIO->hasEntry())
+ entries[i++] = anIO->getEntry();
+ }
+ nbSelected = i;
+ if (nbSelected < 1) return;
+
+ // There is a transaction
+ _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
+ aStudyBuilder->NewCommand();
+
+ for (i = 0; i < nbSelected; i++) {
+ _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
+ if (aSObject) {
+ DeleteSObject(this, aCStudy, aSObject);
+ }
+ }
+
+ // Finish transaction
+ aStudyBuilder->CommitCommand();
+
+ //GetActiveStudy()->unHighlightAll();
+ UpdateObjBrowser(this, true);
+}
+
+void
+VisuGUI::
+OnPlotData()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
+ _PTR(SObject) SO;
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeName) aName;
+ QString SOName;
+ _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
+
if ( !CORBA::is_nil( anObject ) ) {
VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
// Table (VISU object) is selected
CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
if( !CORBA::is_nil( aTbl ) ) {
- VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTbl ) );
- if ( table ) {
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- QString SOName;
- SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
- if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
- SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
- // get name of SObject
- if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
- aName = SALOMEDS::AttributeName::_narrow( anAttr );
- SOName = strdup( aName->Value() );
- }
- Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
- if ( dlg->exec() == QDialog::Accepted ) {
- if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
- // if study is not locked - create new container, create curves
- // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
- int horIndex;
- QValueList<int> verIndices;
- dlg->getCurvesSource( horIndex, verIndices );
- if ( horIndex >= 0 && verIndices.count() > 0 ) {
- CORBA::Object_var aContainer = myComponent->CreateContainer();
- if( !CORBA::is_nil( aContainer ) ) {
- VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ) );
- if ( pContainer ) {
- for ( int i = 0; i < verIndices.count(); i++ ) {
- CORBA::Object_var aNewCurve = myComponent->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
- if( !CORBA::is_nil( aNewCurve ) ) {
- VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aNewCurve ) );
- if ( pCrv ) {
- bool isAuto;
- int marker, line, lineWidth;
- QColor color;
- if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
- SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
- pCrv->SetColor( c );
- pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
- pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
- }
- pContainer->AddCurve( pCrv->_this() );
- }
- }
- }
- VisuGUI::myActiveStudy->updateObjBrowser( true );
- PlotContainer( pContainer, VISU::eDisplay );
- }
- }
- }
- }
- else {
- // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
- Plot2d_CurveContainer container;
- dlg->getCurves( container );
- if ( !container.isEmpty() ) {
- ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
- getRightFrame()->getViewFrame()))->displayCurves( container, true );
- ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
- getRightFrame()->getViewFrame()))->setTitle( SOName );
- }
- }
- }
- delete dlg;
- }
- }
+ VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
+ if ( table ) {
+ _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
+ if ( IsSObjectTable(SO) ) {
+ // get name of SObject
+ if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
+ aName = anAttr;
+ SOName = QString( aName->Value().c_str() );
+ }
+ SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
+ if ( dlg->exec() == QDialog::Accepted ) {
+ if ( !IsStudyLocked( aStudy ) ) {
+ // if study is not locked - create new container, create curves and insert them
+ // into container, then plot container if current viewer is of VIEW_PLOT2D type
+ int horIndex;
+ QValueList<int> verIndices;
+ dlg->getCurvesSource( horIndex, verIndices );
+ if ( horIndex >= 0 && verIndices.count() > 0 ) {
+ CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
+ if( !CORBA::is_nil( aContainer ) ) {
+ VISU::Container_i* pContainer =
+ dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
+ if ( pContainer ) {
+ for ( int i = 0; i < verIndices.count(); i++ ) {
+ CORBA::Object_var aNewCurve =
+ GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
+ if( !CORBA::is_nil( aNewCurve ) ) {
+ VISU::Curve_i* pCrv =
+ dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
+ if ( pCrv ) {
+ bool isAuto;
+ int marker, line, lineWidth;
+ QColor color;
+ if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
+ line, lineWidth, color) && !isAuto ) {
+ SALOMEDS::Color c;
+ c.R = color.red() /255.;
+ c.G = color.green()/255.;
+ c.B = color.blue() /255.;
+ pCrv->SetColor( c );
+ pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
+ pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
+ }
+ pContainer->AddCurve( pCrv->_this() );
+ }
+ }
+ }
+ UpdateObjBrowser(this);
+ PlotContainer( this, pContainer, VISU::eDisplay );
+ }
+ }
+ }
+ }
+ else {
+ // if study is locked just get curves info and plot them
+ // if current viewer is of VIEW_PLOT2D type
+ QPtrList<Plot2d_Curve> container;
+ dlg->getCurves( container );
+ if ( !container.isEmpty() ) {
+ GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
+ GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
+ }
+ }
+ }
+ delete dlg;
+ }
+ }
}
}
}
- else {
- // possibly this is Table SObject
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- QString SOName;
-
+ else if ( !anIO.IsNull() ) {
// check if Table SObject is selected
- SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
- if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
- SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
+ SO = aStudy->FindObjectID( anIO->getEntry() );
+ if ( IsSObjectTable(SO) ) {
// get name of SObject
if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
- aName = SALOMEDS::AttributeName::_narrow( anAttr );
- SOName = strdup( aName->Value() );
+ aName = anAttr;
+ SOName = QString( aName->Value().c_str() );
}
- Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
+ SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
if ( dlg->exec() == QDialog::Accepted ) {
- if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
- // if study is not locked - create new table and container objects, create curves
- // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
- int horIndex;
- QValueList<int> verIndices;
- dlg->getCurvesSource( horIndex, verIndices );
- if ( horIndex >= 0 && verIndices.count() > 0 ) {
- CORBA::Object_var aTable = myComponent->CreateTable( SO->GetID() );
- CORBA::Object_var aContainer = myComponent->CreateContainer();
- if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
- VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
- VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ) );
-
- if ( pContainer && pTable ) {
- for ( int i = 0; i < verIndices.count(); i++ ) {
- CORBA::Object_var aNewCurve = myComponent->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
- if( !CORBA::is_nil( aNewCurve ) ) {
- VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aNewCurve ) );
- if ( pCrv ) {
- bool isAuto;
- int marker, line, lineWidth;
- QColor color;
- if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
- SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
- pCrv->SetColor( c );
- pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
- pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
- }
- pContainer->AddCurve( pCrv->_this() );
- }
- }
- }
- VisuGUI::myActiveStudy->updateObjBrowser( true );
- PlotContainer( pContainer, VISU::eDisplay );
- }
- }
- }
- }
- else {
- // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
- Plot2d_CurveContainer container;
- dlg->getCurves( container );
- if ( !container.isEmpty() ) {
- ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
- getRightFrame()->getViewFrame()))->displayCurves( container, true );
- ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
- getRightFrame()->getViewFrame()))->setTitle( SOName );
- }
- }
- }
+ if ( !IsStudyLocked( aStudy ) ) {
+ // if study is not locked - create new table and container objects, create curves
+ // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
+ int horIndex;
+ QValueList<int> verIndices;
+ dlg->getCurvesSource( horIndex, verIndices );
+ if ( horIndex >= 0 && verIndices.count() > 0 ) {
+ CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
+ CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
+ if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
+ VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
+ VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
+
+ if ( pContainer && pTable ) {
+ for ( int i = 0; i < verIndices.count(); i++ ) {
+ CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
+ ( pTable->_this(), horIndex+1, verIndices[i]+1 );
+ if( !CORBA::is_nil( aNewCurve ) ) {
+ VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
+ if ( pCrv ) {
+ bool isAuto;
+ int marker, line, lineWidth;
+ QColor color;
+ if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
+ line, lineWidth, color) && !isAuto ) {
+ SALOMEDS::Color c;
+ c.R = color.red()/255.;
+ c.G = color.green()/255.;
+ c.B = color.blue()/255.;
+ pCrv->SetColor( c );
+ pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
+ pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
+ }
+ pContainer->AddCurve( pCrv->_this() );
+ }
+ }
+ }
+ UpdateObjBrowser(this);
+ PlotContainer( this, pContainer, VISU::eDisplay );
+ }
+ }
+ }
+ } else {
+ // if study is locked just get curves info and plot them
+ QPtrList<Plot2d_Curve> container;
+ dlg->getCurves( container );
+ if ( !container.isEmpty() ) {
+ GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
+ GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
+ }
+ }
}
delete dlg;
}
}
}
-/*!
- Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
-*/
-void VisuGUI::CurveProperties() {
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
- if( Sel->IObjectCount() !=1 )
- return;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
- SALOMEDS::SObject_var SO;
+
+void
+VisuGUI::
+OnCurveProperties()
+{
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+ if (aListIO.Extent() != 1) return;
+
+ SalomeApp_Study* aAppStudy = GetAppStudy(this);
+ const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+ CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
if (CORBA::is_nil( anObject )) return;
VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
// Curve object
CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
if( !CORBA::is_nil( aCurve ) ) {
- VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
- if ( curve && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
- SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
- dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
- dlg->setMarker( (int)curve->GetMarker() );
- SALOMEDS::Color color = curve->GetColor();
- dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
- if( dlg->exec() == QDialog::Accepted ) {
- curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
- curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
- SALOMEDS::Color newColor;
- newColor.R = dlg->getColor().red()/255.;
- newColor.G = dlg->getColor().green()/255.;
- newColor.B = dlg->getColor().blue()/255.;
- curve->SetColor( newColor );
- QList<QAD_StudyFrame> sfList = VisuGUI::myActiveStudy->getStudyFrames();
- if ( sfList.count() > 0 ) {
- QListIterator<QAD_StudyFrame> it( sfList );
- for ( ; it.current(); ++it ) {
- if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
- Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
- Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
- if ( IO.IsNull() )
- continue;
- Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
- if ( plotCurve ) {
- plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
- plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
- plotCurve->setColor( dlg->getColor() );
- aPlot->updateCurve( plotCurve, true );
- }
- }
- }
- }
- }
- }
+ VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+ if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
+ Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
+
+ aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
+ aDlg.setMarker( (int)aDSCurve->GetMarker() );
+ SALOMEDS::Color aColor = aDSCurve->GetColor();
+ aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
+ if( aDlg.exec() == QDialog::Accepted ) {
+ aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
+ aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
+ SALOMEDS::Color newColor;
+ newColor.R = aDlg.getColor().red()/255.;
+ newColor.G = aDlg.getColor().green()/255.;
+ newColor.B = aDlg.getColor().blue()/255.;
+ aDSCurve->SetColor( newColor );
+ PlotCurve(this, aDSCurve, VISU::eDisplay);
+ }
+ }
}
}
}
-
-/*!
- Slot : Clears container contents : for Container object selected
-*/
-void VisuGUI::ClearContainer() {
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
- if( Sel->IObjectCount() !=1 )
+void
+VisuGUI::
+OnClearContainer()
+{
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aCStudy))
+ return;
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ if (anIO.IsNull() || CORBA::is_nil(anObject))
return;
-
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
- SALOMEDS::SObject_var SO;
- if (CORBA::is_nil( anObject )) return;
VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
// Container object
- CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
- if( !CORBA::is_nil( aCnt ) ) {
- VISU::Container_i* container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aCnt ) );
- if ( container && container->GetNbCurves() > 0 && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
- container->Clear();
- VisuGUI::myActiveStudy->updateObjBrowser();
+ CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
+ if (!CORBA::is_nil(aCnt)) {
+ VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
+ if (container && container->GetNbCurves() > 0) {
+ container->Clear();
+ UpdateObjBrowser(this);
}
}
}
}
+void
+VisuGUI::
+OnEditContainer()
+{
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ if (CORBA::is_nil(anObject)) return;
-void VisuGUI::DeletePrs() {
- DeletePresentation(GetSelectedPrs());
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+ if (!aServant.in()) return;
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
+ if (!aContainer) return;
+
+ VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
+ aDlg->initFromPrsObject(aContainer);
+ if (aDlg->exec()) {
+ aDlg->storeToPrsObject(aContainer);
+ UpdateObjBrowser(this, true);
+ }
+ delete aDlg;
}
-void VisuGUI::SaveViewParams()
+void
+VisuGUI::
+OnSaveViewParams()
{
- if (checkLock(myStudy)) return;
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
- if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aCStudy))
return;
- // getting view manager
- CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager();
- if( CORBA::is_nil( aVM ) )
- return;
- VISU::ViewManager_i* pVM = dynamic_cast<VISU::ViewManager_i*>( VISU::GetServant( aVM ) );
- if ( !pVM )
- return;
- // getting current 3d view
- CORBA::Object_var aView = pVM->GetCurrentView();
- if( CORBA::is_nil( aView ) )
+
+ SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
+ if (aViewMgr->getType() != SVTK_Viewer::Type())
return;
- VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>( VISU::GetServant( aView ) );
- if ( !pView )
+
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+ if (aListIO.Extent() > 1)
return;
- if ( Sel->IObjectCount() == 0 ) {
- // Save view parameters by new name
- pView->SaveViewParams( 0 );
- VisuGUI::myActiveStudy->updateObjBrowser( true );
- }
- else {
- // Try to save view parameters by selected object's name
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
-// QString strIn( aComment.c_str() );
-// VISU::Storable::RestoringMapType aMap;
-// VISU::Storable::StrToMap( strIn,aMap );
-// QString aCmt = VISU::Storable::FindValue( aMap, "myComment" );
- if (ObjectTypes.find( aComment.c_str() ) == 6 ) {
- pView->SaveViewParams( anIO->getName() );
- VisuGUI::myActiveStudy->updateObjBrowser( true );
- }
+
+ if (aListIO.Extent() == 0) {
+ VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
+ } else {
+ const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+ VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
}
+ UpdateObjBrowser(this);
}
-void VisuGUI::RestoreViewParams()
+
+void
+VisuGUI::
+OnRestoreViewParams()
{
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
- if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
- return;
- // getting view manager
- CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager();
- if( CORBA::is_nil( aVM ) )
+ SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
+ if (aViewMgr->getType() != SVTK_Viewer::Type())
return;
- VISU::ViewManager_i* pVM = dynamic_cast<VISU::ViewManager_i*>( VISU::GetServant( aVM ) );
- if ( !pVM )
- return;
- // getting current 3d view
- CORBA::Object_var aView = pVM->GetCurrentView();
- if( CORBA::is_nil( aView ) )
- return;
- VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>( VISU::GetServant( aView ) );
- if ( !pView )
+
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+ if (aListIO.Extent() != 1)
return;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
- QString aCmt = aComment.c_str();
- if ( !aCmt.isEmpty() && ObjectTypes.find( aCmt ) == 6 ) {
- pView->RestoreViewParams( anIO->getName() );
- }
+
+ const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+ //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
+ _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
+ VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
}
-//=====================================================================================
-// function : DeleteViewParams()
-// purpose :
-//=====================================================================================
-void VisuGUI::DeleteViewParams() {
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection());
- if( Sel->IObjectCount() > 0 ) {
- SALOME_ListIteratorOfListIO aSelectionIterator(Sel->StoredIObjects());
- for(;aSelectionIterator.More(); aSelectionIterator.Next()) {
- Handle(SALOME_InteractiveObject) anIO = aSelectionIterator.Value();
- if (anIO->hasEntry()){
- SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry());
- if(!aSObject->_is_nil()){
- SALOMEDS::GenericAttribute_var anAttr;
- if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
- SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
- int aType;
- // possibly this is view params
- QString strIn(aComment->Value());
- VISU::Storable::TRestoringMap aMap;
- VISU::Storable::StrToMap( strIn, aMap );
- QString aCmt;
- bool isExist;
- aCmt = VISU::Storable::FindValue( aMap, "myComment", &isExist );
- if ( isExist ) aType = ObjectTypes.find( aCmt );
- if (aType == 6) {
- MYStudyDocument->NewBuilder()->RemoveObject(aSObject);
- Sel->RemoveIObject(anIO, 0);
- }
- }
- }
+void
+VisuGUI::
+OnRename()
+{
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aCStudy))
+ return;
+
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+
+ _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
+ if (!aSObj) return;
+
+ //TEST DU PARENT == VISU
+ _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
+ _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName");
+ if (anAttr) {
+ _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 (!CORBA::is_nil(anObject)) {
+ VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
+ if (!CORBA::is_nil(aVisuObj)) {
+ switch (aVisuObj->GetType()) {
+ case VISU::TCURVE: // Curve object
+ {
+ CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
+ if (!CORBA::is_nil(aCurve)) {
+ VISU::Curve_i* curve =
+ dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+ if (curve)
+ curve->SetName(Name.latin1());
+ }
+ break;
+ }
+ case VISU::TTABLE: // Table object
+ {
+ CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
+ if (!CORBA::is_nil(aTable)) {
+ VISU::Table_i* table =
+ dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
+ if (table)
+ table->SetName(Name.latin1());
+ }
+ break;
+ }
+ case VISU::TCONTAINER: // Container object
+ {
+ CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
+ if (!CORBA::is_nil(aContainer)) {
+ VISU::Container_i* container =
+ dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
+ if (container)
+ container->SetName(Name.latin1());
+ }
+ break;
+ }
+ default:
+ {
+ }
+ }
+ }
}
+
+ // rename the study object
+ aName->SetValue(Name.latin1()); // rename the SObject
+ anIO->setName(Name.latin1()); // rename the InteractiveObject
+ UpdateObjBrowser(this, false);
+
+ QApplication::restoreOverrideCursor();
}
}
- VisuGUI::myActiveStudy->updateObjBrowser( true );
}
+void
+VisuGUI::
+OnClippingPlanes()
+{
+ new VisuGUI_ClippingDlg (this, "", false);
+}
-//=====================================================================================
-// function : Sweep()
-// purpose :
-//=====================================================================================
-void VisuGUI::Sweep() {
- VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs());
- if (!aPrsObject) return;
-
- int aTemp=100000;
- QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
- if ( !aTempoStr.isEmpty() )
- aTemp = int(1.E6*(aTempoStr.toFloat()));
+void
+VisuGUI::
+OnSweep()
+{
+ // GetSelectedPrs3d
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ if (CORBA::is_nil(anObject)) return;
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+ if (!aServant.in()) return;
- int aCycles=1;
- QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
- if ( !aCyclesStr.isEmpty() )
- aCycles = aCyclesStr.toInt();
+ VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
+ if (!aPrsObject) return;
- int aSteps=40;
- QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
- if ( !aStepsStr.isEmpty() )
- aSteps = aStepsStr.toInt();
+ SVTK_ViewWindow* vw = GetViewWindow();
+ if (!vw) return;
- VISU_Actor* aActor = GetActor(aPrsObject);
+ VISU_Actor* aActor = GetActor(aPrsObject, vw);
if (!aActor) return;
-
+
if (!aActor->GetVisibility()) {
aActor->VisibilityOn();
- if (aActor->HasScalarBar())
- aActor->getScalarBar()->VisibilityOn();
}
- vtkDataSetMapper* aMapper = (vtkDataSetMapper*) aActor->GetMapper();
- VISU_LookupTable* aLookupTbl = (VISU_LookupTable*) aMapper->GetLookupTable();
-
- QApplication::setOverrideCursor( Qt::waitCursor );
- switch (aPrsObject->GetType()) {
- case VISU::TCUTPLANES: // Cut planes 42
- case VISU::TSCALARMAP: // ScalarMap 18
- for (int j=0 ; j<aCycles; j++) {
- for (int i=0 ; i<=aSteps; i++) {
- aLookupTbl->SetMapScale(float(i)/float(aSteps));
- RepaintCurrentView();
- usleep(aTemp);
- }
- }
- break;
+ // Get sweep parameters
+ SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
- case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
- {
- VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
- if (aDefPrs) {
- float aScale = aDefPrs->GetScale();
- bool isColored = aDefPrs->isColored();
-
- vtkWarpVector* aWarp = vtkWarpVector::New();
- if((VISU::Entity)aDefPrs->GetField()->myEntity == VISU::CELL) {
- vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
- aFilter->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput());
- aFilter->PassCellDataOn();
- aWarp->SetInput(aFilter->GetUnstructuredGridOutput());
- aFilter->Delete();
- } else
- aWarp->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput());
- for (int j=0 ; j<aCycles; j++) {
- for (int i=0 ; i<=aSteps; i++) {
- aWarp->SetScaleFactor(aScale*float(i)/float(aSteps));
- aMapper->SetInput(aWarp->GetOutput());
-
- if (isColored)
- aLookupTbl->SetMapScale(float(i)/float(aSteps));
- RepaintCurrentView();
- usleep(aTemp);
- }
- }
- aWarp->Delete();
- }
- }
- break;
+ double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
+ int aTemp = int(1.E6 * aTempoDbl);
- case VISU::TISOSURFACE: // Iso surfaces
- {
- VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
- if (aIsoPrs) {
- int nbIso = aIsoPrs->GetNbSurfaces();
- if (nbIso <= 1) break;
- vtkContourFilter* aContourFilter = vtkContourFilter::New();
- if ((VISU::Entity)aIsoPrs->GetField()->myEntity == VISU::CELL) {
- vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
- aFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput());
- aFilter->PassCellDataOn();
- aContourFilter->SetInput(aFilter->GetOutput());
- aFilter->Delete();
- } else
- aContourFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput());
- float aMul;
- for (int j=0 ; j<aCycles; j++){
- for (int i=0 ; i<aSteps; i++){
- aMul = float(i)/float(aSteps);
- aLookupTbl->SetMapScale(aMul);
- aContourFilter->GenerateValues(nbIso*(i+1)/aSteps,aIsoPrs->GetRangeMin(),aIsoPrs->GetRangeMax());
- aMapper->SetInput(aContourFilter->GetOutput());
- RepaintCurrentView();
- usleep(aTemp);
- }
- }
- aContourFilter->Delete();
+ int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
+ int aSteps = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
+
+ // Sweep
+ QApplication::setOverrideCursor(Qt::waitCursor);
+ try {
+ for (int j = 0; j < aCycles; j++) {
+ for (int i = 0; i <= aSteps; i++) {
+ float aPercents = float(i)/aSteps;
+ aPrsObject->SetMapScale(aPercents);
+ aPrsObject->UpdateActor(aActor);
+ vw->getRenderWindow()->getRenderWindow()->Render();
+ usleep(aTemp);
}
}
- break;
+ } catch (std::exception& exc) {
+ INFOS("Follow exception was occured :\n" << exc.what());
+ } catch (...) {
+ INFOS("Unknown exception was occured!");
}
QApplication::restoreOverrideCursor();
}
+void
+VisuGUI::
+OnTimeAnimation()
+{
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ VisuGUI_TimeAnimationDlg* aAnimationDlg =
+// new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
+ new VisuGUI_TimeAnimationDlg (this, aCStudy);
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
-void VisuGUI::TimeAnimation() {
- VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(myStudy);
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
-
bool isDefined = false;
long aNbTimes = 0;
- SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+ SALOME_ListIteratorOfListIO It (aListIO);
for (; It.More(); It.Next()) {
- SALOMEDS::SObject_var aSObject = myStudy->FindObjectID( It.Value()->getEntry() );
- if (aSObject->_is_nil()) continue;
+ _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
+ if (!aSObject) continue;
if (getValue(aSObject, "myComment") == QString("FIELD")) {
long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
if (aNumber > 1) {
- if (!isDefined) {
- aNbTimes = aNumber;
- aAnimationDlg->addField(aSObject);
- isDefined = true;
- } else if (aNbTimes == aNumber) {
- aAnimationDlg->addField(aSObject);
- }
+ if (!isDefined) {
+ aNbTimes = aNumber;
+ aAnimationDlg->addField(aSObject);
+ isDefined = true;
+ } else if (aNbTimes == aNumber) {
+ aAnimationDlg->addField(aSObject);
+ }
}
}
}
else delete aAnimationDlg;
}
+//************************************************************************
+void
+VisuGUI::
+OnShowAnimation()
+{
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+ if (aListIO.Extent() != 1)
+ return;
-void VisuGUI::ImportMedField() {
- if (checkLock(myStudy)) return;
+ const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
- SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
- QApplication::setOverrideCursor( Qt::waitCursor );
- for(;It.More();It.Next()) {
- Handle(SALOME_InteractiveObject) anIO = It.Value();
- SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry());
- if(!aSObject->_is_nil()){
- SALOMEDS::GenericAttribute_var anAttr;
- aSObject->FindAttribute(anAttr, "AttributeIOR");
- if(!anAttr->_is_nil()){
- SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- if(!anIOR->_is_nil()){
- CORBA::String_var aValue = anIOR->Value();
- if(strcmp(aValue,"") != 0){
- CORBA::ORB_var anORB = VISU::GetORB();
- CORBA::Object_var anObject = anORB->string_to_object(aValue);
- if ( !CORBA::is_nil( anObject ) ) {
- SALOME_MED::FIELD_ptr aField = SALOME_MED::FIELD::_narrow( anObject );
- if( !CORBA::is_nil( aField ) ) {
- VisuGUI::myComponent->ImportMed( aField );
- continue;
- }
- SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject );
- if( !CORBA::is_nil( aMesh ) ) {
- VisuGUI::myComponent->ImportMedMesh( aMesh );
- continue;
- }
- SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject );
- if( !CORBA::is_nil( aSupport ) ) {
- VisuGUI::myComponent->ImportMedSupport( aSupport );
- continue;
- }
- }
- }
- }
- }
- }
- }
- VisuGUI::myActiveStudy->updateObjBrowser( true );
- QApplication::restoreOverrideCursor();
-}
-/*
-void VisuGUI::ImportMedMesh() {
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
- if ( Sel->IObjectCount() != 1 )
- return;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment,anIO, VisuGUI::myActiveStudy);
- if ( !CORBA::is_nil( anObject ) ) {
- SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject );
- if( !CORBA::is_nil( aMesh ) ) {
- VisuGUI::myComponent->ImportMedMesh( aMesh );
- VisuGUI::myActiveStudy->updateObjBrowser( true );
- }
- SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject );
- if( !CORBA::is_nil( aSupport ) ) {
- VisuGUI::myComponent->ImportMedSupport( aSupport );
- VisuGUI::myActiveStudy->updateObjBrowser( true );
- }
- }
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+
+ _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
+ if (!aSObj) return;
+
+ VISU::Storable::TRestoringMap aMap;
+ _PTR(GenericAttribute) anAttr;
+ if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
+
+ _PTR(AttributeComment) aComment (anAttr);
+ string aComm = aComment->Value();
+ QString strIn (aComm.c_str());
+ VISU::Storable::StrToMap(strIn, aMap);
+ bool isExist;
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+ if (aType != VISU::TANIMATION) return;
+
+ VisuGUI_TimeAnimationDlg* aAnimationDlg =
+ new VisuGUI_TimeAnimationDlg(this, aCStudy);
+ aAnimationDlg->restoreFromStudy(aSObj);
+ aAnimationDlg->show();
}
-*/
-//=====================================================================================
-// functions : Rename()
-// purpose :
-//=====================================================================================
-void VisuGUI::Rename() {
- if (checkLock(myStudy)) return;
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
- if ( Sel->IObjectCount() != 1 )
+
+void
+VisuGUI::
+OnCopyPresentation()
+{
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aCStudy))
return;
- SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( Sel->firstIObject()->getEntry() );
- if( aSObj->_is_nil() ) return;
-
- //TEST DU PARENT == VISU
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
- aName = SALOMEDS::AttributeName::_narrow( anAttr );
- QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
- if ( !Name.isEmpty() ) {
- QApplication::setOverrideCursor( Qt::waitCursor );
- VisuGUI::myActiveStudy->renameIObject( Sel->firstIObject(), Name );
- QApplication::restoreOverrideCursor();
-
- //int TypeMode; bool InViewer;
- //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
- //ActorTmp->setName((Standard_CString)Name.latin1());
- }
- }
-}
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ if (CORBA::is_nil(anObject)) return;
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+ if (!aServant.in()) return;
-//=====================================================================================
-// function : CopyPresentation()
-// purpose :
-//=====================================================================================
-void VisuGUI::CopyPresentation(){
- if (checkLock(myStudy)) return;
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
if (!aPrsObject) return;
+
switch (aPrsObject->GetType()) {
case VISU::TMESH:
{
VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
aSameMesh->SameAs(aMeshPrs);
- UpdateViewer(aSameMesh, true);
- }
+ UpdateViewer(this, aSameMesh);
+ }
break;
- case VISU::TSCALARMAP:
+ case VISU::TSCALARMAP:
{
VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
- VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
+ VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
aSameScalar->SameAs(aScalarPrs);
- UpdateViewer(aSameScalar, true);
- }
+ UpdateViewer(this, aSameScalar);
+ }
break;
- case VISU::TDEFORMEDSHAPE:
+ case VISU::TDEFORMEDSHAPE:
{
VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
- VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
+ VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
aSameDeformed->SameAs(aDefPrs);
- UpdateViewer(aSameDeformed, true);
- }
+ UpdateViewer(this, aSameDeformed);
+ }
break;
- case VISU::TCUTPLANES:
+ case VISU::TCUTPLANES:
{
VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
- VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
+ VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
+ aSameCut->SameAs(aCutPrs);
+ UpdateViewer(this, aSameCut);
+ }
+ break;
+ case VISU::TCUTLINES:
+ {
+ VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
+ VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
aSameCut->SameAs(aCutPrs);
- UpdateViewer(aSameCut, true);
- }
+ UpdateViewer(this, aSameCut);
+ }
break;
- case VISU::TISOSURFACE:
+ case VISU::TISOSURFACE:
{
VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
- VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
+ VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
aSameIso->SameAs(aIsoPrs);
- UpdateViewer(aSameIso, true);
- }
+ UpdateViewer(this, aSameIso);
+ }
break;
- case VISU::TSTREAMLINES:
+ case VISU::TSTREAMLINES:
{
VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
- VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
+ VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
aSameLines->SameAs(aLinesPrs);
- UpdateViewer(aSameLines, true);
- }
+ UpdateViewer(this, aSameLines);
+ }
break;
- case VISU::TVECTORS:
+ case VISU::TVECTORS:
{
VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
- VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
+ VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
aSameVectors->SameAs(aVectorsPrs);
- UpdateViewer(aSameVectors, true);
- }
+ UpdateViewer(this, aSameVectors);
+ }
+ break;
+ case VISU::TPLOT3D:
+ {
+ VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
+ VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
+ aSamePlot3D->SameAs(aPlot3DPrs);
+ UpdateViewer(this, aSamePlot3D);
+ }
break;
- }
- myActiveStudy->updateObjBrowser();
+ }
+ UpdateObjBrowser(this);
}
-//=====================================================================================
-// function : InfoOnPoint() [ slot ]
-// purpose :
-//=====================================================================================
-void VisuGUI::InfoOnPoint()
+void
+VisuGUI::
+OnSelectionInfo()
{
- VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
- return;
- int TypeMode;
- VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode );
- if ( !ActorTmp )
- return;
-
- if ( TypeMode == SelectionPoint )
- Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp );
- else
- QAD_MessageBox::warn1( visuGUI->myDesktop,
- tr ("WARNING"),
- tr ("Not Point selection mode"),
- tr ("VISU_BUT_OK") );
-}
-
-//=====================================================================================
-// function : InfoOnCell() [ slot ]
-// purpose :
-//=====================================================================================
-void VisuGUI::InfoOnCell()
-{
- VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
- return;
- int TypeMode;
- VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode );
- if ( !ActorTmp )
- return;
-
- if ( TypeMode == SelectionCell || TypeMode == SelectionEdge )
- Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp );
+ if (GetViewWindow())
+ (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
else
- QAD_MessageBox::warn1( visuGUI->myDesktop,
- tr ("WARNING"),
- tr ("Not Cell/Edge selection mode"),
- tr ("VISU_BUT_OK") );
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ tr("WRN_VISU"),
+ tr("ERR_ACTIVATE_VIEW3D"),
+ tr("BUT_OK") );
}
-//=====================================================================================
-// function : SelectPoint() [ slot ]
-// purpose :
-//=====================================================================================
-void VisuGUI::SelectPoint()
+void
+VisuGUI::
+OnScaling()
{
- VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
- return;
- vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy );
- int TypeMode;
- VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode );
- if ( !ActorTmp )
- return;
- if ( TypeMode != SelectionPoint ) {
- QAD_MessageBox::warn1( visuGUI->myDesktop,
- tr ("WARNING"),
- tr ("Not Point selection mode"),
- tr ("VISU_BUT_OK") );
- return;
- }
-
- bool ok = FALSE;
- vtkDataSetMapper* Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
- Mapper->SetInput(ActorTmp->DataSource);
- vtkDataSet *Data=Mapper->GetInput();
- int nbPoints=Data->GetNumberOfPoints();
- int selectedPoint = SALOMEGUI_SetValueDlg::getInteger( tr("Point selection"),
- tr("Point number:" ),
- 0,
- &ok,
- visuGUI->myDesktop );
- if ( ok && theRenderer && selectedPoint > 0 && selectedPoint <= nbPoints )
- Selection->HighlightPoint( selectedPoint, nbPoints, ActorTmp, theRenderer );
-}
-
-//=====================================================================================
-// function : SelectCell() [ slot ]
-// purpose :
-//=====================================================================================
-void VisuGUI::SelectCell()
-{
- VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
- SALOME_Selection* Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection());
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
- return;
- vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy );
- int TypeMode=Sel->SelectionMode();
- if ( TypeMode != SelectionCell && TypeMode != SelectionEdge ) {
- QAD_MessageBox::warn1( visuGUI->myDesktop,
- tr ("WARNING"),
- tr ("Not Cell/Edge selection mode"),
- tr ("VISU_BUT_OK") );
- return;
- }
- VISU_Actor* ActorTmp;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy);
- //srn: Added check if anObject is Null, then break
-// if(CORBA::is_nil(anObject)) break;
-
- VISU::Prs3d_i* aPrsObject = NULL;
- if(!CORBA::is_nil(anObject))
- aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
- if(aPrsObject){
- //aPrsObject->SetIO(anIO);
- //ActorTmp = aPrsObject->GetActor();
- //UpdateViewer(ActorTmp);
- ActorTmp = visuGUI->UpdateViewer(aPrsObject);
- } else {
- ActorTmp = ActorSelected(visuGUI->myDesktop,true,&TypeMode);
- }
- if (ActorTmp==NULL)
- return;
-
- bool ok=FALSE;
- vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper());
- Mapper->SetInput(ActorTmp->DataSource);
- vtkDataSet *Data=Mapper->GetInput();
- int nbCells=Data->GetNumberOfCells();
- int selectedCell = SALOMEGUI_SetValueDlg::getInteger( tr("Cell selection"),
- tr("Cell number:" ),
- 0,
- &ok,
- visuGUI->myDesktop );
- if ( ok && theRenderer && selectedCell > 0 && selectedCell <= nbCells )
- if (ok && theRenderer )
- Selection->HighlightCell(selectedCell , ActorTmp , theRenderer);
-}
-
-//=====================================================================================
-// function : DefinePopup()
-// purpose :
-//=====================================================================================
-void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
-{
- VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
- theObject = "";
- theContext = "";
-}
-
-
-//=====================================================================================
-// function : CustomPopup()
-// purpose :
-//=====================================================================================
-bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
- const QString & theParent, const QString & theObject)
-{
- int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
- VisuGUI::GetOrCreateVisuGUI(parent);
- QAD_ResourceMgr* rmgr = parent->createResourceManager();
-
- bool isVTKViewer = (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
- thePopup->clear();
-
- SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection());
- if ( Sel->IObjectCount() == 0 ) {
- if ( theParent == "Viewer" && isVTKViewer)
- // Available only for VTK viewer
- thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
- return false;
- }
+ VisuGUI_NonIsometricDlg* m_NonIsoDlg =
+ new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
+ false, Qt::WDestructiveClose);
+ m_NonIsoDlg->show();
+}
- VISU::Storable::TRestoringMap aMap;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(VisuGUI::myActiveStudy,&anIO,&aMap);
- bool isExist;
- string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
- if(!isExist) aComment = "NONE";
- SALOMEDS::GenericAttribute_var anAttr;
-
- if (!CORBA::is_nil(anObject)) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (!CORBA::is_nil(aVisuObj)) {
- if( Sel->IObjectCount() > 1) return false;
-
- VISU::VISUType aType = aVisuObj->GetType();
- MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
- switch (aType) {
- case VISU::TVISUGEN:
- thePopup->insertItem("Import From File", visuGUI, SLOT(ImportFromFile()));
- break;
-
- case VISU::TRESULT:
- //thePopup->insertItem("Create Mesh", visuGUI, SLOT(CreateMesh()));
- thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile()));
- //thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
- break;
-
- case VISU::TTABLE:
- thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
- thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
- thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
- thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
- thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
- }
- break;
-
- case VISU::TCURVE:
- if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) )
- thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
- thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
- else
- thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
- thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
- }
- break;
-
- case VISU::TCONTAINER:
- if( !CORBA::is_nil( anObject ) ) {
- CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
- if( !CORBA::is_nil( aCnt ) ) {
- VISU::Container_i* container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aCnt ) );
- if ( container && container->GetNbCurves() > 0 ) {
- if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) )
- thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
- thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
- thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
- thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
- }
- }
- }
- }
- break;
-
- default: // Presentation
- {
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
- if (aPrsObject) {
- VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject);
- if (isVTKViewer) {
- // Add Presentation menu
- if ((aType != VISU::TSTREAMLINES) && anVISUActor) {
- QPopupMenu* aPresMenu = new QPopupMenu(VisuGUI::myDesktop);
- aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
- aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
- aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
- if (anVISUActor->IsShrinkable) {
- if (anVISUActor->IsShrunk)
- aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
- else
- aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
- }
- thePopup->insertItem("Representation", aPresMenu);
- }
-
- // Add Properties
- QPopupMenu* aPropMenu = new QPopupMenu(VisuGUI::myDesktop);
- if ((aType == VISU::TMESH) ||
- (aType == VISU::TDEFORMEDSHAPE) ||
- (aType == VISU::TVECTORS) ||
- (aType == VISU::TSTREAMLINES)) // Mesh, deformed shape, vectors
- aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
- if (aType == VISU::TMESH)
- aPropMenu->insertItem("Outline Color", visuGUI, SLOT(ChangeOutlineColor()));
-
- if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES))
- aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
- aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
- thePopup->insertItem("Properties", aPropMenu);
-
- thePopup->insertSeparator();
- }
- thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
- if (aType != VISU::TMESH) {
- if (aType != VISU::TSCALARMAP)
- thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
- thePopup->insertItem("Edit Scalar Bar...", visuGUI, SLOT(EditScalarBar()));
-
- if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES) && isVTKViewer)
- thePopup->insertItem("Animate", visuGUI, SLOT(Sweep()));
- }
- if (isVTKViewer) {
- if ( theParent == "Viewer" &&
- ( aType == VISU::TMESH ||
- aType == VISU::TSCALARMAP ||
- aType == VISU::TDEFORMEDSHAPE ) ) {
- thePopup->insertSeparator();
- if ( Sel->SelectionMode() == SelectionPoint ) {
- thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint()));
- thePopup->insertItem("Select a Point", visuGUI, SLOT(SelectPoint()));
- }
- else if ( Sel->SelectionMode() == SelectionCell || Sel->SelectionMode() == SelectionEdge ) {
- thePopup->insertItem("Results on Cell", visuGUI, SLOT(InfoOnCell()));
- thePopup->insertItem("Select a Cell", visuGUI, SLOT(SelectCell()));
- }
- }
- thePopup->insertSeparator();
- if (visuGUI->IsDisplayed(aPrsObject) )
- thePopup->insertItem("Hide", visuGUI, SLOT(ErasePrs()));
- else
- thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
-
- thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
- }
- if (aType != VISU::TMESH)
- thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
- thePopup->insertSeparator();
- thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
- }
- }
- }
- return false;
- }
- else {
- // possibly this is the MED field/mesh and suppot objects
- /*CORBA::Object_var anObj = SALOME_MED::FIELD::_narrow( anObject );
- if( !CORBA::is_nil( anObj ) ) {
- thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
- return false;
- }
- anObj = SALOME_MED::MESH::_narrow( anObject );
- if( !CORBA::is_nil( anObj ) ) {
- thePopup->insertItem( "Import Mesh", visuGUI, SLOT( ImportMedField() ) );
- return false;
- }
- anObj = SALOME_MED::GROUP::_narrow( anObject );
- if( !CORBA::is_nil( anObj ) ) {
- thePopup->insertItem( "Import Group", visuGUI, SLOT( ImportMedField() ) );
- return false;
- }
- anObj = SALOME_MED::FAMILY::_narrow( anObject );
- if( !CORBA::is_nil( anObj ) ) {
- thePopup->insertItem( "Import Family", visuGUI, SLOT( ImportMedField() ) );
- return false;
+void
+VisuGUI::
+OnCubeAxes()
+{
+ //Show dialog that allows to select scale function and corresponding scale factor
+ VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
+ aDlg->show();
+}
+
+void
+VisuGUI::
+OnMergeScalarBars()
+{
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+
+ SALOME_ListIteratorOfListIO It (aListIO);
+
+ // first find the bounds
+ double aMin, aMax; bool first = true;
+ for (; It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject)& anIO = It.Value();
+ std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
+ if (!aPrsList.empty()) {
+ for (int i = 0, n = aPrsList.size(); i < n; i++) {
+ VISU::Prs3d_i* aPrsObject = aPrsList[i];
+ if (aPrsObject) {
+ VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
+ if (aScalar) {
+ if (first) {
+ first = false;
+ aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
+ } else {
+ if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
+ if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
+ }
+ }
+ }
}
- anObj = SALOME_MED::SUPPORT::_narrow( anObject );
- if( !CORBA::is_nil( anObj ) ) {
- thePopup->insertItem( "Import Support", visuGUI, SLOT( ImportMedField() ) );
- return false;
- }*/
}
}
- int aType = ObjectTypes.find( aComment.c_str() );
- if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - aComment = "<<aComment<<"; aType = "<<aType);
- SALOMEDS::SObject_var obj = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
- if ( aType < 0 ) {
- // possibly this is Table SObject
- if ( !obj->_is_nil() && ( obj->FindAttribute( anAttr, "AttributeTableOfInteger" )
- || obj->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
- thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
- thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
- }
- return false;
- }
- if(aComment == "ENTITY" || aComment == "FAMILY" || aComment == "GROUP")
- thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
- switch (aType) {
- case 0: // Field
- if (getValue(obj, "myNbTimeStamps").toLong() > 1)
- thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
- break;
-
- case 6: // VIEW3D node
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
- // Available only for VTK viewer
- thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
- thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
- }
- thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
- thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
- break;
- //case 13: // Mesh node
- //thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
- //break;
-
- case 18: { // Timestamp
-// if( isStudyLocked(VisuGUI::myActiveStudy->getStudyDocument()))
-// return false;
- int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
- thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ),
- "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
- thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
- "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
- thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
- "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
- if(aNunComponent > 1){
- thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
- "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
- thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
- "Vectors...", visuGUI, SLOT(CreateVectors()));
- thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
- "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
+ // set the computed range to every selected ScalarMap
+ bool update = false;
+ for (It.Initialize(aListIO); It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject)& anIO = It.Value();
+ std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
+ if (!aPrsList.empty()) {
+ for (int i = 0, n = aPrsList.size(); i < n; i++) {
+ VISU::Prs3d_i* aPrsObject = aPrsList[i];
+ if(aPrsObject){
+ VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
+ if (aScalar) {
+ aScalar->SetRange(aMin, aMax);
+ RecreateActor(this, aScalar);
+ update = true;
+ }
+ }
+ }
}
}
+ if (update) {
+ if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
+//if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
+ vw->getRenderer()->ResetCameraClippingRange();
+ vw->Repaint();
+//}
+ }
}
- return false;
}
-//===========================================================================
-// BuildPresentation
-//===========================================================================
-void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
+void
+VisuGUI::
+OnFreeScalarBars()
{
- BEGIN_OF("VisuGUI::BuildPresentation");
-
- if (theIO.IsNull()) {
- MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
- return;
- }
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
- /* Create or retrieve an object VisuGUI */
+ SALOME_ListIteratorOfListIO It (aListIO);
- VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
-
- SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
-
- vtkRenderer *Renderer = GetRenderer(visuGUI->myActiveStudy);
-
- SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
- SCRUTE(aSObj);
- if (aSObj -> _is_nil() ) {
- MESSAGE("No SObject for interacative object is found");
- return;
- }
-
- CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
- if(!CORBA::is_nil(anObject)) {
-
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
- if ( !aPrsObject ) {
- MESSAGE("The object is not VISU::Prs3d_i");
- return;
- }
- VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
- if ( ! SelectedActor )
- SelectedActor = aPrsObject -> CreateActor();
- SCRUTE(SelectedActor);
- if ( SelectedActor == NULL ) {
- MESSAGE("VisuGUI::BuildPresentation(): actor doesn't exist in Render");
- return;
- }
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- vf->AddActor(SelectedActor);
- if(SelectedActor->HasScalarBar()){
- Renderer->AddActor2D(SelectedActor->getScalarBar());
+ // restore the source range for every ScalarMap
+ bool update = false;
+ for (; It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject)& anIO = It.Value();
+ std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
+ if (!aPrsList.empty()) {
+ for (int i = 0, n = aPrsList.size(); i < n; i++) {
+ VISU::Prs3d_i* aPrsObject = aPrsList[i];
+ if (aPrsObject) {
+ VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
+ if (aScalar) {
+ aScalar->SetSourceRange();
+ RecreateActor(this, aScalar);
+ update = true;
+ }
+ }
+ }
}
}
- else {
- MESSAGE("CORBA::is_nil(anObject) = true");
+ if (update) {
+ if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
+//if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
+ vw->getRenderer()->ResetCameraClippingRange();
+ vw->Repaint();
+//}
}
- END_OF("VisuGUI::BuildPresentation");
-
+ }
}
-extern "C"
+void
+VisuGUI::
+OnTranslatePrs()
{
-
- bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
- {
- //MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID);
- return VisuGUI::OnGUIEvent(theCommandID, parent);
- }
-
- bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
- {
- MESSAGE("VisuGUI::OnKeyPress ");
- return VisuGUI::OnKeyPress (pe, parent, studyFrame);
- }
-
- bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
- {
- //MESSAGE("VisuGUI::OnMousePress ");
- return VisuGUI::OnMousePress (pe, parent, studyFrame);
- }
-
- bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
- {
- //MESSAGE("VisuGUI::OnMouseMove ");
- return VisuGUI::OnMouseMove (pe, parent, studyFrame);
- }
+ if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
+ VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
- bool SetSettings ( QAD_Desktop* parent )
- {
- return VisuGUI::setSettings( parent );
- }
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
- bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
- const QString & theParent, const QString & theObject )
- {
- return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
- }
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
- void definePopup ( QString & theContext, QString & theParent, QString & theObject )
- {
- VisuGUI::DefinePopup( theContext, theParent, theObject );
+ SALOME_ListIteratorOfListIO It (aListIO);
+ for (; It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject)& anIO = It.Value();
+ if (anIO->hasEntry()) {
+ _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+ if (aSObject) {
+ CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
+ if (!CORBA::is_nil(aCORBAObject)) {
+ PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
+ if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
+ aDlg->addPresentation(aPrsObject);
+ }
+ }
+ }
+ }
}
+ if (aDlg->getPrsCount() > 0)
+ aDlg->show();
+ else
+ delete aDlg;
+}
- bool activeStudyChanged ( QAD_Desktop* parent )
- {
- //VisuGUI::activeStudyChanged( parent );
- }
- void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
- {
- VisuGUI::BuildPresentation(theIO);
+void
+VisuGUI::
+OnArrangeActors()
+{
+ SVTK_ViewWindow* vw = GetViewWindow();
+ if (vw) {
+ ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
+ aDlg->exec();
+ delete aDlg;
}
-
}
-// ====================================================================================================================
-// ===================================================================================================================
-bool VisuGUI::getObjectRef( QAD_Desktop* parent, SALOMEDS::SObject_ptr obj,
- _CORBA_ObjRef_OUT_arg< SALOMEDS::_objref_SObject, SALOMEDS::SObject_Helper > objres,
- const char* Type) {
-
- VisuGUI::GetOrCreateVisuGUI(parent);
- SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument();
- SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(obj);
- SALOMEDS::SObject_var RefObj;
-
- for (; it->More();it->Next()) {
- SALOMEDS::SObject_var Fils = it->Value();
-
- if ( Fils->ReferencedObject( RefObj ) ) {
- SALOMEDS::SComponent_var theComponent = RefObj->GetFatherComponent();
- Standard_CString nameComponent = theComponent->ComponentDataType();
+void
+VisuGUI::
+initialize( CAM_Application* theApp )
+{
+ SalomeApp_Module::initialize( theApp );
- if ( TCollection_AsciiString(nameComponent).IsEqual(strdup(Type)) ) {
- objres = SALOMEDS::SObject::_narrow(RefObj);
- return true;
- }
- }
- }
- return false;
+ createActions();
+ createMenus();
+ createToolBars();
+ createPopupMenus();
}
-//////////////////////////////////////////////////////////////////////////////////
-//////////////// CHANGE ACTOR COLOR ////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-// change actor color
-// In : Name of Actor
-//
-//
-
-void VisuGUI::NewColor(VISU_Actor *Actor)
+void
+VisuGUI::
+createActions()
{
- float oldcolor[3],newcolor[3];
- Actor->GetProperty()->GetColor(oldcolor);
- QColor colorold;
- colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255);
- QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() );
+ QPixmap aPixmap;
+ QWidget* aParent = application()->desktop();
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ // Create actions
+ createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
+ tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
+ this, SLOT(OnImportFromFile()));
+
+ createAction( VISU_EXPLORE_MED, "", QIconSet(),
+ tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
+ this, SLOT(OnExploreMEDFile()));
+
+ createAction( VISU_IMPORT_TABLE, "", QIconSet(),
+ tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
+ this, SLOT(OnImportTableFromFile()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
+ createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap),
+ tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
+ this, SLOT(OnCreateScalarMap()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
+ createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap),
+ tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
+ this, SLOT(OnCreateDeformedShape()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
+ createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap),
+ tr("MEN_VECTORS"), "", 0, aParent, false,
+ this, SLOT(OnCreateVectors()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
+ createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap),
+ tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
+ this, SLOT(OnCreateIsoSurfaces()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
+ createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap),
+ tr("MEN_CUT_PLANES"), "", 0, aParent, false,
+ this, SLOT(OnCreateCutPlanes()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
+ createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap),
+ tr("MEN_STREAM_LINES"), "", 0, aParent, false,
+ this, SLOT(OnCreateStreamLines()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
+ createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap),
+ tr("MEN_CUT_LINES"), "", 0, aParent, false,
+ this, SLOT(OnCreateCutLines()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
+ createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
+ tr("MEN_PLOT_3D"), "", 0, aParent, false,
+ this, SLOT(OnCreatePlot3D()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
+ createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
+ tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
+ this, SLOT(OnCreatePlot2dView()));
+
+ createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
+ tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
+ this, SLOT(OnDeleteObjects()));
+
+ createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(),
+ tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
+ this, SLOT(OnShowTable()));
+
+ createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(),
+ tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
+ this, SLOT(OnPlotData()));
+
+ createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(),
+ tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
+ this, SLOT(OnExportTableToFile()));
+
+ createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
+ tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
+ this, SLOT(OnImportMedField()));
+
+ createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
+ tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
+ this, SLOT(OnImportMedField()));
+
+ createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
+ tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
+ this, SLOT(OnImportMedField()));
+
+ createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(),
+ tr("MEN_CREATE_PRS"), "", 0, aParent, false,
+ this, SLOT(OnCreateMesh()));
+
+ createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
+ tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
+ this, SLOT(OnCreateManyMesh()));
+
+ createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
+ tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
+ this, SLOT(OnTranslatePrs()));
+
+ createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
+ tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
+ this, SLOT(OnMergeScalarBars()));
+
+ createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
+ tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
+ this, SLOT(OnFreeScalarBars()));
+
+ createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(),
+ tr("MEN_ERASE"), "", 0, aParent, false,
+ this, SLOT(OnErasePrs()));
+
+ createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(),
+ tr("MEN_DISPLAY"), "", 0, aParent, false,
+ this, SLOT(OnDisplayPrs()));
+
+ createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(),
+ tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
+ this, SLOT(OnDisplayOnlyPrs()));
+
+ createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(),
+ tr("MEN_COPY_PRS"), "", 0, aParent, false,
+ this, SLOT(OnCopyPresentation()));
+
+ createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(),
+ tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
+ this, SLOT(OnCurveProperties()));
+
+ createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
+ this, SLOT(OnRename()));
+
+ createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(),
+ tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
+ this, SLOT(OnEditContainer()));
+
+ createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(),
+ tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
+ this, SLOT(OnClearContainer()));
+
+ createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
+ tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
+ this, SLOT(OnSaveViewParams()));
+ createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
+ tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
+ this, SLOT(OnSaveViewParams()));
+
+ createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
+ tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
+ this, SLOT(OnRestoreViewParams()));
- if (!colornew.isValid()) return;
+ //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
+ // tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
+ // this, SLOT(OnDeleteObjects()));
- newcolor[0]=colornew.red()/255.;
- newcolor[1]=colornew.green()/255.;
- newcolor[2]=colornew.blue()/255.;
- Actor->GetProperty()->SetColor(newcolor);
- if (Actor->getPrs3d())
- Actor->getPrs3d()->SetColor(newcolor);
-}
+ createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
+ tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
+ this, SLOT(OnArrangeActors()));
-void VisuGUI::NewOutlineColor(VISU_Actor *Actor)
-{
- float oldcolor[3],newcolor[3];
- Actor->EdgeDevice->GetProperty()->GetColor(oldcolor);
- QColor colorold;
- colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255);
- QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() );
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
+ createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap),
+ tr("MEN_POINTS"), "", 0, aParent, false,
+ this, SLOT(OnMakePoints()));
- if (!colornew.isValid()) return;
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
+ createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap),
+ tr("MEN_WIREFRAME"), "", 0, aParent, false,
+ this, SLOT(OnMakeWireframe()));
- SALOMEDS::Color aColor;
- aColor.R = newcolor[0]=colornew.red()/255.;
- aColor.G = newcolor[1]=colornew.green()/255.;
- aColor.B = newcolor[2]=colornew.blue()/255.;
- Actor->EdgeDevice->GetProperty()->SetColor(newcolor);
- if (Actor->getPrs3d())
- dynamic_cast<VISU::Mesh_i*>(Actor->getPrs3d())->SetLinkColor(aColor);
-}
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
+ createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap),
+ tr("MEN_SURFACE"), "", 0, aParent, false,
+ this, SLOT(OnMakeSurface()));
+
+ createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(),
+ tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
+ this, SLOT(OnMakeInsideframe()));
+
+ createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(),
+ tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
+ this, SLOT(OnMakeSurfaceframe()));
+
+ createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(),
+ tr("MEN_SHRINK"), "", 0, aParent, false,
+ this, SLOT(OnMakeShrink()));
+
+ createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(),
+ tr("MEN_UNSHRINK"), "", 0, aParent, false,
+ this, SLOT(OnMakeShrink()));
+
+ createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(),
+ tr("MEN_CELL_COLOR"), "", 0, aParent, false,
+ this, SLOT(OnChangeColor()));
+
+ createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(),
+ tr("MEN_COLOR"), "", 0, aParent, false,
+ this, SLOT(OnChangeColor()));
+
+ createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(),
+ tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
+ this, SLOT(OnChangeWireframeColor()));
+
+ createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(),
+ tr("MEN_OPACITY"), "", 0, aParent, false,
+ this, SLOT(OnChangeOpacity()));
+
+ createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(),
+ tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
+ this, SLOT(OnChangeLines()));
+
+
+ createAction( VISU_EDIT_SCALARMAP, tr("MEN_EDIT_PRS"), QIconSet(),
+ tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+ this, SLOT(OnEditScalarMap()));
+
+ createAction( VISU_EDIT_DEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIconSet(),
+ tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+ this, SLOT(OnEditDeformedShape()));
+
+ createAction( VISU_EDIT_CUTPLANES, tr("MEN_EDIT_PRS"), QIconSet(),
+ tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+ this, SLOT(OnEditCutPlanes()));
+
+ createAction( VISU_EDIT_CUTLINES, tr("MEN_EDIT_PRS"), QIconSet(),
+ tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+ this, SLOT(OnEditCutLines()));
+
+ createAction( VISU_EDIT_ISOSURFACE, tr("MEN_EDIT_PRS"), QIconSet(),
+ tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+ this, SLOT(OnEditIsoSurfaces()));
+
+ createAction( VISU_EDIT_VECTORS, tr("MEN_EDIT_PRS"), QIconSet(),
+ tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+ this, SLOT(OnEditVectors()));
+
+ createAction( VISU_EDIT_STREAMLINES, tr("MEN_EDIT_PRS"), QIconSet(),
+ tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+ this, SLOT(OnEditStreamLines()));
+
+ createAction( VISU_EDIT_PLOT3D, tr("MEN_EDIT_PRS"), QIconSet(),
+ tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+ this, SLOT(OnEditPlot3D()));
+
+
+ createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(),
+ tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
+ this, SLOT(OnCreateTable()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
+ createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap),
+ tr("MEN_SWEEP"), "", 0, aParent, false,
+ this, SLOT(OnSweep()));
+
+ createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
+ tr("MEN_CLIPPING"), "", 0, aParent, false,
+ this, SLOT(OnClippingPlanes()));
+
+ createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
+ tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
+ this, SLOT(OnSelectionInfo()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
+ createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
+ tr("MEN_ANIMATION"), "", 0, aParent, false,
+ this, SLOT(OnTimeAnimation()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
+ createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
+ tr("MEN_ERASE_ALL"), "", 0, aParent, false,
+ this, SLOT(OnEraseAll()));
-//////////////////////////////////////////////////////////////////////////////////
-//////////////// CHANGE ACTOR OPACITY ////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-// change actor opacity
-// In : Name of Actor
-//
-// Use CursorDlg to select a value between 0 and 100
-//
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
+ createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
+ tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
+ //this, SLOT(OnEraseAll()));
+ this);
-void VisuGUI::NewOpacity(VISU_Actor *Actor)
-{
-
- VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
-
- float oldopac,newopac;
- int intopac;
- CursorDlg->Comment1->setText( tr( "Set value between") );
- CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
- oldopac=Actor->GetProperty()->GetOpacity();
- intopac=int(oldopac*100.);
- CursorDlg->SpinBox1->setMinValue(0);
- CursorDlg->SpinBox1->setMaxValue(100);
- CursorDlg->SpinBox1->setValue(intopac);
-
- int ret = CursorDlg->exec();
- if (ret == 1)
- {
- intopac = CursorDlg->SpinBox1->value() ;
- newopac = intopac/100.;
- Actor->GetProperty()->SetOpacity(newopac);
- }
- delete CursorDlg;
-}
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
+ createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
+ tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
+ //this, SLOT(OnEraseAll()));
+ this);
-//////////////////////////////////////////////////////////////////////////////////
-//////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-// change actor linewidth
-// In : Name of Actor
-//
-// Use CursorDlg to select a value between 0 and 10
-//
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
+ createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
+ tr("MEN_SCALING"), "", 0, aParent, false,
+ this, SLOT(OnScaling()));
-void VisuGUI::NewLinewidth(VISU_Actor *Actor)
-{
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
+ createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
+ tr("MEN_CUBE_AXES"), "", 0, aParent, false,
+ this, SLOT(OnCubeAxes()));
- VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
-
- float oldlwid,newlwid;
- int intlwid;
- CursorDlg->Comment1->setText("Set value between");
- CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
- oldlwid=Actor->GetProperty()->GetLineWidth();
- intlwid=int(oldlwid);
- CursorDlg->SpinBox1->setMinValue(1);
- CursorDlg->SpinBox1->setMaxValue(10);
- CursorDlg->SpinBox1->setValue(intlwid);
-
- int ret = CursorDlg->exec();
- if (ret == 1) {
- intlwid = CursorDlg->SpinBox1->value() ;
- newlwid = intlwid;
- Actor->GetProperty()->SetLineWidth(newlwid);
- }
- delete CursorDlg;
+ createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
+ tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
+ this, SLOT(OnShowAnimation()));
}
-/* ======================================================================================== */
-/* Setting parameters for Scalar Bar */
-/* ======================================================================================== */
-void VisuGUI::ChangeScalarBar()
+void
+VisuGUI::
+createMenus()
{
- VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
- Scbar->initFromResources();
- int ret = Scbar->exec();
- if ( ret ) {
- Scbar->storeToResources();
- }
- delete Scbar;
-}
-
-/* ======================================================================================== */
-/* Setting parameters for Sweeping */
-/* ======================================================================================== */
-void VisuGUI::SetSweepingPreferences()
+ // Add actions to menus
+ int aMenuId;
+ aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
+ createMenu( separator(), aMenuId, -1, 10 );
+ createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
+ createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
+ createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
+
+ aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
+ createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
+ createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
+ createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
+ createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
+ createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
+ createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
+ createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
+ createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
+
+ aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
+ createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
+
+ aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
+ int parentId =
+ createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
+ createMenu( VISU_POINTS, parentId, 10 ); // points
+ createMenu( VISU_WIREFRAME, parentId, 10 ); // wireframe
+ createMenu( VISU_SURFACE, parentId, 10 ); // surface
+ createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
+ createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
+ createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
+ createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
+ createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
+}
+
+void
+VisuGUI::
+createToolBars()
{
- float tempo=0.2;
- int cycles=1;
- int steps=20;
-
- QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
- if ( !Tempo.isEmpty() )
- tempo = Tempo.toFloat();
-
- QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
- if ( !Cycles.isEmpty() )
- cycles = Cycles.toInt();
-
- QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
- if ( !Steps.isEmpty() )
- steps = Steps.toInt();
+ int aToolId = createTool(tr("TOOL_VISUALISATION"));
+ createTool( VISU_SCALAR_MAP, aToolId );
+ createTool( VISU_DEFORMED_SHAPE, aToolId );
+ createTool( VISU_VECTORS, aToolId );
+ createTool( VISU_ISO_SURFACES, aToolId );
+ createTool( VISU_CUT_PLANES, aToolId );
+ createTool( VISU_CUT_LINES, aToolId );
+ createTool( VISU_STREAM_LINES, aToolId );
+ createTool( VISU_PLOT_3D, aToolId );
+
+ aToolId = createTool(tr("TOOL_REPRESENTATION"));
+ createTool( VISU_POINTS, aToolId );
+ createTool( VISU_WIREFRAME, aToolId );
+ createTool( VISU_SURFACE, aToolId );
+ createTool( VISU_ERASE_ALL, aToolId );
+ createTool( VISU_GLOBAL_SELECTION, aToolId );
+ createTool( VISU_PARTIAL_SELECTION, aToolId );
+ createTool( VISU_SCALING, aToolId );
+ createTool( VISU_CUBE_AXES, aToolId );
+}
+
+void
+VisuGUI::
+createPopupMenus()
+{
+ // Prepare popup menus
+ QtxPopupMgr* mgr = popupMgr();
- VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
+ // VISU root commands
+ mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED 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
+
+ //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
+
+ // create
+ mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
+ mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
+ mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
+ mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
+ mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
+ mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
+ mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
+ mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
+
+ mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
+ mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
+
+ mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
+
+ // edit
+ mgr->insert( action( VISU_EDIT_SCALARMAP ), -1, -1, -1 );
+ mgr->insert( action( VISU_EDIT_DEFORMEDSHAPE ), -1, -1, -1 );
+ mgr->insert( action( VISU_EDIT_CUTPLANES ), -1, -1, -1 );
+ mgr->insert( action( VISU_EDIT_CUTLINES ), -1, -1, -1 );
+ mgr->insert( action( VISU_EDIT_ISOSURFACE ), -1, -1, -1 );
+ mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 );
+ mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 );
+ mgr->insert( action( VISU_EDIT_PLOT3D ), -1, -1, -1 );
+ mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
+
+ // rename
+ mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
+
+ // copy
+ mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
+
+ // delete
+ mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
+
+ // table commands
+ //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
+ //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
+ //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
+
+ mgr->insert( separator(), -1, -1, -1 );
+
+ mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
+ mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
+ mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
+
+ // "Representation" submenu
+ int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
+ mgr->insert( action( VISU_POINTS ) , parentId, -1, -1 ); // points
+ mgr->insert( action( VISU_WIREFRAME ) , parentId, -1, -1 ); // wireframe
+ mgr->insert( action( VISU_SURFACE ) , parentId, -1, -1 ); // surface
+ mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
+ mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
+ mgr->insert( action( VISU_SHRINK ) , parentId, -1, -1 ); // shrink
+ mgr->insert( action( VISU_UNSHRINK ) , parentId, -1, -1 ); // unshrink
+
+ // "Properties" submenu
+ parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
+ mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
+ mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
+ mgr->insert( action( VISU_COLOR ) , parentId, -1, -1 ); // color
+ mgr->insert( action( VISU_OPACITY ) , parentId, -1, -1 ); // opacity
+ mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
+
+ mgr->insert( separator(), -1, -1, -1 );
+
+ // Other presentations management
+ mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
+ mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
+
+ mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
+ mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
+
+ mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
+ mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
+
+ mgr->insert( separator(), -1, -1, -1 );
+
+ // view parameters commands
+ mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
+ mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
+ mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
+ //mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
+
+ 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_SELECTION_INFO ), -1, -1, -1 ); // Selection info
+
+ // Rules
+
+ QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
+ "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
+
+ // VISU root commands
+ QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
+ mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
+ mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
+ mgr->setRule( action( VISU_PLOT2D ), aRule, true );
+
+ // timestamp commands
+ aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTIMESTAMP'";
+ mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
+ mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
+ mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
+ mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
+ mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
+ aRule += " and nbComponents>1";
+ mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
+ mgr->setRule( action( VISU_VECTORS ), aRule, true );
+ mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
+
+ // display/erase commands
+ QString andInvisible = " and (((not isVisible) and isActiveView) or (not isActiveView))";
+ QString aTableOrCont = "(type='VISU::TTABLE' and nbChildren>0) or type='VISU::TCONTAINER'";
+ QString orCurveVisible = "or (type='VISU::TCURVE' and isVisible)";
+ QString orCurveInvisible = "or (type='VISU::TCURVE'" + andInvisible + ")";
+ QString aPrsVisible = "(($type in {'VISU::TMESH' " + aPrsAll + "}) and isVisible)";
+ QString aPrsInvisible = "(($type in {'VISU::TMESH' " + aPrsAll + "})" + andInvisible + ")";
+
+ QString anEraseRule = "selcount>0 and (" + aPrsVisible +
+ " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveVisible + ")))";
+
+ QString aDisplayRule = "selcount>0 and (" + aPrsInvisible +
+ " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveInvisible + ")))";
+
+ QString aDOnlyRule = "selcount>0 and (($type in {'VISU::TMESH' " + aPrsAll + "})"
+ " or (client='ObjectBrowser' and ((type='VISU::TTABLE' and nbChildren>0) or"
+ " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))))";
+
+ mgr->setRule( action( VISU_ERASE ), anEraseRule, true );
+ mgr->setRule( action( VISU_DISPLAY ), aDisplayRule, true );
+ mgr->setRule( action( VISU_DISPLAY_ONLY ), aDOnlyRule, true );
+
+ aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
+ mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
+
+ aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
+ mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
+ mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
+
+ // view parameters
+ aRule = "selcount=1 and type='VISU::TVIEW3D'";
+ mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
+ mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
+ mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
+ //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
+
+ mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
+
+ // 3D presentations commands
+ QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
+ QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
+ QString aSurfType = " and $type in {'VISU::TMESH'}";
+ QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
+ "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
+ QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
+ "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
+
+ aRule = "selcount=1";
+ mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
+
+ // "Representation" submenu
+ QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
+ QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
+ QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
+ QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
+ QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
+
+ mgr->setRule( action( VISU_POINTS ) , aRule + aPrsType + aNotPoints, true );
+ mgr->setRule( action( VISU_WIREFRAME ) , aRule + aPrsType + aNotWirefr, true );
+ mgr->setRule( action( VISU_SURFACE ) , aRule + aPrsType + aNotSurfac, true );
+ mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
+ mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
+
+ mgr->setRule( action( VISU_SHRINK ) , aRule + aShrinkType + " and isShrunk=0", true );
+ mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
+
+ // "Properties" submenu
+ mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
+ mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
+ mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
+ " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
+ "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
+ mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
+ mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
+
+ // rename command
+ QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
+
+ aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})";
+ mgr->setRule( action( VISU_RENAME ), aRule, true );
+
+ // copy presentation command
+ aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
+ mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
+
+ // curve commands
+ aRule = "selcount=1 and type='VISU::TCURVE'";
+ mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
+
+ // curve container commands
+ aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'";
+ mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
+ mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
+
+ mgr->setRule( action( VISU_EDIT_SCALARMAP ),
+ "selcount=1 and type='VISU::TSCALARMAP'", true );
+ mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
+ "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true );
+ mgr->setRule( action( VISU_EDIT_CUTPLANES ),
+ "selcount=1 and type='VISU::TCUTPLANES'", true );
+ mgr->setRule( action( VISU_EDIT_CUTLINES ),
+ "selcount=1 and type='VISU::TCUTLINES'", true );
+ mgr->setRule( action( VISU_EDIT_ISOSURFACE ),
+ "selcount=1 and type='VISU::TISOSURFACE'", true );
+ mgr->setRule( action( VISU_EDIT_VECTORS ),
+ "selcount=1 and type='VISU::TVECTORS'", true );
+ mgr->setRule( action( VISU_EDIT_STREAMLINES ),
+ "selcount=1 and type='VISU::TSTREAMLINES'", true );
+ mgr->setRule( action( VISU_EDIT_PLOT3D ),
+ "selcount=1 and type='VISU::TPLOT3D'", true );
+
+ aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
+ mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
+
+ aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
+ mgr->setRule( action( VISU_SWEEP ), aRule, true );
+
+ // "Selection info" popup item
+ aRule = "client='VTKViewer' and selcount=1" + aInsideType;
+ mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
+
+ aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
+ mgr->setRule( action( VISU_ANIMATION ), aRule, true );
+
+ aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
+ mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
+ mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
+
+ //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
+ //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
+}
+
+//***************************************************************************
+void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
+{
+ SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
- Sweep->setTimeStep( tempo );
- Sweep->setNbCycles( cycles );
- Sweep->setNbSteps ( steps );
+ OB_Browser* ob = getApp()->objectBrowser();
+ bool isOBClient = (ob && theClient == ob->popupClientType());
- if ( Sweep->exec() )
- {
- tempo = Sweep->getTimeStep();
- cycles = Sweep->getNbCycles();
- steps = Sweep->getNbSteps();
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
- QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
- QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
- QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
- }
- delete Sweep;
-}
-
-/* ======================================================================================== */
-/* Returns Visu input files directory (default is CSF_PATHData) */
-/* ======================================================================================== */
-QString VisuGUI::getVisuInputDir()
-{
- QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
- if ( Tmp.isEmpty() )
- Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
- Tmp = QAD_Tools::addSlash(Tmp);
- return (Tmp);
-}
-
-/* ======================================================================================== */
-/* Returns Visu output files directory (default is InputDir) */
-/* ======================================================================================== */
-QString VisuGUI::getVisuOutputDir()
-{
- QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
- if ( Tmp.isEmpty() )
- {
- QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
- if ( Tmp2.isEmpty() )
- Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
- else
- Tmp = Tmp2;
- }
- Tmp = QAD_Tools::addSlash(Tmp);
- return (Tmp);
-}
-
-
-/* ======================================================================================== */
-/* Global Method for Scalar Map */
-/* ======================================================================================== */
-VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
- if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOMEDS::SObject_var aSObj = theField->GetFather();
- aSObj = aSObj->GetFather();
- aSObj = aSObj->GetFather();
- aSObj = aSObj->GetFather();
- CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
- if(CORBA::is_nil(anObject)) return NULL;
- theResult = VISU::Result::_narrow(anObject);
- VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject));
- if(pResult == NULL)
- QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("No Available data in selection"),
- tr ("VISU_BUT_OK"));
- return pResult;
-}
-
-#define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
-PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
- const char* theMeshName, VISU::Entity theEntity, \
- const char* theFieldName, double theTimeId) {\
- VISU::Result_var aResult; \
- VISU::Result_i* pResult = CreatePresent(theField,aResult); \
- if(pResult){ \
- if(PRSTYPE::IsPossible(pResult,theMeshName,(VISU::Entity)theEntity,theFieldName,theTimeId)){ \
- QApplication::setOverrideCursor( Qt::waitCursor ); \
- VISU::VISU_Gen_var aVisuGen = VISU::GetVisu(); \
- CORBA::Object_var anObject = \
- aVisuGen->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
- QApplication::restoreOverrideCursor(); \
- if(CORBA::is_nil(anObject)) return NULL; \
- return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject)); \
- } \
- } else { \
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
- tr ("The presentation can't be builded."), \
- tr ("VISU_BUT_OK") ); \
- } \
- return NULL; \
-}
-
-CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
-CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
-CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
-CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
-CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
-CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
-
-
-#define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
-bool FNAME(SALOMEDS::SObject_var theField) { \
- VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
- bool isExist; \
- QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
- if(!isExist && aType.toInt() != VISU::TTIMESTAMP) return false; \
- QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
- QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
- QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
- QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
- TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toDouble()); \
- if (pPresent) { \
- DLGNAME* aDlg = new DLGNAME(); \
- aDlg->initFromPrsObject(pPresent); \
- if (aDlg->exec()) { \
- aDlg->storeToPrsObject(pPresent); \
- } else { \
- DeletePresentation(pPresent); \
- delete aDlg; \
- return false; \
- } \
- delete aDlg; \
- CreateActor(pPresent); \
- return true; \
- } \
- return false; \
-}
-
-BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
-BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
-BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
-BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
-BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
-BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
-
-
-
-/* ======================================================================================== */
-/* Global Method to import tables from file */
-/* ======================================================================================== */
-void VisuGUI::ImportTablesFromFile(){
- QStringList flt;
- flt.append( "Files (*.xls *.txt *.tab)" );
- flt.append( "All Files (*.*)" );
- QString aDir = getVisuInputDir();
- QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
- aDir,flt,tr("Import From File"),true);
- if(!aFile.isEmpty()){
- QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." );
- aDir = QAD_Tools::getDirFromPath(aFile);
- QAD_CONFIG->addSetting("Visu:InputDir",aDir);
- QApplication::setOverrideCursor( Qt::waitCursor );
- QAD_PyInterp* myPyInterp = myActiveStudy->get_PyInterp();
- myPyInterp->run("import VisuGUI");
- myPyInterp->run("reload(VisuGUI)");
- myPyInterp->run("VisuGUI.AddTablesInStudyFromFile('"+aFile+"')");
- // VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1());
- // if(aResult->_is_nil())
- // QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- // tr ("There is an error in imported file"),
- // tr ("VISU_BUT_OK") );
- // else
- // QAD_Application::getDesktop()->putInfo(aFile+" imported.");
- myActiveStudy->updateObjBrowser(); //update Object browser
- QApplication::restoreOverrideCursor();
- }
-}
+ if (aListIO.Extent() < 1) return;
-/* ======================================================================================== */
-/* Global Method to import mesh results in MED and DAT format */
-/* ======================================================================================== */
-void VisuGUI::ImportFromFile(){
- if (checkLock(myActiveStudy->getStudyDocument())) return;
- QStringList flt;
- //flt.append( "Exportable Files (*.med *.dat)" );
- //flt.append( "Dat Files (*.dat)" );
- flt.append( "Med Files (*.med)" );
- QString aDir = getVisuInputDir();
- QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
- aDir,flt,tr("Import From File"),true);
- if(!aFile.isEmpty()){
- QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." );
- aDir = QAD_Tools::getDirFromPath(aFile);
- QAD_CONFIG->addSetting("Visu:InputDir",aDir);
- QApplication::setOverrideCursor( Qt::waitCursor );
- VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1());
- if(aResult->_is_nil())
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("There is an error in imported file"),
- tr ("VISU_BUT_OK") );
- else
- QAD_Application::getDesktop()->putInfo(aFile+" imported.");
- myActiveStudy->updateObjBrowser(); //update Object browser
- QApplication::restoreOverrideCursor();
- }
-}
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-void VisuGUI::ExportToFile(){
- VISU::Base_i* aBase = GetSelectedVisuObj();
- if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
- QStringList flt;
- flt.append( "Dat Files (*.dat)" );
- flt.append( "Med Files (*.med)" );
- QString aDir = getVisuOutputDir();
- QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
- aDir,flt,tr("Export To File"),false);
- if(!aFile.isEmpty()){
- QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
- aDir = QAD_Tools::getDirFromPath(aFile);
- QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
- if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
- try{
- aResult->GetInput()->ToFile(aFile.latin1());
- QAD_Application::getDesktop()->putInfo(aFile+" exported.");
- }catch(...){
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("There is an error during exporting to file"),
- tr ("VISU_BUT_OK") );
- }
- }
- }
- }else
- QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("No Available data in selection"),
- tr ("VISU_BUT_OK"));
-}
-
-
-/* ======================================================================================== */
-/* Find an Actor to be the reference for a new visualization */
-/* ======================================================================================== */
-VISU_Actor *VisuGUI::ReferenceActor(QAD_Desktop* parent)
-{
- bool exiDS = false, exiVE = false, exiSM = false, exiIS = false, exiCP = false;
- int nbSf = visuGUI->myActiveStudy->getStudyFramesCount();
- int nbObj = 0;
- for ( int i = 0; i < nbSf; i++ ) {
- QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i);
- if ( sf->getTypeView() == VIEW_VTK ) {
- vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
- vtkActorCollection* ac = aRenderer->GetActors();
- vtkActor *anActor;
- for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) {
- if ( anActor->IsA( "VISU_Actor" ) ) {
- VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor);
- if (VisuGUI_VisuAsDlg::ActorTypeIsValid(VISUActor,-1)) {
- // VisuAs->ListObjects->insertItem(VISUActor->getName());
- nbObj++;
- int test = VISUActor->VisuActorType;
- if(test == VisuActorType_DeformedShape)
- exiDS=true;
- else if(test == VisuActorType_Vectors)
- exiVE=true;
- else if(test == VisuActorType_ScalarMap)
- exiSM=true;
- else if(test == VisuActorType_IsoSurfaces)
- exiIS=true;
- else if(test == VisuActorType_CutPlanes)
- exiCP=true;
- }
- }
- }
- }
- }
-
- if ( nbObj > 0 ) {
- VisuGUI_VisuAsDlg * VisuAs = new VisuGUI_VisuAsDlg(QAD_Application::getDesktop(), 0, true, 0 );
-
- if(exiDS)
- VisuAs->addType( tr( "Deformed Shape" ) );
- if(exiVE)
- VisuAs->addType( tr( "Vectors" ) );
- if(exiSM)
- VisuAs->addType( tr( "Scalar Map" ) );
- if(exiIS)
- VisuAs->addType( tr( "Iso-Surfaces" ) );
- if(exiCP)
- VisuAs->addType( tr( "Cut Planes" ) );
-
- if ( VisuAs->exec() ) {
- QString nameActor = VisuAs->getObject();
- if ( !nameActor.isNull() ) {
- MESSAGE("Actor --> "<<nameActor.latin1());
- for ( int i = 0; i < nbSf; i++ ) {
- QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i);
- if ( sf->getTypeView() == VIEW_VTK ) {
- vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
- vtkActorCollection* ac = aRenderer->GetActors();
- vtkActor *anActor;
- for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) {
- if ( anActor->IsA( "VISU_Actor" ) ) {
- VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor);
- if (strcmp(VISUActor->getName(),nameActor) == 0)
- return VISUActor;
- }
- }
- }
- }
+ // Check if "Merge Scalar Range" can be applied
+ int nbPrs = 0;
+ SALOME_ListIteratorOfListIO It (aListIO);
+ for (; It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject)& anIO = It.Value();
+
+ if (!anIO.IsNull() && anIO->hasEntry()) {
+ _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+ CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
+ if (CORBA::is_nil(aCORBAObject)) {
+ _PTR(GenericAttribute) anAttr;
+ if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
+ _PTR(AttributeComment) aComment (anAttr);
+ string aComm = aComment->Value();
+ QString strIn (aComm.c_str());
+ VISU::Storable::TRestoringMap pMap;
+ VISU::Storable::StrToMap(strIn, pMap);
+ bool isExist;
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
+ if (isExist && aType == VISU::TTIMESTAMP) {
+ _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
+ _PTR(SObject) aPrs;
+ for (; anIter->More(); anIter->Next()) {
+ aPrs = anIter->Value();
+ if (!aPrs) continue;
+ std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
+ nbPrs += aSubList.size();
+ }
+ }
+ }
}
}
}
- return NULL;
-}
-
-/* ======================================================================================== */
-/* Test and Read Object Browser before display */
-/* ======================================================================================== */
-bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var *objVisu ){
- if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
- SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
- if(It.More()){
- Handle(SALOME_InteractiveObject) IObject = It.Value();
- SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active
- if (IObject->hasEntry()){
- *objVisu = aStudy->FindObjectID(IObject->getEntry());
- if(!(*objVisu)->_is_nil()) return true;
- }
+
+ if (nbPrs > 1) {
+ theMenu->insertSeparator();
+ action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
+ action( VISU_FREE_SCALAR_BARS )->addTo(theMenu);
}
- QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr("No Available data in selection"),
- tr("VISU_BUT_OK") );
- return false;
-}
-
-/* ======================================================================================== */
-/* Print the render window */
-/* ======================================================================================== */
-void VisuGUI::PrintRW( QString prFile, bool toPrinter)
-{
- ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->Repaint();
-
- vtkRenderWindow *renwin = vtkRenderWindow::New();
- vtkRenderWindowInteractor *theInteractor = vtkRenderWindowInteractor::New();
- theInteractor = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
- //visuGUI->myActiveStudy->getActiveStudyFrame()->getVTKRWInteractor();
-
- renwin=theInteractor->GetRenderWindow();
- vtkWindowToImageFilter *w2if = vtkWindowToImageFilter::New();
- vtkTIFFWriter *rttiffw = vtkTIFFWriter::New();
- w2if->SetInput(renwin);
- rttiffw->SetInput(w2if->GetOutput());
- rttiffw->SetFileName(prFile);
- rttiffw->Write();
-
- if (toPrinter) // print the file
- {
- QString printer = QAD_CONFIG->getSetting("Visu:Printer");
- if (printer.isEmpty())
- printer="kprinter";
- system(printer + " " + prFile);
- }
-}
-/**
- * Returns Actor of presentation if it exists
- */
-VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs){
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (!vf) return NULL;
-
- vtkRenderer *aRen = vf->getRenderer();
- vtkActorCollection *anActColl = aRen->GetActors();
- vtkActor *anActor;
- VISU_Actor* anVISUActor = NULL;
- VISU_Actor* aResActor = NULL;
- long aSrcAddr = (long) thePrs;
- for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
- if(anActor->IsA("VISU_Actor")){
- anVISUActor = VISU_Actor::SafeDownCast(anActor);
- long aCurrAddr = (long) anVISUActor->getPrs3d();
- if (aSrcAddr == aCurrAddr) {
- return anVISUActor;
- }
- }
+ theMenu->insertSeparator();
+
+ // Check if some (nb > 0) removable objects selected
+ if (isOBClient && IsRemovableSelected(this)) {
+ action( VISU_DELETE_OBJS )->addTo(theMenu);
}
- return NULL;
-}
-
-/**
- * Displays only actor of given presentation
- * Creates it if it is abcent
- */
-VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (!vf) return NULL;
-
- vtkRenderer *aRen = vf->getRenderer();
- vtkActorCollection *anActColl = aRen->GetActors();
-
- vtkActor *anActor;
- VISU_Actor* anVISUActor = NULL;
- VISU_Actor* aResActor = NULL;
- long aSrcAddr = (long) thePrs;
- for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
- if(anActor->IsA("VISU_Actor")){
- anVISUActor = VISU_Actor::SafeDownCast(anActor);
- long aCurrAddr = (long) anVISUActor->getPrs3d();
- if (aSrcAddr == aCurrAddr) {
- aResActor = anVISUActor;
- aResActor->VisibilityOn();
- if ( aResActor->VisuActorType == VisuActorType_Mesh ) {
- if ( aResActor->GetProperty()->GetRepresentation() == 2 && !aResActor->IsShrunk )
- aResActor->EdgeDevice->VisibilityOn();
- else
- aResActor->EdgeDevice->VisibilityOff();
- }
- if (aResActor->HasScalarBar())
- aResActor->getScalarBar()->VisibilityOn();
- } else if (theDispOnly) {
- anVISUActor->VisibilityOff();
- if ( anVISUActor->VisuActorType == VisuActorType_Mesh) {
- anVISUActor->EdgeDevice->VisibilityOff();
- }
- if (anVISUActor->HasScalarBar())
- anVISUActor->getScalarBar()->VisibilityOff();
+
+ // Check single selection
+ if (aListIO.Extent() != 1) return;
+
+ Handle(SALOME_InteractiveObject) anIO;
+ VISU::Storable::TRestoringMap aMap;
+ CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
+
+ _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
+ bool isExist;
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+
+ if (aType == VISU::TANIMATION) {
+ action( VISU_SHOW_ANIMATION )->addTo(theMenu);
+
+ } else if (isOBClient) {
+ if (IsSObjectTable(SO)) {
+ action( VISU_SHOW_TABLE )->addTo(theMenu);
+ action( VISU_CREATE_CURVES )->addTo(theMenu);
+ action( VISU_EXPORT_TABLE )->addTo(theMenu);
+ theMenu->insertSeparator();
+ } else {
+ if (!CORBA::is_nil(anObject)) {
+ SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
+ if (!CORBA::is_nil(aMED.in())) {
+ action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
+ }
+
+ SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
+ if (!CORBA::is_nil(aField)) {
+ action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
+ }
+ } else {
+ _PTR(SObject) aSFather = SO->GetFather();
+ if (aSFather) {
+ _PTR(GenericAttribute) anAttr;
+ aSFather->FindAttribute(anAttr, "AttributeName");
+ if (anAttr) {
+ _PTR(AttributeName) aName (anAttr);
+ std::string aValue = aName->Value();
+ if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
+ action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
+ }
+ }
+ }
}
- }
- }
- if (aResActor) return aResActor;
-#ifdef CHECKTIME
- OSD_Timer timer;
- timer.Start();
-#endif
- anVISUActor = thePrs->CreateActor();
- MESSAGE("UpdateViewer - thePrs->CreateActor() = "<<anVISUActor);
- if ( anVISUActor ) {
- vf->AddActor(anVISUActor);
- if(anVISUActor->HasScalarBar()){
- aRen->AddActor2D(anVISUActor->getScalarBar());
}
- } else
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("Can't visulize current object"),
- tr ("VISU_BUT_OK") );
-#ifdef CHECKTIME
- timer.Stop();
- MESSAGE("Cheking time in VisuGUI::UpdateViewer - thePrs->CreateActor + vf->AddActor + aRen->AddActor2D");
- timer.Show();
-#endif
- return anVISUActor;
-}
-
-
-/**
- * Returns TRUE if Presentation is displayed
- */
-bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
- VISU_Actor* anVISUActor = GetActor(thePrs);
- return (anVISUActor)? anVISUActor->GetVisibility() : false;
-}
-
-/**
- * Erases Presentation
- */
-void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
- myActiveStudy->unHighlightAll();
- VISU_Actor* anVISUActor = GetActor(thePrs);
- if (anVISUActor) {
- anVISUActor->VisibilityOff();
- if ( anVISUActor->VisuActorType == VisuActorType_Mesh )
- anVISUActor->EdgeDevice->VisibilityOff();
- if (anVISUActor->HasScalarBar())
- anVISUActor->getScalarBar()->VisibilityOff();
}
}
-/**
- * Deletes given presentation from Data structure
- */
-void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
- if (checkLock(myStudy)) return;
- if (!thePrs) return;
-
- myActiveStudy->unHighlightAll();
-
- vtkActor *anActor;
- VISU_Actor* aVISUActor = NULL;
- long aSrcAddr = (long) thePrs;
- int nbFrames = myActiveStudy->getStudyFramesCount();
- QAD_StudyFrame* aFrame;
-
- for(int i=0; i<nbFrames; i++) {
- aFrame = myActiveStudy->getStudyFrame(i);
- if(!aFrame || aFrame->getTypeView() != VIEW_VTK) continue;
- vtkRenderer* aRen = ((VTKViewer_ViewFrame*)aFrame->getRightFrame()->getViewFrame())->getRenderer();
- vtkActorCollection *anActColl = aRen->GetActors();
-
- for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
- if(anActor->IsA("VISU_Actor")) {
- aVISUActor = VISU_Actor::SafeDownCast(anActor);
- if (aSrcAddr == ((long) aVISUActor->getPrs3d())) {
- if (aVISUActor->HasScalarBar())
- aRen->RemoveActor(aVISUActor->getScalarBar());
- aRen->RemoveActor(aVISUActor);
- aVISUActor->EdgeDevice->Delete();
- aVISUActor->Delete();
- aVISUActor = NULL;
- }
- }
- }
- }
- SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(thePrs->GetEntry());
- if(aSObj->_is_nil()) return;
- myStudyBuilder->RemoveObject(aSObj);
- myActiveStudy->updateObjBrowser(); //update Object browser
-}
-
-/**
- * Creates new actor of presentation
- */
-void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
- if (!thePrs) return;
- QApplication::setOverrideCursor( Qt::waitCursor );
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf) {
-#ifdef CHECKTIME
- OSD_Timer timer;
- timer.Start();
-#endif
- VISU_Actor* aActor = thePrs->CreateActor();
- if ( ! aActor ) {
- QApplication::restoreOverrideCursor();
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("The presentation can't be visualized.\n Null actor is created."),
- tr ("VISU_BUT_OK") );
- return;
- }
-#ifdef CHECKTIME
- timer.Stop();
- MESSAGE("Cheking time in VisuGUI::CreateActor - thePrs->CreateActor");
- timer.Show();
-#endif
- vtkRenderer *aRenderer = vf->getRenderer();
- //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1);
- //visuGUI->ShowTrihedron(true);
-#ifdef CHECKTIME
- timer.Reset();
- timer.Start();
-#endif
- vf->AddActor(aActor);
- if (aActor->HasScalarBar())
- aRenderer->AddActor2D(aActor->getScalarBar());
-#ifdef CHECKTIME
- timer.Stop();
- MESSAGE("Cheking time in VisuGUI::CreateActor - vf->AddActor");
- timer.Show();
-#endif
- }
- QApplication::restoreOverrideCursor();
+
+//***************************************************************************
+void
+VisuGUI::
+windows( QMap<int, int>& theMap ) const
+{
+ theMap.clear();
+ theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
+ theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
}
+void
+VisuGUI::
+viewManagers( QStringList& theList ) const
+{
+ theList.clear();
+ theList.append( SVTK_Viewer::Type() );
+}
-/* ======================================================================================== */
-/* Functions to State of VisuGUI and Dialog Box */
-/* ======================================================================================== */
-void VisuGUI::SetState(int aState )
-{
- this->myState = aState ;
- return ;
+QString
+VisuGUI::
+engineIOR() const
+{
+ CORBA::String_var anIOR = GetVisuGen(this)->GetID();
+ return QString(anIOR.in());
}
-void VisuGUI::ResetState()
-{
- this->myState = -1 ;
- return ;
+bool
+VisuGUI::
+activateModule( SUIT_Study* theStudy )
+{
+ SalomeApp_Module::activateModule( theStudy );
+ studyActivated();
+ setMenuShown( true );
+ setToolShown( true );
+ return true;
}
-void VisuGUI::EmitSignalDeactivateDialog()
+
+bool
+VisuGUI::
+deactivateModule( SUIT_Study* theStudy )
{
- emit this->SignalDeactivateActiveDialog() ;
- return ;
+ setMenuShown( false );
+ setToolShown( false );
+
+ SalomeApp_Module::deactivateModule( theStudy );
+ return true;
}
-void VisuGUI::EmitSignalCloseAllDialogs()
+SalomeApp_Selection*
+VisuGUI::
+createSelection() const
{
- emit this->SignalCloseAllDialogs() ;
- return ;
+ return new VisuGUI_Selection( (SalomeApp_Module*)this );
}
-QDialog* VisuGUI::GetActiveDialogBox()
+//******************************************************************
+void VisuGUI::studyActivated()
{
- return this->myActiveDialogBox ;
+ GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
}
-void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
+/*
+extern "C" {
+ CAM_Module*
+ createModule()
+ {
+ return new VisuGUI();
+ }
+}
+*/
+void VisuGUI::createPreferences()
+{
+ int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
+
+ int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
+ int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
+ addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
+ int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
+ addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
+
+ QStringList fam;
+ fam.append( tr( "VISU_FONT_ARIAL" ) );
+ fam.append( tr( "VISU_FONT_COURIER" ) );
+ fam.append( tr( "VISU_FONT_TIMES" ) );
+ int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
+
+ setPreferenceProperty( tfont, "families", fam );
+ setPreferenceProperty( tfont, "system", false );
+ setPreferenceProperty( tfont, "widget_flags", wflag );
+ setPreferenceProperty( lfont, "families", fam );
+ setPreferenceProperty( lfont, "system", false );
+ setPreferenceProperty( lfont, "widget_flags", wflag );
+
+ int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
+
+ int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
+ setPreferenceProperty( numcol, "min", 2 );
+ setPreferenceProperty( numcol, "max", 64 );
+
+ int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
+ setPreferenceProperty( numlab, "min", 2 );
+ setPreferenceProperty( numlab, "max", 65 );
+
+ int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
+ int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
+ QStringList orients;
+ orients.append( tr( "VISU_VERTICAL" ) );
+ orients.append( tr( "VISU_HORIZONTAL" ) );
+ QValueList<QVariant> indices;
+ indices.append( 0 );
+ indices.append( 1 );
+ setPreferenceProperty( orient, "strings", orients );
+ setPreferenceProperty( orient, "indexes", indices );
+
+ int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
+ int xv = addPreference( tr( "VISU_X" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
+ int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
+ int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
+ int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
+ setPreferenceProperty( xv, "step", 0.1 );
+ setPreferenceProperty( yv, "step", 0.1 );
+ setPreferenceProperty( wv, "step", 0.1 );
+ setPreferenceProperty( hv, "step", 0.1 );
+ setPreferenceProperty( xv, "min", 0.0 );
+ setPreferenceProperty( yv, "min", 0.0 );
+ setPreferenceProperty( wv, "min", 0.0 );
+ setPreferenceProperty( hv, "min", 0.0 );
+ setPreferenceProperty( xv, "max", 1.0 );
+ setPreferenceProperty( yv, "max", 1.0 );
+ setPreferenceProperty( wv, "max", 1.0 );
+ setPreferenceProperty( hv, "max", 1.0 );
+
+ int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
+ int xh = addPreference( tr( "VISU_X" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
+ int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
+ int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
+ int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
+ setPreferenceProperty( xh, "step", 0.1 );
+ setPreferenceProperty( yh, "step", 0.1 );
+ setPreferenceProperty( wh, "step", 0.1 );
+ setPreferenceProperty( hh, "step", 0.1 );
+ setPreferenceProperty( xh, "min", 0.0 );
+ setPreferenceProperty( yh, "min", 0.0 );
+ setPreferenceProperty( wh, "min", 0.0 );
+ setPreferenceProperty( hh, "min", 0.0 );
+ setPreferenceProperty( xh, "max", 1.0 );
+ setPreferenceProperty( yh, "max", 1.0 );
+ setPreferenceProperty( wh, "max", 1.0 );
+ setPreferenceProperty( hh, "max", 1.0 );
+
+ int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) );
+
+ int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab );
+ setPreferenceProperty( rangeGr, "columns", 1 );
+
+ int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
+ QStringList modes;
+ modes.append( tr( "VISU_MODULUS" ) );
+ modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
+ modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
+ modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
+ indices.clear();
+ indices.append( 0 );
+ indices.append( 1 );
+ indices.append( 2 );
+ indices.append( 3 );
+ setPreferenceProperty( mode, "strings", modes );
+ setPreferenceProperty( mode, "indexes", indices );
+
+ addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, SalomeApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
+
+ int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_range_type" );
+ QStringList types;
+ types.append( tr( "VISU_FIELD_RANGE" ) );
+ types.append( tr( "VISU_IMPOSED_RANGE" ) );
+ indices.clear();
+ indices.append( 0 );
+ indices.append( 1 );
+ setPreferenceProperty( rangetype, "strings", types );
+ setPreferenceProperty( rangetype, "indexes", indices );
+
+ int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab );
+
+ int min = addPreference( tr( "VISU_MIN" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
+ int max = addPreference( tr( "VISU_MAX" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
+ setPreferenceProperty( min, "step", 0.1 );
+ setPreferenceProperty( max, "step", 0.1 );
+
+ int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
+ setPreferenceProperty( sweepGr, "columns", 1 );
+
+ int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, SalomeApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
+ int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
+ int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
+ setPreferenceProperty( timestep, "min", 0.1 );
+ setPreferenceProperty( timestep, "step", 0.1 );
+ setPreferenceProperty( timestep, "max", 1000 );
+ setPreferenceProperty( nbcycles, "max", 100 );
+ setPreferenceProperty( nbsteps, "max", 200 );
+
+ int importGr = addPreference( tr( "MED files import" ), srangeTab );
+ addPreference( tr( "Full MED loading" ), importGr, SalomeApp_Preferences::Bool, "VISU", "full_med_loading" );
+}
+
+void VisuGUI::preferencesChanged( const QString&, const QString& )
{
- this->myActiveDialogBox = (QDialog*)aDlg ;
- return ;
}
-QAD_Study* VisuGUI::GetActiveStudy()
+SUIT_ViewManager*
+VisuGUI
+::getViewManager(const QString& theType,
+ const bool theIsCreate)
{
- return this->myActiveStudy ;
+ return getApp()->getViewManager(theType,theIsCreate);
}
-QAD_Desktop* VisuGUI::GetDesktop()
+SalomeApp_Displayer* VisuGUI::displayer()
{
- return this->myDesktop ;
+ return 0;
}