1 // Copyright (C) 2023 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SPV3D_ViewManager.h"
21 #include "SPV3D_ViewModel.h"
22 #include "SPV3D_ViewWindow.h"
24 #include <PV3DViewer_ViewManager.h>
26 #include "PVViewer_InitSingleton.h"
27 #include "PVViewer_GUIElements.h"
28 #include "PVServer_ServiceWrapper.h"
30 #include <SUIT_Desktop.h>
32 #include <pqObjectBuilder.h>
33 #include <pqApplicationCore.h>
34 #include <pqServerManagerModel.h>
35 #include <pqServerResource.h>
37 #include <pqPVApplicationCore.h>
38 #include <pqParaViewBehaviors.h>
40 #include <QVBoxLayout>
41 #include <QApplication>
46 SPV3D_ViewManager::SPV3D_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop )
47 : SUIT_ViewManager( study, theDesktop, new SPV3D_ViewModel() )
49 setTitle( SPV3D_ViewManager::tr( "PARAVIEW3D_VIEW_TITLE" ) );
50 /*QStringList args = QCoreApplication::arguments();
51 int argc = args.length();
52 char **argv = new char *[argc+1];
53 for(auto i = 0 ; i < argc ; ++i)
54 argv[i] = strdup(args[i].toStdString().c_str());
56 pqPVApplicationCore appPV(argc,argv);
57 QApplication::instance()->installEventFilter(&appPV);
58 new pqParaViewBehaviors(theDesktop,theDesktop);
59 pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
60 pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:")));
61 pqView *view=builder->createView(QString("RenderView"),serv);
62 static_cast<SPV3D_ViewModel *>(this->getViewModel())->setView(view);*/
63 //QVBoxLayout *lay(new QVBoxLayout(theDesktop));
64 //lay->addWidget( view->widget() );
65 //view->widget()->setParent( theDesktop);
66 // Initialize minimal paraview stuff (if not already done)
67 //PVViewer_InitSingleton::Init(theDesktop);
69 connect( theDesktop, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
70 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
72 SPV3D_ViewModel *vm = dynamic_cast<SPV3D_ViewModel*>(getViewModel());
80 SPV3D_ViewManager::~SPV3D_ViewManager()
85 \return corresponding main window
87 SUIT_Desktop* SPV3D_ViewManager::getDesktop()
92 /*!Enable toolbars if view \a view is ParaView viewer and disable otherwise.
94 void SPV3D_ViewManager::onWindowActivated(SUIT_ViewWindow* view)
98 SPV3D_ViewWindow* pvWindow = dynamic_cast<SPV3D_ViewWindow*>(view);
99 PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance( myDesktop );
100 guiElements->setToolBarEnabled(pvWindow!=0);