Salome HOME
Copyright update 2022
[modules/paravis.git] / test / standalone / gui / main.cpp
1 // Copyright (C) 2010-2022  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author: Adrien Bruneton (CEA)
20
21 #include <iostream>
22
23 #include "PVViewer_Core.h"
24 #include "PVViewer_Behaviors.h"
25 #include "PLMainWindow.hxx"
26
27 #include <pqApplicationCore.h>
28 #include <pqSettings.h>
29 #include <pqParaViewBehaviors.h>
30 #include <pqServerResource.h>
31 #include <pqServerConnectReaction.h>
32 #include <pqServerDisconnectReaction.h>
33
34 int main(int argc, char ** argv)
35 {
36   std::cout << "Starting LightParaView ..." << std::endl;
37
38   std::cout << "Init Qt app ..." << std::endl;
39   QApplication qtapp(argc, argv);
40   QApplication::setApplicationName("LightPara");
41
42   std::cout << "Create Qt main window ..." << std::endl;
43   PLMainWindow * para_widget = new PLMainWindow();
44
45   std::cout << "Init appli core ..." << std::endl;
46   PVViewer_Core::ParaviewInitApp(para_widget, NULL);
47
48   std::cout << "Binding ParaView widget in QMainWindow ..." << std::endl;
49   para_widget->finishUISetup();
50
51   /* Install event filter */
52 //  std::cout << "Install event filter ..." << std::endl;
53 //  pqPVApplicationCore * plApp = PVViewer_Core::GetPVApplication();
54 //  QApplication::instance()->installEventFilter(plApp);
55
56   std::cout << "Init behaviors ..." << std::endl;
57   PVViewer_Core::ParaviewInitBehaviors(true, para_widget);
58
59   //para_widget->updateActiveServer();
60
61   std::cout << "Load config ..." << std::endl;
62   PVViewer_Core::ParaviewLoadConfigurations(QString(":/LightPara/Configuration"));
63
64   /* Inspired from ParaView source code:
65    * leave time for the GUI to update itself before displaying the main window: */
66   QApplication::instance()->processEvents();
67
68   // Try to connect
69 //  std::cout << "about to try to connect ...\n";
70 //  const char * server_url = "cs://localhost";
71 //  if (!pqServerConnectReaction::connectToServer(pqServerResource(server_url)))
72 //    {
73 //      std::cerr << "Could not connect to requested server \""
74 //          << server_url << "\". Creating default builtin connection.\n";
75 //    }
76
77   /* ... and GO: */
78   std::cout << "Show !" << std::endl;
79   para_widget->show();
80   int ret_code = qtapp.exec();
81
82   /* then disconnect and leave nicely */
83   //pqServerDisconnectReaction::disconnectFromServer();
84
85   std::cout << "Clean up ..." << std::endl;
86   PVViewer_Core::ParaviewCleanup();
87
88   delete para_widget;
89
90   std::cout << "Done." << std::endl;
91   return ret_code;
92 }
93
94
95