-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 "VISU_Gen_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_PrsObject_i.hh"
+#include "VISU_ViewManager_i.hh"
+
+#include "VISU_PipeLine.hxx"
+
+#include "VISU_Prs3d_i.hh"
+#include "VISU_Mesh_i.hh"
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_IsoSurfaces_i.hh"
+#include "VISU_DeformedShape_i.hh"
+#include "VISU_CutPlanes_i.hh"
+#include "VISU_CutLines_i.hh"
+#include "VISU_Vectors_i.hh"
+#include "VISU_StreamLines_i.hh"
+#include "VISU_Table_i.hh"
+
+#include "VISU_Actor.h"
+#include "VISU_MeshAct.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_CutLinesDlg.h"
#include "VisuGUI_VectorsDlg.h"
#include "VisuGUI_IsoSurfacesDlg.h"
#include "VisuGUI_StreamLinesDlg.h"
+#include "VisuGUI_EditContainerDlg.h"
#include "VisuGUI_TimeAnimation.h"
#include "VisuGUI_Selection.h"
-#include "VisuGUI_VisuAsDlg.h"
-#include "VisuGUI_SelVectCompDlg.h"
#include "VisuGUI_NonIsometricDlg.h"
-#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"
-
#include "SALOMEGUI_ImportOperation.h"
#include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "utilities.h"
#include "QAD_Resource.h"
#include "QAD_ResourceMgr.h"
#include "QAD_FileDlg.h"
+#include "QAD_WaitCursor.h"
#include "SALOME_Selection.h"
#include "SALOMEGUI_NameDlg.h"
#include "SALOMEGUI_TableDlg.h"
#include "SALOMEGUI_SetupCurveDlg.h"
#include "SALOMEGUI_SetValueDlg.h"
+#include "SALOMEGUI_Desktop.h"
#include "Plot2d_SetupPlot2dDlg.h"
#include "Plot2d_ViewFrame.h"
#include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_RenderWindow.h"
+#include "VTKViewer_InteractorStyleSALOME.h"
+#include "VTKViewer_RenderWindowInteractor.h"
+#include "VisuGUI_FileDlg.h"
// QT Includes
#define INCLUDE_MENUITEM_DEF
#include <qthread.h>
#include <qlistbox.h>
#include <qcombobox.h>
+#include <qregexp.h>
//VRV: porting on Qt 3.0.5
#if QT_VERSION >= 0x030005
#include <qmessagebox.h>
#include <med.h>
-#include CORBA_CLIENT_HEADER(Med_Gen)
+#include CORBA_CLIENT_HEADER(MED_Gen)
#include <vtkActor.h>
-#include <vtkCellCenters.h>
-//#include <vtkOutlineFilter.h>
+#include <vtkRenderer.h>
#include <vtkDataSetMapper.h>
-#include <vtkWarpVector.h>
-#include <vtkContourFilter.h>
-#include <vtkCellDataToPointData.h>
-#include <vtkShrinkFilter.h>
+#include <vtkActorCollection.h>
// Open CASCADE Include
#include <TCollection_AsciiString.hxx>
-//#define CHECKTIME
+//#define CHECKTIME
#ifdef CHECKTIME
-#include <OSD_Timer.hxx>
+static int MYCHECKTIME = 1;
+#else
+static int MYCHECKTIME = 0;
#endif
+#include <Utils_Timer.hxx>
+
+using namespace std;
-#ifdef DEBUG
-static int MYDEBUG = 1;
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
#endif
-// unique name visu entity
-//static bool localContext = false;
-static VisuGUI_Selection *Selection;
-static int VISU_POINT_SIZE = 5;
-
-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;
-
-QAD_Study* MYActiveStudy = NULL;
-SALOMEDS::StudyBuilder_var MYStudyBuilder = SALOMEDS::StudyBuilder::_nil();
-SALOMEDS::Study_var MYStudyDocument = SALOMEDS::Study::_nil();
-
-const QString ObjectTypes("FIELD VIEW3D MESH TIMESTAMP ENTITY FAMILY GROUP");
-
-
-class CustomItem : public QCustomMenuItem
-{
+class CustomItem : public QCustomMenuItem{
public:
CustomItem( const QString& s, const QFont& f )
: string( s ), font( f ){};
QFont font;
};
-static VisuGUI *visuGUI = 0;
-static QString PREFIX = QString(getenv("USER")) + "-VISU-";
+inline bool IsSObjectTable(SALOMEDS::SObject_ptr theSObject){
+ if(!theSObject->_is_nil()) {
+ SALOMEDS::GenericAttribute_var anAttr;
+ if(theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
+ return true;
+ if(theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
+ return true;
+ }
+ return false;
+}
+
+
+static VisuGUI MYVISUGUI;
+VisuGUI *visuGUI = &MYVISUGUI;
+
+VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
+ VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
+ return VISU::VISU_Gen_i::GetVisuGenImpl();
+}
+
+static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6],
+ const char* theActorClassName = "VISU_Actor")
+{
+ vtkRenderer *aRen = theViewFrame->getRenderer();
+ vtkActorCollection *anActColl = aRen->GetActors();
+ vtkProp *prop;
+ float *bounds;
+ int nothingVisible=1;
+
+ allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
+ allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
+ // loop through all props
+ for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
+ // if it's invisible, or has no geometry, we can skip the rest
+ if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
+ bounds = prop->GetBounds();
+ // make sure we haven't got bogus bounds
+ if ( bounds != NULL &&
+ bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
+ bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
+ bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
+ {
+ nothingVisible = 0;
+ if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
+ if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
+ if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
+ if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
+ if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
+ if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
+ }//not bogus
+ }
+ }
+ return nothingVisible;
+}
+
+VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){
+ static float PRECISION = 0.000001;
+ static float DEVIATION = 600;
+ float XYZ_Bnd[6];
+ if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
+
+ float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
+
+ float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
+
+ float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
+
+ CameraOrient aCameraOrient = e3D;
+ if(absX <= PRECISION) aCameraOrient = eFront;
+ else {if(absY <= PRECISION) aCameraOrient = eLeft;
+ else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
+
+ float dev_abs_XY = absX / absY;
+ float dev_abs_YZ = absY / absZ;
+ float dev_abs_XZ = absX / absZ;
+ if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
+ else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront;
+ else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}
+
+ switch(aCameraOrient){
+ case eFront: theViewFrame->onViewFront(); break;
+ case eLeft: theViewFrame->onViewLeft(); break;
+ case eTop: theViewFrame->onViewTop(); break;
+ case e3D: theViewFrame->onViewReset(); break;
+ }
+ theViewFrame->getRenderer()->ResetCameraClippingRange();
+ theViewFrame->onViewFitAll();
+ return aCameraOrient;
+}
+
+QAD_Desktop* VisuGUI::GetDesktop(){
+ return QAD_Application::getDesktop() ;
+}
+
+QAD_Study* VisuGUI::GetActiveStudy(){
+ return GetDesktop()->getActiveStudy() ;
+}
+
+vtkRenderer* VisuGUI::GetRenderer(){
+ if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
+ return aViewFrame->getRenderer();
+ return NULL;
+}
+
+VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
+ QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
+ return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
+}
+static void UpdateViewFrame() {
+ QList<QAD_StudyFrame> aFrameList = VisuGUI::GetActiveStudy()->getStudyFrames();
+
+ for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
+ if (aStudyFrame->getTypeView() == VIEW_VTK) {
+ QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
+ VTKViewer_ViewFrame* aVtkViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
+ if (!aVtkViewFrame) continue;
+ VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
+ if (anInteractor) {
+ anInteractor->SetSelectionProp();
+ anInteractor->SetSelectionTolerance();
+ VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
+ if (aStyle) {
+ aStyle->setPreselectionProp();
+ }
+ }
+ }
+ }
+}
-vtkRenderer* VisuGUI::GetRenderer(QAD_Study* theStudy){
- if (theStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
- return NULL;
+SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
+ return GetActiveStudy()->getStudyDocument();
+}
- return ((VTKViewer_ViewFrame*)theStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
+ return GetStudyDocument()->NewBuilder();
}
}
-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,
+CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = 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()){
+ if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
+ SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
+ if(aSel->IObjectCount() > 0){
+ const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
+ if(pIO != NULL) *pIO = anIO;
+ if(anIO->hasEntry()){
SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
if(!aSObject->_is_nil()){
return CORBA::Object::_nil();
}
-int IsTrihedronDisplayed(){
- QAD_ViewFrame* aViewFrame = MYActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- VTKViewer_ViewFrame* aVTKViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
- return aVTKViewFrame->isTrihedronDisplayed();
-}
-
-VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
- QAD_ViewFrame* aViewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
+int IsTrihedronDisplayed(){
+ if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
+ return aVTKViewFrame->isTrihedronDisplayed();
+ return 1;
}
void RepaintCurrentView(){
- VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
- if (vf)
- vf->Repaint();
-}
-
-
-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;
+ if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
}
-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();
-
- MYActiveStudy = myActiveStudy;
- MYStudyDocument = myStudy;
- MYStudyBuilder = myStudyBuilder;
- return visuGUI;
-}
-
-/* ********************************************************************************* */
-/* Function to return VisuGUI object */
-/* ********************************************************************************* */
-VisuGUI* VisuGUI::GetVisuGUI( )
-{
- return VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
+VisuGUI::VisuGUI( const QString& theName, QObject* theParent ):
+ SALOMEGUI( theName, theParent )
+{
+ mySelectionDlg = 0;
}
/* ==================================================================================== */
static int checkLock(const SALOMEDS::Study_var& theStudy) {
if (isStudyLocked(theStudy)) {
QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
- QObject::tr("WARNING"),
+ QObject::tr("WRN_WARNING"),
QObject::tr("WRN_STUDY_LOCKED"),
QObject::tr("BUT_OK") );
return true;
bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
{
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);
-
- //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;
-
- 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;
-
+ QString VisuInputDir = getVisuInputDir();
+ QString VisuOutputDir = getVisuOutputDir();
+ vtkRenderer *theRenderer = GetRenderer();
+
+ SALOMEDS::Study_var aStudy = GetActiveStudy()->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;
+
+ switch (theCommandID){
/* ======================================================================================== */
/* Import Table from file */
/* ======================================================================================== */
-
case 199:
{
if(checkLock(aStudy)) break;
/* Import Mesh from MED, DAT file */
/* ======================================================================================== */
+ case 111:
+ {
+ visuGUI->CopyAndImportFile();
+ break;
+ }
case 112:
{
- visuGUI->ImportFromFile();
+ visuGUI->ImportFile();
break;
}
case 122:
{
- visuGUI->ExportToFile();
+ //visuGUI->ExportToFile();
break;
}
- /* ========================================================================================================================= */
- /* 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);
- }
- break;
- }
-
/* ========================================================================== */
/* Visualization of Results : */
/* 4011 : Scalar Map */
case 4015 :
visuGUI->CreateCutPlanes();
break;
+ case 4018 :
+ visuGUI->CreateCutLines();
+ 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 :
+ visuGUI->SelectionInfo();
+ break;
/* ========================================================================================================================= */
/* Visualization - Wireframe */
/* ========================================================================================================================= */
case 4211 :
- ChangeViewer(parent, theRenderer, true, 1);
+ ChangeViewer(1);
break;
/* ========================================================================================================================= */
/* ========================================================================================================================= */
case 4212 :
- ChangeViewer(parent, theRenderer, true, 2);
+ ChangeViewer(2);
break;
/* ========================================================================================================================= */
/* ========================================================================================================================= */
case 4213 :
- ChangeViewer(parent, theRenderer, true, 0);
+ ChangeViewer(0);
break;
/* ========================================================================================================================= */
/* ========================================================================================================================= */
case 422 :
- if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
- ClearViewer(parent, theRenderer, -1);
+ ChangeViewer(-1);
break;
/* ========================================================================================================================= */
case 8041 : // Object representation : Wireframe
case 9041 : // Object representation : Wireframe
- visuGUI->ChangeRepresentation(WIREFRAME);
+ visuGUI->ChangeRepresentation(VISU::WIREFRAME);
break;
case 8042 : // Object representation : Surface
case 9042 : // Object representation : Surface
- visuGUI->ChangeRepresentation(SURFACE);
+ visuGUI->ChangeRepresentation(VISU::SHADED);
break;
case 8043 : // Object representation : Points
case 9043 : // Object representation : Points
- visuGUI->ChangeRepresentation(POINTS);
+ visuGUI->ChangeRepresentation(VISU::POINT);
break;
case 8044 : // Object representation : Shrink/Unshrink
case 9044 : // Object representation : Shrink/Unshrink
- visuGUI->ChangeRepresentation(SHRINK);
+ visuGUI->ChangeRepresentation(VISU::SHRINK);
break;
case 8051 : // Change object color
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())
- }
-
- 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;
}
SetSweepingPreferences();
}
break;
-
+
+/* ======================================================================================== */
+/* Preferences for Full loading */
+/* ======================================================================================== */
+ case 53:
+ case 54:
+ {
+ QMenuData* pp;
+ QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
+ bool check = !pp->isItemChecked(theCommandID);
+ pp->setItemChecked(theCommandID,check);
+ switch(theCommandID){
+ case 53:
+ QAD_CONFIG->addSetting( "Visu:BuildResult", check );
+ break;
+ case 54:
+ QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
+ break;
+ }
+ }
+ break;
case 113: // Load MED using MED component
{
- if (checkLock(myStudy)) break;
+ if (checkLock(GetStudyDocument())) break;
- Engines::Component_var aMedComp = myDesktop->getEngine("FactoryServer", "Med");
+ Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
if (CORBA::is_nil(aMedComp)) return false;
- Engines::Med_Gen_var aMedGen = Engines::Med_Gen::_narrow(aMedComp);
+ SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::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,
+ QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
"",
filtersList,
tr("MED_MEN_IMPORT"),
true);
if (!aFileName.isEmpty()) {
QApplication::setOverrideCursor( Qt::waitCursor );
- aMedGen->readStructFileWithFieldType(aFileName.latin1(), myActiveStudy->getTitle());
- myActiveStudy->updateObjBrowser();
+ aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
+ GetActiveStudy()->updateObjBrowser();
QApplication::restoreOverrideCursor();
}
}
default:
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("Not Yet Implemented"),
+ tr ("MSG_NOT_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") );
+ }
+ } catch (const std::bad_alloc& e ) {
+ INFOS("bad_alloc exception is caught "<<e.what());
+ QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr("ERR_NO_MEMORY") + " " + tr(e.what()),
+ tr("VISU_BUT_OK") );
return false;
- }
-*/
- catch (const SALOME::SALOME_Exception& S_ex) {
+ }
+ catch (std::exception& e){
+ INFOS(e.what());
+ QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr(e.what()),
+ tr("VISU_BUT_OK") );
+ }catch (const SALOME::SALOME_Exception& S_ex) {
+ INFOS("const SALOME::SALOME_Exception& S_ex");
QtCatchCorbaException(S_ex);
return false;
}
catch(...) {
+ INFOS(tr("ERR_UNKNOWN_EXCEPTION").latin1());
QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr("Unknown exception was caught in VISU module"),
+ tr("ERR_UNKNOWN_EXCEPTION"),
tr("VISU_BUT_OK") );
return false;
}
return true;
}
-
-/* ********************************************************************************* */
-/* 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;
- }
- }
- }
- return NULL;
+void VisuGUI::SelectionInfo() {
+ mySelectionDlg = new VisuGUI_SelectionDlg();
+ mySelectionDlg->show();
}
-/* ********************************************************************************* */
-/* 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);
- }
- 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;
- }
- return (ActorTmp);
-}
-
-/* ********************************************************************************** */
-/* Function ClearViewer - Erase the actors displayed on the viewer */
-/* ********************************************************************************** */
-
-void VisuGUI::ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor)
-{
- // TypeOfActor = -1 : All
- // = 1 : VisuActor
- // = 2 : ScalarBarActor
- // = 4 : Other Actor2D
-
- vtkActorCollection *ac;
- vtkActor2DCollection *ac2D;
- vtkActor *actor;
- vtkActor2D *actor2D;
- ac = ren->GetActors();
- ac2D = ren->GetActors2D();
-
- 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();
- }
- }
-}
-
-/* ********************************************************************************** */
-/* Function ShowTrihedron */
+/* Function ShowTrihedron */
/* ********************************************************************************** */
void VisuGUI::ShowTrihedron(bool ShowThd){
bool ThdIsVisible = true;
if( ShowThd && !ThdIsVisible)
- ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
+ ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
if( !ShowThd && ThdIsVisible)
- ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
+ ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
}
/* ********************************************************************************** */
/* ********************************************************************************** */
VisuGUI::~VisuGUI(){
- MESSAGE("VisuGUI::~VisuGUI");
+ if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI");
}
/* ********************************************************************************** */
/* Change representation of all actors */
/* ********************************************************************************** */
-void VisuGUI::ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type)
-{
- if (!ren) return;
- VisuGUI::GetOrCreateVisuGUI(parent);
- vtkActorCollection *ac;
- vtkActor *actor;
- ac = ren->GetActors();
-
- for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;)
- actor->GetProperty()->SetRepresentation(Type);
+void VisuGUI::ChangeViewer(int theType){
+ if(theType < 0 )
+ GetActiveStudy()->unHighlightAll();
+ if(vtkRenderer *aRen = 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();
+ if(theType >= 0)
+ anVISUActor->SetRepresentation(theType);
+ else
+ anVISUActor->VisibilityOff();
+ }
+ }
+ RepaintCurrentView();
+ }
}
-
// -----------------------------------------------------------------------------------------
// EVENTS
// -----------------------------------------------------------------------------------------
bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
{
- VisuGUI::GetOrCreateVisuGUI(parent);
return true;
}
bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
{
- VisuGUI::GetOrCreateVisuGUI(parent);
return true;
}
bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
{
- VisuGUI::GetOrCreateVisuGUI(parent);
- if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
+ if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
return false;
- MESSAGE ( "VisuGUI::onKeyPress : " << pe->key() )
+ if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
switch ( pe->key() )
{
case Key_Escape :
{
- MESSAGE("--> Key : Escape")
+ if(MYDEBUG) MESSAGE("--> Key : Escape")
return true;
}
default :
// Slot-functions for presentations creation
//=====================================================================================
-
#define CREATEPRESENTATION(FunctionName) \
void FunctionName() { \
- if (checkLock(myStudy)) return; \
+ if (checkLock(GetStudyDocument())) return; \
SALOMEDS::SObject_var objVisu; \
- if (!TestObjectBrowser(&objVisu)) return; \
+ if (!TestObjectBrowser(objVisu)) return; \
if(!FunctionName(objVisu)) return; \
- visuGUI->myActiveStudy->updateObjBrowser(); \
- myDesktop->putInfo("Ready"); \
+ GetActiveStudy()->updateObjBrowser(); \
+ GetDesktop()->putInfo("Ready"); \
VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
if (vf) { \
/*vf->getRenderer()->ResetCameraClippingRange();*/ \
CREATEPRESENTATION(VisuGUI::CreateVectors);
CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
+CREATEPRESENTATION(VisuGUI::CreateCutLines);
CREATEPRESENTATION(VisuGUI::CreateStreamLines);
-
//=====================================================================================
-// function : setSettings()
+// function : SetSettings()
// purpose :
//=====================================================================================
-bool VisuGUI::setSettings(QAD_Desktop* parent)
+bool VisuGUI::SetSettings(QAD_Desktop* parent)
{
- VisuGUI::GetOrCreateVisuGUI(parent);
+ int anId = 53;
+ QMenuData* pp;
+ QMenuItem* item = parent->menuBar()->findItem(anId,&pp);
+ QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult");
+
+ if(aValue.isEmpty()? 0 : aValue.toInt())
+ pp->setItemChecked(anId, true);
+
+ anId = 54;
+ item = parent->menuBar()->findItem(anId,&pp);
+ aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
+
+ if(aValue.isEmpty()? 0 : aValue.toInt())
+ pp->setItemChecked(anId, true);
+
+ anId = 50;
+ parent->menuBar()->changeItem(anId,parent->getComponentUserName("VISU"));
+
+ ::UpdateViewFrame();
+
return true;
}
// purpose :
//=====================================================================================
void VisuGUI::DisplayPrs() {
- MESSAGE("VisuGUI::DisplayPrs");
- string aComment;
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
+ CORBA::Object_var anObject = GetSelectedObj(&anIO);
if ( !CORBA::is_nil( anObject ) ) {
// is it Prs3d object ?
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
if(aPrsObject){
- MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
UpdateViewer(aPrsObject);
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf) {
+ if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
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));
+ VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
if(aCurve){
- MESSAGE("VisuGUI::DisplayPrs : Curve object");
+ if(MYDEBUG) 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));
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
if(aContainer){
- MESSAGE("VisuGUI::DisplayPrs : Container object");
+ if(MYDEBUG) 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));
+ VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
if(aTable){
- MESSAGE("VisuGUI::DisplayPrs : Table object");
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
PlotTable(aTable, VISU::eDisplay );
return;
}
// purpose :
//=====================================================================================
void VisuGUI::DisplayOnlyPrs() {
- MESSAGE("VisuGUI::DisplayOnlyPrs");
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy);
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
+ CORBA::Object_var anObject = GetSelectedObj();
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");
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+ if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
+ if(MYDEBUG) 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");
+ }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
+ if(MYDEBUG) 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");
+ }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in())){
+ if(MYDEBUG) 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");
+ }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant.in())){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
PlotTable(aTable, VISU::eDisplayOnly );
- return;
}
}
}
// function : ErasePrs()
// purpose :
//=====================================================================================
-void VisuGUI::ErasePrs() {
- MESSAGE("VisuGUI::ErasePrs");
- 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::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 );
+static void ErasePrs(CORBA::Object_ptr theObject) {
+ if(MYDEBUG) MESSAGE("ErasePrs");
+ if ( !CORBA::is_nil( theObject ) ) {
+ VISU::Base_var aBase = VISU::Base::_narrow(theObject);
+ if ( CORBA::is_nil( aBase ) ) return;
+ VISU::VISUType aType = aBase->GetType();
+ switch (aType){
+ case VISU::TCURVE:{
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
+ VisuGUI::PlotCurve(aCurve, VISU::eErase );
+ break;
}
- // 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 );
+ case VISU::TCONTAINER:{
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
+ VisuGUI::PlotContainer(aContainer, VISU::eErase );
+ break;
}
- // 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 );
+ case VISU::TTABLE:{
+ if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
+ VisuGUI::PlotTable(aTable, VISU::eErase );
+ break;
}
+ default:{
+ if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
+ VisuGUI::ErasePrs(aPrsObject);
+ if (VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame())
+ vf->Repaint();
+ }
+ }}
}
}
+void VisuGUI::ErasePrs() {
+ ::ErasePrs(GetSelectedObj());
+}
+
//=====================================================================================
-// function : RecreateActor()
+// function : DisplayManyPrs()
// 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::DisplayManyPrs()
+{
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
+ SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for ( ; It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject)& anIO = It.Value();
+ if ( anIO->hasEntry() ) {
+ SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
+ VISU::Storable::TRestoringMap pMap;
+ if( !aSObject->_is_nil() ) {
+ CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
+ if ( !CORBA::is_nil( aCORBAObject ) ) {
+ // is it Prs3d object ?
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aPrsObject){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
+ UpdateViewer(aPrsObject);
+ VTKViewer_ViewFrame* vf = GetVtkViewFrame();
+ if (vf) {
+ vf->getRenderer()->ResetCameraClippingRange();
+ vf->Repaint();
+ vf->highlight(anIO, 1);
+ }
+ continue;
+ }
+ // is it Curve ?
+ VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aCurve){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
+ PlotCurve(aCurve, VISU::eDisplay );
+ continue;
+ }
+ // is it Container ?
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aContainer){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
+ PlotContainer(aContainer, VISU::eDisplay );
+ continue;
+ }
+ // is it Table ?
+ VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aTable){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
+ PlotTable(aTable, VISU::eDisplay );
+ continue;
+ }
+ }
+ }
}
}
- vf->Repaint();
-
- QApplication::restoreOverrideCursor();
+}
- END_OF("VisuGUI::RecreateActor") */
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (!vf) return;
+//=====================================================================================
+// function : DisplayOnlyManyPrs()
+// purpose :
+//=====================================================================================
+void VisuGUI::DisplayOnlyManyPrs() {
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
+ SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ bool aFirstElem = true;
+ for ( ; It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject)& anIO = It.Value();
+ if ( anIO->hasEntry() ) {
+ SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
+ VISU::Storable::TRestoringMap pMap;
+ if( !aSObject->_is_nil() ) {
+ CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
+ if ( !CORBA::is_nil( aCORBAObject ) ) {
+ // is it Prs3d object ?
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aPrsObject){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
+ UpdateViewer(aPrsObject, aFirstElem);
+ if (aFirstElem) aFirstElem = false;
+ VTKViewer_ViewFrame* vf = GetVtkViewFrame();
+ if (vf) {
+ vf->getRenderer()->ResetCameraClippingRange();
+ vf->Repaint();
+ vf->highlight(anIO, 1);
+ }
+ continue;
+ }
+ // is it Curve ?
+ VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aCurve){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
+ if (aFirstElem) {
+ PlotCurve(aCurve, VISU::eDisplayOnly );
+ aFirstElem = false;
+ }
+ else PlotCurve(aCurve, VISU::eDisplay );
+ continue;
+ }
+ // is it Container ?
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aContainer){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
+ if (aFirstElem) {
+ PlotContainer(aContainer, VISU::eDisplayOnly );
+ aFirstElem = false;
+ }
+ else PlotContainer(aContainer, VISU::eDisplay );
+ continue;
+ }
+ // is it Table ?
+ VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aTable){
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
+ if (aFirstElem) {
+ PlotTable(aTable, VISU::eDisplayOnly );
+ aFirstElem = false;
+ }
+ else PlotTable(aTable, VISU::eDisplay );
+ continue;
+ }
+ }
+ }
+ }
+ }
+}
- 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();
+//=====================================================================================
+// function : EraseManyPrs()
+// purpose :
+//=====================================================================================
+void VisuGUI::EraseManyPrs()
+{
+ if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
+ SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
+ SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
+ SALOME_ListIteratorOfListIO It( LIO );
+ for ( ; It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject)& anIO = It.Value();
+ if ( anIO->hasEntry() ) {
+ SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
+ VISU::Storable::TRestoringMap pMap;
+ if( !aSObject->_is_nil() ) {
+ CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
+ if ( !CORBA::is_nil( aCORBAObject ) ) {
+ // is it Prs3d object ?
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aPrsObject){
+ if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
+ ErasePrs(aPrsObject);
+ VTKViewer_ViewFrame* vf = GetVtkViewFrame();
+ if (vf) {
+ vf->Repaint();
+ }
+ continue;
+ }
+ // is it Curve ?
+ VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aCurve){
+ if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
+ PlotCurve(aCurve, VISU::eErase );
+ continue;
+ }
+ // is it Container ?
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aContainer){
+ if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
+ PlotContainer(aContainer, VISU::eErase );
+ continue;
+ }
+ // is it Table ?
+ VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
+ if(aTable){
+ if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
+ PlotTable(aTable, VISU::eErase );
+ continue;
+ }
+ }
+ }
+ }
+ }
+}
- if (!anVISUActor) return;
- anVISUActor->SetVisibility(isVisible);
- aRen->AddActor(anVISUActor);
- if (anVISUActor->HasScalarBar()) {
- anVISUActor->getScalarBar()->SetVisibility(isVisible);
- aRen->AddActor2D(anVISUActor->getScalarBar());
+//=====================================================================================
+// function : RecreateActor()
+// purpose :
+//=====================================================================================
+void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
+ QApplication::setOverrideCursor(Qt::waitCursor);
+ try{
+ thePrs->Update();
+ //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
+ for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
+ if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
+ QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
+ if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
+ if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
+ thePrs->UpdateActor(anActor);
+ }
+ }catch(std::runtime_error& ex){
+ INFOS(ex.what());
+ QApplication::restoreOverrideCursor();
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()),
+ tr ("VISU_BUT_OK") );
+ for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
+ if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
+ QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
+ if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)) {
+ if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
+ aViewFrame->RemoveActor(anActor);
+ anActor->Delete();
+ }
+ }
+ }
+ return;
}
+ QApplication::restoreOverrideCursor();
}
PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
if (aPrsObject) { \
DlgName* aDlg = new DlgName(); \
- aDlg->initFromPrsObject(aPrsObject); \
+ aDlg->initFromPrsObject(aPrsObject); \
if ( aDlg->exec() ) { \
- aDlg->storeToPrsObject(aPrsObject); \
+ if(!(aDlg->storeToPrsObject(aPrsObject))){ \
+ delete aDlg; \
+ return; \
+ } \
RecreateActor(aPrsObject); \
- /*RepaintCurrentView();*/ \
- VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
- if (vf) { \
+ if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
vf->getRenderer()->ResetCameraClippingRange(); \
- vf->onViewFitAll(); \
+ vf->Repaint(); \
}\
} \
} \
} \
}
-
void VisuGUI::EditPrs() {
- VISU::Prs3d_i* aPrs3d = GetSelectedPrs();
+ VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
switch (aPrs3d->GetType()) {
case VISU::TMESH: // Mesh 13
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);
+ //EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
+ {
+ VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
+ if (aPrsObject) {
+ VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false);
+ aDlg->initFromPrsObject(aPrsObject);
+ aDlg->show();
+ myActiveDialogBox = aDlg;
+// if ( aDlg->exec() ) {
+// if(!(aDlg->storeToPrsObject(aPrsObject))){
+// delete aDlg;
+// return;
+// }
+// RecreateActor(aPrsObject);
+// if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
+// if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
+// vf->getRenderer()->ResetCameraClippingRange();
+// vf->Repaint();
+// }
+// }
+// }
+// delete aDlg;
+ }
+ }
+ break;
+
+ case VISU::TCUTLINES: // Cut planes 42
+ //EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
+ {
+ VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
+ if (aPrsObject) {
+ VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(false);
+ aDlg->initFromPrsObject(aPrsObject);
+ aDlg->show();
+ myActiveDialogBox = aDlg;
+// if ( aDlg->exec() ) {
+// aDlg->storeToPrsObject(aPrsObject);
+// RecreateActor(aPrsObject);
+// if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
+// if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
+// vf->getRenderer()->ResetCameraClippingRange();
+// vf->Repaint();
+// }
+// }
+// // Remove old Table
+// SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
+// SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(aPrsObject->GetEntry());
+// if(!aSObject->_is_nil()) {
+// SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
+// SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
+// for ( ;aIter->More(); aIter->Next()) {
+// SALOMEDS::SObject_var aTblObj = aIter->Value();
+// if (!aTblObj->_is_nil()) {
+// SALOMEDS::GenericAttribute_var anAttr;
+// if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
+// aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
+// break;
+// }
+// }
+// }
+// if (aDlg->isGenerateTable()) {
+// GetVisuGen()->CreateTable(aSObject->GetID());
+// if (aDlg->isGenerateCurves()) {
+// SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
+// SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
+// SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
+// for ( ;aIter->More(); aIter->Next()) {
+// SALOMEDS::SObject_var aTblObj = aIter->Value();
+// if (!aTblObj->_is_nil()) {
+// SALOMEDS::GenericAttribute_var anAttr;
+// if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
+// CreatePlot(aTblObj);
+// }
+// }
+
+// }
+// }
+// }
+// GetActiveStudy()->updateObjBrowser();
+// }
+// }
+// delete aDlg;
+ }
+ }
break;
case VISU::TISOSURFACE: // Iso surfaces
case VISU::TSTREAMLINES:
EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
- }
-}
-
-
-//=====================================================================================
-// 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();
- }
- delete aDlg;
+ break;
+ default:
+ return;
}
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(&anIO);
+ if ( !CORBA::is_nil( anObject ) )
+ if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
+ vf->highlight(anIO, 1);
}
// purpose :
//=====================================================================================
void VisuGUI::CreateMesh() {
+ SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
+ SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
- //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;
+ if (checkLock(GetStudyDocument())) return;
SALOMEDS::SObject_var aSObj = aSObject->GetFather();
aSObj = aSObj->GetFather();
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::Result_var aResult;
+ if (!CORBA::is_nil(anObject)) {
+ aResult = VISU::Result::_narrow(anObject);
+ }
+ if(CORBA::is_nil(aResult)) {
+ QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("WRN_NO_AVAILABLE_DATA"),
+ tr ("VISU_BUT_OK"));
+ return;
+ }
VISU::Storable::TRestoringMap aMap;
SALOMEDS::GenericAttribute_var anAttr;
if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
if(!isExist) return;
CORBA::Object_var aMesh;
string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
+#ifdef CHECKTIME
+ Utils_Timer timer;
+ timer.Start();
+#endif
+ VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
if(aComment == "ENTITY"){
VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
- aMesh = myComponent->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
+ if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
+ aMesh = GetVisuGen()->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());
+ if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
+ aMesh = GetVisuGen()->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());
+ if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
+ aMesh = GetVisuGen()->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");
+ MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
timer.Show();
#endif
+
+ QApplication::restoreOverrideCursor();
+ VISU::Mesh_i* pPresent = NULL;
+ if(!CORBA::is_nil(aMesh))
+ pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
+ if (pPresent == NULL) {
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_CANT_BUILD_PRESENTATION"),
+ tr ("VISU_BUT_OK") );
+ return;
+ }
+
if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
- vtkRenderer *aRenderer = vf->getRenderer();
- //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1);
- //visuGUI->ShowTrihedron(true);
+ try{
+ VISU_Actor *anActor = pPresent->CreateActor();
#ifdef CHECKTIME
- OSD_Timer timer;
- timer.Start();
+ Utils_Timer timer;
+ timer.Start();
#endif
- vf->AddActor(anActor);
- vf->getRenderer()->AddActor(anActor->EdgeDevice);
- vf->getRenderer()->ResetCameraClippingRange();
- vf->onViewFitAll();
+ vf->AddActor(anActor);
+ SetFitAll(vf);
#ifdef CHECKTIME
- timer.Stop();
- MESSAGE("Check time on VisuGUI::CreateMesh - vf->AddActor + vf->onViewFitAll");
- timer.Show();
+ timer.Stop();
+ MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
+ timer.Show();
#endif
+ //GetActiveStudy()->updateObjBrowser(); //not necessary
+ GetDesktop()->putInfo("Ready");
+ }catch(std::runtime_error& exc){
+ INFOS(exc.what());
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()),
+ tr ("VISU_BUT_OK") );
+ }
}
- myActiveStudy->updateObjBrowser(); //update Object browser
- myDesktop->putInfo("Ready");
}
+//=====================================================================================
+// function : CreateManyMesh()
+// purpose :
+//=====================================================================================
+void VisuGUI::CreateManyMesh(){
+ if (checkLock(GetStudyDocument())) return;
+
+ SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for ( ; It.More(); It.Next() ) {
+ SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
+ 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 = GetVisuGen()->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 = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
+ }else if(aComment == "GROUP"){
+ string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
+ aMesh = GetVisuGen()->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).in());
+ try{
+ VISU_Actor *anActor = pPresent->CreateActor();
+ if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
+ vf->AddActor(anActor);
+ SetFitAll(vf);
+ }
+ GetDesktop()->putInfo("Ready");
+ }catch(std::runtime_error& exc){
+ INFOS(exc.what());
+ }
+ }
+}
//=====================================================================================
// 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();
+static void ShrinkMesh(VISU_Actor *theActor){
+ if(theActor->IsShrunk())
+ theActor->UnShrink();
+ else
+ theActor->SetShrink();
+}
+
+void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
+ if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
+ if(VISU_Actor* anActor = GetActor(aPrsObject)){
+ switch (theType) {
+ case VISU::SHRINK:
+ ShrinkMesh(anActor);
break;
+ default:
+ if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
+ aMesh->SetPresentationType(theType);
+ RecreateActor(aMesh);
+ }else
+ anActor->SetRepresentation(theType);
}
- aPrevSource = anObject->GetSource();
- anObject = aPrevSource->GetInputs()[0];
+ if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
+ vf->Repaint();
}
-
+}
- Actor->IsShrunk = false;
- if ( Actor->GetProperty()->GetRepresentation() == 2 )
- Actor->EdgeDevice->VisibilityOn();
- }
+
+void VisuGUI::MakeSurfaceframe() {
+ ChangeRepresentation(VISU::SURFACEFRAME);
}
-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::MakeInsideframe() {
+ ChangeRepresentation(VISU::INSIDEFRAME);
+}
void VisuGUI::MakeWireframe() {
- ChangeRepresentation(WIREFRAME);
+ ChangeRepresentation(VISU::WIREFRAME);
}
-
void VisuGUI::MakeSurface() {
- ChangeRepresentation(SURFACE);
+ ChangeRepresentation(VISU::SHADED);
}
-
void VisuGUI::MakePoints() {
- ChangeRepresentation(POINTS);
+ ChangeRepresentation(VISU::POINT);
}
-
void VisuGUI::MakeShrink() {
- ChangeRepresentation(SHRINK);
+ ChangeRepresentation(VISU::SHRINK);
}
// 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::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
+ CORBA::Object_var anObject = GetSelectedObj(theIO);
+ if(CORBA::is_nil(anObject)) return NULL;
+ PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+ if(!aServant.in()) return NULL;
+ return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
}
void VisuGUI::ChageColor() {
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
+ VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
if(!aPrsObject) return;
VISU_Actor* anActor = GetActor(aPrsObject);
NewColor(anActor);
}
-void VisuGUI::ChangeOutlineColor() {
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
+void VisuGUI::ChangeWireframeColor() {
+ VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
if(!aPrsObject) return;
- VISU_Actor* anActor = GetActor(aPrsObject);
+ VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
if (!anActor) return;
- NewOutlineColor(anActor);
+ NewWireframeColor(anActor);
}
void VisuGUI::ChangeOpacity() {
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
+ VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
if(!aPrsObject) return;
VISU_Actor* anActor = GetActor(aPrsObject);
void VisuGUI::ChangeLines() {
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
+ VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
if(!aPrsObject) return;
VISU_Actor* anActor = GetActor(aPrsObject);
}
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 ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
+ Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->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() );
+ SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
if ( !TableSO->_is_nil() ) {
- SALOMEDS::ChildIterator_var Iter = visuGUI->myActiveStudy->getStudyDocument()->NewChildIterator( TableSO );
+ SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->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 ) );
+ VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
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() ) ) {
}
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() ) );
+ plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
+ //plotCurve->setVerTitle( theCurve->GetVerTitle().c_str() );
+ plotCurve->setVerTitle( theCurve->GetName() );
+ plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
+ plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
/* - DATA NOT UPDATED */
- if ( !plotCurve->isAutoAssign() ) {
+ double* xList = 0;
+ double* yList = 0;
+ int nbPoints = theCurve->GetData( xList, yList );
+ if ( nbPoints > 0 && xList && yList ) {
+ plotCurve->setData( xList, yList, nbPoints );
+ }
+ if ( !theCurve->IsAuto() ) {
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() );
}
+ plotCurve->setAutoAssign( theCurve->IsAuto() );
aPlot->displayCurve( plotCurve, false );
}
else {
Plot2d_Curve* crv = theCurve->CreatePresentation();
- if ( crv )
+ if ( crv ) {
aPlot->displayCurve( crv, false );
+ theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
+ theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
+ SALOMEDS::Color newColor;
+ newColor.R = crv->getColor().red()/255.;
+ newColor.G = crv->getColor().green()/255.;
+ newColor.B = crv->getColor().blue()/255.;
+ theCurve->SetColor( newColor );
+ crv->setAutoAssign( theCurve->IsAuto() );
+ }
}
}
}
}
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 ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
+ Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
// if ( theDisplaying == VISU::eDisplayOnly )
// aPlot->EraseAll();
QList<Plot2d_Curve> clist;
}
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->setHorTitle( theCurve->GetHorTitle().c_str() );
+ //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
+ plotCurve->setVerTitle( theCurve->GetName() );
+ plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
+ plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
+ double* xList = 0;
+ double* yList = 0;
+ int nbPoints = theCurve->GetData( xList, yList );
+ if ( nbPoints > 0 && xList && yList ) {
+ plotCurve->setData( xList, yList, nbPoints );
+ }
+ if ( !theCurve->IsAuto() ) {
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() );
}
+ plotCurve->setAutoAssign( theCurve->IsAuto() );
aPlot->displayCurve( plotCurve, false );
}
else {
Plot2d_Curve* crv = theCurve->CreatePresentation();
if ( crv ) {
aPlot->displayCurve( crv, false );
+ theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
+ theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
+ SALOMEDS::Color newColor;
+ newColor.R = crv->getColor().red()/255.;
+ newColor.G = crv->getColor().green()/255.;
+ newColor.B = crv->getColor().blue()/255.;
+ theCurve->SetColor( newColor );
+ crv->setAutoAssign( theCurve->IsAuto() );
}
}
}
}
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 ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
+ Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
if ( theDisplaying == VISU::eDisplayOnly )
aPlot->EraseAll();
QList<Plot2d_Curve> clist;
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()), "", "" ) );
+ Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( 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 );
}
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->setHorTitle( theCurve->GetHorTitle().c_str() );
+ //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
+ plotCurve->setVerTitle( theCurve->GetName() );
+ plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
+ plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
+ double* xList = 0;
+ double* yList = 0;
+ int nbPoints = theCurve->GetData( xList, yList );
+ if ( nbPoints > 0 && xList && yList ) {
+ plotCurve->setData( xList, yList, nbPoints );
+ }
+ if ( !theCurve->IsAuto() ) {
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() );
}
+ plotCurve->setAutoAssign( theCurve->IsAuto() );
aPlot->displayCurve( plotCurve, false );
}
else {
Plot2d_Curve* crv = theCurve->CreatePresentation();
- if ( crv )
+ if ( crv ) {
aPlot->displayCurve( crv, false );
+ theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
+ theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
+ SALOMEDS::Color newColor;
+ newColor.R = crv->getColor().red()/255.;
+ newColor.G = crv->getColor().green()/255.;
+ newColor.B = crv->getColor().blue()/255.;
+ theCurve->SetColor( newColor );
+ crv->setAutoAssign( theCurve->IsAuto() );
+ }
}
}
}
aPlot->Repaint();
}
}
+
/*!
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() );
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
if( Sel->IObjectCount() !=1 )
return;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(&anIO);
SALOMEDS::SObject_var SO;
if ( !CORBA::is_nil( 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 ) );
+ VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
if ( table ) {
- SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
+ SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
}
}
}
} else {
// possibly this is Table SObject
- SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( anIO->getEntry() );
+ SO = GetActiveStudy()->getStudyDocument()->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 );
+ false,
+ //SAL2670 Orientation of show tables
+ SALOMEGUI_TableDlg::ttAuto,
+ Qt::Vertical );
dlg->show();
}
+
+
+/*!
+ Slot : opens Table view : for Table object or SObject with table attribute selected
+*/
+void VisuGUI::CreateTable() {
+ SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
+ if( aSel->IObjectCount() !=1 )
+ return;
+
+ Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
+ if (anIO->hasEntry()){
+ SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
+ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
+ if(!aSObject->_is_nil()) {
+ CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
+ VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
+ if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
+ GetVisuGen()->CreateTable(aSObject->GetID());
+ GetActiveStudy()->updateObjBrowser();
+ }
+ }
+ }
+}
+
+
+/*!
+ Slot : deletes SObject with all subobjects
+*/
+void VisuGUI::DeleteObject() {
+ SALOMEDS::Study_var aStudy = GetStudyDocument();
+ if (checkLock(aStudy)) return;
+
+ SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
+ if( aSel->IObjectCount() !=1 )
+ return;
+ Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
+ if (anIO->hasEntry()){
+ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
+ if(!aSObject->_is_nil()){
+ SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
+ for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
+ SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
+ CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
+ ::ErasePrs(aChildObj);
+ }
+ SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
+ // There is a transaction
+ aStudyBuilder->NewCommand();
+ CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
+ if(!CORBA::is_nil(anObj)){
+ VISU::Base_var aBase = VISU::Base::_narrow(anObj);
+ if(!CORBA::is_nil(aBase)){
+ VISU::VISUType aType = aBase->GetType();
+ switch (aType){
+ case VISU::TRESULT:{
+ SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
+ for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
+ SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
+ CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
+ if(CORBA::is_nil(aChildObj)) continue;
+ VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
+ if(CORBA::is_nil(aPrs3d)) continue;
+ VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
+ DeletePresentation(pPrs3d);
+ }
+ break;
+ }}
+ }
+ }
+ aStudyBuilder->RemoveObjectWithChildren(aSObject);
+ aStudyBuilder->CommitCommand();
+ GetActiveStudy()->unHighlightAll();
+ GetActiveStudy()->updateObjBrowser(true);
+ }
+ }
+}
+
+
+/*!
+ Slot : deletes empty container
+*/
+void VisuGUI::CreatePlot2dView() {
+ if (checkLock(GetStudyDocument())) return;
+ GetVisuGen()->CreateContainer();
+ GetActiveStudy()->updateObjBrowser( true );
+}
+
+
+
/*!
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() );
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
if( Sel->IObjectCount() !=1 )
return;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
+ CORBA::Object_var anObject = GetSelectedObj();
SALOMEDS::SObject_var SO;
if ( !CORBA::is_nil( anObject ) ) {
VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
// 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 ) );
+ VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
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" ) ) ) {
+ SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
+ if ( IsSObjectTable(SO) ) {
// get name of SObject
if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
aName = SALOMEDS::AttributeName::_narrow( anAttr );
- SOName = strdup( aName->Value() );
+ SOName = aName->Value();
}
Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
if ( dlg->exec() == QDialog::Accepted ) {
- if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
+ if ( !isStudyLocked( GetActiveStudy()->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();
+ CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
if( !CORBA::is_nil( aContainer ) ) {
- VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( 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 = myComponent->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
+ CORBA::Object_var aNewCurve = GetVisuGen()->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 ) );
+ VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
if ( pCrv ) {
bool isAuto;
int marker, line, lineWidth;
}
}
}
- VisuGUI::myActiveStudy->updateObjBrowser( true );
+ GetActiveStudy()->updateObjBrowser( true );
PlotContainer( pContainer, VISU::eDisplay );
}
}
Plot2d_CurveContainer container;
dlg->getCurves( container );
if ( !container.isEmpty() ) {
- ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
+ ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
getRightFrame()->getViewFrame()))->displayCurves( container, true );
- ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
+ ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
getRightFrame()->getViewFrame()))->setTitle( SOName );
}
}
QString SOName;
// 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" ) ) ) {
+ SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
+ if ( IsSObjectTable(SO) ) {
// get name of SObject
if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
aName = SALOMEDS::AttributeName::_narrow( anAttr );
- SOName = strdup( aName->Value() );
+ SOName = aName->Value();
}
Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
if ( dlg->exec() == QDialog::Accepted ) {
- if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) {
+ if ( !isStudyLocked( GetActiveStudy()->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();
+ CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
+ CORBA::Object_var aContainer = GetVisuGen()->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 ) );
+ 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 = myComponent->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
+ CORBA::Object_var aNewCurve = GetVisuGen()->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 ) );
+ VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
if ( pCrv ) {
bool isAuto;
int marker, line, lineWidth;
}
}
}
- VisuGUI::myActiveStudy->updateObjBrowser( true );
+ GetActiveStudy()->updateObjBrowser( true );
PlotContainer( pContainer, VISU::eDisplay );
}
}
}
- }
- else {
+ } 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 ) {
+ if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
Plot2d_CurveContainer container;
dlg->getCurves( container );
if ( !container.isEmpty() ) {
- ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
+ ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
getRightFrame()->getViewFrame()))->displayCurves( container, true );
- ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()->
+ ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
getRightFrame()->getViewFrame()))->setTitle( SOName );
}
}
}
}
delete dlg;
+ }
+ }
+}
+
+
+void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) {
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+
+ if ( IsSObjectTable(theTableSO) ) {
+ CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO);
+ CORBA::Object_var aContainer = GetVisuGen()->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 = 2; i <= pTable->GetNbRows(); i++ ) {
+ CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), 1, i );
+ if( !CORBA::is_nil( aNewCurve ) ) {
+ VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
+ if ( pCrv ) {
+ pContainer->AddCurve( pCrv->_this() );
+ }
+ }
+ }
+ GetActiveStudy()->updateObjBrowser( true );
+ PlotContainer( pContainer, VISU::eDisplay );
+ }
}
}
}
+
+
/*!
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() );
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
if( Sel->IObjectCount() !=1 )
return;
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
+ CORBA::Object_var anObject = GetSelectedObj();
SALOMEDS::SObject_var SO;
if (CORBA::is_nil( anObject )) return;
// 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() ) ) {
+ VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+ if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
dlg->setMarker( (int)curve->GetMarker() );
newColor.G = dlg->getColor().green()/255.;
newColor.B = dlg->getColor().blue()/255.;
curve->SetColor( newColor );
- QList<QAD_StudyFrame> sfList = VisuGUI::myActiveStudy->getStudyFrames();
+ QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
if ( sfList.count() > 0 ) {
QListIterator<QAD_StudyFrame> it( sfList );
for ( ; it.current(); ++it ) {
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() );
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
if( Sel->IObjectCount() !=1 )
return;
-
- string aComment;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy );
+
+ CORBA::Object_var anObject = GetSelectedObj();
SALOMEDS::SObject_var SO;
if (CORBA::is_nil( anObject )) return;
// 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() ) ) {
+ VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
+ if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
container->Clear();
- VisuGUI::myActiveStudy->updateObjBrowser();
+ GetActiveStudy()->updateObjBrowser();
}
}
}
}
+/*!
+ Slot : Edit container contents : for Container object selected
+*/
+void VisuGUI::EditContainer() {
+ CORBA::Object_var anObject = GetSelectedObj();
+ if(CORBA::is_nil(anObject)) return;
+ 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();
+ aDlg->initFromPrsObject(aContainer);
+ if (aDlg->exec()) {
+ aDlg->storeToPrsObject(aContainer);
+ GetActiveStudy()->updateObjBrowser( true );
+ }
+ delete aDlg;
+}
+
void VisuGUI::DeletePrs() {
- DeletePresentation(GetSelectedPrs());
+ SALOMEDS::Study_var aStudy = GetStudyDocument();
+ if (checkLock(aStudy)) return;
+
+ // There is a transaction
+ SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
+ aStudyBuilder->NewCommand();
+
+ DeletePresentation(GetSelectedPrs3d());
+
+ aStudyBuilder->CommitCommand();
}
+
void VisuGUI::SaveViewParams()
{
- 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 )
- 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 )
+ if (checkLock(GetStudyDocument())) return;
+ SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
+ QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
+ if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
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 )
- 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 ( aSel->IObjectCount() == 0 ) {
+ VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1());
+ }else{
+ const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
+ VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName());
}
+ GetActiveStudy()->updateObjBrowser( true );
}
+
+
void VisuGUI::RestoreViewParams()
{
- 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 ) )
+ SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
+ QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
+ if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
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 )
- 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 = aSel->firstIObject();
+ VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName());
}
+
//=====================================================================================
// 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);
- }
- }
- }
- }
- }
+ bool isExist;
+ VISU::Storable::TRestoringMap aMap;
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+ if(isExist && aType == VISU::TVIEW3D){
+ SALOMEDS::Study_var aStudy = GetStudyDocument();
+ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
+ aStudy->NewBuilder()->RemoveObject(aSObject);
+
+ SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
+ aSel->RemoveIObject(anIO, 0);
+
+ GetActiveStudy()->updateObjBrowser( true );
}
- VisuGUI::myActiveStudy->updateObjBrowser( true );
}
// purpose :
//=====================================================================================
void VisuGUI::Sweep() {
- VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs());
+ VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
if (!aPrsObject) return;
+ VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
+ if(!vf) return;
+
int aTemp=100000;
QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
if ( !aTempoStr.isEmpty() )
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
+ try{
for (int j=0 ; j<aCycles; j++) {
for (int i=0 ; i<=aSteps; i++) {
- aLookupTbl->SetMapScale(float(i)/float(aSteps));
- RepaintCurrentView();
+ float aPercents = float(i)/aSteps;
+ aPrsObject->SetMapScale(aPercents);
+ aPrsObject->UpdateActor(aActor);
+ vf->getRW()->getRenderWindow()->Render();
usleep(aTemp);
}
}
- break;
-
- 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;
-
- 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();
- }
- }
- break;
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!");
}
QApplication::restoreOverrideCursor();
}
void VisuGUI::TimeAnimation() {
- VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(myStudy);
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
+ VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
bool isDefined = false;
long aNbTimes = 0;
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
for (; It.More(); It.Next()) {
- SALOMEDS::SObject_var aSObject = myStudy->FindObjectID( It.Value()->getEntry() );
+ SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() );
if (aSObject->_is_nil()) continue;
if (getValue(aSObject, "myComment") == QString("FIELD")) {
long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
}
-
void VisuGUI::ImportMedField() {
- if (checkLock(myStudy)) return;
-
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
+ if (checkLock(GetStudyDocument())) return;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->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());
+ SALOMEDS::SObject_var aSObject = GetStudyDocument()->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;
- }
- }
- }
- }
+ 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()->ImportMed( aSObject );
+ SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
+ if(!CORBA::is_nil(aField.in()))
+ GetVisuGen()->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()->ImportMed(aSObject);
+ //if(strcmp(aValue.in(),"MEDMESH") == 0)
+ // VisuGUI::myComponent->ImportMed(aSObject);
}
}
}
- VisuGUI::myActiveStudy->updateObjBrowser( true );
+ GetActiveStudy()->updateObjBrowser( true );
QApplication::restoreOverrideCursor();
}
-/*
-void VisuGUI::ImportMedMesh() {
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
+
+//=====================================================================================
+// functions : Rename()
+// purpose :
+//=====================================================================================
+void VisuGUI::Rename() {
+ if (checkLock(GetStudyDocument())) return;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->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 );
+ SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
+ if( aSObj->_is_nil() ) return;
+
+ VISU::Curve_i* curve = 0;
+ CORBA::Object_var anObject = GetSelectedObj();
+ if ( !CORBA::is_nil( anObject )) {
+ VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
+ if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
+ // Curve object
+ CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
+ if( !CORBA::is_nil( aCurve ) ) {
+ curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+ }
}
- SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject );
- if( !CORBA::is_nil( aSupport ) ) {
- VisuGUI::myComponent->ImportMedSupport( aSupport );
- VisuGUI::myActiveStudy->updateObjBrowser( true );
+ }
+
+ //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 );
+ if ( curve )
+ curve->SetName( Name.latin1() );
+ GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
+ QApplication::restoreOverrideCursor();
+
+ //int TypeMode; bool InViewer;
+ //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
+ //ActorTmp->setName((Standard_CString)Name.latin1());
}
}
}
-*/
+
//=====================================================================================
-// functions : Rename()
+// functions : RenameTable()
// purpose :
//=====================================================================================
-void VisuGUI::Rename() {
- if (checkLock(myStudy)) return;
- VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
- SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() );
+void VisuGUI::RenameTable() {
+ if (checkLock(GetStudyDocument())) return;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
+ if ( Sel->IObjectCount() != 1 )
+ return;
+ SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
+ if( aSObj->_is_nil() ) return;
+
+ VISU::Table_i* table = 0;
+ CORBA::Object_var anObject = GetSelectedObj();
+ if ( !CORBA::is_nil( anObject )) {
+ VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
+ if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
+ // Table object
+ CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
+ if( !CORBA::is_nil( aTable ) ) {
+ table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
+ }
+ }
+ }
+
+ //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 );
+ if ( table )
+ table->SetName( Name.latin1() );
+ GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
+ QApplication::restoreOverrideCursor();
+
+ //int TypeMode; bool InViewer;
+ //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
+ //ActorTmp->setName((Standard_CString)Name.latin1());
+ }
+ }
+}
+
+
+
+//=====================================================================================
+// functions : RenameContainer()
+// purpose :
+//=====================================================================================
+void VisuGUI::RenameContainer() {
+ if (checkLock(GetStudyDocument())) return;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
if ( Sel->IObjectCount() != 1 )
return;
- SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( Sel->firstIObject()->getEntry() );
+ SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
if( aSObj->_is_nil() ) return;
+ VISU::Container_i* container = 0;
+ CORBA::Object_var anObject = GetSelectedObj();
+ if ( !CORBA::is_nil( anObject )) {
+ VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
+ if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
+ // Curve object
+ CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
+ if( !CORBA::is_nil( aContainer ) ) {
+ container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
+ }
+ }
+ }
+
//TEST DU PARENT == VISU
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
if ( !Name.isEmpty() ) {
QApplication::setOverrideCursor( Qt::waitCursor );
- VisuGUI::myActiveStudy->renameIObject( Sel->firstIObject(), Name );
+ if ( container )
+ container->SetName( Name.latin1() );
+ GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
QApplication::restoreOverrideCursor();
//int TypeMode; bool InViewer;
}
+
//=====================================================================================
// function : CopyPresentation()
// purpose :
//=====================================================================================
void VisuGUI::CopyPresentation(){
- if (checkLock(myStudy)) return;
- VISU::Prs3d_i* aPrsObject = GetSelectedPrs();
+ if (checkLock(GetStudyDocument())) return;
+ VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
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(aSameMesh);
}
break;
case VISU::TSCALARMAP:
VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
aSameScalar->SameAs(aScalarPrs);
- UpdateViewer(aSameScalar, true);
+ UpdateViewer(aSameScalar);
}
break;
case VISU::TDEFORMEDSHAPE:
VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
aSameDeformed->SameAs(aDefPrs);
- UpdateViewer(aSameDeformed, true);
+ UpdateViewer(aSameDeformed);
}
break;
case VISU::TCUTPLANES:
VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
aSameCut->SameAs(aCutPrs);
- UpdateViewer(aSameCut, true);
+ UpdateViewer(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());
+ aSameCut->SameAs(aCutPrs);
+ UpdateViewer(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());
aSameIso->SameAs(aIsoPrs);
- UpdateViewer(aSameIso, true);
+ UpdateViewer(aSameIso);
}
break;
case VISU::TSTREAMLINES:
VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
aSameLines->SameAs(aLinesPrs);
- UpdateViewer(aSameLines, true);
+ UpdateViewer(aSameLines);
}
break;
case VISU::TVECTORS:
VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
aSameVectors->SameAs(aVectorsPrs);
- UpdateViewer(aSameVectors, true);
+ UpdateViewer(aSameVectors);
}
break;
}
- myActiveStudy->updateObjBrowser();
+ GetActiveStudy()->updateObjBrowser();
}
-//=====================================================================================
-// function : InfoOnPoint() [ slot ]
-// purpose :
-//=====================================================================================
-void VisuGUI::InfoOnPoint()
-{
- 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 );
- else
- QAD_MessageBox::warn1( visuGUI->myDesktop,
- tr ("WARNING"),
- tr ("Not Cell/Edge selection mode"),
- tr ("VISU_BUT_OK") );
-}
//=====================================================================================
-// function : SelectPoint() [ slot ]
+// function : DefinePopup()
// purpose :
//=====================================================================================
-void VisuGUI::SelectPoint()
+void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
{
- 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 );
+ theObject = "";
+ theContext = "";
}
+
//=====================================================================================
-// function : SelectCell() [ slot ]
-// purpose :
+// function : checkHomoSelection()
+// purpose :
//=====================================================================================
-void VisuGUI::SelectCell()
+enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
+int VisuGUI::checkHomoSelection()
{
- 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);
+ int selMode = homoNone;
+ SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for ( ; It.More(); It.Next() ) {
+ int selNext = homoOther;
+ Handle(SALOME_InteractiveObject)& anIO = It.Value();
+ if ( anIO->hasEntry() ) {
+ SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
+ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
+ VISU::Storable::TRestoringMap pMap;
+ if( !aSObject->_is_nil() ) {
+ CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
+ if ( !CORBA::is_nil( aCORBAObject ) ) {
+ VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
+ if ( !CORBA::is_nil( aVisuObj ) ) {
+ VISU::VISUType aType = aVisuObj->GetType();
+ switch( aType ) {
+ case VISU::TTABLE:
+ case VISU::TCURVE:
+ case VISU::TCONTAINER:
+ selNext = homoCurves; break;
+ case VISU::TMESH:
+ case VISU::TSCALARMAP:
+ case VISU::TISOSURFACE:
+ case VISU::TDEFORMEDSHAPE:
+ case VISU::TCUTPLANES:
+ case VISU::TCUTLINES:
+ case VISU::TVECTORS:
+ case VISU::TSTREAMLINES:
+ selNext = homoPresentations; break;
+ case VISU::TFIELD:
+ if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
+ selNext = homoAnimatable; break;
+ }
+ selNext = homoOther; break;
+ default:
+ selNext = homoOther;
+ }
+ }
+ }
+ else {
+ 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, pMap );
+ bool isExist;
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
+ if( isExist ) {
+ switch ( aType ) {
+ case VISU::TENTITY:
+ case VISU::TFAMILY:
+ case VISU::TGROUP:
+ selNext = homoPresentable; break;
+ case VISU::TFIELD:
+ if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
+ selNext = homoAnimatable; break;
+ }
+ selNext = homoOther; break;
+ default:
+ selNext = homoOther;
+ }
+ }
+ }
+ }
+ }
+ }
+ if ( selMode == homoNone )
+ selMode = selNext;
+ else {
+ if ( selMode != selNext )
+ return homoNone;
+ }
}
- 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);
+ return selMode;
}
//=====================================================================================
-// function : DefinePopup()
-// purpose :
+// function : GetNbChildren() [ static ]
+// purpose : get number of children
//=====================================================================================
-void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
+int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
{
- VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
- theObject = "";
- theContext = "";
+ if ( SO->_is_nil() )
+ return 0;
+ int cnt = 0;
+ SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
+ for ( ; Iter->More(); Iter->Next() ) {
+ SALOMEDS::SObject_var refSO;
+ if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
+ cnt++;
+ }
+ return cnt;
}
-
//=====================================================================================
// function : CustomPopup()
// purpose :
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);
+ bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() );
+
+ bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
+ SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
+ QString aParentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
+ int nbSel = aSelection->IObjectCount();
+
thePopup->clear();
- SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection());
- if ( Sel->IObjectCount() == 0 ) {
- if ( theParent == "Viewer" && isVTKViewer)
- // Available only for VTK viewer
+ if ( nbSel == 0 ) {
+ if ( theParent == "Viewer" && isVTKViewer && !aIsLocked)
thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
return false;
}
-
+ if( nbSel > 1 ) {
+ int selMode = checkHomoSelection();
+ if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
+ if ( selMode == homoCurves ) {
+ if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
+ thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
+ thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
+ thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
+ }
+ }
+ else if ( selMode == homoPresentations ) {
+ if (isVTKViewer) {
+ thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
+ thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
+ }
+ }
+ else if ( selMode == homoPresentable ) {
+ if (!aIsLocked) thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));
+ }
+ else if ( selMode == homoAnimatable ) {
+ thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
+ }
+ return true;
+ }
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;
-
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
if (!CORBA::is_nil(anObject)) {
+ SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
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);
+ if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
switch (aType) {
case VISU::TVISUGEN:
- thePopup->insertItem("Import From File", visuGUI, SLOT(ImportFromFile()));
+ thePopup->insertItem("Import MED", visuGUI, SLOT(ImportFile()));
+ thePopup->insertItem("Import TABLE", visuGUI, SLOT(ImportTablesFromFile()));
+ thePopup->insertItem("Create Plot2d View", visuGUI, SLOT(CreatePlot2dView()));
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()));
+ if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
break;
case VISU::TTABLE:
+ if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
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() ) );
+ if (!aIsLocked) thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
+ thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
+ thePopup->insertSeparator();
+ if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
+ if ( GetNbChildren( aSObject, false ) > 0 ) {
+ thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
+ thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
+ thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
+ }
}
+ thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
break;
case VISU::TCURVE:
- if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) )
+ if ( !aIsLocked ) {
thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
+ thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
+ }
+ if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
+ if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
else
thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
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() ) );
- }
- }
- }
+// 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).in());
+// if ( container ) {
+// if ( !aIsLocked ) {
+// thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
+// thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
+// if (container->GetNbCurves() > 0)
+// thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
+// }
+// if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
+// thePopup->insertSeparator();
+// thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
+// thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
+// thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
+// }
+// }
+// }
+// }
+ if ( !aIsLocked ) {
+ thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
+ thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
+ thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
+ }
+ if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
+ thePopup->insertSeparator();
+ thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
+ thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
+ thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
}
+ if ( !aIsLocked ) thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
break;
default: // Presentation
{
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
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()));
+ if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
+ QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
+ int aRepresent = anVISUActor->GetRepresentation();
+ switch(aRepresent){
+ case VISU::POINT :
+ aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
+ aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
+ if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
+ aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
+ if (aType == VISU::TMESH)
+ aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
+ break;
+ case VISU::WIREFRAME :
+ aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
+ aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
+ if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
+ aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
+ if (aType == VISU::TMESH)
+ aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
+ break;
+ case VISU::SHADED :
+ aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
+ aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
+ if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
+ aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
+ if (aType == VISU::TMESH)
+ aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
+ break;
+ case VISU::INSIDEFRAME :
+ aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
+ aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
+ aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
+ if (aType == VISU::TMESH)
+ aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
+ break;
+ case VISU::SURFACEFRAME :
+ aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
+ aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
+ aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
+ aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
+ break;
}
- thePopup->insertItem("Representation", aPresMenu);
+ if(anVISUActor->IsShrunkable())
+ if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
+ 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(GetDesktop());
+ if(aType == VISU::TMESH){
+ if(aRepresent == VISU::SURFACEFRAME){
+ aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
+ aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
+ }else
+ aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
+ }else if(aType == VISU::TDEFORMEDSHAPE)
+ aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
+
+ if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
+ aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
+ if (aType != VISU::TVECTORS){
+ aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
+ thePopup->insertItem("Properties", aPropMenu);
+ }
+ thePopup->insertSeparator();
}
-
- // 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 ( !aIsLocked ) 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::TSCALARMAP)
+ if ( !aIsLocked ) thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
+
+ if (aType == VISU::TCUTLINES) {
+ // Check: Does it has living children (tables)
+ SALOMEDS::ChildIterator_var aIter =
+ GetActiveStudy()->getStudyDocument()->NewChildIterator( aSObject );
+ bool isPresent = false;
+ for ( ;aIter->More(); aIter->Next()) {
+ SALOMEDS::SObject_var aTblObj = aIter->Value();
+ isPresent = !aTblObj->_is_nil();
+ if (isPresent) {
+ SALOMEDS::GenericAttribute_var anAttr;
+ isPresent = aTblObj->FindAttribute(anAttr, "AttributeName");
+ if (isPresent) break; // We have at least a one child
+ }
+ }
+ if ((!isPresent) && (!aIsLocked) )
+ thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
+ }
+ thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
- 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();
+ thePopup->insertItem("Selection info...", visuGUI, SLOT(SelectionInfo()));
}
thePopup->insertSeparator();
- if (visuGUI->IsDisplayed(aPrsObject) )
- thePopup->insertItem("Hide", visuGUI, SLOT(ErasePrs()));
+
+ if (visuGUI->IsDisplayed(aPrsObject) ){
+ thePopup->insertItem("Erase", 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()));
+ thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
+ if ((aType != VISU::TMESH) && (!aIsLocked)) {
+ 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;
+ // possibly this is the MED field/mesh and support objects
+ SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
+ if(!CORBA::is_nil(aMED))
+ thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
+ SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
+ if(!CORBA::is_nil(aField))
+ thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
+ if ( aParentComponent != parent->getActiveComponent() ) {
+ //insert pre-defined Display/Erase items
+ if ( thePopup->count() > 0 ) {
+ thePopup->insertSeparator();
+ }
+ thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
+ thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
+ thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
}
- 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() ) );
+ return false;
}
- thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
- thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
- break;
+ }else{
+ SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
+ if(!aSObject->_is_nil()){
+ bool isExist;
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+ if(isExist){
+ switch (aType) {
+ case VISU::TENTITY:
+ case VISU::TFAMILY:
+ case VISU::TGROUP:
+ if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
+ break;
+ case VISU::TVIEW3D:
+ if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
+ thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
+ if ( !aIsLocked ) {
+ if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ // Available only for VTK viewer
+ thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
+ }
+ thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
+ thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
+ }
+ break;
+ case VISU::TFIELD:
+ if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
+ thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
+ break;
+ case VISU::TTIMESTAMP: {
+ 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()));
+ thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
+ "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
+ 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()));
+ }
+ break;
+ }
+ }
+ return false;
+ }else{
+
+ if(IsSObjectTable(aSObject)){
+ thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable()));
+ thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
+ thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
+ thePopup->insertSeparator();
+ thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
+ return false;
+ }
+
+ CORBA::Long aTag = 1;
+ SALOMEDS::SObject_var aSubObject;
+ if(aSObject->FindSubObject(aTag,aSubObject) && IsSObjectTable(aSubObject)) {
+ thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
+ return false;
+ }
- //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( "VisuGUI", tr("ICON_SCALAR_MAP") ),
- "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
- thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_ISO_SURFACES") ),
- "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
- thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_PLANES") ),
- "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
- if(aNunComponent > 1){
- thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_DEFORMED_SHAPE") ),
- "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
- thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_VECTORS") ),
- "Vectors...", visuGUI, SLOT(CreateVectors()));
- thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_STREAM_LINES") ),
- "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
+ aSObject = aSObject->GetFather();
+ if(aSObject->_is_nil()) return false;
+ SALOMEDS::GenericAttribute_var anAttr;
+ aSObject->FindAttribute(anAttr, "AttributeName");
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ if(aName->_is_nil()) return false;
+ CORBA::String_var aValue = aName->Value();
+ //if(strcmp(aValue.in(),"MEDMESH") == 0)
+ // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
+ if(strcmp(aValue.in(),"MEDFIELD") == 0)
+ thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
+ if ( aParentComponent != parent->getActiveComponent() ) {
+ //insert pre-defined Display/Erase items
+ if ( thePopup->count() > 0 ) {
+ thePopup->insertSeparator();
+ }
+ thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
+ thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
+ thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
+ }
+ return false;
+ }
}
}
- }
return false;
}
//===========================================================================
// BuildPresentation
//===========================================================================
-void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
+void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
+ QAD_ViewFrame* )
{
BEGIN_OF("VisuGUI::BuildPresentation");
if (theIO.IsNull()) {
- MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
+ if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
return;
}
- /* Create or retrieve an object VisuGUI */
-
- VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
-
- SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument();
+ SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
+ if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
- vtkRenderer *Renderer = GetRenderer(visuGUI->myActiveStudy);
+ vtkRenderer *Renderer = GetRenderer();
SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
SCRUTE(aSObj);
if (aSObj -> _is_nil() ) {
- MESSAGE("No SObject for interacative object is found");
+ if(MYDEBUG) 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));
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
if ( !aPrsObject ) {
- MESSAGE("The object is not VISU::Prs3d_i");
+ if(MYDEBUG) 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());
- }
- }
- else {
- MESSAGE("CORBA::is_nil(anObject) = true");
- }
+ if(!SelectedActor)
+ try{
+ SelectedActor = aPrsObject -> CreateActor();
+ if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
+ vf->AddActor(SelectedActor);
+ }catch(std::runtime_error& exc){
+ INFOS(exc.what());
+ throw exc;
+ }
+ }else
+ if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
END_OF("VisuGUI::BuildPresentation");
-
}
-extern "C"
-{
-
- 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);
- }
-
- bool SetSettings ( QAD_Desktop* parent )
- {
- return VisuGUI::setSettings( parent );
- }
-
- bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
- const QString & theParent, const QString & theObject )
- {
- return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
- }
- void definePopup ( QString & theContext, QString & theParent, QString & theObject )
- {
- VisuGUI::DefinePopup( theContext, theParent, theObject );
- }
+//===========================================================================
+// SupportedViewType
+//===========================================================================
+void VisuGUI::SupportedViewType(int* buffer, int bufferSize)
+{
+ if (!buffer || !bufferSize) return;
+ buffer[0] = (int)VIEW_VTK;
+ if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
+}
- bool activeStudyChanged ( QAD_Desktop* parent )
- {
- //VisuGUI::activeStudyChanged( parent );
- }
- void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
- {
- VisuGUI::BuildPresentation(theIO);
+extern "C"
+{
+ Standard_EXPORT SALOMEGUI* GetComponentGUI() {
+ if ( !visuGUI )
+ visuGUI = new VisuGUI( "" );
+ return visuGUI;
}
-
}
-// ====================================================================================================================
-// ===================================================================================================================
-
-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();
-
- if ( TCollection_AsciiString(nameComponent).IsEqual(strdup(Type)) ) {
- objres = SALOMEDS::SObject::_narrow(RefObj);
- return true;
- }
- }
- }
- return false;
-}
//////////////////////////////////////////////////////////////////////////////////
//////////////// CHANGE ACTOR COLOR ////////////////////////
//////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
+///////////////// /////////////////////////////////////////////////////////////////
// change actor color
// In : Name of Actor
//
//
-void VisuGUI::NewColor(VISU_Actor *Actor)
-{
- 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() );
-
- if (!colornew.isValid()) return;
-
- 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);
+void VisuGUI::NewColor(VISU_Actor *theActor){
+ if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
+ 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 = theActor->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 = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
+ QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
+ 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(aPrs3d);
+ }
+ }
}
-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() );
-
- if (!colornew.isValid()) return;
-
- 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);
+void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
+ if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
+ if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
+ SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
+ QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
+ QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
+ if(aColorNew.isValid()){
+ aNewColor.R = aColorNew.red()/255.;
+ aNewColor.G = aColorNew.green()/255.;
+ aNewColor.B = aColorNew.blue()/255.;
+ aMesh->SetLinkColor(aNewColor);
+ VisuGUI::RecreateActor(aMesh);
+ }
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////////////
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.);
+ oldopac=Actor->GetOpacity();
+ intopac=int(oldopac*100.+0.5);
CursorDlg->SpinBox1->setMinValue(0);
CursorDlg->SpinBox1->setMaxValue(100);
CursorDlg->SpinBox1->setValue(intopac);
{
intopac = CursorDlg->SpinBox1->value() ;
newopac = intopac/100.;
- Actor->GetProperty()->SetOpacity(newopac);
+ Actor->SetOpacity(newopac);
}
delete CursorDlg;
}
int intlwid;
CursorDlg->Comment1->setText("Set value between");
CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
- oldlwid=Actor->GetProperty()->GetLineWidth();
+ oldlwid=Actor->GetLineWidth();
intlwid=int(oldlwid);
CursorDlg->SpinBox1->setMinValue(1);
CursorDlg->SpinBox1->setMaxValue(10);
if (ret == 1) {
intlwid = CursorDlg->SpinBox1->value() ;
newlwid = intlwid;
- Actor->GetProperty()->SetLineWidth(newlwid);
+ Actor->SetLineWidth(newlwid);
}
delete CursorDlg;
}
/* ======================================================================================== */
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();
+ SALOMEDS::SObject_var aSObj = theField->GetFather();
+ if (CORBA::is_nil(aSObj)) return NULL;
+ aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
+ aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
+ aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
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));
+ VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
if(pResult == NULL)
QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("No Available data in selection"),
+ tr ("WRN_NO_AVAILABLE_DATA"),
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) {\
+ const char* theFieldName, int 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") ); \
+ if(pResult != NULL){ \
+ QApplication::setOverrideCursor( Qt::waitCursor ); \
+ CORBA::Object_var anObject = \
+ GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
+ QApplication::restoreOverrideCursor(); \
+ if(!CORBA::is_nil(anObject)) \
+ return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject).in()); \
} \
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
+ tr ("ERR_CANT_BUILD_PRESENTATION"), \
+ tr ("VISU_BUT_OK") ); \
return NULL; \
}
CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
+CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
bool isExist; \
QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
- if(!isExist && aType.toInt() != VISU::TTIMESTAMP) return false; \
+ 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()); \
+ Utils_Timer timer; \
+ if(MYCHECKTIME) timer.Start(); \
+ TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
+ if(MYCHECKTIME) { \
+ timer.Stop(); \
+ MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \
+ timer.Show(); \
+ } \
if (pPresent) { \
- DLGNAME* aDlg = new DLGNAME(); \
- aDlg->initFromPrsObject(pPresent); \
- if (aDlg->exec()) { \
- aDlg->storeToPrsObject(pPresent); \
- } else { \
- DeletePresentation(pPresent); \
- delete aDlg; \
- return false; \
+ QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
+ if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
+ DLGNAME* aDlg = new DLGNAME(); \
+ aDlg->initFromPrsObject(pPresent); \
+ if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) { \
+ delete aDlg; \
+ } else { \
+ DeletePresentation(pPresent); \
+ delete aDlg; \
+ return false; \
+ } \
} \
- delete aDlg; \
- CreateActor(pPresent); \
+ try { \
+ CreateActor(pPresent); \
+ }catch (...) {\
+ return false;} \
return true; \
} \
return false; \
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::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
+//BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
+bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) {
+ try {
+ 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();
+ Utils_Timer timer;
+ if(MYCHECKTIME) timer.Start();
+ VISU::CutPlanes_i* pPresent =
+ CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt());
+ if(MYCHECKTIME) {
+ timer.Stop();
+ MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT");
+ timer.Show();
+ }
+ if (pPresent) {
+ QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
+ if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
+ VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(true, false);
+ aDlg->initFromPrsObject(pPresent);
+ aDlg->show();
+ myActiveDialogBox = aDlg;
+// if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) {
+// delete aDlg;
+// } else {
+// DeletePresentation(pPresent);
+// delete aDlg;
+// return false;
+// }
+// }
+// CreateActor(pPresent);
+ return true;
+ }
+ }
+}catch (...){return false;}
+ return false;
+}
+
+bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) {
+try {
+ 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();
+ Utils_Timer timer;
+ if(MYCHECKTIME) timer.Start();
+ VISU::CutLines_i* pPresent = CreateCutLinesPrs(theField,aMeshName,
+ (VISU::Entity)anEntity.toInt(),
+ aFieldName,aTimeStampId.toInt());
+ if(MYCHECKTIME) {
+ timer.Stop();
+ MESSAGE("BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT");
+ timer.Show();
+ }
+ if (pPresent) {
+ QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
+ if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
+ VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(true);
+ aDlg->initFromPrsObject(pPresent);
+ aDlg->show();
+ myActiveDialogBox = aDlg;
+ return true;
+// if (aDlg->exec()) {
+// aDlg->storeToPrsObject(pPresent);
+// if (aDlg->isGenerateTable()) {
+// GetVisuGen()->CreateTable(pPresent->GetEntry());
+// if (aDlg->isGenerateCurves()) {
+// SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
+// SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(pPresent->GetEntry());
+// if(!aSObject->_is_nil()) {
+// SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
+// SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
+// for ( ;aIter->More(); aIter->Next()) {
+// SALOMEDS::SObject_var aTblObj = aIter->Value();
+// if (!aTblObj->_is_nil()) {
+// SALOMEDS::GenericAttribute_var anAttr;
+// if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
+// CreatePlot(aTblObj);
+// }
+// }
+// }
+// }
+// }
+// GetActiveStudy()->updateObjBrowser();
+// }
+// } else {
+// DeletePresentation(pPresent);
+// delete aDlg;
+// return false;
+// }
+// delete aDlg;
+// }
+// CreateActor(pPresent);
+// return true;
+ }
+ }
+}catch (...){return false; }
+ return false;
+}
+
+
/* ======================================================================================== */
/* Global Method to import tables from file */
/* ======================================================================================== */
void VisuGUI::ImportTablesFromFile(){
+ if (checkLock(GetActiveStudy()->getStudyDocument())) return;
QStringList flt;
flt.append( "Files (*.xls *.txt *.tab)" );
flt.append( "All Files (*.*)" );
QString aDir = getVisuInputDir();
- QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
+ QFileInfo aFileInfo = 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);
+
+ if(aFileInfo.exists()){
+ QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
+ aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
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();
+ QAD_WaitCursor wc;
+
+ CORBA::Object_var anObject;
+#ifdef CHECKTIME
+ Utils_Timer timer;
+ timer.Start();
+#endif
+
+ anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
+
+#ifdef CHECKTIME
+ timer.Stop();
+ MESSAGE("VisuGUI::ImportTablesFromFile() - IMPORT FILE");
+ timer.Show();
+#endif
+
+ if(CORBA::is_nil(anObject)) {
+ wc.stop();
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_ERROR_IN_THE_FILE"),
+ tr ("VISU_BUT_OK") );
+ wc.start();
+ }
+ else {
+ QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
+ }
+ GetActiveStudy()->updateObjBrowser(); //update Object browser
}
-}
+}
+
+void VisuGUI::ExportTableToFile()
+{
+ QAD_Study *aQADStudy = VisuGUI::GetActiveStudy();
+ SALOME_Selection* aSel = SALOME_Selection::Selection ( aQADStudy -> getSelection() );
+
+ if( aSel->IObjectCount() > 0 ) {
+ const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
+ if(anIO->hasEntry()){
+ SALOMEDS::Study_var aStudy = aQADStudy->getStudyDocument();
+ SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID(anIO->getEntry());
+ if(CORBA::is_nil(aSObj)) return;
+
+ QString aTitle;
+ SALOMEDS::GenericAttribute_var anAttr;
+
+ if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
+ !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
+ aSObj = aSObj->GetFather(); //if the current SObject is a table title
+ // we take a father contaning the table
+ if (!CORBA::is_nil(aSObj)) {
+ if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
+ !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger"))
+ return;
+ }
+ else return;
+ }
+ if (CORBA::is_nil(anAttr)) return;
+ SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
+ if (!CORBA::is_nil(aTabAttr))
+ aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
+ else {
+ SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
+ if (!CORBA::is_nil(aTabAttr))
+ aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
+ else return;
+ }
+ aTitle.simplifyWhiteSpace();
+ QStringList flt;
+ flt.append("Table Files (*.xls)");
+
+ QAD_FileDlg *aDlg = new QAD_FileDlg(QAD_Application::getDesktop(), false, true, true);
+ aDlg -> setCaption("Export Table To File");
+ aDlg -> setDir( getVisuOutputDir() );
+ aDlg -> setFilters(flt);
+ aDlg -> setSelection(aTitle.replace(QRegExp(" "), "_"));
+ aDlg -> exec();
+ QString aFile = aDlg -> selectedFile();
+ delete aDlg;
+
+ if(!aFile.isEmpty()){
+ QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
+ QString aDir = QAD_Tools::getDirFromPath(aFile);
+ QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
+
+ try {
+ GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
+ QAD_Application::getDesktop()->putInfo(aFile+" exported.");
+ } catch(std::exception& ex) {
+ INFOS(ex.what());
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
+ tr ("VISU_BUT_OK") );
+ } catch(...) {
+ INFOS(tr ("ERR_ERROR_DURING_EXPORT"));
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_ERROR_DURING_EXPORT"),
+ tr ("VISU_BUT_OK") );
+ }
+ }
+ }
+ }
+}
/* ======================================================================================== */
/* Global Method to import mesh results in MED and DAT format */
/* ======================================================================================== */
-void VisuGUI::ImportFromFile(){
- if (checkLock(myActiveStudy->getStudyDocument())) return;
+void VisuGUI::ImportFile(){
+ VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::ImportFile);
+}
+void VisuGUI::CopyAndImportFile(){
+ VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::CopyAndImportFile);
+}
+void VisuGUI::ImportFromFile(TImportFun theImportFun){
+ if (checkLock(GetActiveStudy()->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);
+ QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
+ aDir,flt,tr("Import From File"),true);
+
+ if(aFileInfo.exists()){
+ QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
+ aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
QAD_CONFIG->addSetting("Visu:InputDir",aDir);
- QApplication::setOverrideCursor( Qt::waitCursor );
- VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1());
- if(aResult->_is_nil())
+ QAD_WaitCursor wc;
+
+ VISU::Result_var aResult;
+
+#ifdef CHECKTIME
+ Utils_Timer timer;
+ timer.Start();
+#endif
+ if(aFileInfo.extension(false) == "med"){
+ QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
+ bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
+ if (VisuGUI_FileDlg::IsBuild){
+ aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
+ if(!CORBA::is_nil(aResult.in()))
+ if(VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(GetServant(aResult).in())){
+ if(!pResult->IsPossible())
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_CANT_BUILD_PRESENTATION"),
+ tr ("VISU_BUT_OK") );
+ else
+ aResult->BuildAll();
+ }
+ }else{
+ QAD_CONFIG->addSetting( "Visu:BuildResult", false );
+ //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1
+ aResult=GetVisuGen()->ImportFile(aFileInfo.filePath()); // APO: 18/12/03 - fix crash on Linux RedHat 7.1
+ QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
+ }
+ }
+#ifdef CHECKTIME
+ timer.Stop();
+ MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE");
+ timer.Show();
+#endif
+
+ if(CORBA::is_nil(aResult.in())) {
+ wc.stop();
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("There is an error in imported file"),
+ tr ("ERR_ERROR_IN_THE_FILE"),
tr ("VISU_BUT_OK") );
- else
- QAD_Application::getDesktop()->putInfo(aFile+" imported.");
- myActiveStudy->updateObjBrowser(); //update Object browser
- QApplication::restoreOverrideCursor();
+ wc.start();
+ }
+ else {
+ QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
+ }
+ GetActiveStudy()->updateObjBrowser(); //update Object browser
}
}
void VisuGUI::ExportToFile(){
- VISU::Base_i* aBase = GetSelectedVisuObj();
+ CORBA::Object_var anObject = GetSelectedObj();
+ if(CORBA::is_nil(anObject)) return;
+ VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
QStringList flt;
flt.append( "Dat Files (*.dat)" );
QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
try{
- aResult->GetInput()->ToFile(aFile.latin1());
+ //APO - aResult->GetInput()->ToFile(aFile.latin1());
QAD_Application::getDesktop()->putInfo(aFile+" exported.");
- }catch(...){
+ }catch(std::exception& ex) {
+ INFOS(ex.what());
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_ERROR_DURING_EXPORT") + " " +tr(ex.what()),
+ tr ("VISU_BUT_OK") );
+ }
+ catch(...){
+ INFOS(tr ("ERR_ERROR_DURING_EXPORT").latin1());
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("There is an error during exporting to file"),
+ tr ("ERR_ERROR_DURING_EXPORT"),
tr ("VISU_BUT_OK") );
}
}
}
}else
QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("No Available data in selection"),
+ tr ("WRN_NO_AVAILABLE_DATA"),
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;
- }
- }
- }
- }
- }
- }
- }
- return NULL;
-}
-
/* ======================================================================================== */
/* Test and Read Object Browser before display */
/* ======================================================================================== */
-bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var *objVisu ){
+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;
- }
+ Handle(SALOME_InteractiveObject) anIO;
+ CORBA::Object_var anObject = GetSelectedObj(&anIO);
+ if(!anIO.IsNull() && anIO->hasEntry()){
+ objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
+ QString aValue = getValue(objVisu,"myType");
+ if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
}
QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr("No Available data in selection"),
+ tr("WRN_NO_AVAILABLE_DATA"),
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();
+VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
+ VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: 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;
- }
- }
- }
+ vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
+ for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
+ if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
+ if(thePrs == anVISUActor->GetPrs3d())
+ return anVISUActor->GetParent();
return NULL;
}
vtkActor *anActor;
VISU_Actor* anVISUActor = NULL;
VISU_Actor* aResActor = NULL;
- long aSrcAddr = (long) thePrs;
+ VISU::Prs3d_i* aSrcAddr = 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;
+ VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
+ if(aPrs == NULL) continue;
+ if (thePrs == aPrs) {
+ aResActor = anVISUActor->GetParent();
+ thePrs->UpdateActor(aResActor);
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();
+ anVISUActor->GetParent()->VisibilityOff();
+ } else {
}
+ } else if (theDispOnly && anActor->GetVisibility()) {
+ anActor->VisibilityOff();
+ } else {
}
}
if (aResActor) return aResActor;
-#ifdef CHECKTIME
- OSD_Timer timer;
- timer.Start();
-#endif
- anVISUActor = thePrs->CreateActor();
- MESSAGE("UpdateViewer - thePrs->CreateActor() = "<<anVISUActor);
- if ( anVISUActor ) {
+ try{
+ anVISUActor = thePrs->CreateActor();
vf->AddActor(anVISUActor);
- if(anVISUActor->HasScalarBar()){
- aRen->AddActor2D(anVISUActor->getScalarBar());
- }
- } else
+ } catch ( std::runtime_error& exc ){
+ INFOS(exc.what());
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
+ tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
+ tr ("VISU_BUT_OK") );
+ anVISUActor = NULL;
+ }
return anVISUActor;
}
* Erases Presentation
*/
void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
- myActiveStudy->unHighlightAll();
+ GetActiveStudy()->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;
+ if(checkLock(GetStudyDocument()) || !thePrs) return;
+ GetActiveStudy()->unHighlightAll();
+ for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
+ if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
+ QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
+ if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)){
+ if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
+ aViewFrame->RemoveActor(anActor);
+ anActor->Delete();
}
+ aViewFrame->unHighlightAll();
}
}
- }
- SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(thePrs->GetEntry());
- if(aSObj->_is_nil()) return;
- myStudyBuilder->RemoveObject(aSObj);
- myActiveStudy->updateObjBrowser(); //update Object browser
+ thePrs->RemoveFromStudy();
+ GetActiveStudy()->updateObjBrowser(); //update Object browser
}
/**
* Creates new actor of presentation
*/
void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
- if (!thePrs) return;
+ if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
+ if (!thePrs) return;
QApplication::setOverrideCursor( Qt::waitCursor );
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf) {
+ if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
#ifdef CHECKTIME
- OSD_Timer timer;
+ Utils_Timer timer;
timer.Start();
#endif
- VISU_Actor* aActor = thePrs->CreateActor();
- if ( ! aActor ) {
+ try{
+ MESSAGE("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
+ VISU_Actor* aActor = thePrs->CreateActor();
+ vf->AddActor(aActor);
+ }catch(std::runtime_error& exc) {
+ INFOS("std::runtime_error "<<exc.what());
+ INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
QApplication::restoreOverrideCursor();
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
- tr ("The presentation can't be visualized.\n Null actor is created."),
+ tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr(exc.what()),
+ tr ("VISU_BUT_OK") );
+ throw exc;
+ } catch (...) {
+ MESSAGE(" Unknown exception");
+ QApplication::restoreOverrideCursor();
+ INFOS("Unknown exception is caught in VisuGUI::CreateActor");
+ INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr("ERR_UNKNOWN_EXCEPTION"),
tr ("VISU_BUT_OK") );
- return;
+ throw ;
}
#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");
+ MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR");
timer.Show();
#endif
}
this->myActiveDialogBox = (QDialog*)aDlg ;
return ;
}
-
-QAD_Study* VisuGUI::GetActiveStudy()
-{
- return this->myActiveStudy ;
-}
-
-QAD_Desktop* VisuGUI::GetDesktop()
-{
- return this->myDesktop ;
-}