# Load the dependencies for the libraries of @PROJECT_NAME@
# (contains definitions for IMPORTED targets). This is only
# imported if we are not built as a subproject (in this case targets are already there)
-IF(NOT TARGET Event AND NOT @PROJECT_NAME@_BINARY_DIR)
+IF(NOT TARGET PARAVIS AND NOT @PROJECT_NAME@_BINARY_DIR)
INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE_LOCAL@/@PROJECT_NAME@Targets.cmake")
ENDIF()
SET(PARAVIS_SalomeIDLPARAVIS SalomeIDLPARAVIS)
SET(PARAVIS_PARAVIS PARAVIS)
SET(PARAVIS_PARAVISEngine PARAVISEngine)
+SET(PARAVIS_PVViewer PVViewer)
+
setupDockWidgets();
- // Behaviors and connection must be instanciated *after* widgets are in place:
+ // Behaviors and connection must be instanciated *after* widgets are in place
+ // In PARAVIS module we do not wait for PVViewer_ViewWindow to be instanciated to have this:
PVViewer_ViewManager::ParaviewInitBehaviors(true, aDesktop);
PVViewer_ViewManager::ConnectToExternalPVServer(aDesktop);
// }
// }
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
- QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
- if (!aPath.isNull()) {
- pqPVApplicationCore * pvApp = GetPVApplication();
- pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
- pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
- pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewSources.xml");
- pvApp->loadConfiguration(aPath + QDir::separator() + "ParaViewWriters.xml");
- }
-
+ PVViewer_ViewManager::ParaviewLoadConfigurations();
updateObjBrowser();
// Find created toolbars
PVViewer_ViewWindow* pvWnd = dynamic_cast<PVViewer_ViewWindow*>( viewMgr->getActiveView() );
if ( !pvWnd ) {
pvWnd = dynamic_cast<PVViewer_ViewWindow*>( viewMgr->createViewWindow() );
+ // this also connects to the pvserver and instantiates relevant PV behaviors
}
pvWnd->setShown( toShow );
bool isDone = SalomeApp_Module::activateModule( study );
if ( !isDone ) return false;
- showView( true );
+ showView( true ); // this will also trigger the connection to the server
+ // and the instanciation of the relevant PV behaviors
if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId);
if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId);
if ( myFiltersMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
#include <pqFixPathsInStateFilesBehavior.h>
#include <pqApplyBehavior.h>
-bool PVViewer_Behaviors::hasMinimalInstanciated = false;
+#include <pqPropertiesPanel.h>
+
+int PVViewer_Behaviors::BehaviorLoadingLevel = 0;
PVViewer_Behaviors::PVViewer_Behaviors(SUIT_Desktop * parent)
: QObject(static_cast<QObject *>(parent))
*/
void PVViewer_Behaviors::instanciateMinimalBehaviors(SUIT_Desktop * desk)
{
- hasMinimalInstanciated = true;
-
- // Register ParaView interfaces.
- pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker();
-
- // Register standard types of property widgets.
- pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
- // Register standard types of view-frame actions.
- pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm));
-
- // Load plugins distributed with application.
- pqApplicationCore::instance()->loadDistributedPlugins();
-
- new pqDefaultViewBehavior(this); // shows a 3D view as soon as a server connection is made
- new pqAlwaysConnectedBehavior(this); // client always connected to a server
- new pqAutoLoadPluginXMLBehavior(this); // auto load plugins
- new pqVerifyRequiredPluginBehavior(this);
- new pqPluginSettingsBehavior(this);
- new pqFixPathsInStateFilesBehavior(this);
- new pqCrashRecoveryBehavior(this);
- new pqCommandLineOptionsBehavior(this);
+ if (BehaviorLoadingLevel < 1)
+ {
+ // Register ParaView interfaces.
+ pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker();
+
+ // Register standard types of property widgets.
+ pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
+ // Register standard types of view-frame actions.
+ pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm));
+
+ // Load plugins distributed with application.
+ pqApplicationCore::instance()->loadDistributedPlugins();
+
+ new pqDefaultViewBehavior(this); // shows a 3D view as soon as a server connection is made
+ new pqAlwaysConnectedBehavior(this); // client always connected to a server
+ new pqAutoLoadPluginXMLBehavior(this); // auto load plugins
+ new pqVerifyRequiredPluginBehavior(this);
+ new pqPluginSettingsBehavior(this);
+ new pqFixPathsInStateFilesBehavior(this);
+ new pqCrashRecoveryBehavior(this);
+ new pqCommandLineOptionsBehavior(this);
+
+ // Create a hidden pqPropertiesPanel()
+ hiddenProp = new pqPropertiesPanel(desk);
+
+ BehaviorLoadingLevel = 1;
+ }
}
/**! Instanciate usual ParaView behaviors.
// exclude using of pqQtMessageHandlerBehaviour
// Define application behaviors.
- if (!hasMinimalInstanciated)
+ if (BehaviorLoadingLevel < 1)
instanciateMinimalBehaviors(desk);
- //new pqQtMessageHandlerBehavior(this); // THIS ONE TO EXCLUDE !! see comment above
- new pqDataTimeStepBehavior(this);
- new pqSpreadSheetVisibilityBehavior(this);
- new pqPipelineContextMenuBehavior(this);
- new pqUndoRedoBehavior(this);
- new pqPluginDockWidgetsBehavior(desk);
- new pqPluginActionGroupBehavior(desk);
- new pqPersistentMainWindowStateBehavior(desk);
- new pqObjectPickingBehavior(desk);
- new pqCollaborationBehavior(this);
- new pqViewStreamingBehavior(this);
-
- pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
- foreach (pqPropertiesPanel* ppanel, desk->findChildren<pqPropertiesPanel*>())
+
+ if (BehaviorLoadingLevel < 2)
{
- applyBehavior->registerPanel(ppanel);
+ //new pqQtMessageHandlerBehavior(this); // THIS ONE TO EXCLUDE !! see comment above
+ new pqDataTimeStepBehavior(this);
+ new pqSpreadSheetVisibilityBehavior(this);
+ new pqPipelineContextMenuBehavior(this);
+ new pqUndoRedoBehavior(this);
+ new pqPluginDockWidgetsBehavior(desk);
+ new pqPluginActionGroupBehavior(desk);
+ new pqPersistentMainWindowStateBehavior(desk);
+ new pqObjectPickingBehavior(desk);
+ new pqCollaborationBehavior(this);
+ new pqViewStreamingBehavior(this);
+
+ pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
+ foreach (pqPropertiesPanel* ppanel, desk->findChildren<pqPropertiesPanel*>())
+ {
+ applyBehavior->registerPanel(ppanel);
+ }
+ BehaviorLoadingLevel = 2;
}
+}
+void PVViewer_Behaviors::onEmulateApply()
+{
+ if (hiddenProp)
+ hiddenProp->apply();
}
class SalomeApp_Module;
class SUIT_Desktop;
+class pqPropertiesPanel;
/**!
* PARAVIS behaviors - mimic what is done in
virtual ~PVViewer_Behaviors() {}
+public slots:
+ void onEmulateApply();
+
private:
- static bool hasMinimalInstanciated;
+ static int BehaviorLoadingLevel;
+
+ pqPropertiesPanel * hiddenProp;
};
#endif /* PVGUIBEHAVIORS_H_ */
#include <SUIT_MessageBox.h>
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
#include <PyInterp_Interp.h>
#include <PyConsole_Interp.h>
#include <PyConsole_Console.h>
#include <QApplication>
#include <QStringList>
+#include <QDir>
#include <string>
#include <pqOptions.h>
//---------- Static init -----------------
pqPVApplicationCore* PVViewer_ViewManager::MyCoreApp = 0;
PARAVIS_ORB::PARAVIS_Gen_var PVViewer_ViewManager::MyEngine;
-
+bool PVViewer_ViewManager::ConfigLoaded = false;
+PVViewer_Behaviors * PVViewer_ViewManager::ParaviewBehaviors = NULL;
/*!
Constructor
{
MESSAGE("PARAVIS - view manager created ...")
setTitle( tr( "PARAVIEW_VIEW_TITLE" ) );
+ // Initialize minimal paraview stuff (if not already done)
+ ParaviewInitApp(desk);
+
+ connect(this, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onPVViewCreated(SUIT_ViewWindow*)));
}
pqPVApplicationCore * PVViewer_ViewManager::GetPVApplication()
void PVViewer_ViewManager::ParaviewInitBehaviors(bool fullSetup, SUIT_Desktop* aDesktop)
{
- PVViewer_Behaviors * behav = new PVViewer_Behaviors(aDesktop);
+ if (!ParaviewBehaviors)
+ ParaviewBehaviors = new PVViewer_Behaviors(aDesktop);
+
if(fullSetup)
- behav->instanciateAllBehaviors(aDesktop);
+ ParaviewBehaviors->instanciateAllBehaviors(aDesktop);
else
- behav->instanciateMinimalBehaviors(aDesktop);
+ ParaviewBehaviors->instanciateMinimalBehaviors(aDesktop);
+}
+
+void PVViewer_ViewManager::ParaviewLoadConfigurations()
+{
+ if (!ConfigLoaded)
+ {
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
+ if (!aPath.isNull()) {
+ MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
+ MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
+ MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewSources.xml");
+ MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewWriters.xml");
+ }
+ ConfigLoaded = true;
+ }
}
void PVViewer_ViewManager::ParaviewCleanup()
pqApplicationCore::instance()->settings()->sync();
pqPVApplicationCore * app = GetPVApplication();
+ // [ABN] : TODO review this, this triggers an ugly crash (Python thread state mix-up)
+ // at SALOME's exit.
// Schedule destruction of PVApplication singleton:
- if (app)
- app->deleteLater();
+// if (app)
+// app->deleteLater();
}
PARAVIS_ORB::PARAVIS_Gen_var PVViewer_ViewManager::GetEngine()
}
return true;
}
+
+void PVViewer_ViewManager::onPVViewCreated(SUIT_ViewWindow* w)
+{
+ PVViewer_ViewWindow * w2 = dynamic_cast<PVViewer_ViewWindow *>(w);
+ Q_ASSERT(w2 != NULL);
+ connect(w2, SIGNAL(applyRequest()), ParaviewBehaviors, SLOT(onEmulateApply()));
+}
class SUIT_Desktop;
class SUIT_Study;
+class SUIT_ViewWindow;
class pqTabbedMultiViewWidget;
class pqPVApplicationCore;
+class PVViewer_Behaviors;
+class pqPropertiesPanel;
class PVViewer_ViewManager : public SUIT_ViewManager
{
//! Initialize ParaView if not yet done (once per session)
static bool ParaviewInitApp(SUIT_Desktop* aDesktop);
static void ParaviewInitBehaviors(bool fullSetup=false, SUIT_Desktop* aDesktop=0);
-
+ static void ParaviewLoadConfigurations();
static void ParaviewCleanup();
//! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not
//! already up.
static bool ConnectToExternalPVServer(SUIT_Desktop* aDesktop);
+public slots:
+ void onPVViewCreated(SUIT_ViewWindow*);
+
private:
static pqPVApplicationCore* MyCoreApp;
static PARAVIS_ORB::PARAVIS_Gen_var MyEngine;
-
+ static bool ConfigLoaded;
+ static PVViewer_Behaviors * ParaviewBehaviors;
};
#endif
virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
virtual QString getType() const { return Type(); }
static QString Type() { return "ParaView"; }
-
};
#endif // !defined(_PVViewer_VIEWMODEL_H)
//
#include "PVViewer_ViewWindow.h"
+#include "PVViewer_ViewManager.h"
#include <SUIT_ViewManager.h>
#include <SUIT_ResourceMgr.h>
/*!
\brief Constructor.
\param theDesktop parent desktop window
- \param theModel plt2d view model
+ \param theModel view model
*/
PVViewer_ViewWindow::PVViewer_ViewWindow( SUIT_Desktop* theDesktop, PVViewer_Viewer* theModel )
: SUIT_ViewWindow( theDesktop ), myPVMgr( 0 )
// This is mandatory, see setParent() method in Qt 4 documentation
myPVMgr->show();
setCentralWidget( myPVMgr );
+
+ // Finish ParaView set up: behaviors, connection and configurations.
+ // None of this is invoked in PARAVIS module case as it done earlier than View creation:
+ PVViewer_ViewManager::ParaviewInitBehaviors(true, theDesktop);
+ PVViewer_ViewManager::ConnectToExternalPVServer(theDesktop);
+ PVViewer_ViewManager::ParaviewLoadConfigurations();
} else
qDebug("No multiViewManager defined");
}
{
return myPVMgr;
}
+
+void PVViewer_ViewWindow::onEmulateApply()
+{
+ emit this->applyRequest();
+}
pqTabbedMultiViewWidget* getMultiViewManager() const;
+signals:
+ void applyRequest();
+
+public slots:
+ void onEmulateApply();
+
private:
PVViewer_Viewer* myModel;
pqTabbedMultiViewWidget* myPVMgr;