From: smh Date: Thu, 1 Apr 2004 16:36:44 +0000 (+0000) Subject: Implement two test VISU events X-Git-Tag: mergeto_Event_Server_20Apr04~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ff14be77883e6426490cbddf7bb8e0aafc0a9350;p=modules%2Fvisu.git Implement two test VISU events --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 22dd69bb..7a9461cd 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -964,7 +964,8 @@ provided by %ViewManager. /*! SAN & VSR : Test QT_EVENT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ - void DoSomething(); + void CreateTestView(); + void ShowTestObject(); /*! SAN & VSR : Test QT_EVENT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index 3744c066..5fee7356 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -35,7 +35,9 @@ VPATH=.:@srcdir@ # header files EXPORT_HEADERS= \ - VisuGUI_NonIsometricDlg.h + VisuGUI_NonIsometricDlg.h \ + VisuGUI_Swig.hxx \ + VisuGUI_Swig.i # .po files to transform in .qm PO_FILES = \ @@ -57,7 +59,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_TimeAnimation.cxx \ VisuGUI_CutLinesDlg.cxx \ VisuGUI_FileDlg.cxx \ - VisuGUI_EditContainerDlg.cxx + VisuGUI_EditContainerDlg.cxx \ + VisuGUI_Swig.cxx LIB_MOC = \ VisuGUI.h \ @@ -96,7 +99,7 @@ CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) \ -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS += $(MED2_LIBS) $(HDF5_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeGUI -lSalomeNS \ - -lVisuObject -lVISUEngine -lmed -lVTKViewer -L${KERNEL_ROOT_DIR}/lib/salome + -lVisuObject -lVISUEngine -lVISUEvent -lmed -lVTKViewer -L${KERNEL_ROOT_DIR}/lib/salome @CONCLUDE@ diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index f9438ddf..4fc35b65 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -28,6 +28,8 @@ #include "VisuGUI.h" +#include "VISU_Event.h" + #include "VISU_Gen_i.hh" #include "VISU_Result_i.hh" #include "VISU_PrsObject_i.hh" @@ -380,7 +382,6 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ======================================================================================== */ /* Import Table from file */ /* ======================================================================================== */ - case 199: { if(checkLock(aStudy)) break; @@ -394,11 +395,15 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 111: { + ShowTestObject(); + break; visuGUI->CopyAndImportFile(); break; } case 112: { + ShowTestObject(); + break; visuGUI->ImportFile(); break; } @@ -661,8 +666,12 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) //=========================================================================== bool VisuGUI::CanProcessEvent(SALOME_Event* se) { -// return ( se && se->getType() > VISU_FIRST_EVENT && se->getType() < VISU_LAST_EVENT ); - return true; + if ( se && se->getType() >= VISU_START_EVENT && se->getType() < VISU_Event::LastEvent ) { + VISU_Event* ve = dynamic_cast( se ); + if ( ve ) + return true; + } + return false; } //=========================================================================== @@ -670,7 +679,21 @@ bool VisuGUI::CanProcessEvent(SALOME_Event* se) //=========================================================================== bool VisuGUI::ProcessEvent(SALOME_Event* se) { - return true; + if ( se && se->getType() >= VISU_START_EVENT && se->getType() < VISU_Event::LastEvent ) { + VISU_Event* ve = dynamic_cast( se ); + if ( ve ) { + switch ( se->getType() ) { + case VISU_Event::CreateTestViewEvent: + VisuGUI::CreateTestView(); + break; + case VISU_Event::ShowTestObjectEvent: + VisuGUI::ShowTestObject(); + break; + } + return true; + } + } + return false; } void VisuGUI::SelectionInfo() { @@ -3139,73 +3162,7 @@ extern "C" visuGUI = new VisuGUI( "" ); return visuGUI; } - -//*************************************** -// san - obsolete code - TO BE REMOVED! -// No extern "C" fucntions below will be necessary! -//************************************** - - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - { - //if(MYDEBUG) MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID); - return visuGUI->OnGUIEvent(theCommandID, parent); - } - - bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - { - if(MYDEBUG) MESSAGE("VisuGUI::OnKeyPress "); - return visuGUI->OnKeyPress (pe, parent, studyFrame); - } - - bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - { - //if(MYDEBUG) MESSAGE("VisuGUI::OnMousePress "); - return visuGUI->OnMousePress (pe, parent, studyFrame); - } - - bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - { - //if(MYDEBUG) 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 ); - } - - bool activeStudyChanged ( QAD_Desktop* parent ) - { - //VisuGUI::activeStudyChanged( parent ); - } - void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO ) - { - visuGUI->BuildPresentation(theIO); - } - - void supportedViewType(int* buffer, int bufferSize) - { - if (!buffer || !bufferSize) return; - buffer[0] = (int)VIEW_VTK; - if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D; - } - } -//*************************************** -// san - temporary code - TO BE REMOVED! -// No extern "C" fucntions will be necessary! -//************************************** ////////////////////////////////////////////////////////////////////////////////// @@ -4048,3 +4005,66 @@ void VisuGUI::SetActiveDialogBox(QDialog* aDlg) this->myActiveDialogBox = (QDialog*)aDlg ; return ; } + +void VisuGUI::CreateTestView() +{ + QAD_Desktop* desktop = VisuGUI::GetDesktop(); + QAD_Study* aStudy = desktop->getActiveStudy(); + if ( !aStudy ) { + QString defViewer = QAD_CONFIG->getSetting( "Viewer::DefaultViewer" ); + int dv = defViewer.toInt(); + QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( VIEW_VTK ) ); + desktop->createStudy(); + if ( !defViewer.isEmpty() ) { + QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( dv ) ); +} + } + else { + aStudy->newWindow3d( "", VIEW_VTK ); + } +} + +#include +#include + +void VisuGUI::ShowTestObject() +{ + MESSAGE("1") + vtkSphereSource* aSource = vtkSphereSource::New(); + MESSAGE("2") + aSource->SetRadius( 100. ); + MESSAGE("3") + + vtkProperty* prop = vtkProperty::New(); + MESSAGE("4") + + vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); + MESSAGE("5") + aMapper->SetInput( aSource->GetOutput() ); + MESSAGE("6") + + vtkActor* sphere = vtkActor::New(); + MESSAGE("7") + sphere->SetMapper( aMapper ); + MESSAGE("8") + sphere->SetProperty( prop ); + MESSAGE("9") + + QAD_Desktop* desktop = VisuGUI::GetDesktop(); + MESSAGE("10") + QAD_Study* aStudy = desktop->getActiveStudy(); + MESSAGE("11") + if ( !aStudy ) { + CreateTestView(); + MESSAGE("12") + } + MESSAGE("13") + VTKViewer_ViewFrame* vf = (VTKViewer_ViewFrame*)(desktop->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()); + MESSAGE("14") + sphere->SetVisibility( true ); + MESSAGE("15") + vf->getRenderer()->AddActor(sphere); + MESSAGE("16") + vf->Repaint(); + MESSAGE("17") +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index d301e1e3..f9c7dec4 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -95,6 +95,8 @@ class VisuGUI : public SALOMEGUI{ static SALOMEDS::Study_var GetStudyDocument(); static SALOMEDS::StudyBuilder_var NewBuilder(); static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject); + static void CreateTestView(); + static void ShowTestObject(); static VISU::Result_i* CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult); diff --git a/src/VISUGUI/VisuGUI_Swig.cxx b/src/VISUGUI/VisuGUI_Swig.cxx new file mode 100644 index 00000000..79951c6e --- /dev/null +++ b/src/VISUGUI/VisuGUI_Swig.cxx @@ -0,0 +1,54 @@ +// VISU VISUGUI : GUI for 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_Swig.cxx +// Author : Vadim SANDLER +// Module : VISU +// $Header$ + +using namespace std; +#include "VisuGUI_Swig.hxx" +#include "VISU_Event.h" +#include + +VISU_Swig::VISU_Swig() +{ +} + +VISU_Swig::~VISU_Swig() +{ +} + +void VISU_Swig::CreateTestView() +{ + VISU_Event* ve = new VISU_Event( VISU_Event::CreateTestViewEvent, false ); + ve->process(); + qApp->processEvents(); +} + +void VISU_Swig::ShowTestObject() +{ + VISU_Event* ve = new VISU_Event( VISU_Event::ShowTestObjectEvent, false ); + ve->process(); + qApp->processEvents(); +} diff --git a/src/VISUGUI/VisuGUI_Swig.hxx b/src/VISUGUI/VisuGUI_Swig.hxx new file mode 100644 index 00000000..6cc801e2 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Swig.hxx @@ -0,0 +1,42 @@ +// VISU VISUGUI : GUI for 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_Swig.hxx +// Author : Vadim SANDLER +// Module : VISU +// $Header$ + +#ifndef _VISUGUI_SWIG_HXX_ +#define _VISUGUI_SWIG_HXX_ + +class VISU_Swig +{ +public: + VISU_Swig(); + ~VISU_Swig(); + + void CreateTestView(); + void ShowTestObject(); +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_Swig.i b/src/VISUGUI/VisuGUI_Swig.i new file mode 100644 index 00000000..d470357c --- /dev/null +++ b/src/VISUGUI/VisuGUI_Swig.i @@ -0,0 +1,41 @@ +// VISU VISUGUI : GUI for 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_Swig.i +// Author : Vadim SANDLER +// Module : VISU +// $Header$ + +%{ +#include "VisuGUI_Swig.hxx" +%} + +class VISU_Swig +{ + public: + VISU_Swig(); + ~VISU_Swig(); + + void CreateTestView(); + void ShowTestObject(); +}; diff --git a/src/VISU_Event/VISU_Event.h b/src/VISU_Event/VISU_Event.h index c91b87ba..dde06bc8 100644 --- a/src/VISU_Event/VISU_Event.h +++ b/src/VISU_Event/VISU_Event.h @@ -31,7 +31,7 @@ #include "SALOME_Event.hxx" -// VISU event types: 10000...11000 +// VISU event types: 10000...10999 #define VISU_START_EVENT 10000 /* Customized VISU component event */ @@ -39,8 +39,8 @@ class VISU_Event : public SALOME_Event { public: enum { CreateTestViewEvent = VISU_START_EVENT, - ShowTestObjectEent, - LastEvent = VISU_START_EVENT + 999 }; + ShowTestObjectEvent, + LastEvent = VISU_START_EVENT + 1000 }; VISU_Event( int eventType, bool wait ); virtual ~VISU_Event(); diff --git a/src/VISU_I/Makefile.in b/src/VISU_I/Makefile.in index 59f715ef..21317423 100644 --- a/src/VISU_I/Makefile.in +++ b/src/VISU_I/Makefile.in @@ -54,7 +54,7 @@ CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES LDFLAGS += $(QT_MT_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeNS -lTOOLSDS \ -lSalomeContainer -lOpUtil -lSalomeGUI -lVTKViewer -lSalomeHDFPersist \ - -lVisuConvertor -lVisuPipeLine -lVisuObject -lSalomeGenericObj -lEvent \ + -lVisuConvertor -lVisuPipeLine -lVisuObject -lSalomeGenericObj -lVISUEvent \ -L${KERNEL_ROOT_DIR}/lib/salome LIBS+= $(PYTHON_LIBS) $(MED2_LIBS) $(HDF5_LIBS) -lPlot2d \ diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 59f69286..89a9c84d 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -57,7 +57,7 @@ #include #include -#include "SALOME_Event.hxx" +#include "VISU_Event.h" using namespace std; @@ -892,18 +892,22 @@ namespace VISU{ /*! SAN & VSR : Test QT_EVENT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ - #define TEST_EVENT 1 - void VISU_Gen_i::DoSomething() { - MESSAGE("VISU_Gen_i::DoSomething : myMutex = "<process(); return; } - myVisuGen->DoSomething(); + myVisuGen->CreateTestView(); + } + + void VISU_Gen_i::ShowTestObject() { + if(myMutex){ + VISU_Event* ve = new VISU_Event( VISU_Event::ShowTestObjectEvent, true ); + ve->process(); + return; + } + myVisuGen->ShowTestObject(); } /*! SAN & VSR : Test QT_EVENT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index df9a352c..5aa3f453 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -41,7 +41,8 @@ namespace VISU{ /*! SAN & VSR : Test QT_EVENT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ - virtual void DoSomething(); + virtual void CreateTestView(); + virtual void ShowTestObject(); /*! SAN & VSR : Test QT_EVENT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ diff --git a/src/VISU_SWIG/Makefile.in b/src/VISU_SWIG/Makefile.in index ff40e7bc..d5580141 100644 --- a/src/VISU_SWIG/Makefile.in +++ b/src/VISU_SWIG/Makefile.in @@ -51,7 +51,7 @@ LIB_CLIENT_IDL = CPPFLAGS += -ftemplate-depth-32 $(PYTHON_INCLUDES) $(QT_INCLUDES) \ $(VTK_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -LDFLAGS += $(PYTHON_LIBS) -lVisuConvertor -lVisuPipeLine +LDFLAGS += $(PYTHON_LIBS) $(VTK_LIBS) -lVisuConvertor -lVisuPipeLine -lVISUGUI @CONCLUDE@ \ No newline at end of file diff --git a/src/VISU_SWIG/batchmode_visu.py b/src/VISU_SWIG/batchmode_visu.py index 559a3eb4..3a0093d7 100644 --- a/src/VISU_SWIG/batchmode_visu.py +++ b/src/VISU_SWIG/batchmode_visu.py @@ -10,6 +10,8 @@ from batchmode_salome import * import visu +sg = SalomeGUI() + myVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,myStudy,10) if myVisu is None: raise RuntimeError, "myVisu is none, VISU component is not loaded or found" diff --git a/src/VISU_SWIG/libVISU_Swig.i b/src/VISU_SWIG/libVISU_Swig.i index 1f9a4de7..820042db 100644 --- a/src/VISU_SWIG/libVISU_Swig.i +++ b/src/VISU_SWIG/libVISU_Swig.i @@ -31,6 +31,7 @@ #include "VISU_Gen_s.hh" %} +%include "VisuGUI_Swig.i" class Convertor{ public: