SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
# Find KERNEL
# ===========
CMAKE_DEPENDENT_OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF
"NOT SALOME_KERNEL_LIGHT_ONLY" ON)
-IF(SALOME_BUILD_TESTS)
- ENABLE_TESTING()
-ENDIF()
-
# Prerequisites
# =============
# Find "big" prerequisites first - they reference themselves many others
or SALOME_PARAVIS_USE_SMESH_SOURCE=OFF")
ENDIF()
+IF(SALOME_BUILD_TESTS)
+ ENABLE_TESTING()
+ FIND_PACKAGE(SalomeCppUnit)
+ SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
+ENDIF()
+
## Detection summary:
SALOME_PACKAGE_REPORT_AND_CHECK()
// GUI includes
#include <LightApp_Study.h>
+#include <LightApp_Module.h>
+#include <LightApp_Application.h>
+#include <LightApp_DataModel.h>
#include <CAM_DataObject.h>
+#include <SUIT_Tools.h>
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
+// KERNEL
+#include <utilities.h>
// Qt includes
#include <QFile>
+#include <QFileInfo>
#include <QTextStream>
+#include <QDomNode>
+
+// ParaView include
+#include <pqApplicationCore.h>
+#include <pqServer.h>
+#include <pqFixPathsInStateFilesBehavior.h>
+
+const QString PVGUI_DataModel::RESTORE_FLAG_FILE = "do_restore_paravis_references.par";
+
+/*!
+ * XML processing functions to handle the PV state file.
+ */
+namespace {
+
+ void processElements(QDomNode& thePropertyNode, QStringList& theFileNames,
+ const QString& theNewPath, bool theRestore)
+ {
+ QDomNode aElementNode = thePropertyNode.firstChild();
+ while (aElementNode.isElement()) {
+ QDomElement aElement = aElementNode.toElement();
+ if (aElement.tagName() == "Element") {
+ QString aIndex = aElement.attribute("index");
+ if (aIndex == "0") {
+ QString aValue = aElement.attribute("value");
+ if (!aValue.isNull()) {
+ if (theNewPath.isEmpty()) {
+ QFileInfo aFInfo(aValue);
+ if (aFInfo.exists()) {
+ theFileNames<<aValue;
+ aElement.setAttribute("value", aFInfo.fileName());
+ }
+ break;
+ } else {
+ if (theRestore)
+ aElement.setAttribute("value", QString(theNewPath) + aValue);
+ }
+ }
+ }
+ }
+ aElementNode = aElementNode.nextSibling();
+ }
+ }
+
+ void processProperties(QDomNode& theProxyNode, QStringList& theFileNames,
+ const QString& theNewPath, bool theRestore)
+ {
+ QDomNode aPropertyNode = theProxyNode.firstChild();
+ while (aPropertyNode.isElement()) {
+ QDomElement aProperty = aPropertyNode.toElement();
+ QString aName = aProperty.attribute("name");
+ if ((aName == "FileName") || (aName == "FileNameInfo") || (aName == "FileNames")) {
+ processElements(aPropertyNode, theFileNames, theNewPath, theRestore);
+ }
+ aPropertyNode = aPropertyNode.nextSibling();
+ }
+ }
+
+
+ void processProxies(QDomNode& theNode, QStringList& theFileNames,
+ const QString& theNewPath, bool theRestore)
+ {
+ QDomNode aProxyNode = theNode.firstChild();
+ while (aProxyNode.isElement()) {
+ QDomElement aProxy = aProxyNode.toElement();
+ if (aProxy.tagName() == "Proxy") {
+ QString aGroup = aProxy.attribute("group");
+ if (aGroup == "sources") {
+ processProperties(aProxyNode, theFileNames, theNewPath, theRestore);
+ }
+ }
+ aProxyNode = aProxyNode.nextSibling();
+ }
+ }
+
+ bool processAllFilesInState(const QString& aFileName, QStringList& theFileNames,
+ const QString& theNewPath, bool theRestore)
+ {
+ QFile aFile(aFileName);
+ if (!aFile.open(QFile::ReadOnly)) {
+ MESSAGE("Can't open state file "<<aFileName.toStdString());
+ return false;
+ }
+ QDomDocument aDoc;
+ bool aRes = aDoc.setContent(&aFile);
+ aFile.close();
+
+ if (!aRes) {
+ MESSAGE("File "<<aFileName.toStdString()<<" is not XML document");
+ return false;
+ }
+
+ QDomElement aRoot = aDoc.documentElement();
+ if ( aRoot.isNull() ) {
+ MESSAGE( "Invalid XML root" );
+ return false;
+ }
+
+ QDomNode aNode = aRoot.firstChild();
+ while (aRes && !aNode.isNull() ) {
+ aRes = aNode.isElement();
+ if ( aRes ) {
+ QDomElement aSection = aNode.toElement();
+ if (aSection.tagName() == "ServerManagerState") {
+ processProxies(aNode, theFileNames, theNewPath, theRestore);
+ }
+ }
+ aNode = aNode.nextSibling();
+ }
+ if (!aFile.open(QFile::WriteOnly | QFile::Truncate)) {
+ MESSAGE("Can't open state file "<<aFileName.toStdString()<<" for writing");
+ return false;
+ }
+ QTextStream out(&aFile);
+ aDoc.save(out, 2);
+ aFile.close();
+
+ return true;
+ }
+}
+
PVGUI_DataModel::PVGUI_DataModel( PVGUI_Module* theModule ):
- LightApp_DataModel(theModule)
+ LightApp_DataModel(theModule),
+ myStudyURL("")
{}
PVGUI_DataModel::~PVGUI_DataModel()
{}
+bool PVGUI_DataModel::create( CAM_Study* theStudy) {
+ bool res = LightApp_DataModel::create(theStudy);
+ publishComponent(theStudy);
+ return res;
+}
+
+void PVGUI_DataModel::publishComponent( CAM_Study* theStudy ) {
+ LightApp_Study* study = dynamic_cast<LightApp_Study*>( theStudy );
+ CAM_ModuleObject *aModelRoot = dynamic_cast<CAM_ModuleObject*>( root());
+ if( study && aModelRoot == NULL ) {
+ aModelRoot = createModuleObject( theStudy->root() );
+ aModelRoot->setDataModel( this );
+ setRoot(aModelRoot);
+ }
+}
+
bool PVGUI_DataModel::dumpPython( const QString& path, CAM_Study* std,
bool isMultiFile, QStringList& listOfFiles)
{
return true;
}
-/*-----------------------------------------------------------------------------------------*/
-bool PVGUI_DataModel::open( const QString& theName, CAM_Study* theStudy, QStringList theList) {
- bool res = LightApp_DataModel::open(theName, theStudy, theList);
+/*!
+ \brief Open data model (read ParaView pipeline state from the files).
+ \param theName study file path
+ \param theStudy study pointer
+ \param theList list of the (temporary) files with data
+ \return operation status (\c true on success and \c false on error)
+*/
+bool PVGUI_DataModel::open( const QString& theName, CAM_Study* theStudy, QStringList theList)
+{
+ bool ret = false;
+ LightApp_Study* aDoc = dynamic_cast<LightApp_Study*>( theStudy );
+ if ( !aDoc )
+ return false;
+
+ LightApp_DataModel::open( theName, aDoc, theList );
publishComponent(theStudy);
- return res;
+
+ // The first list item contains path to a temporary
+ // directory, where the persistent files was placed
+ if ( theList.count() > 0 ) {
+ QString aTmpDir ( theList[0] );
+
+ if ( theList.size() >= 2 ) {
+ myStudyURL = theName;
+ QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + theList[1];
+// std::cout << "open: tmp dir is" << aFullPath.toStdString() << std::endl;
+ PVGUI_Module * mod = dynamic_cast<PVGUI_Module *>(getModule());
+ if (mod)
+ {
+ bool doRestore = false;
+ QStringList srcFilesEmpty;
+ createAndCheckRestoreFlag(aTmpDir, srcFilesEmpty, /*out*/doRestore);
+ if(doRestore)
+ {
+ // Update state file so that it points to new dir:
+ processAllFilesInState(aFullPath, srcFilesEmpty, aTmpDir.toStdString().c_str(), true);
+ }
+
+ pqFixPathsInStateFilesBehavior::blockDialog(true);
+ mod->loadParaviewState(aFullPath);
+ pqFixPathsInStateFilesBehavior::blockDialog(false);
+ ret = true;
+ }
+ ret = true;
+ }
+ }
+
+ return ret;
}
-/*-----------------------------------------------------------------------------------------*/
-bool PVGUI_DataModel::create( CAM_Study* theStudy) {
- bool res = LightApp_DataModel::create(theStudy);
- publishComponent(theStudy);
- return res;
+/*!
+ * Create an empty file indicating whether source files in the pipeline should be restored.
+ */
+bool PVGUI_DataModel::createAndCheckRestoreFlag(const QString& tmpdir, QStringList& listOfFiles, bool & alreadyThere)
+{
+ QString aFullPath = SUIT_Tools::addSlash( tmpdir ) + RESTORE_FLAG_FILE;
+ QFile f(aFullPath);
+ if (f.exists())
+ {
+ alreadyThere = true;
+ return true;
+ }
+ else
+ {
+ bool ret = f.open(QFile::WriteOnly);
+ if (ret)
+ {
+ f.close();
+ listOfFiles << RESTORE_FLAG_FILE;
+ }
+ return ret;
+ }
}
-/*-----------------------------------------------------------------------------------------*/
-void PVGUI_DataModel::publishComponent( CAM_Study* theStudy ) {
- LightApp_Study* study = dynamic_cast<LightApp_Study*>( theStudy );
- CAM_ModuleObject *aModelRoot = dynamic_cast<CAM_ModuleObject*>( root());
- if( study && aModelRoot == NULL ) {
- aModelRoot = createModuleObject( theStudy->root() );
- aModelRoot->setDataModel( this );
- setRoot(aModelRoot);
+
+
+/*!
+ \brief Save data model (write ParaView pipeline to the files).
+ \param listOfFiles returning list of the (temporary) files with saved data
+ \return operation status (\c true on success and \c false on error)
+*/
+bool PVGUI_DataModel::save( QStringList& theListOfFiles)
+{
+ bool isMultiFile = false; // TODO: decide, how to access this parameter
+ bool ret = false;
+
+ LightApp_DataModel::save( theListOfFiles );
+
+ LightApp_Study* study = dynamic_cast<LightApp_Study*>( getModule()->getApp()->activeStudy() );
+ QString aTmpDir = study->GetTmpDir( myStudyURL.toLatin1(), isMultiFile ).c_str();
+// std::cout << "save: tmp dir is" << aTmpDir.toStdString() << std::endl;
+
+ QString aFileName = SUIT_Tools::file( myStudyURL, false ) + "_PARAVIS.pvsm";
+ QString aFullPath = aTmpDir + aFileName;
+
+ PVGUI_Module * mod = dynamic_cast<PVGUI_Module *>(getModule());
+ QStringList srcFiles;
+ if (mod)
+ {
+ // Create ParaView state file:
+ mod->saveParaviewState(aFullPath.toStdString().c_str());
+
+ // add this to the list to be saved:
+ theListOfFiles << aTmpDir;
+ theListOfFiles << aFileName;
+
+ // Potentially save referenced files:
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+ int aSavingType = aResourceMgr->integerValue( "PARAVIS", "savestate_type", 0 );
+
+ bool unused;
+ bool isBuiltIn = false;
+ pqServer* aServer;
+ QString nullS;
+
+ switch (aSavingType) {
+ case 0: // Save referenced files when they are accessible
+ createAndCheckRestoreFlag(aTmpDir, theListOfFiles ,unused);
+ processAllFilesInState(aFullPath, srcFiles, nullS, false);
+ break;
+ case 1: // Save referenced files only if this is the builtin server
+ aServer = pqApplicationCore::instance()->getActiveServer();
+ if (aServer)
+ isBuiltIn != aServer->isRemote();
+ if(isBuiltIn)
+ {
+ createAndCheckRestoreFlag(aTmpDir, theListOfFiles, unused);
+ processAllFilesInState(aFullPath, srcFiles, nullS, false);
+ }
+ break;
+ case 2: // Do not save referenced file
+ break;
+ default:
+ break;
+ }
+
+ ret = true;
+ }
+ // Copying valid source files to the temp directory and adding them to the list
+ foreach(QString fName, srcFiles)
+ {
+ QFile fSrc(fName);
+ if (fSrc.exists())
+ {
+ QFileInfo inf(fSrc);
+ QString newPth(SUIT_Tools::addSlash( aTmpDir ) + inf.fileName());
+ if (fSrc.copy(newPth))
+ {
+ theListOfFiles << inf.fileName();
+ }
+ }
}
+
+ return ret;
+}
+
+/*!
+ \brief Save data model (write ParaView pipeline state to the files).
+ \param url study file path
+ \param study study pointer
+ \param listOfFiles returning list of the (temporary) files with saved data
+ \return operation status (\c true on success and \c false on error)
+*/
+bool PVGUI_DataModel::saveAs( const QString& url, CAM_Study* study, QStringList& theListOfFiles)
+{
+ myStudyURL = url;
+ return save( theListOfFiles );
}
virtual bool dumpPython( const QString&, CAM_Study*, bool, QStringList& );
virtual bool open( const QString&, CAM_Study*, QStringList );
+ virtual bool save( QStringList& );
+ virtual bool saveAs( const QString&, CAM_Study*, QStringList& );
virtual bool create( CAM_Study* );
private:
void publishComponent(CAM_Study*);
+
+ bool createAndCheckRestoreFlag(const QString& tmpdir, QStringList& listOfFiles, bool & alreadyThere);
+
+ QString myStudyURL;
+
+ static const QString RESTORE_FLAG_FILE;
};
#endif /* PVGUIDATAMODEL_H_ */
/*!
\brief Saves ParaView state to a disk file
*/
-void PVGUI_Module::saveParaviewState( const char* theFileName )
+void PVGUI_Module::saveParaviewState( const QString& theFileName )
{
- pqApplicationCore::instance()->saveState( theFileName );
+ pqApplicationCore::instance()->saveState( theFileName.toStdString().c_str() );
}
/*!
/*!
\brief Restores ParaView state from a disk file
*/
-void PVGUI_Module::loadParaviewState( const char* theFileName )
+void PVGUI_Module::loadParaviewState( const QString& theFileName )
{
- pqApplicationCore::instance()->loadState( theFileName, getActiveServer() );
+ pqApplicationCore::instance()->loadState( theFileName.toStdString().c_str(), getActiveServer() );
}
/*!
addPreference( tr( "PREF_NO_EXT_PVSERVER" ), aParaVisSettingsTab,
LightApp_Preferences::Bool, PARAVIS_MODULE_NAME, "no_ext_pv_server" );
- /* VSR: not used
int aSaveType = addPreference( tr( "PREF_SAVE_TYPE_LBL" ), aParaVisSettingsTab,
LightApp_Preferences::Selector,
PARAVIS_MODULE_NAME, "savestate_type" );
aStrings << tr("PREF_SAVE_TYPE_0") << tr("PREF_SAVE_TYPE_1") << tr("PREF_SAVE_TYPE_2");
setPreferenceProperty( aSaveType, "strings", aStrings );
setPreferenceProperty( aSaveType, "indexes", aIndices );
- */
// ... "Language" group <<start>>
int traceGroup = addPreference( tr( "PREF_GROUP_TRACE" ), aParaVisSettingsTab );
void openFile( const char* ); // not used inside PARAVIS
void executeScript( const char* ); // not used inside PARAVIS
- void saveParaviewState( const char* ); // not used inside PARAVIS
- void loadParaviewState( const char* ); // not used inside PARAVIS
+
+ void saveParaviewState( const QString& );
+ void loadParaviewState( const QString& );
void clearParaviewState();
QString getTraceString();
</message>
<message>
<source>PREF_SAVE_TYPE_0</source>
- <translation>Save referenced files only for builtin server</translation>
+ <translation>Always save referenced files when they are accessible</translation>
</message>
<message>
<source>PREF_SAVE_TYPE_1</source>
- <translation>Always save referenced files when they are accessible</translation>
+ <translation>Save referenced files only for builtin server</translation>
</message>
<message>
<source>PREF_SAVE_TYPE_2</source>
</message>
<message>
<source>PREF_SAVE_TYPE_0</source>
- <translation>N'enregistrer les fichiers de référence qu'au serveur de babillard</translation>
+ <translation>Toujours enregistrer les fichiers de référence s'ils sont accessibles</translation>
</message>
<message>
<source>PREF_SAVE_TYPE_1</source>
- <translation>Toujours enregistrer les fichiers de référence s'ils sont accessibles</translation>
+ <translation>N'enregistrer les fichiers de référence que pour le serveur builtin</translation>
</message>
<message>
<source>PREF_SAVE_TYPE_2</source>
</message>
<message>
<source>PREF_SAVE_TYPE_0</source>
- <translation>掲示板サーバーだけに参照ファイルを保存します。</translation>
+ <translation>アクセス可能な場合は常に参照のファイルを保存します。</translation>
</message>
<message>
<source>PREF_SAVE_TYPE_1</source>
- <translation>アクセス可能な場合は常に参照のファイルを保存します。</translation>
- </message>
+ <translation>掲示板サーバーだけに参照ファイルを保存します。</translation>
+ </message>
<message>
<source>PREF_SAVE_TYPE_2</source>
<translation>参照ファイルを保存します。</translation>
if is_proportional:
mult = multiplier
- if mult is None:
+ if mult is None and data_range[1] != 0:
mult = abs(0.1 / data_range[1])
gausspnt.RadiusScalarRange = data_range
gausspnt.RadiusTransferFunctionMode = 'Table'
gausspnt.RadiusScalarRange = data_range
gausspnt.RadiusUseScalarRange = 1
- gausspnt.RadiusIsProportional = 1
- gausspnt.RadiusProportionalFactor = mult
+ if mult is not None:
+ gausspnt.RadiusIsProportional = 1
+ gausspnt.RadiusProportionalFactor = mult
else:
gausspnt.RadiusTransferFunctionEnabled = 0
gausspnt.RadiusMode = 'Constant'
if is_proportional:
mult = multiplier
- if mult is None:
+ if mult is None and data_range[1] != 0:
mult = abs(0.1 / data_range[1])
gausspnt.RadiusScalarRange = data_range
gausspnt.RadiusTransferFunctionMode = 'Table'
gausspnt.RadiusScalarRange = data_range
gausspnt.RadiusUseScalarRange = 1
- gausspnt.RadiusIsProportional = 1
- gausspnt.RadiusProportionalFactor = mult
+ if mult is not None:
+ gausspnt.RadiusIsProportional = 1
+ gausspnt.RadiusProportionalFactor = mult
else:
gausspnt.RadiusTransferFunctionEnabled = 0
gausspnt.RadiusMode = 'Constant'
proxy.UpdatePipeline()
# Get timestamps
- entity_data_info = proxy.GetCellDataInformation()
timestamps = proxy.TimestepValues.GetData()
for prs_type in prs_types:
if (scalar_range[0] == scalar_range[1]):
continue
print "Creating " + prs_name + " on " + field_name + ", time = " + str(time) + "... "
- prs = create_prs(prs_type, proxy,
- field_entity, field_name, timestamp_nb)
+ try:
+ prs = create_prs(prs_type, proxy,
+ field_entity, field_name, timestamp_nb)
+ except ValueError:
+ """ This exception comes from get_nb_components(...) function.
+ The reason of exception is an implementation of MEDReader
+ activating the first leaf when reading MED file (refer to
+ MEDFileFieldRepresentationTree::activateTheFirst() and
+ MEDFileFieldRepresentationTree::getTheSingleActivated(...) methods).
+ """
+ print "ValueError exception is catched"
+ continue
if prs is None:
print "FAILED"
continue
EllipseBuilder
DifferenceTimesteps
ArrayRenamer
+ JSONReader
)
IF(NOT SALOME_LIGHT_ONLY)
--- /dev/null
+# Copyright (C) 2015 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# Author : Roman NIKOLAEV
+
+PROJECT(JSONReader)
+
+cmake_minimum_required(VERSION 2.8)
+
+# Find ParaView
+FIND_PACKAGE(ParaView REQUIRED)
+INCLUDE(${PARAVIEW_USE_FILE})
+
+# Standard CMake option for building libraries shared or static by default.
+OPTION(BUILD_SHARED_LIBS "Build with shared libraries" ${VTK_BUILD_SHARED_LIBS})
+
+# Add subdirectories
+ADD_SUBDIRECTORY(JSONParser)
+ADD_SUBDIRECTORY(ParaViewPlugin)
+IF(SALOME_BUILD_TESTS)
+ ENABLE_TESTING()
+ ADD_SUBDIRECTORY(Test)
+ENDIF()
\ No newline at end of file
--- /dev/null
+{
+ "_metadata": {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "_metadata": {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight"],
+ "long_names": ["Pressure", "Velocity", "Total weight"],
+ "date" : "12/12/12",
+ "units": ["Pa", "m/s", "kg"]
+ },
+
+ "item1" : {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ "item2" :
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ "item3" :
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+}
--- /dev/null
+{
+
+ "item1" : {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ "item2" :
+ {
+ "P": 4.156,
+ "u": 465.0,
+ "weight": 137.5
+ },
+
+ "item3" :
+ {
+ "P": -3.0305890e+4,
+ "u": 1.0305890e-1,
+ "weight": -3.0305890e+5
+ }
+}
--- /dev/null
+# Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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, or (at your option) any later version.
+#
+# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author: Roman NIKOLAEV
+
+SET(PARCER_SRCS
+ vtkJSONParser.cxx)
+
+ADD_LIBRARY(vtkJSONParser ${PARCER_SRCS})
+
+TARGET_LINK_LIBRARIES(vtkJSONParser ${VTK_LIBRARIES})
+
+INSTALL(
+ TARGETS vtkJSONParser
+ DESTINATION lib/salome)
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Roman NIKOLAEV
+
+#include "vtkJSONParser.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkTable.h>
+#include <vtkInformation.h>
+#include <vtkDoubleArray.h>
+
+#include <algorithm>
+#include <sstream>
+#include <list>
+#include <map>
+
+//DEBUG macro
+//#define __DEBUG
+
+
+// Key worlds
+#define MD "_metadata"
+#define CMT "_comment"
+#define TBN "table_name"
+#define TBD "table_description"
+#define SHT "short_names"
+#define LNG "long_names"
+#define UNT "units"
+#define DT "date"
+
+// Separators
+#define COMMA ','
+
+#define COLON ':'
+
+#define OSB '['
+#define CSB ']'
+
+#define OCB '{'
+#define CCB '}'
+#define ENDL '\n'
+#define QTS '"'
+#define SPS ' '
+#define TAB '\t'
+
+#define NA "n/a"
+
+
+#define addInfo(info) \
+ Info I; \
+ I.type = info; \
+ I.ln = this->LineNumber; \
+ I.cn = this->ColumnNumber; \
+ I.pos = ftell(this->File); \
+ this->CInfoVector.push_back(I);
+
+//---------------------------------------------------
+bool isBlankOrEnd(const char c) {
+ return c == SPS || c == ENDL || c == TAB || c == EOF;
+}
+
+bool isDigitOrDot(const char c) {
+ return (c >= '.' && c <='9') || c == '+' || c == '-' || c == 'e';
+}
+
+// Exception
+//---------------------------------------------------
+vtkJSONException::vtkJSONException(const char *reason) : Reason(reason) {
+}
+
+//---------------------------------------------------
+vtkJSONException::~vtkJSONException() throw () {
+}
+
+//---------------------------------------------------
+const char* vtkJSONException::what() const throw() {
+ return Reason.c_str();
+}
+
+// Containers to store information about nodes:
+
+// Base node
+//---------------------------------------------------
+class vtkJSONNode {
+public:
+ vtkJSONNode() { Name = 0; }
+ virtual ~vtkJSONNode() { }
+ const char* GetName() { return this->Name ; }
+ void SetName(const char* name) { this->Name = name; }
+private:
+ const char* Name;
+};
+
+class vtkJSONMetaNode : public vtkJSONNode {
+public:
+ vtkJSONMetaNode() : vtkJSONNode() {
+ this->SetName(MD);
+ this->Comment = 0;
+ this->TableName = 0;
+ this->TableDescription = 0;
+ this->Date = 0;
+ }
+
+ virtual ~vtkJSONMetaNode() {
+ delete this->Comment; this->Comment = 0;
+ delete this->TableName; this->TableName = 0;
+ delete this->Date; this->Date= 0;
+ delete this->TableDescription; this->TableDescription = 0;
+ for(int i = 0; i < this->ShortNames.size(); i++) {
+ delete this->ShortNames[i]; this->ShortNames[i] = 0;
+ }
+ for(int i = 0; i < this->LongNames.size(); i++) {
+ delete this->LongNames[i]; this->LongNames[i] = 0;
+ }
+ for(int i = 0; i < this->Units.size(); i++) {
+ delete this->Units[i]; this->Units[i] = 0;
+ }
+ }
+
+ void SetComment(const char* comment) { this->Comment = comment; }
+ const char* GetComment() { return this->Comment; }
+
+ void SetTableName(const char* name) { this->TableName = name; }
+ const char* GetTableName() { return this->TableName; }
+
+ void SetDate(const char* name) { this->Date = name; }
+ const char* GetDate() { return this->Date; }
+
+ void SetTableDescription(const char* description) { this->TableDescription = description; }
+ const char* GetDescription() { return this->TableDescription; }
+
+ void SetShortNames(std::vector<const char*> names) { this->ShortNames = names; }
+ std::vector<const char*> GetShortNames() { return this->ShortNames; }
+
+ void SetLongNames(std::vector<const char*> names) { this->LongNames = names; }
+ std::vector<const char*> GetLongNames() { return this->LongNames; }
+
+ void SetUnits(std::vector<const char*> units) { this->Units = units; }
+ std::vector<const char*> GetUnits() { return this->Units; }
+
+private:
+ const char* Comment;
+ const char* TableName;
+ const char* TableDescription;
+ const char* Date;
+ std::vector<const char*> ShortNames;
+ std::vector<const char*> LongNames;
+ std::vector<const char*> Units;
+};
+
+struct char_cmp {
+ bool operator () (const char *a, const char *b) const
+ {
+ return strcmp(a,b)<0;
+ }
+};
+
+typedef std::map<const char*, double, char_cmp> vtkJSONMap;
+
+class vtkJSONInfoNode : public vtkJSONNode {
+public:
+ vtkJSONInfoNode(const char* name) : vtkJSONNode() {
+ this->SetName(name);
+ }
+ virtual ~vtkJSONInfoNode() {
+ vtkJSONMap::iterator it = this->Values.begin();
+ for( ;it != this->Values.end(); it++) {
+ delete it->first;
+ const char* c = it->first;
+ c = 0;
+ }
+ }
+ void AddValue(const char* key, const double value) {
+ this->Values.insert(std::pair<const char*,double>(key,value));
+ }
+ vtkJSONMap& GetValues() { return this->Values; }
+private:
+ vtkJSONMap Values;
+};
+
+
+//---------------------------------------------------
+vtkStandardNewMacro(vtkJSONParser);
+
+//---------------------------------------------------
+vtkJSONParser::vtkJSONParser()
+{
+ this->FileName = NULL;
+ this->LineNumber = 1;
+ this->ColumnNumber = 0;
+ this->File = 0;
+ this->InsideQuotes = false;
+ this->LastString = 0;
+ this->CurrentNode = 0;
+ this->ParseList = false;
+ this->ParseObjectList = false;
+ this->LastValue = NAN;
+ this->ShortNamesFilled = false;
+}
+
+//---------------------------------------------------
+vtkJSONParser::~vtkJSONParser()
+{
+ delete this->FileName;
+ this->FileName = 0;
+}
+
+
+//---------------------------------------------------
+int vtkJSONParser::Parse(vtkTable* theTable)
+{
+ if(!this->FileName) {
+ vtkErrorMacro("The name of the file is not defined");
+ return 1;
+ }
+ this->File = fopen( this->FileName, "r" );
+
+ if( !this->File ) {
+ std::string message = std::string("Can't open file: ") + std::string(this->FileName);
+ throwSimpleException(message.c_str());
+ return 1;
+ }
+ char ch = 0;
+
+ this->ExpectedCharacters.push_back(OCB);
+
+ while( ch != EOF ) {
+ ch = fgetc(this->File);
+ processCharacter(ch);
+ if(isDigitsAllowed() && isDigitOrDot(ch)) {
+ readDoubleValue();
+ }
+ int nb = 1;
+ switch(ch) {
+ case OCB: processOCB(); break;
+ case CCB: processCCB(); break;
+
+ case OSB: processOSB(); break;
+ case CSB: processCSB(); break;
+
+ case ENDL: processENDL(); nb = 0; break;
+
+ case QTS: processQTS(); break;
+
+ case COLON: processCOLON(); break;
+
+ case COMMA: processCOMMA(); break;
+ }
+ this->ColumnNumber+=nb;
+ }
+ fclose(this->File);
+
+ if(this->CInfoVector.size() > 0 ) {
+ throwException("braket is not closed ",
+ this->CInfoVector.back().ln,
+ this->CInfoVector.back().cn);
+ }
+
+ finalize(theTable);
+ clean();
+ return 1;
+}
+
+//---------------------------------------------------
+void vtkJSONParser::finalize( vtkTable *t ) {
+ std::vector<vtkJSONNode*>::iterator it = this->Nodes.begin();
+ vtkJSONMetaNode* mn = 0;
+ for( ; it != this->Nodes.end(); it++ ) {
+ mn = dynamic_cast<vtkJSONMetaNode*>(*it);
+ if (mn)
+ break;
+ }
+ std::vector<const char*> units;
+ if(mn) {
+ if(!mn->GetShortNames().empty()) {
+ this->ShortNames.clear();
+ this->ShortNames = mn->GetShortNames();
+ }
+ t->GetInformation()->Set(vtkDataObject::FIELD_NAME(), mn->GetTableName() ? mn->GetTableName() : "");
+ units = mn->GetUnits();
+ }
+
+ long nbRow = mn ? (this->Nodes.size() - 1 ) : this->Nodes.size();
+ for (long col=0; col < this->ShortNames.size(); col++) {
+ vtkDoubleArray* newCol = vtkDoubleArray::New();
+ newCol->SetNumberOfValues(nbRow);
+ vtkJSONInfoNode* in = 0;
+ std::string name = this->ShortNames[col];
+ name += "[";
+ if(col < units.size()){
+ name += units[col];
+ } else {
+ name += NA;
+ }
+ name += "]";
+ newCol->SetName(name.c_str());
+ it = this->Nodes.begin();
+ long row = 0;
+ for( ; it != this->Nodes.end(); it++ ) {
+ in = dynamic_cast<vtkJSONInfoNode*>(*it);
+ if (in) {
+ vtkJSONMap& vl = in->GetValues();
+ vtkJSONMap::iterator mit = vl.find(this->ShortNames[col]);
+ if(mit != vl.end()) {
+ newCol->SetValue(row, mit->second);
+ vl.erase(mit);
+ delete mit->first;
+ const char* c = mit->first;
+ c = 0;
+ row++;
+ } else {
+ std::string s("Item with name '");
+ s+=in->GetName();
+ s+="' has not key '";
+ s+=this->ShortNames[col];
+ s+="' !";
+ throwSimpleException(s.c_str());
+ }
+ }
+ }
+ t->AddColumn(newCol);
+ }
+ it = this->Nodes.begin();
+ vtkJSONInfoNode* in = 0;
+ for( ; it != this->Nodes.end(); it++ ) {
+ in = dynamic_cast<vtkJSONInfoNode*>(*it);
+ if (in) {
+ vtkJSONMap& vl = in->GetValues();
+ if(vl.size() > 0 ) {
+ std::string s("Item with name '");
+ s+=in->GetName();
+ s+="' has unexpected key '";
+ s+=vl.begin()->first;
+ s+="' !";
+ throwSimpleException(s.c_str());
+ }
+ }
+ }
+}
+
+//---------------------------------------------------
+void vtkJSONParser::processQTS() {
+ this->InsideQuotes = !this->InsideQuotes;
+ if(this->InsideQuotes) {
+ addInfo(QTS);
+ } else {
+ // Quotes is closed, get content
+ Info i = this->CInfoVector.back();
+ this->CInfoVector.pop_back();
+ if(i.type == QTS) {
+ long begin = i.pos;
+ long end = ftell(this->File) - 1;
+ this->LastString = getString(begin, end);
+ bool parse_list = (this->CInfoVector.size() >= 1 && this->CInfoVector.back().type == OSB);
+ if(parse_list) {
+ this->CurrentList.push_back(this->LastString);
+ } else {
+ this->Strings.push_back(this->LastString);
+ processMetaNode();
+ }
+#ifdef __DEBUG
+ std::cout<<"String : "<<this->LastString<<std::endl;
+#endif
+
+ this->ExpectedCharacters.clear();
+ this->ExpectedCharacters.push_back(COLON);
+ this->ExpectedCharacters.push_back(COMMA);
+ this->ExpectedCharacters.push_back(CCB);
+ this->ExpectedCharacters.push_back(CSB);
+ }
+ }
+}
+
+//---------------------------------------------------
+void vtkJSONParser::processCOLON() {
+ if (this->InsideQuotes)
+ return;
+ this->ExpectedCharacters.clear();
+ this->ExpectedCharacters.push_back(OCB);
+ this->ExpectedCharacters.push_back(QTS);
+ this->ExpectedCharacters.push_back(OSB);
+ if(GetInfoNode() && Strings.size() == 1 ) {
+ allowsDigits();
+ }
+}
+
+//---------------------------------------------------
+void vtkJSONParser::processOCB() {
+ if (this->InsideQuotes)
+ return;
+ this->ExpectedCharacters.clear();
+ this->ExpectedCharacters.push_back(QTS);
+ this->ExpectedCharacters.push_back(CCB);
+
+ // Create node
+ if(this->CInfoVector.size() >= 1) {
+ if ( !GetMetaNode() && this->Strings.size() > 0 &&
+ this->Strings.back() &&
+ strcmp(this->Strings.back(), MD) == 0 ) {
+#ifdef __DEBUG
+ std::cout<<"Create new Meta Node !!!"<<std::endl;
+#endif
+ this->CurrentNode = new vtkJSONMetaNode();
+ delete this->Strings.back();
+ this->Strings.back() = 0;
+ this->Strings.pop_back();
+ } else {
+ if(this->CInfoVector.back().type == OSB ) {
+ this->ParseObjectList = true;
+ }
+#ifdef __DEBUG
+ std::cout<<"Create new Node with name '"<<(this->Strings.size() == 0 ? "" : this->Strings.back())<<"' !!!"<<std::endl;
+#endif
+ this->CurrentNode = new vtkJSONInfoNode(this->Strings.size() == 0 ? "" : this->Strings.back());
+ if(!this->ParseObjectList && this->Strings.size() == 1) {
+ this->Strings.pop_back();
+ }
+ }
+ }
+ addInfo(OCB);
+}
+
+//---------------------------------------------------
+vtkJSONMetaNode* vtkJSONParser::GetMetaNode() {
+ vtkJSONMetaNode *mnode = 0;
+ if( this->CurrentNode ) {
+ mnode = dynamic_cast<vtkJSONMetaNode*>(this->CurrentNode);
+ }
+ return mnode;
+}
+
+//---------------------------------------------------
+vtkJSONInfoNode* vtkJSONParser::GetInfoNode() {
+ vtkJSONInfoNode *mnode = 0;
+ if( this->CurrentNode ) {
+ mnode = dynamic_cast<vtkJSONInfoNode*>(this->CurrentNode);
+ }
+ return mnode;
+}
+
+//---------------------------------------------------
+void vtkJSONParser::processENDL() {
+ if(this->InsideQuotes) {
+
+ throwException("quote is not closed !");
+ }
+ this->LineNumber++;
+ this->ColumnNumber=0;
+}
+
+
+//---------------------------------------------------
+void vtkJSONParser::processCSB() {
+ if (this->InsideQuotes)
+ return;
+
+ if(this->CInfoVector.back().type == OSB) {
+ if(this->ParseList) {
+ this->ParseList = false;
+ }
+ if(this->ParseObjectList) {
+ this->ParseObjectList = false;
+ }
+ this->CInfoVector.pop_back();
+ }
+
+ this->ExpectedCharacters.clear();
+ this->ExpectedCharacters.push_back(COMMA);
+ this->ExpectedCharacters.push_back(OCB);
+ this->ExpectedCharacters.push_back(CCB);
+}
+
+//---------------------------------------------------
+void vtkJSONParser::processOSB() {
+ if (this->InsideQuotes)
+ return;
+
+ if(this->ParseList) {
+ Info i = CInfoVector.back();
+ if(i.type == OSB) {
+ throwException("list, which has been opened in this place, has not been closed !", i.ln, i.cn);
+ }
+ }
+ if(GetMetaNode()) {
+ this->ParseList = true;
+ } else {
+ if( this->Strings.size() > 0 ) {
+ delete this->Strings[Strings.size()-1];
+ this->Strings[Strings.size()-1] = 0;
+ this->Strings.pop_back();
+ }
+ }
+ addInfo(OSB);
+ this->ExpectedCharacters.clear();
+ this->ExpectedCharacters.push_back(QTS);
+ this->ExpectedCharacters.push_back(OCB);
+}
+
+//---------------------------------------------------
+void vtkJSONParser::processCCB() {
+ if (this->InsideQuotes)
+ return;
+
+ this->ExpectedCharacters.clear();
+ this->ExpectedCharacters.push_back(COMMA);
+ this->ExpectedCharacters.push_back(CCB);
+ if(this->ParseObjectList) {
+ this->ExpectedCharacters.push_back(CSB);
+ }
+
+ processMetaNode();
+ processInfoNode();
+
+ if(this->CurrentNode)
+ this->Nodes.push_back(this->CurrentNode);
+ if( !this->ShortNamesFilled ){
+ vtkJSONInfoNode* n = dynamic_cast<vtkJSONInfoNode*>(this->CurrentNode);
+ if(n){
+ this->ShortNamesFilled = true;
+ }
+ }
+
+#ifdef __DEBUG
+ if(this->CurrentNode)
+ std::cout<<"End parsing node with name '"<<this->CurrentNode->GetName()<<"' !!!!"<<std::endl;
+#endif
+
+ if (this->CInfoVector.size() > 0 && this->CInfoVector.back().type == OCB ) {
+ this->CInfoVector.pop_back();
+ } else{
+ throwException ("unexpected closed braket '}' !");
+ }
+
+ this->CurrentNode = 0;
+}
+
+//---------------------------------------------------
+void vtkJSONParser::processCOMMA() {
+ if (this->InsideQuotes)
+ return;
+ this->ExpectedCharacters.clear();
+ this->ExpectedCharacters.push_back(QTS);
+ this->ExpectedCharacters.push_back(OCB);
+ processMetaNode();
+ processInfoNode();
+}
+
+void vtkJSONParser::processMetaNode() {
+ vtkJSONMetaNode* mn = GetMetaNode();
+ if(mn) {
+ bool strings = this->Strings.size() == 2 && !this->ParseList;
+ bool str_and_list = (this->Strings.size() == 1 && this->CurrentList.size() > 0 && !this->ParseList);
+
+ if( strings ) {
+ if ( strcmp(this->Strings[0], CMT) == 0 ) {
+ mn->SetComment(this->Strings[1]);
+#ifdef __DEBUG
+ std::cout<<"Table Comment : "<<this->Strings[1]<<std::endl;
+#endif
+ } else if ( strcmp(this->Strings[0], TBN) == 0 ) {
+ mn->SetTableName(this->Strings[1]);
+#ifdef __DEBUG
+ std::cout<<"Table Name : "<<this->Strings[1]<<std::endl;
+#endif
+ } else if ( strcmp(this->Strings[0], TBD) == 0 ) {
+ mn->SetTableDescription(this->Strings[1]);
+#ifdef __DEBUG
+ std::cout<<"Table Description : "<<this->Strings[1]<<std::endl;
+#endif
+ } else if ( strcmp(this->Strings[0], DT) == 0 ) {
+ mn->SetDate(this->Strings[1]);
+#ifdef __DEBUG
+ std::cout<<"Date : "<<this->Strings[1]<<std::endl;
+#endif
+ } else {
+ std::stringstream s;
+ s << "File : "<< this->FileName;
+ s << ", line "<<this->LineNumber;
+ s << " unexpected key world: '"<<this->Strings[0]<<"'";
+ }
+ delete this->Strings[0];
+ this->Strings[0] = 0;
+ Strings.pop_back();
+ Strings.pop_back();
+
+ } else if(str_and_list) {
+ if ( strcmp(this->Strings[0], SHT) == 0 ) {
+ std::vector<const char*>::const_iterator it = this->CurrentList.begin();
+ for( ;it != this->CurrentList.end(); it++) {
+ checkShortName(*it);
+ }
+ mn->SetShortNames(this->CurrentList);
+#ifdef __DEBUG
+ std::cout<<"Short Names : "<<std::endl;
+#endif
+ } else if ( strcmp(this->Strings[0], LNG) == 0 ) {
+ mn->SetLongNames(this->CurrentList);
+#ifdef __DEBUG
+ std::cout<<"Long Names : "<<std::endl;
+#endif
+ } else if ( strcmp(this->Strings[0], UNT) == 0 ) {
+ mn->SetUnits(this->CurrentList);
+#ifdef __DEBUG
+ std::cout<<"Units : ";
+#endif
+ } else {
+ std::stringstream s;
+ s << "File : "<< this->FileName;
+ s << ", line "<<this->LineNumber;
+ s << " unexpected key world: '"<<this->Strings[0]<<"'";
+ }
+ delete this->Strings[0];
+ this->Strings[0] = 0;
+ Strings.pop_back();
+#ifdef __DEBUG
+ std::vector<const char*>::const_iterator it = this->CurrentList.begin();
+ std::cout<<"[ ";
+ for( ;it != this->CurrentList.end(); it++) {
+ std::cout<<"'"<<*it<<"'";
+ if ( it+1 != this->CurrentList.end() )
+ std::cout<<", ";
+ }
+ std::cout<<" ]"<<std::endl;
+#endif
+ this->CurrentList.clear();
+ }
+ }
+}
+//---------------------------------------------------
+void vtkJSONParser::processInfoNode() {
+ vtkJSONInfoNode* in = GetInfoNode();
+ if(in) {
+ if(this->Strings.size() == 1 && !isnan(this->LastValue)) {
+ in->AddValue(this->Strings[0],this->LastValue);
+ if(!ShortNamesFilled) {
+ char* name = new char[strlen(Strings[0])];
+ strcpy(name, Strings[0]);
+ this->ShortNames.push_back(name);
+ }
+ this->Strings.pop_back();
+ this->LastValue = NAN;
+ }
+ }
+}
+
+//---------------------------------------------------
+void vtkJSONParser::processCharacter(const char ch) {
+ if (this->InsideQuotes)
+ return;
+ if(isBlankOrEnd(ch))
+ return;
+
+ if(this->ExpectedCharacters.empty())
+ return;
+
+ std::vector<char>::const_iterator it = std::find(this->ExpectedCharacters.begin(),
+ this->ExpectedCharacters.end(),
+ ch);
+
+ // Unexpected character is found
+ if(it == this->ExpectedCharacters.end()) {
+ std::string s("unexpected character '");
+ s+=ch;
+ s+="' !";
+ throwException(s.c_str());
+
+ }
+}
+
+//---------------------------------------------------
+char* vtkJSONParser::getString(long b, long e) {
+ char* result = 0;
+
+ long old_pos = ftell(this->File);
+ fseek(this->File, b, SEEK_SET);
+ long data_s = e - b;
+ result = new char[data_s];
+ result[0] = 0;
+ size_t nb_read = fread(result, sizeof(char), data_s, this->File);
+ result[nb_read] = '\0';
+ fseek(this->File, old_pos, SEEK_SET);
+ return result;
+}
+
+//---------------------------------------------------
+void vtkJSONParser::allowsDigits() {
+ for(char c = '.'; c <= '9'; c++) {
+ ExpectedCharacters.push_back(c);
+ }
+ ExpectedCharacters.push_back('-');
+ ExpectedCharacters.push_back('+');
+ ExpectedCharacters.push_back('e');
+}
+
+//---------------------------------------------------
+bool vtkJSONParser::isDigitsAllowed() {
+ std::vector<char>::const_iterator it = std::find(this->ExpectedCharacters.begin(),
+ this->ExpectedCharacters.end(),
+ '0');
+ return (it != this->ExpectedCharacters.end());
+}
+
+//---------------------------------------------------
+void vtkJSONParser::readDoubleValue() {
+ long b = ftell(this->File);
+
+ while(1) {
+ char ch = fgetc(this->File);
+ if(!isDigitOrDot(ch)) {
+ break;
+ }
+ }
+
+ long e = ftell(this->File);
+ fseek(this->File, b-1, SEEK_SET);
+ long data_s = e - b;
+ char* result = new char[data_s];
+ result[0] = 0;
+ size_t nb_read = fread(result, sizeof(char), data_s, this->File);
+ result[nb_read] = '\0';
+ this->ExpectedCharacters.clear();
+ this->ExpectedCharacters.push_back(COMMA);
+ this->ExpectedCharacters.push_back(CCB);
+ this->LastValue = atof(result);
+#ifdef __DEBUG
+ std::cout<<"Read number : "<<this->LastValue<<std::endl;
+#endif
+}
+
+//---------------------------------------------------
+void vtkJSONParser::checkShortName(const char* name) {
+ size_t ln = strlen(name);
+ if( ln > 0 ){
+ for( size_t i = 0; i < ln; i++ ) {
+ // a - z
+ if(!(name[i] >= 'a' && name[i] <= 'z') &&
+ // A - Z
+ !(name[i] >= 'A' && name[i] <= 'Z') ) {
+ std::string s("wrong short name '");
+ s += name;
+ s += "' !";
+ throwException(s.c_str(), this->LineNumber);
+ }
+ }
+ }
+}
+
+void vtkJSONParser::clean() {
+ std::vector<vtkJSONNode*>::iterator it = this->Nodes.begin();
+ for( ; it != this->Nodes.end(); it++ ) {
+ delete *(it);
+ *it = 0;
+ }
+}
+
+//---------------------------------------------------
+void vtkJSONParser::throwException(const char* message) {
+ std::stringstream s;
+ s << "File : "<< this->FileName;
+ s << ", line "<<this->LineNumber;
+ s << ", column " << this->ColumnNumber<<" : ";
+ s << message;
+ clean();
+ throw vtkJSONException(s.str().c_str());
+}
+
+//---------------------------------------------------
+void vtkJSONParser::throwException(const char* message, int ln, int cn) {
+ std::stringstream s;
+ s << "File : "<< this->FileName;
+ s << ", line "<<ln;
+ s << ", column :" << cn << " ";
+ s << message;
+ clean();
+ throw vtkJSONException(s.str().c_str());
+}
+//---------------------------------------------------
+void vtkJSONParser::throwException(const char* message, int ln) {
+ std::stringstream s;
+ s << "File "<< this->FileName;
+ s << ", line "<<ln <<" : ";
+ s << message;
+ clean();
+ throw vtkJSONException(s.str().c_str());
+}
+
+//---------------------------------------------------
+void vtkJSONParser::throwSimpleException(const char* message) {
+ clean();
+ throw vtkJSONException(message);
+}
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Autor: Roman NIKOLAEV (roman.nikolaev@opencascade.com)
+
+#ifndef __vtkJSONParser_h_
+#define __vtkJSONParser_h_
+
+#include <vtkObject.h>
+#include <vector>
+#include <stdio.h>
+#include <exception>
+#include <string>
+
+
+class vtkTable;
+class vtkJSONNode;
+class vtkJSONMetaNode;
+class vtkJSONInfoNode;
+
+//---------------------------------------------------
+class vtkJSONException : public std::exception {
+ public:
+ vtkJSONException(const char *reason);
+ ~vtkJSONException() throw ();
+ const char* what() const throw();
+ protected:
+ std::string Reason;
+};
+
+class vtkJSONParser : public vtkObject
+{
+public:
+ static vtkJSONParser* New();
+
+ // Description:
+ // Specifies the name of the file
+ vtkGetStringMacro(FileName);
+ vtkSetStringMacro(FileName);
+
+ virtual int Parse(vtkTable* theTable);
+
+protected:
+
+ //Struct to store cursor information
+ //----------------------------------
+ struct Info {
+ public:
+ char type;
+ long ln;
+ long cn;
+ long pos;
+
+ Info() {
+ type = 0;
+ ln = -1;
+ cn = -1;
+ pos = -1;
+ }
+ };
+
+ vtkJSONParser();
+ ~vtkJSONParser();
+
+ // name of the file to read from
+ //----------------------------------
+ char* FileName;
+
+ // current line and column
+ //----------------------------------
+ int LineNumber;
+ int ColumnNumber;
+
+ // markup information
+ //----------------------------------
+ std::vector<Info> CInfoVector;
+
+ // file
+ //----------------------------------
+ FILE* File;
+
+ // Nodes
+ //----------------------------------
+ std::vector<vtkJSONNode*> Nodes;
+ vtkJSONNode* CurrentNode;
+ vtkJSONMetaNode* MetaNode;
+
+ // Nodes
+ //----------------------------------
+ std::vector<char> ExpectedCharacters;
+
+ // Flags
+ //----------------------------------
+ bool InsideQuotes;
+ bool ParseList;
+ bool ParseObjectList;
+ bool ShortNamesFilled;
+
+ // Last parced string
+ //----------------------------------
+ char* LastString;
+ std::vector<const char*> Strings;
+ std::vector<const char*> CurrentList;
+ std::vector<const char*> ShortNames;
+
+ // Last parced values
+ //----------------------------------
+ double LastValue;
+
+private:
+ vtkJSONParser(const vtkJSONParser&); // Not implemented.
+ void operator=(const vtkJSONParser&); // Not implemented.
+
+ vtkJSONMetaNode* GetMetaNode();
+ vtkJSONInfoNode* GetInfoNode();
+
+ void processOCB();
+ void processCCB();
+
+ void processOSB();
+ void processCSB();
+
+ void processCOMMA();
+
+ void processCOLON();
+
+ void processENDL();
+
+ void processQTS();
+
+ void processCharacter(const char ch);
+
+ void processMetaNode();
+ void processInfoNode();
+
+ void readDoubleValue();
+
+ char* getString(long b, long e);
+
+ void allowsDigits();
+
+ bool isDigitsAllowed();
+
+ void checkShortName(const char* unit);
+
+ void finalize(vtkTable *t);
+
+ void clean();
+
+ void throwSimpleException(const char* message);
+
+ void throwException(const char* message);
+
+ void throwException(const char* message, int ln, int cn);
+
+ void throwException(const char* message, int ln);
+};
+#endif //__vtkJSONParser_h_
--- /dev/null
+# Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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, or (at your option) any later version.
+#
+# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author : Roman NIKOLAEV
+
+INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/JSONParser )
+
+ADD_PARAVIEW_PLUGIN(JSONReader "1.0"
+ SERVER_MANAGER_XML JSONReader.xml
+ SERVER_MANAGER_SOURCES vtkJSONReader.cxx
+ REQUIRED_ON_SERVER)
+
+TARGET_LINK_LIBRARIES(JSONReader vtkJSONParser)
+
+INSTALL(TARGETS JSONReader
+ DESTINATION lib/paraview
+)
--- /dev/null
+<ServerManagerConfiguration>
+ <ProxyGroup name="sources">
+ <SourceProxy name="JSONReader" class="vtkJSONReader" label="JSON Reader">
+
+ <Hints>
+ <ReaderFactory extensions="json"
+ file_description="JSON file" />
+ </Hints>
+
+ <Documentation
+ short_help="Reads JSON file"
+ long_help="Reads JSON file and converts it to the VTK table">
+ </Documentation>
+
+ <StringVectorProperty
+ name="FileName"
+ command="SetFileName"
+ number_of_elements="1"
+ panel_visibility="never">
+ <FileListDomain name="files"/>
+ <Documentation>
+ This property specifies the file name for the JSON reader
+ </Documentation>
+ </StringVectorProperty>
+ </SourceProxy>
+ </ProxyGroup>
+</ServerManagerConfiguration>
--- /dev/null
+pv_plugin(JSONReader
+ DESCRIPTION "Reads the JSON file and converts it to the VTK table"
+ DEFAULT_ENABLED)
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Roman NIKOLAEV
+
+#include "vtkJSONReader.h"
+#include "vtkJSONParser.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkTable.h>
+#include <vtkInformationVector.h>
+#include <vtkInformation.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkVariantArray.h>
+#include <vtkStringArray.h>
+#include <vtkStringToNumeric.h>
+
+#include <vtksys/stl/stdexcept>
+#include <vtksys/ios/sstream>
+
+vtkStandardNewMacro(vtkJSONReader);
+
+//---------------------------------------------------
+vtkJSONReader::vtkJSONReader()
+{
+ this->SetNumberOfInputPorts(0);
+ this->SetNumberOfOutputPorts(1);
+ this->FileName = NULL;
+ this->Parser = vtkJSONParser::New();
+}
+
+//---------------------------------------------------
+vtkJSONReader::~vtkJSONReader()
+{
+ this->SetFileName(NULL);
+ this->Parser->Delete();
+}
+
+//---------------------------------------------------
+int vtkJSONReader::CanReadFile(const char* fname)
+{
+ return 1;
+}
+
+//---------------------------------------------------
+void vtkJSONReader::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os, indent);
+ os << indent << "FileName: "
+ << (this->FileName ? this->FileName : "(none)") << endl;
+ os << indent << "Parser: "<<this->Parser << endl;
+}
+
+//---------------------------------------------------
+int vtkJSONReader::RequestData(vtkInformation*,
+ vtkInformationVector**,
+ vtkInformationVector* outputVector)
+{
+ vtkTable* const output_table = vtkTable::GetData(outputVector);
+
+ vtkInformation* const outInfo = outputVector->GetInformationObject(0);
+ if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) &&
+ outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) > 0)
+ {
+ return 1;
+ }
+
+ // If the filename is not defined
+ if (!this->FileName && !this->Parser)
+ {
+ return 1;
+ }
+
+ this->Parser->SetFileName(this->FileName);
+ try{
+ return this->Parser->Parse(output_table);
+ } catch(vtkJSONException e) {
+ std::cout<<e.what()<<std::endl;
+ return 1;
+ }
+}
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Autor: Roman NIKOLAEV (roman.nikolaev@opencascade.com)
+
+#ifndef __vtkJSONReader_h_
+#define __vtkJSONReader_h_
+
+#include "vtkTableAlgorithm.h"
+
+class vtkStringArray;
+class vtkJSONParser;
+
+class VTK_EXPORT vtkJSONReader: public vtkTableAlgorithm
+{
+public:
+ static vtkJSONReader* New();
+ vtkTypeMacro(vtkJSONReader, vtkTableAlgorithm)
+ void PrintSelf(ostream& os, vtkIndent indent);
+
+ // Description:
+ // Specifies the name of the file
+ vtkGetStringMacro(FileName);
+ vtkSetStringMacro(FileName);
+
+ // Description:
+ // Determine whether the given file can be read
+ virtual int CanReadFile(const char* fname);
+
+ // Description:
+ // Request Data
+ virtual int RequestData(vtkInformation*,
+ vtkInformationVector**,
+ vtkInformationVector*);
+
+
+protected:
+ vtkJSONReader();
+ ~vtkJSONReader();
+ // name of the file to read from
+ char* FileName;
+
+ vtkJSONParser* Parser;
+
+private:
+ vtkJSONReader(const vtkJSONReader&); // Not implemented.
+ void operator=(const vtkJSONReader&); // Not implemented.
+};
+
+#endif //__vtkJSONReader_h_
--- /dev/null
+a {
+ "_metadata": {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "_metadata" : {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
--- /dev/null
+{
+ "_metadata" : {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+} 9999
\ No newline at end of file
--- /dev/null
+{ b
+ "_metadata": {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "_metadata: {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "_metadata" : c {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "_metadata" : {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015",
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "_metadata" : {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ,
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "_metadata" : {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items":
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "_metadata" : {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": "43.5"
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+{
+ "_metadata" : {
+ "_comment": "",
+ "table_name": "Short name of the table",
+ "table_description": "A somewhat longer description for the table",
+
+ "short_names": ["P", "u", "weight" ],
+ "long_names": [ "Pressure", "Velocity", "Total weight" ],
+ "units": [ "Pa", "m/s", "kg" ],
+ "date" : "12/09/2015"
+ },
+
+ "items": [
+ {
+ "P":3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0,
+ "weight": 43.5
+ },
+
+ {
+ "P": 3.15,
+ "u": 0.0 0.0,
+ "weight": 43.5
+ }
+ ]
+}
\ No newline at end of file
--- /dev/null
+# Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/../JSONParser
+ ${CPPUNIT_INCLUDE_DIRS}
+)
+
+SET(JSONParserTest_SOURCES
+ JSONParserTest.cxx
+ vtkJSONParserTest.cxx
+ )
+
+ADD_EXECUTABLE(vtkJSONParserTest ${JSONParserTest_SOURCES})
+TARGET_LINK_LIBRARIES(vtkJSONParserTest vtkJSONParser ${CPPUNIT_LIBRARIES})
+ADD_TEST(vtkJSONParserTest vtkJSONParserTest)
+
+
+
--- /dev/null
+
+#include "vtkJSONParserTest.hxx"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( vtkJSONParserTest );
+
+#include "MainTest.hxx"
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _MAINTEST_HXX_
+#define _MAINTEST_HXX_
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TextTestProgressListener.h>
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/TestRunner.h>
+#include <stdexcept>
+
+#include <iostream>
+#include <fstream>
+
+// ============================================================================
+/*!
+ * Main program source for Unit Tests with cppunit package does not depend
+ * on actual tests, so we use the same for all partial unit tests.
+ */
+// ============================================================================
+
+int main(int argc, char* argv[])
+{
+ // --- Create the event manager and test controller
+ CPPUNIT_NS::TestResult controller;
+
+ // --- Add a listener that colllects test result
+ CPPUNIT_NS::TestResultCollector result;
+ controller.addListener( &result );
+
+ // --- Add a listener that print dots as test run.
+#ifdef WIN32
+ CPPUNIT_NS::TextTestProgressListener progress;
+#else
+ CPPUNIT_NS::BriefTestProgressListener progress;
+#endif
+ controller.addListener( &progress );
+
+ // --- Get the top level suite from the registry
+
+ CPPUNIT_NS::Test *suite =
+ CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
+
+ // --- Adds the test to the list of test to run
+
+ CPPUNIT_NS::TestRunner runner;
+ runner.addTest( suite );
+ runner.run( controller);
+
+ // --- Print test in a compiler compatible format.
+
+ std::ofstream testFile;
+ testFile.open("UnitTestsResult.txt", std::ios::out | std::ios::trunc);
+ //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
+ CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
+ outputter.write();
+
+ // --- Run the tests.
+
+ bool wasSucessful = result.wasSuccessful();
+ testFile.close();
+
+ // --- Return error code 1 if the one of test failed.
+
+ return wasSucessful ? 0 : 1;
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+
+#include "vtkJSONParserTest.hxx"
+#include <vtkJSONParser.h>
+
+#include <vtkTable.h>
+#include <vtkVariant.h>
+#include <vtkAbstractArray.h>
+
+#include <iostream>
+#include <sstream>
+#include <stdlib.h>
+
+//---------------------------------------------------
+std::string vtkJSONParserTest::getGoodFilesDir() {
+ char* c = getenv("PARAVIS_SRC_DIR");
+ std::string s = std::string(c == 0 ? "" : c);
+ if( !s.empty() ) {
+ s+="/src";
+ s+="/Plugins";
+ s+="/JSONReader";
+ s+="/Examples/";
+ }
+ return s;
+}
+
+//---------------------------------------------------
+std::string vtkJSONParserTest::getBadFilesDir() {
+ char* c = getenv("PARAVIS_SRC_DIR");
+ std::string s = std::string(c == 0 ? "" : c);
+ if( !s.empty() ) {
+ s+="/src";
+ s+="/Plugins";
+ s+="/JSONReader";
+ s+="/Test";
+ s+="/BadFiles";
+ s+="/";
+ }
+ return s;
+}
+
+//---------------------------------------------------
+void vtkJSONParserTest::testParseBadFiles() {
+ std::string dir = getBadFilesDir();
+ if(dir.empty())
+ CPPUNIT_FAIL("Can't get examples dir !!! ");
+ std::string fn = "bad_ex";
+
+ // 11 existing files, bad_ex12.json doesn't exists, check exception
+ for(int i = 1; i <=12; i++) {
+ std::string s = dir + fn;
+ std::stringstream convert;
+ convert << i;
+ s += convert.str();
+ s += ".json";
+ vtkJSONParser* Parser = vtkJSONParser::New();
+ vtkTable* table = vtkTable::New();
+ Parser->SetFileName(s.c_str());
+ bool expected_exception_thrown = false;
+ try{
+ Parser->Parse(table);
+ } catch(vtkJSONException e) {
+ expected_exception_thrown = true;
+ }
+ Parser->Delete();
+ table->Delete();
+ if(!expected_exception_thrown) {
+ CPPUNIT_FAIL("Expected exception is not thrown !!! ");
+ }
+ }
+}
+
+//---------------------------------------------------
+void vtkJSONParserTest::testParseGoodFiles() {
+ std::string dir = getGoodFilesDir();
+ if(dir.empty())
+ CPPUNIT_FAIL("Can't get examples dir !!! ");
+ std::string fn = "example";
+
+ for(int i = 1; i <=2; i++) {
+ std::string s = dir + fn;
+ std::stringstream convert;
+ convert << i;
+ s += convert.str();
+ s += ".json";
+ vtkJSONParser* Parser = vtkJSONParser::New();
+ vtkTable* table = vtkTable::New();
+ Parser->SetFileName(s.c_str());
+ bool exception_thrown = false;
+ try{
+ Parser->Parse(table);
+ } catch(vtkJSONException e) {
+ exception_thrown = true;
+ }
+ Parser->Delete();
+ table->Delete();
+
+ if(exception_thrown) {
+ CPPUNIT_FAIL("Unexpected exception has been thrown !!! ");
+ }
+ }
+
+ vtkJSONParser* Parser = vtkJSONParser::New();
+ vtkTable* table = vtkTable::New();
+ fn = "example";
+ std::string s = dir + fn;
+ std::stringstream convert;
+ convert << 2;
+ s += convert.str();
+ s += "_wo_metadata.json";
+ Parser->SetFileName(s.c_str());
+ bool exception_thrown = false;
+ try{
+ Parser->Parse(table);
+ } catch(vtkJSONException e) {
+ exception_thrown = true;
+ }
+ if(exception_thrown) {
+ CPPUNIT_FAIL("Unexpected exception has been thrown !!! ");
+ }
+
+ double v = table->GetValue(2,0).ToDouble();
+ double v1 = table->GetValue(2,1).ToDouble();
+ double v2 = table->GetValue(2,2).ToDouble();
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected value : ", 3.15, table->GetValue(0,0).ToDouble(), 0.001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected value : ", 0.0, table->GetValue(0,1).ToDouble(), 0.001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected value : ", 43.5, table->GetValue(0,2).ToDouble(), 0.001);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected value : ", 4.156, table->GetValue(1,0).ToDouble(), 0.001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected value : ", 465, table->GetValue(1,1).ToDouble(), 0.001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected value : ", 137.5, table->GetValue(1,2).ToDouble(), 0.001);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected value : ", -3.0305890e+4, table->GetValue(2,0).ToDouble(), 0.001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected value : ", 1.0305890e-1, table->GetValue(2,1).ToDouble(), 0.001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unexpected value : ", -3.0305890e+5, table->GetValue(2,2).ToDouble(), 0.001);
+
+ std::string s1 ();
+
+ CPPUNIT_ASSERT_EQUAL( std::string("P[n/a]"), std::string(table->GetColumn(0)->GetName()));
+ CPPUNIT_ASSERT_EQUAL( std::string("u[n/a]"), std::string(table->GetColumn(1)->GetName()));
+ CPPUNIT_ASSERT_EQUAL( std::string("weight[n/a]"), std::string(table->GetColumn(2)->GetName()));
+
+ Parser->Delete();
+ table->Delete();
+}
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __VTKJSONPARSERTEST_HXX__
+#define __VTKJSONPARSERTEST_HXX__
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <string.h>
+
+class vtkJSONParserTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(vtkJSONParserTest);
+ CPPUNIT_TEST( testParseGoodFiles );
+ CPPUNIT_TEST( testParseBadFiles );
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ void testParseGoodFiles();
+ void testParseBadFiles();
+private:
+ std::string getGoodFilesDir();
+ std::string getBadFilesDir();
+};
+
+#endif
# Stream Lines creation
prs= StreamLinesOnField(aProxy,EntityType.NODE,'vitesse' , 1)
-prs.Visibility=1
+if prs is None:
+ # TODO: check why stream lines prs is empty
+ print "WARNING! StreamLines presentation wasn't created or is empty..."
+else:
+ prs.Visibility=1
aView.ResetCamera()
print "Creating an Animation.....................",
my_format = "jpeg"
from paravistest import datadir, Import_Med_Field
med_file = datadir + "ResOK_0000.med"
-field_names = ["temperature", "vitesse", "pression"]
-prs_list = [ [1,2,3,4,8], range(1,10), [0,1,2,3,4,8] ]
+field_names1 = ["temperature", "vitesse", "pression"]
+prs_list1 = [ [1,2,3,4,8], [1,2,3,4,5,6,8,9], [0,1,2,3,4,8] ]
-Import_Med_Field(med_file, field_names, 1, prs_list)
+Import_Med_Field(med_file, field_names1, 1, prs_list1)
+
+# Stream Lines presentation on "vitesse" field is created
+# by ParaView as an empty presentation: no any cells or points.
+# TODO: check why presentation is empty.
+field_names2 = ["vitesse"]
+prs_list2 = [ [7] ]
+
+Import_Med_Field(med_file, field_names2, 0, prs_list2)
# This case corresponds to: /visu/SWIG_scripts/A8 case
# Create table
-# Do not use pv as a short name.
-# It is a name of function from numpy and may be redefined implicitly by 'from numpy import *' call.
-# import paraview.simple as pv
-import paraview.simple as pvs
-import paraview.servermanager as sm
-
+import pvsimple
# Define script for table creation
script = """
"""
# Creating programmable source (table)
-ps = pvs.ProgrammableSource()
+ps = pvsimple.ProgrammableSource()
ps.OutputDataSetType = 'vtkTable'
ps.Script = script
-pvs.RenameSource("Very useful data", ps)
+pvsimple.RenameSource("Very useful data", ps)
ps.UpdatePipeline()
# This case corresponds to: /visu/SWIG_scripts/C3 case
# Create table and display curves
-# Do not use pv as a short name.
-# It is a name of function from numpy and may be redefined implicitly by 'from numpy import *' call.
-# import paraview.simple as pv
-import paraview.simple as pvs
-import paraview.servermanager as sm
-
+import pvsimple
# Define script for table creation
script = """
"""
# Creating programmable source (table)
-ps = pvs.ProgrammableSource()
+ps = pvsimple.ProgrammableSource()
ps.OutputDataSetType = 'vtkTable'
ps.Script = script
-pvs.RenameSource("Very useful data", ps)
+pvsimple.RenameSource("Very useful data", ps)
ps.UpdatePipeline()
# Display table
# TODO: no possibility to create spreadsheet view
# Display curves
-xy_view = pvs.CreateXYPlotView()
+xy_view = pvsimple.CreateXYPlotView()
xy_view.ChartTitle = 'Very useful data'
-xy_view.AxisTitle = ['[ Wt ]', 'Frequency [ Hz ]']
+xy_view.BottomAxisTitle = '[ Wt ]'
+xy_view.LeftAxisTitle = 'Frequency [ Hz ]'
-xy_rep = pvs.Show(ps)
+xy_rep = pvsimple.Show(ps)
xy_rep.AttributeType = 'Row Data'
xy_rep.UseIndexForXAxis = 0
xy_rep.XArrayName = 'Frequency'
xy_rep.SeriesVisibility = ['Frequency', '0']
-pvs.Render(xy_view)
+pvsimple.Render(xy_view)
# Hide legend
xy_view.ShowLegend = 0
-pvs.Render(xy_view)
+pvsimple.Render(xy_view)
-# Set logarithmic scaling for X axis
-xy_view.AxisLogScale[1] = 1
-pvs.Render(xy_view)
+# Set logarithmic scaling for Y axis
+xy_view.LeftAxisLogScale = 1
+pvsimple.Render(xy_view)
-# Set linear scaling for X axis
-xy_view.AxisLogScale[1] = 0
-pvs.Render(xy_view)
+# Set linear scaling for Y axis
+xy_view.LeftAxisLogScale = 0
+pvsimple.Render(xy_view)
# Set logarithmic scaling for X axis
-xy_view.AxisLogScale[0] = 1
-pvs.Render(xy_view)
+xy_view.BottomAxisLogScale = 1
+pvsimple.Render(xy_view)
# Show legend
xy_view.ShowLegend = 1
-pvs.Render(xy_view)
+pvsimple.Render(xy_view)
samples_dir = os.getenv("DATA_DIR")
datadir = None
tablesdir = None
+texturesdir = None
if samples_dir is not None:
samples_dir = os.path.normpath(samples_dir)
datadir = samples_dir + "/MedFiles/"
tablesdir = samples_dir + "/Tables/"
+ texturesdir = samples_dir + "/Textures/"
# Graphics files extension
pictureext = os.getenv("PIC_EXT")
err = nb_errors
for type in prs[i]:
- if type==0:
- if presentations.GaussPointsOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created GaussPoints presentation is None!!!"; nb_errors+=1
- if type==1:
- if presentations.ScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created ScalarMap presentation is None!!!"; nb_errors+=1
- if type==2:
- if presentations.IsoSurfacesOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created IsoSurfaces presentation is None!!!"; nb_errors+=1
- if type==3:
- if presentations.CutPlanesOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created CutPlanes presentation is None!!!"; nb_errors+=1
- if type==4:
- if presentations.CutLinesOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created CutLines presentation is None!!!"; nb_errors+=1
- if type==5:
- if presentations.DeformedShapeOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created DeformedShape presentation is None!!!"; nb_errors+=1
- if type==6:
- if presentations.VectorsOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created Vectors presentation is None!!!"; nb_errors+=1
- if type==7:
- if presentations.StreamLinesOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created StreamLines presentation is None!!!"; nb_errors+=1
- if type==8:
- if presentations.Plot3DOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created Plot3D presentation is None!!!"; nb_errors+=1
- if type==9:
- if presentations.DeformedShapeAndScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created ScalarMapOnDeformedShape presentation is None!!!"; nb_errors+=1
+ try:
+ if type==0:
+ if presentations.GaussPointsOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created GaussPoints presentation is None!!!"; nb_errors+=1
+ if type==1:
+ if presentations.ScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created ScalarMap presentation is None!!!"; nb_errors+=1
+ if type==2:
+ if presentations.IsoSurfacesOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created IsoSurfaces presentation is None!!!"; nb_errors+=1
+ if type==3:
+ if presentations.CutPlanesOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created CutPlanes presentation is None!!!"; nb_errors+=1
+ if type==4:
+ if presentations.CutLinesOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created CutLines presentation is None!!!"; nb_errors+=1
+ if type==5:
+ if presentations.DeformedShapeOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created DeformedShape presentation is None!!!"; nb_errors+=1
+ if type==6:
+ if presentations.VectorsOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created Vectors presentation is None!!!"; nb_errors+=1
+ if type==7:
+ if presentations.StreamLinesOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created StreamLines presentation is None!!!"; nb_errors+=1
+ if type==8:
+ if presentations.Plot3DOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created Plot3D presentation is None!!!"; nb_errors+=1
+ if type==9:
+ if presentations.DeformedShapeAndScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created ScalarMapOnDeformedShape presentation is None!!!"; nb_errors+=1
+ except ValueError:
+ """ This exception comes from get_nb_components(...) function.
+ The reason of exception is an implementation of MEDReader
+ activating the first leaf when reading MED file (refer to
+ MEDFileFieldRepresentationTree::activateTheFirst() and
+ MEDFileFieldRepresentationTree::getTheSingleActivated(...) methods).
+ """
+ print "ValueError exception is catched"
+ continue
# check if number of errors has increased
if err == nb_errors:
return result_name
+#
+# NB! An 'Unknown exception' is raised, when a user try to open
+# "Bug619-result_calcul_OCC.med" file in MED module via 'Add Data Source' functionality.
+# Refer to LastTest.log file for more information.
+# TODO: check MedReader pb.
+#
# 1. Import of the "Bug619-result_calcul_OCC.med" file
med_file_path = datadir + "Bug619-result_calcul_OCC.med"
prs = eval(name + "OnField(med_reader, EntityType.NODE, med_field, 1)")
if prs is None:
print "ERROR!!! ", name," presentation wasn't created..."
- errors += 1
+ # StreamLines presentation is empty for "vitesse" field defined in the loaded MED file.
+ # TODO: check why stream lines prs is empty
+ if name == "StreamLines":
+ print "WARNING: Stream lines presentation is empty!"
+ else:
+ errors += 1
else:
RenameSource(name, prs.Input)
prs_list.append(prs)
# This case corresponds to: /visu/imps/B1 case
-from paravistest import datadir
+from paravistest import datadir, texturesdir
from presentations import *
import pvsimple
# Set texture
scalarmap.RenderMode = 'Texture'
-scalarmap.Texture = [os.path.join(datadir, "Textures", "texture1.dat")]
+# COMMENTED OUT! Currently this does not work as Point Sprite ParaView plugin is not correctly wrapped to Python.
+# As soon as problem is fixed, below code probably need to be modified, but it should be something similar.
+#import vtk
+#texture = vtk.vtkTexture()
+#pngReader = vtk.vtkPNGReader()
+#pngReader.SetFileName(os.path.join(texturesdir, "texture1.png"))
+#texture.SetInputConnection(pngReader.GetOutputPort())
+#texture.InterpolateOn()
+#scalarmap.Texture = texture
pvsimple.Render()
PROJECT(LightPARAVIS)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
SET(CMAKE_BUILD_TYPE "Debug")
-FIND_PACKAGE(Qt4 REQUIRED)
+OPTION(LIGHTPARAVIS_WITH_GUI "Build GUI test app" ON)
+# Package detection
+FIND_PACKAGE(Qt4 REQUIRED)
LIST(APPEND CMAKE_PREFIX_PATH "$ENV{PARAVIEW_ROOT_DIR}")
-FIND_PACKAGE(ParaView 4.3 REQUIRED)
+FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
INCLUDE(ParaViewMacros)
+SET(CMAKE_INCLUDE_CURRENT_DIR ON)
-# Main application
-ADD_SUBDIRECTORY(src)
+# Main applications
+IF(LIGHTPARAVIS_WITH_GUI)
+ ADD_SUBDIRECTORY(gui)
+ENDIF()
+ADD_SUBDIRECTORY(simple)
--- /dev/null
+# Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author: Adrien Bruneton (CEA)
+
+SET(pl_HEADERS
+ PLMainWindow.hxx
+ PLViewTab.hxx
+ PVViewer_Behaviors.h
+ PVViewer_GUIElements.h
+ )
+
+SET(pl_OTHER_HEADERS
+ PVViewer_Core.h
+ )
+
+SET(pl_SOURCES
+ main.cpp
+ PLMainWindow.cxx
+ PLViewTab.cxx
+ PVViewer_Behaviors.cxx
+ PVViewer_GUIElements.cxx
+ PVViewer_Core.cxx
+ )
+
+SET(pl_FORMS
+ ui/light_para.ui
+ ui/view_tab.ui
+ )
+
+SET(CMAKE_INCLUDE_CURRENT_DIR ON)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+INCLUDE_DIRECTORIES(${PARAVIEW_INCLUDE_DIRS})
+
+INCLUDE(${QT_USE_FILE})
+ADD_DEFINITIONS(${QT_DEFINITIONS})
+
+# Generate resources that will embedded
+SET(ui_resources
+ "${CMAKE_CURRENT_BINARY_DIR}/LightPara_configuration.qrc")
+
+GENERATE_QT_RESOURCE_FROM_FILES(
+ "${ui_resources}"
+ "/LightPara/Configuration"
+ "${PROJECT_SOURCE_DIR}/gui/xml/ParaViewReaders.xml")
+
+QT4_ADD_RESOURCES(rcs_sources
+ ${ui_resources}
+ )
+QT4_WRAP_UI(pl_FORMS_HEADERS ${pl_FORMS})
+QT4_WRAP_CPP(pl_HEADERS_MOC ${pl_HEADERS})
+
+ADD_EXECUTABLE(paraLight
+ ${pl_SOURCES}
+ ${pl_HEADERS_MOC}
+ ${pl_FORMS_HEADERS}
+ ${rcs_sources})
+
+TARGET_LINK_LIBRARIES(paraLight ${QT_LIBRARIES} pqApplicationComponents vtkRenderingFreeTypeOpenGL)
+#INSTALL(TARGET paraLight bin)
+
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#include "PVViewer_GUIElements.h"
+#include "PLMainWindow.hxx"
+#include "PVViewer_Core.h"
+#include "PLViewTab.hxx"
+
+#include <iostream>
+#include <QObject>
+#include <QtGui/QFileDialog>
+#include <QMessageBox>
+
+#include <pqTabbedMultiViewWidget.h>
+#include <pqApplicationCore.h>
+#include <pqPVApplicationCore.h>
+#include <pqObjectBuilder.h>
+#include <pqLoadDataReaction.h>
+#include <pqPipelineSource.h>
+#include <pqManagePluginsReaction.h>
+#include <pqPropertiesPanel.h>
+#include <pqPipelineBrowserWidget.h>
+#include <pqServerManagerModel.h>
+#include <pqRenderView.h>
+#include <pqActiveObjects.h>
+#include <pqProxy.h>
+
+#include <vtkSMSourceProxy.h>
+#include <vtkSMProperty.h>
+#include <vtkSMStringVectorProperty.h>
+
+PLMainWindow::PLMainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ _pAppC(0),
+ _simplePipeline(),
+ _autoApply(true)
+{
+ _mainWindow.setupUi(this);
+ _autoApply = _mainWindow.actionAuto_apply->isChecked();
+ QObject::connect(this, SIGNAL(apply()), this, SLOT(onApply()));
+ QObject::connect(this, SIGNAL(changedCurrentFile(QString)), this, SLOT(onApply()));
+ addTab();
+}
+
+// Called after ParaView application initialisation:
+void PLMainWindow::finishUISetup()
+{
+ _pAppC = PVViewer_Core::GetPVApplication();
+ PVViewer_GUIElements * pvgui = PVViewer_GUIElements::GetInstance(this);
+ QWidget * wprop = pvgui->getPropertiesPanel();
+ QWidget * wpipe = pvgui->getPipelineBrowserWidget();
+ wprop->setParent(_mainWindow.propFrame);
+ _mainWindow.verticalLayoutProp->addWidget(wprop);
+ wpipe->setParent(_mainWindow.pipelineFrame);
+ _mainWindow.verticalLayoutPipe->addWidget(wpipe);
+
+ PVViewer_GUIElements * pvge = PVViewer_GUIElements::GetInstance(this);
+// pvge->setToolBarVisible(false);
+
+ // In this mockup, we play on the parent widget visibility (a QFrame), so show these:
+ pvge->getPipelineBrowserWidget()->show();
+ pvge->getPropertiesPanel()->show();
+ // and hide these:
+ _mainWindow.propFrame->hide();
+ _mainWindow.pipelineFrame->hide();
+// pvge->setToolBarEnabled(false);
+// pvge->setToolBarVisible(false);
+
+}
+
+void PLMainWindow::autoApplyCheck(bool isChecked)
+{
+ _autoApply = isChecked;
+}
+
+void PLMainWindow::onApply()
+{
+ if (_autoApply)
+ {
+ PVViewer_GUIElements * pvgui = PVViewer_GUIElements::GetInstance(this);
+ pqPropertiesPanel * wprop = pvgui->getPropertiesPanel();
+ wprop->apply();
+ }
+}
+
+void PLMainWindow::showProp(bool isChecked)
+{
+ isChecked ? _mainWindow.propFrame->show() : _mainWindow.propFrame->hide();
+}
+
+void PLMainWindow::showPipeline(bool isChecked)
+{
+ isChecked ? _mainWindow.pipelineFrame->show() : _mainWindow.pipelineFrame->hide();
+}
+
+void PLMainWindow::addTab()
+{
+ int c = _mainWindow.tabWidget->count();
+ PLViewTab * newTab = new PLViewTab(_mainWindow.tabWidget);
+ int newIdx = _mainWindow.tabWidget->addTab(newTab, QString("Tab %1").arg(c+1));
+ _mainWindow.tabWidget->setCurrentIndex(newIdx);
+
+ // Connect buttons
+ QObject::connect(newTab, SIGNAL(onInsertSingleView(PLViewTab *)), this, SLOT(insertSingleView(PLViewTab *)));
+ QObject::connect(newTab, SIGNAL(onInsertMultiView(PLViewTab *)), this, SLOT(insertMultiView(PLViewTab *)));
+}
+
+void PLMainWindow::deleteTab()
+{
+ int c = _mainWindow.tabWidget->currentIndex();
+ if (c != -1)
+ {
+ _mainWindow.tabWidget->removeTab(c);
+ }
+}
+
+void PLMainWindow::currentTabChanged(int tabIdx)
+{
+ QWidget * w = _mainWindow.tabWidget->widget(tabIdx);
+ if (w)
+ {
+ PLViewTab * viewtab = qobject_cast<PLViewTab *>(w);
+ if (viewtab && viewtab->getpqView())
+ {
+ pqActiveObjects::instance().setActiveView(viewtab->getpqView());
+ }
+ }
+}
+
+void PLMainWindow::doOpenFile()
+{
+ // Clean up vizu
+// cleanAll();
+
+ // Load the stuff as wireframe in the main view:
+ QList<pqPipelineSource *> many = pqLoadDataReaction::loadData();
+ if (many.isEmpty())
+ {
+ std::cout << "no file selected!" << std::endl;
+ return;
+ }
+ if (many.count() > 1)
+ {
+ QMessageBox msgBox;
+ msgBox.setText("Select one file only!");
+ msgBox.exec();
+ cleanAll();
+ return;
+ }
+
+ pqPipelineSource * src = many.at(0);
+ std::cout << "num of out ports: " << src->getNumberOfOutputPorts() << std::endl;
+
+ // A cone to start with:
+// pqPipelineSource * src = this->_pAppC->getObjectBuilder()->createSource(QString("sources"), QString("ConeSource"),
+// this->_activeServer);
+ if(src)
+ _simplePipeline.push(src);
+
+ // Retrieve loaded file name
+ vtkSMProperty * prop = src->getSourceProxy()->GetProperty("FileName");
+ vtkSMStringVectorProperty * prop2 = vtkSMStringVectorProperty::SafeDownCast(prop);
+ QString fName(prop2->GetElement(0));
+
+ // Emit signal
+ emit changedCurrentFile(fName);
+}
+
+void PLMainWindow::insertSingleView(PLViewTab * tab)
+{
+ // Create a new view proxy on the server
+ pqObjectBuilder* builder = _pAppC->getObjectBuilder();
+ pqServer* active_serv = pqActiveObjects::instance().activeServer();
+
+ std::cout << "About to create single view ..." << std::endl;
+ pqView * pqview = builder->createView(QString("RenderView"), active_serv);
+ std::cout << "Created: " << pqview << "!" << std::endl;
+
+ // Retrieve its widget and pass it to the Qt tab:
+ QWidget* viewWidget = pqview->getWidget();
+
+// QWidget* viewWidget = new QPushButton("toto");
+ tab->hideAndReplace(viewWidget, pqview);
+
+ pqActiveObjects::instance().setActiveView(pqview);
+}
+
+void PLMainWindow::insertMultiView(PLViewTab * tab)
+{
+ // Retrieve TabbedMultiView and see if it is already attached to someone:
+ PVViewer_GUIElements * pvgui = PVViewer_GUIElements::GetInstance(this);
+ pqTabbedMultiViewWidget * multiv = pvgui->getTabbedMultiViewWidget();
+
+ QWidget * parent = multiv->nativeParentWidget();
+ if (parent)
+ {
+ QMessageBox msgBox;
+ msgBox.setText("Multi-view already in use in another tab! Close it first.");
+ msgBox.exec();
+ }
+ else
+ {
+ tab->hideAndReplace(multiv, NULL);
+ }
+}
+
+
+void PLMainWindow::doShrink()
+{
+ if(!_simplePipeline.isEmpty())
+ {
+ cleanAllButSource();
+
+ pqPipelineSource * src = this->_pAppC->getObjectBuilder()->createFilter(QString("filters"),
+ QString("ShrinkFilter"), _simplePipeline.top());
+ if(src)
+ _simplePipeline.push(src);
+
+ // Hit apply
+ emit apply();
+ }
+}
+
+void PLMainWindow::doSlice()
+{
+ if(!_simplePipeline.isEmpty())
+ {
+ cleanAllButSource();
+
+ pqPipelineSource * src = this->_pAppC->getObjectBuilder()->createFilter(QString("filters"),
+ QString("Cut"), _simplePipeline.top());
+ if(src)
+ _simplePipeline.push(src);
+
+ // Hit apply
+ emit apply();
+ }
+}
+
+void PLMainWindow::doManagePlugins()
+{
+ pqManagePluginsReaction::managePlugins();
+}
+
+void PLMainWindow::cleanAll()
+{
+ this->_pAppC->getObjectBuilder()->destroyPipelineProxies();
+ _simplePipeline.resize(0);
+}
+
+void PLMainWindow::cleanAllButSource()
+{
+ while(_simplePipeline.size() > 1)
+ this->_pAppC->getObjectBuilder()->destroy(_simplePipeline.pop());
+}
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#ifndef PLVIEWWIDGET_H_
+#define PLVIEWWIDGET_H_
+
+#include <QMainWindow>
+#include "ui_light_para.h"
+#include <QStack>
+
+class pqPVApplicationCore;
+class pqPipelineSource;
+class pqServer;
+class pqProxy;
+
+class PLViewTab;
+
+/** Main window of the application.
+ */
+class PLMainWindow: public QMainWindow {
+ Q_OBJECT
+
+public:
+ PLMainWindow(QWidget * parent=0);
+ virtual ~PLMainWindow() {}
+
+ void finishUISetup();
+
+protected:
+ void doOpenFile();
+ void doManagePlugins();
+
+ void doSlice();
+ void doShrink();
+
+ void cleanAll();
+ void cleanAllButSource();
+
+signals:
+ void changedCurrentFile(QString fileName);
+ void apply(); // convenience signal to forward to the real ParaView apply
+
+private slots:
+ void autoApplyCheck(bool);
+ void onApply();
+ void showPipeline(bool);
+ void showProp(bool);
+
+ void addTab();
+ void deleteTab();
+
+ void onFileOpen() { doOpenFile(); };
+ void slice() { doSlice(); };
+ void shrink() { doShrink(); };
+ void managePlugins() { doManagePlugins(); };
+
+ void insertSingleView(PLViewTab *);
+ void insertMultiView(PLViewTab *);
+
+ void currentTabChanged(int);
+
+private:
+ Ui::MainWindow _mainWindow;
+
+ pqPVApplicationCore * _pAppC;
+ //pqServer * _activeServer;
+ //pqPipelineSource * _activeSource; // last pipeline element
+ QStack<pqPipelineSource *> _simplePipeline;
+
+ bool _autoApply;
+};
+
+#endif /* PLVIEWWIDGET_H_ */
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#include <iostream>
+#include "PLViewTab.hxx"
+
+PLViewTab::PLViewTab(QWidget * parent):
+QWidget(parent),
+_renderView(0)
+{
+ _viewTab.setupUi(this);
+}
+
+void PLViewTab::insertSingleView()
+{
+ emit onInsertSingleView(this);
+}
+
+void PLViewTab::insertMultiView()
+{
+ emit onInsertMultiView(this);
+}
+
+void PLViewTab::hideAndReplace(QWidget * w, pqView * view)
+{
+ _viewTab.frameButtons->hide();
+ w->setParent(_viewTab.frameView);
+ QVBoxLayout * vbox = _viewTab.verticalLayoutView;
+ vbox->addWidget(w);
+ _renderView = view;
+}
+
+void PLViewTab::viewDestroyed()
+{
+ std::cout << "View destroyed!" << std::endl;
+}
+
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#ifndef SRC_PLVIEWTAB_HXX_
+#define SRC_PLVIEWTAB_HXX_
+
+#include "ui_view_tab.h"
+
+class pqView;
+
+/** Widget inserted when a new tab is requested in the application.
+ */
+class PLViewTab: public QWidget {
+ Q_OBJECT
+
+public:
+ PLViewTab(QWidget * parent=0);
+ virtual ~PLViewTab() {}
+
+ // Hide buttons, and put widget in the QFrame with a vertical layout
+ void hideAndReplace(QWidget * w, pqView * view);
+
+ pqView * getpqView() { return _renderView; }
+
+private slots:
+ void insertSingleView();
+ void insertMultiView();
+ void viewDestroyed();
+
+signals:
+ void onInsertSingleView(PLViewTab *);
+ void onInsertMultiView(PLViewTab *);
+
+private:
+ Ui::ViewTab _viewTab;
+ pqView * _renderView;
+};
+
+#endif /* SRC_PLVIEWTAB_HXX_ */
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#include "PVViewer_Behaviors.h"
+
+#include <QMainWindow>
+
+#include <pqInterfaceTracker.h>
+#include <pqApplicationCore.h>
+#include <pqPluginManager.h>
+#include <pqStandardPropertyWidgetInterface.h>
+#include <pqStandardViewFrameActionsImplementation.h>
+#include <pqPropertiesPanel.h>
+
+#include <pqAlwaysConnectedBehavior.h>
+#include <pqAutoLoadPluginXMLBehavior.h>
+#include <pqCommandLineOptionsBehavior.h>
+#include <pqCrashRecoveryBehavior.h>
+#include <pqDataTimeStepBehavior.h>
+#include <pqDefaultViewBehavior.h>
+#include <pqObjectPickingBehavior.h>
+#include <pqPersistentMainWindowStateBehavior.h>
+#include <pqPipelineContextMenuBehavior.h>
+#include <pqPluginActionGroupBehavior.h>
+#include <pqPluginDockWidgetsBehavior.h>
+#include <pqSpreadSheetVisibilityBehavior.h>
+#include <pqUndoRedoBehavior.h>
+#include <pqViewStreamingBehavior.h>
+#include <pqCollaborationBehavior.h>
+#include <pqVerifyRequiredPluginBehavior.h>
+#include <pqPluginSettingsBehavior.h>
+#include <pqFixPathsInStateFilesBehavior.h>
+#include <pqApplyBehavior.h>
+
+#include <pqPropertiesPanel.h>
+
+int PVViewer_Behaviors::BehaviorLoadingLevel = 0;
+
+PVViewer_Behaviors::PVViewer_Behaviors(QMainWindow * parent)
+ : QObject(parent)
+{
+}
+
+/**! Instanciate minimal ParaView behaviors needed when using an instance of PVViewer.
+ * This method should be updated at each new version of ParaView with what is found in
+ * Qt/ApplicationComponents/pqParaViewBehaviors.cxx
+ */
+void PVViewer_Behaviors::instanciateMinimalBehaviors(QMainWindow * desk)
+{
+ 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 pqVerifyRequiredPluginBehavior(this);
+ new pqPluginSettingsBehavior(this);
+ new pqFixPathsInStateFilesBehavior(this);
+ new pqCrashRecoveryBehavior(this);
+ new pqCommandLineOptionsBehavior(this);
+
+ BehaviorLoadingLevel = 1;
+ }
+}
+
+/**! Instanciate usual ParaView behaviors.
+ * This method should be updated at each new version of ParaView with what is found in
+ * Qt/ApplicationComponents/pqParaViewBehaviors.cxx
+ */
+void PVViewer_Behaviors::instanciateAllBehaviors(QMainWindow * desk)
+{
+ // "new pqParaViewBehaviors(anApp->desktop(), this);"
+ // -> (which loads all standard ParaView behaviors at once) has to be replaced in order to
+ // exclude using of pqQtMessageHandlerBehaviour
+
+ // Define application behaviors.
+ if (BehaviorLoadingLevel < 1)
+ instanciateMinimalBehaviors(desk);
+
+ if (BehaviorLoadingLevel < 2)
+ {
+ //new pqQtMessageHandlerBehavior(this); // THIS ONE TO EXCLUDE !! see comment above
+ new pqDataTimeStepBehavior(this);
+ new pqSpreadSheetVisibilityBehavior(this);
+ new pqPipelineContextMenuBehavior(this);
+ new pqUndoRedoBehavior(this);
+ new pqAutoLoadPluginXMLBehavior(this); // auto load plugins GUI stuff
+ 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;
+ }
+}
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+
+#ifndef PVGUIBEHAVIORS_H_
+#define PVGUIBEHAVIORS_H_
+
+#include <QObject>
+
+class QMainWindow;
+class pqPropertiesPanel;
+
+/**!
+ * PARAVIS behaviors - mimic what is done in
+ * Qt/ApplicationComponents/pqParaViewBehaviors.cxx
+ * Except a few ones, behaviors are destroyed when the module is destroyed.
+ */
+class PVViewer_Behaviors: public QObject
+{
+ Q_OBJECT
+
+public:
+ PVViewer_Behaviors(QMainWindow * parent);
+
+ void instanciateMinimalBehaviors(QMainWindow * desk);
+ void instanciateAllBehaviors(QMainWindow * desk);
+
+ virtual ~PVViewer_Behaviors() {}
+
+private:
+ static int BehaviorLoadingLevel;
+};
+
+#endif /* PVGUIBEHAVIORS_H_ */
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Adrien Bruneton (CEA)
+//
+
+#include "PVViewer_Core.h"
+//#include "PVViewer_LogWindowAdapter.h"
+#include "PVViewer_GUIElements.h"
+#include "PVViewer_Behaviors.h"
+#include "PVViewer_Core.h"
+
+#include <QApplication>
+#include <QStringList>
+#include <QDir>
+#include <QMainWindow>
+
+#include <string>
+
+#include <pqOptions.h>
+#include <pqSettings.h>
+#include <pqPVApplicationCore.h>
+#include <pqTabbedMultiViewWidget.h>
+#include <pqParaViewMenuBuilders.h>
+#include <pqActiveObjects.h>
+#include <pqPipelineBrowserWidget.h>
+#include <pqServerDisconnectReaction.h>
+
+
+//---------- Static init -----------------
+pqPVApplicationCore* PVViewer_Core::MyCoreApp = 0;
+bool PVViewer_Core::ConfigLoaded = false;
+PVViewer_Behaviors * PVViewer_Core::ParaviewBehaviors = NULL;
+
+pqPVApplicationCore * PVViewer_Core::GetPVApplication()
+{
+ return MyCoreApp;
+}
+
+/*!
+ \brief Static method, performs initialization of ParaView session.
+ \param fullSetup whether to instanciate all behaviors or just the minimal ones.
+ \return \c true if ParaView has been initialized successfully, otherwise false
+*/
+bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop, LogWindow * logWindow)
+{
+ if ( ! MyCoreApp) {
+ // Obtain command-line arguments
+ int argc = 0;
+ char** argv = 0;
+ QString aOptions = getenv("PARAVIEW_OPTIONS");
+ QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts);
+ argv = new char*[aOptList.size() + 1];
+ QStringList args = QApplication::arguments();
+ argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis");
+ argc++;
+
+ foreach (QString aStr, aOptList) {
+ argv[argc] = strdup( aStr.toLatin1().constData() );
+ argc++;
+ }
+ MyCoreApp = new pqPVApplicationCore (argc, argv);
+ if (MyCoreApp->getOptions()->GetHelpSelected() ||
+ MyCoreApp->getOptions()->GetUnknownArgument() ||
+ MyCoreApp->getOptions()->GetErrorMessage() ||
+ MyCoreApp->getOptions()->GetTellVersion()) {
+ return false;
+ }
+
+ // Direct VTK log messages to our SALOME window - TODO: review this
+// PVViewer_LogWindowAdapter * w = PVViewer_LogWindowAdapter::New();
+// w->setLogWindow(logWindow);
+// vtkOutputWindow::SetInstance(w);
+
+// new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation
+
+ for (int i = 0; i < argc; i++)
+ free(argv[i]);
+ delete[] argv;
+ }
+ // Initialize GUI elements if needed:
+ PVViewer_GUIElements::GetInstance(aDesktop);
+ return true;
+}
+
+void PVViewer_Core::ParaviewInitBehaviors(bool fullSetup, QMainWindow* aDesktop)
+{
+ if (!ParaviewBehaviors)
+ ParaviewBehaviors = new PVViewer_Behaviors(aDesktop);
+
+ if(fullSetup)
+ ParaviewBehaviors->instanciateAllBehaviors(aDesktop);
+ else
+ ParaviewBehaviors->instanciateMinimalBehaviors(aDesktop);
+}
+
+void PVViewer_Core::ParaviewLoadConfigurations(const QString & configPath, bool force)
+{
+ if (!ConfigLoaded || force)
+ {
+ if (!configPath.isNull()) {
+ MyCoreApp->loadConfiguration(configPath + QDir::separator() + "ParaViewFilters.xml");
+ MyCoreApp->loadConfiguration(configPath + QDir::separator() + "ParaViewSources.xml");
+ }
+ ConfigLoaded = true;
+ }
+}
+
+void PVViewer_Core::ParaviewCleanup()
+{
+ // Disconnect from server
+ pqServer* server = pqActiveObjects::instance().activeServer();
+ if (server && server->isRemote())
+ {
+ pqServerDisconnectReaction::disconnectFromServer();
+ }
+
+ pqApplicationCore::instance()->settings()->sync();
+
+ pqPVApplicationCore * app = GetPVApplication();
+ // Schedule destruction of PVApplication singleton:
+ if (app)
+ app->deleteLater();
+}
+
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Adrien Bruneton (CEA)
+
+#ifndef SRC_PVVIEWER_PVVIEWER_CORE_H_
+#define SRC_PVVIEWER_PVVIEWER_CORE_H_
+
+#include <QString>
+
+class PVServer_ServiceWrapper;
+class PVViewer_Behaviors;
+class LogWindow;
+class QMainWindow;
+class pqPVApplicationCore;
+
+/**
+ Pure static class gathering most of the interactions with ParaView's API and ParaView's
+ start sequence.
+ */
+class PVViewer_Core
+{
+public:
+ static pqPVApplicationCore * GetPVApplication();
+
+
+ //! Initialize ParaView if not yet done (once per session)
+ static bool ParaviewInitApp(QMainWindow* aDesktop, LogWindow * w);
+ static void ParaviewInitBehaviors(bool fullSetup=false, QMainWindow* aDesktop=0);
+ static void ParaviewLoadConfigurations(const QString & configPath, bool force=false);
+ static void ParaviewCleanup();
+
+private:
+ PVViewer_Core();
+ virtual ~PVViewer_Core();
+
+ static pqPVApplicationCore* MyCoreApp;
+ static bool ConfigLoaded;
+ static PVViewer_Behaviors * ParaviewBehaviors;
+};
+
+#endif /* SRC_PVVIEWER_PVVIEWER_CORE_H_ */
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#include <iostream>
+
+#include "PVViewer_GUIElements.h"
+#include "PVViewer_Core.h"
+
+#include <pqPVApplicationCore.h>
+#include <pqActiveObjects.h>
+#include <pqObjectBuilder.h>
+
+#include <pqPropertiesPanel.h>
+#include <pqPipelineBrowserWidget.h>
+#include <pqTabbedMultiViewWidget.h>
+#include <pqParaViewMenuBuilders.h>
+#include <pqMainControlsToolbar.h>
+#include <pqVCRToolbar.h>
+#include <pqAnimationTimeToolbar.h>
+#include <pqColorToolbar.h>
+#include <pqRepresentationToolbar.h>
+#include <pqCameraToolbar.h>
+#include <pqAxesToolbar.h>
+#include <pqSetName.h>
+
+#include <pqPythonManager.h>
+#include <pqApplicationCore.h>
+
+#include <QMainWindow>
+#include <QMenu>
+#include <QList>
+#include <QAction>
+#include <QToolBar>
+#include <QLayout>
+
+#include <QCoreApplication>
+
+PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
+
+PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desk) :
+ propertiesPanel(0), pipelineBrowserWidget(0),
+ sourcesMenu(0)
+{
+ propertiesPanel = new pqPropertiesPanel(desk);
+ propertiesPanel->hide();
+ pipelineBrowserWidget = new pqPipelineBrowserWidget(desk);
+ pipelineBrowserWidget->hide();
+
+ sourcesMenu = new QMenu(0);
+ pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
+ filtersMenu = new QMenu(0);
+ pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
+ macrosMenu = new QMenu(0);
+ pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
+
+ //myBuildToolbars(desk);
+}
+
+PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(QMainWindow* desk)
+{
+ if (! theInstance)
+ theInstance = new PVViewer_GUIElements(desk);
+ return theInstance;
+}
+
+
+pqTabbedMultiViewWidget * PVViewer_GUIElements::getTabbedMultiViewWidget()
+{
+ pqTabbedMultiViewWidget * multiv =
+ qobject_cast<pqTabbedMultiViewWidget*>(PVViewer_Core::GetPVApplication()->manager("MULTIVIEW_WIDGET"));
+
+ // If not found, instanciate it. It will then register automatically as a MULTIVIEW_WIDGET.
+ // Also create a single view that will be attached by the tabbedMultiView automatically
+ // (in PV this is done automatically upon server connection event).
+ if (!multiv)
+ {
+ multiv = new pqTabbedMultiViewWidget();
+
+ // Create a new view proxy on the server
+ pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
+ pqServer* active_serv = pqActiveObjects::instance().activeServer();
+ pqView * pqview = builder->createView(QString("RenderView"), active_serv);
+ }
+
+ return multiv;
+}
+
+
+/**
+ * See ParaView source code: pqParaViewMenuBuilders::buildToolbars()
+ * to keep this function up to date:
+ */
+void PVViewer_GUIElements::myBuildToolbars(QMainWindow* mainWindow)
+{
+ mainToolBar = new pqMainControlsToolbar(mainWindow)
+ << pqSetName("MainControlsToolbar");
+ mainToolBar->layout()->setSpacing(0);
+
+ vcrToolbar = new pqVCRToolbar(mainWindow)
+ << pqSetName("VCRToolbar");
+ vcrToolbar->layout()->setSpacing(0);
+
+ timeToolbar = new pqAnimationTimeToolbar(mainWindow)
+ << pqSetName("currentTimeToolbar");
+ timeToolbar->layout()->setSpacing(0);
+
+ colorToolbar = new pqColorToolbar(mainWindow)
+ << pqSetName("variableToolbar");
+ colorToolbar->layout()->setSpacing(0);
+
+ reprToolbar = new pqRepresentationToolbar(mainWindow)
+ << pqSetName("representationToolbar");
+ reprToolbar->layout()->setSpacing(0);
+
+ cameraToolbar = new pqCameraToolbar(mainWindow)
+ << pqSetName("cameraToolbar");
+ cameraToolbar->layout()->setSpacing(0);
+
+ axesToolbar = new pqAxesToolbar(mainWindow)
+ << pqSetName("axesToolbar");
+ axesToolbar->layout()->setSpacing(0);
+
+ // Give the macros menu to the pqPythonMacroSupervisor
+ pqPythonManager* manager = qobject_cast<pqPythonManager*>(
+ pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
+
+ macrosToolbar = new QToolBar("Macros Toolbars", mainWindow)
+ << pqSetName("MacrosToolbar");
+ manager->addWidgetForRunMacros(macrosToolbar);
+
+ commonToolbar = new QToolBar("Common", mainWindow) << pqSetName("Common");
+ commonToolbar->layout()->setSpacing(0);
+
+ dataToolbar = new QToolBar("DataAnalysis", mainWindow) << pqSetName("DataAnalysis");
+ dataToolbar->layout()->setSpacing(0);
+
+ //addToolbars(mainWindow);
+}
+
+void PVViewer_GUIElements::setToolBarVisible(bool show)
+{
+ QCoreApplication::processEvents();
+ mainAction->setChecked(!show);
+ mainAction->setVisible(show);
+ mainAction->trigger();
+ vcrAction->setChecked(!show);
+ vcrAction->setVisible(show);
+ vcrAction->trigger();
+ timeAction->setChecked(!show);
+ timeAction->setVisible(show);
+ timeAction->trigger();
+ colorAction->setChecked(!show);
+ colorAction->setVisible(show);
+ colorAction->trigger();
+ reprAction->setChecked(!show);
+ reprAction->setVisible(show);
+ reprAction->trigger();
+ cameraAction->setChecked(!show);
+ cameraAction->setVisible(show);
+ cameraAction->trigger();
+ axesAction->setChecked(!show);
+ axesAction->setVisible(show);
+ axesAction->trigger();
+ macrosAction->setChecked(!show);
+ macrosAction->setVisible(show);
+ macrosAction->trigger();
+ commonAction->setChecked(!show);
+ commonAction->setVisible(show);
+ commonAction->trigger();
+ dataAction->setChecked(!show);
+ dataAction->setVisible(show);
+ dataAction->trigger();
+}
+
+void PVViewer_GUIElements::addToolbars(QMainWindow* desk)
+{
+ desk->addToolBar(Qt::TopToolBarArea, mainToolBar);
+ desk->addToolBar(Qt::TopToolBarArea, vcrToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, timeToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, colorToolbar);
+ desk->insertToolBarBreak(colorToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, reprToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, cameraToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, axesToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, macrosToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, commonToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, dataToolbar);
+
+ mainAction = mainToolBar->toggleViewAction();
+ vcrAction = vcrToolbar->toggleViewAction();
+ timeAction = timeToolbar->toggleViewAction();
+ colorAction = colorToolbar->toggleViewAction();
+ reprAction = reprToolbar->toggleViewAction();
+ cameraAction = cameraToolbar->toggleViewAction();
+ axesAction = axesToolbar->toggleViewAction();
+ macrosAction = macrosToolbar->toggleViewAction();
+ commonAction = commonToolbar->toggleViewAction();
+ dataAction = dataToolbar->toggleViewAction();
+}
+
+void PVViewer_GUIElements::onEmulateApply()
+{
+ if (propertiesPanel)
+ propertiesPanel->apply();
+}
+
+QList<QToolBar*> PVViewer_GUIElements::getToolbars()
+{
+ QList<QToolBar*> l;
+ l << mainToolBar << vcrToolbar << timeToolbar << colorToolbar
+ << reprToolbar << cameraToolbar << axesToolbar << macrosToolbar
+ << commonToolbar << dataToolbar;
+ return l;
+}
+
+void PVViewer_GUIElements::setToolBarEnabled(bool enabled)
+{
+ mainToolBar ->setEnabled(enabled);
+ vcrToolbar ->setEnabled(enabled);
+ timeToolbar ->setEnabled(enabled);
+ colorToolbar ->setEnabled(enabled);
+ reprToolbar ->setEnabled(enabled);
+ cameraToolbar->setEnabled(enabled);
+ axesToolbar ->setEnabled(enabled);
+ macrosToolbar->setEnabled(enabled);
+ commonToolbar->setEnabled(enabled);
+ dataToolbar ->setEnabled(enabled);
+}
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#ifndef PVVIEWERGUIELEMENTS_H_
+#define PVVIEWERGUIELEMENTS_H_
+
+#include <QObject>
+#include <QList>
+
+class pqPropertiesPanel;
+class pqPipelineBrowserWidget;
+class pqTabbedMultiViewWidget;
+class QMainWindow;
+class QMenu;
+class QToolBar;
+class QAction;
+class pqAnimationTimeToolbar;
+class pqVCRToolbar;
+
+/*!
+ * Some GUI elements of ParaView need to be instanciated in a proper order. This class
+ * holds all of them for the sake of clarity.
+ */
+class PVViewer_GUIElements: public QObject
+{
+ Q_OBJECT
+
+public:
+ static PVViewer_GUIElements * GetInstance(QMainWindow * desk);
+
+ pqPropertiesPanel * getPropertiesPanel() { return propertiesPanel; }
+ pqPipelineBrowserWidget * getPipelineBrowserWidget() { return pipelineBrowserWidget; }
+ pqTabbedMultiViewWidget * getTabbedMultiViewWidget();
+
+ QMenu* getFiltersMenu() { return filtersMenu; }
+ QMenu* getSourcesMenu() { return sourcesMenu; }
+ QMenu* getMacrosMenu() { return macrosMenu; }
+
+ pqVCRToolbar* getVCRToolbar() { return vcrToolbar; }
+ pqAnimationTimeToolbar* getTimeToolbar() { return timeToolbar; }
+
+ void myBuildToolbars(QMainWindow* desk);
+ void addToolbars(QMainWindow* desk);
+ void setToolBarVisible(bool show);
+ void setToolBarEnabled(bool enabled);
+ QList<QToolBar*> getToolbars();
+
+public slots:
+ void onEmulateApply(); // better use the slot from PVViewer_ViewManager if you want to trigger "Apply"
+
+private:
+ PVViewer_GUIElements(QMainWindow* desk);
+ virtual ~PVViewer_GUIElements() {}
+
+ static PVViewer_GUIElements* theInstance;
+
+ // Widgets
+ pqPropertiesPanel* propertiesPanel;
+ pqPipelineBrowserWidget* pipelineBrowserWidget;
+ pqTabbedMultiViewWidget* tabbedMultiViewWidget;
+
+ // Dummy QMenus receiving ParaView's reaction for automatic add when new sources are added
+ QMenu* sourcesMenu;
+ QMenu* filtersMenu;
+ QMenu* macrosMenu;
+
+ // Toolbars also need to be instanciated early:
+ QToolBar* mainToolBar;
+ pqVCRToolbar* vcrToolbar;
+ pqAnimationTimeToolbar* timeToolbar;
+ QToolBar* colorToolbar;
+ QToolBar* reprToolbar;
+ QToolBar* cameraToolbar;
+ QToolBar* axesToolbar;
+ QToolBar* macrosToolbar;
+ QToolBar* commonToolbar;
+ QToolBar* dataToolbar;
+
+public:
+ QAction* mainAction;
+ QAction* vcrAction;
+ QAction* timeAction;
+ QAction* colorAction;
+ QAction* reprAction;
+ QAction* cameraAction;
+ QAction* axesAction;
+ QAction* macrosAction;
+ QAction* commonAction;
+ QAction* dataAction;
+};
+
+#endif /* PVVIEWERGUIELEMENTS_H_ */
--- /dev/null
+This light application was built to mimick the key elements at hand
+when integrating ParaView into SALOME (i.e. when designing PARAVIS).
+
+Notably the following classes are (almost) a copy/paste of what is
+found in the PVViewer subfolder of GUI:
+ PVViewer_Core
+ PVViewer_GUIElements
+ PVViewer_Behaviors
+
+The application should have a boot sequence similar to the start-up
+of the PVViewer in SALOME, or to the activation of the PARAVIS module.
+
+The main executable is called
+ paraLight
+and is *not* installed (it can be executed from the build directory).
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Adrien Bruneton (CEA)
+
+#include <iostream>
+
+#include "PVViewer_Core.h"
+#include "PVViewer_Behaviors.h"
+#include "PLMainWindow.hxx"
+
+#include <pqApplicationCore.h>
+#include <pqSettings.h>
+#include <pqParaViewBehaviors.h>
+#include <pqServerResource.h>
+#include <pqServerConnectReaction.h>
+#include <pqServerDisconnectReaction.h>
+
+int main(int argc, char ** argv)
+{
+ std::cout << "Starting LightParaView ..." << std::endl;
+
+ std::cout << "Init Qt app ..." << std::endl;
+ QApplication qtapp(argc, argv);
+ QApplication::setApplicationName("LightPara");
+
+ std::cout << "Create Qt main window ..." << std::endl;
+ PLMainWindow * para_widget = new PLMainWindow();
+
+ std::cout << "Init appli core ..." << std::endl;
+ PVViewer_Core::ParaviewInitApp(para_widget, NULL);
+
+ std::cout << "Binding ParaView widget in QMainWindow ..." << std::endl;
+ para_widget->finishUISetup();
+
+ /* Install event filter */
+// std::cout << "Install event filter ..." << std::endl;
+// pqPVApplicationCore * plApp = PVViewer_Core::GetPVApplication();
+// QApplication::instance()->installEventFilter(plApp);
+
+ std::cout << "Init behaviors ..." << std::endl;
+ PVViewer_Core::ParaviewInitBehaviors(true, para_widget);
+
+ //para_widget->updateActiveServer();
+
+ //std::cout << "Load config ..." << std::endl;
+ //PVViewer_Core::ParaviewLoadConfigurations(QString(":/LightPara/Configuration/"));
+
+ /* Inspired from ParaView source code:
+ * leave time for the GUI to update itself before displaying the main window: */
+ QApplication::instance()->processEvents();
+
+ // Try to connect
+// std::cout << "about to try to connect ...\n";
+// const char * server_url = "cs://localhost";
+// if (!pqServerConnectReaction::connectToServer(pqServerResource(server_url)))
+// {
+// std::cerr << "Could not connect to requested server \""
+// << server_url << "\". Creating default builtin connection.\n";
+// }
+
+ /* ... and GO: */
+ std::cout << "Show !" << std::endl;
+ para_widget->show();
+ int ret_code = qtapp.exec();
+
+ /* then disconnect and leave nicely */
+ //pqServerDisconnectReaction::disconnectFromServer();
+
+ std::cout << "Clean up ..." << std::endl;
+ PVViewer_Core::ParaviewCleanup();
+
+ delete para_widget;
+
+ std::cout << "Done." << std::endl;
+ return ret_code;
+}
+
+
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1010</width>
+ <height>678</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>PARAVIS Light!</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QSplitter" name="splitter_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QFrame" name="pipelineFrame">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayoutPipe">
+ <item>
+ <widget class="QWidget" name="widget" native="true"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QFrame" name="propFrame">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayoutProp">
+ <item>
+ <widget class="QWidget" name="widget_2" native="true"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>-1</number>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Chosen file:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="currentFileLabel">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="openButton">
+ <property name="text">
+ <string>Open ...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <spacer name="horizontalSpacer_6">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="addTabButton">
+ <property name="text">
+ <string>Add tab ...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_7">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="detTabButton">
+ <property name="text">
+ <string>Delete current tab</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_8">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pluginsButton">
+ <property name="text">
+ <string>Manage Plugins ...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="sliceButton">
+ <property name="text">
+ <string>Slice</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="shrinkButton">
+ <property name="text">
+ <string>Shrink</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="quitButton">
+ <property name="text">
+ <string> Quit </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1010</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>File</string>
+ </property>
+ <addaction name="actionOpen_file"/>
+ <addaction name="actionQuit"/>
+ </widget>
+ <widget class="QMenu" name="menuSimple_actions">
+ <property name="title">
+ <string>Simple actions</string>
+ </property>
+ <addaction name="actionSlice"/>
+ <addaction name="actionShrink"/>
+ </widget>
+ <widget class="QMenu" name="menuTabs">
+ <property name="title">
+ <string>Tabs</string>
+ </property>
+ <addaction name="actionAdd_tab"/>
+ <addaction name="actionDelete_tab"/>
+ </widget>
+ <widget class="QMenu" name="menuOptions">
+ <property name="title">
+ <string>Options</string>
+ </property>
+ <addaction name="actionAuto_apply"/>
+ <addaction name="actionShow_prop_widget"/>
+ <addaction name="actionShow_pipeline"/>
+ </widget>
+ <addaction name="menuFile"/>
+ <addaction name="menuSimple_actions"/>
+ <addaction name="menuOptions"/>
+ <addaction name="menuTabs"/>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ <action name="actionOpen_file">
+ <property name="text">
+ <string>Open file ...</string>
+ </property>
+ </action>
+ <action name="actionQuit">
+ <property name="text">
+ <string>Quit</string>
+ </property>
+ </action>
+ <action name="actionSlice">
+ <property name="text">
+ <string>Slice</string>
+ </property>
+ </action>
+ <action name="actionShrink">
+ <property name="text">
+ <string>Shrink</string>
+ </property>
+ </action>
+ <action name="actionAdd_tab">
+ <property name="text">
+ <string>Add tab</string>
+ </property>
+ </action>
+ <action name="actionDelete_tab">
+ <property name="text">
+ <string>Delete tab</string>
+ </property>
+ </action>
+ <action name="actionAuto_apply">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Auto apply</string>
+ </property>
+ </action>
+ <action name="actionShow_prop_widget">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Show prop widget</string>
+ </property>
+ </action>
+ <action name="actionShow_pipeline">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Show pipeline</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>quitButton</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>871</x>
+ <y>588</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>439</x>
+ <y>210</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>openButton</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>onFileOpen()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>1004</x>
+ <y>271</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>456</x>
+ <y>258</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>MainWindow</sender>
+ <signal>changedCurrentFile(QString)</signal>
+ <receiver>currentFileLabel</receiver>
+ <slot>setText(QString)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>456</x>
+ <y>258</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>211</x>
+ <y>259</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>shrinkButton</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>shrink()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>674</x>
+ <y>588</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>456</x>
+ <y>258</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>sliceButton</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>slice()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>472</x>
+ <y>588</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>pluginsButton</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>managePlugins()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>279</x>
+ <y>588</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionSlice</sender>
+ <signal>triggered()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>slice()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionShrink</sender>
+ <signal>triggered()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>shrink()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionOpen_file</sender>
+ <signal>triggered()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>onFileOpen()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionQuit</sender>
+ <signal>triggered()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionAdd_tab</sender>
+ <signal>triggered()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>addTab()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionDelete_tab</sender>
+ <signal>triggered()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>deleteTab()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>addTabButton</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>addTab()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>350</x>
+ <y>430</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>detTabButton</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>deleteTab()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>750</x>
+ <y>430</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionAuto_apply</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>MainWindow</receiver>
+ <slot>autoApplyCheck(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionShow_pipeline</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>MainWindow</receiver>
+ <slot>showPipeline(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionShow_prop_widget</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>MainWindow</receiver>
+ <slot>showProp(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>tabWidget</sender>
+ <signal>currentChanged(int)</signal>
+ <receiver>MainWindow</receiver>
+ <slot>currentTabChanged(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>894</x>
+ <y>101</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>504</x>
+ <y>338</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <signal>changedCurrentFile(QString)</signal>
+ <slot>onFileOpen()</slot>
+ <slot>slice()</slot>
+ <slot>shrink()</slot>
+ <slot>managePlugins()</slot>
+ <slot>addTab()</slot>
+ <slot>deleteTab()</slot>
+ <slot>autoApplyCheck(bool)</slot>
+ <slot>showPipeline(bool)</slot>
+ <slot>showProp(bool)</slot>
+ <slot>currentTabChanged(int)</slot>
+ </slots>
+</ui>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ViewTab</class>
+ <widget class="QWidget" name="ViewTab">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>550</width>
+ <height>620</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QFrame" name="frameButtons">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>243</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string>Choose what to display:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="showTabbedButton">
+ <property name="text">
+ <string>Tabbed multi-view widget</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="singleViewButton">
+ <property name="text">
+ <string>Single render view</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QFrame" name="frameView">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayoutView">
+ <item>
+ <widget class="QWidget" name="widget" native="true"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>singleViewButton</sender>
+ <signal>clicked()</signal>
+ <receiver>ViewTab</receiver>
+ <slot>insertSingleView()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>170</x>
+ <y>262</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>170</x>
+ <y>239</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>showTabbedButton</sender>
+ <signal>clicked()</signal>
+ <receiver>ViewTab</receiver>
+ <slot>insertMultiView()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>170</x>
+ <y>234</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>170</x>
+ <y>239</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <slot>insertMultiView()</slot>
+ <slot>insertSingleView()</slot>
+ </slots>
+</ui>
--- /dev/null
+<ParaViewReaders>
+ <!--
+ NOTE: Readers are tried in reverse order that they are present in this
+ list i.e. if two readers can read the same extension, then the reader
+ apperaring later will be tried first when reading the file.
+ -->
+ <ProxyManager type="reader" />
+ <Proxy group="sources" name="LSDynaReader" />
+ <Proxy group="sources" name="PVDReader" />
+ <Proxy group="sources" name="XMLHierarchicalBoxDataReader" />
+ <Proxy group="sources" name="XMLPolyDataReader"/>
+ <Proxy group="sources" name="XMLUnstructuredGridReader" />
+ <Proxy group="sources" name="XMLImageDataReader" />
+ <Proxy group="sources" name="XMLStructuredGridReader" />
+ <Proxy group="sources" name="XMLRectilinearGridReader" />
+ <Proxy group="sources" name="XMLPPolyDataReader" />
+ <Proxy group="sources" name="XMLPUnstructuredGridReader" />
+ <Proxy group="sources" name="XMLPImageDataReader" />
+ <Proxy group="sources" name="XMLPStructuredGridReader" />
+ <Proxy group="sources" name="XMLPRectilinearGridReader" />
+ <Proxy group="sources" name="XMLMultiBlockDataReader" />
+ <Proxy group="sources" name="XMLUniformGridAMRReader" />
+ <Proxy group="sources" name="LegacyVTKFileReader" />
+ <Proxy group="sources" name="pvtkfile" />
+ <Proxy group="sources" name="ensight" />
+ <Proxy group="sources" name="ensightMS" />
+ <Proxy group="sources" name="TecplotReader" />
+ <Proxy group="sources" name="netCDFReader" />
+ <Proxy group="sources" name="byureader" />
+ <Proxy group="sources" name="objreader" />
+ <Proxy group="sources" name="ProStarReader" />
+ <Proxy group="sources" name="XdmfReader" />
+ <Proxy group="sources" name="pdbreader" />
+ <Proxy group="sources" name="xyzreader" />
+ <Proxy group="sources" name="P3DReader" />
+ <Proxy group="sources" name="Plot3DMetaReader"/>
+ <Proxy group="sources" name="spcthreader" />
+ <Proxy group="sources" name="SPCTHRestartReader" />
+ <Proxy group="sources" name="spcthhistoryreader" />
+ <Proxy group="sources" name="DEMReader" />
+ <Proxy group="sources" name="vrmlreader" />
+ <Proxy group="sources" name="plyreader" />
+ <Proxy group="sources" name="stlreader" />
+ <Proxy group="sources" name="gaussiancubereader" />
+ <Proxy group="sources" name="ImageReader" />
+ <Proxy group="sources" name="popreader"/>
+ <Proxy group="sources" name="AVSucdSeriesReader" />
+ <Proxy group="sources" name="MetaImageReader" />
+ <Proxy group="sources" name="NrrdReader" />
+ <Proxy group="sources" name="FacetReader" />
+ <Proxy group="sources" name="PNGSeriesReader" />
+ <Proxy group="sources" name="JPEGSeriesReader" />
+ <Proxy group="sources" name="TIFFSeriesReader" />
+ <Proxy group="sources" name="PhastaReader" />
+ <Proxy group="sources" name="EnzoReader" />
+ <Proxy group="sources" name="FlashReader" />
+ <Proxy group="sources" name="SESAMEReader" />
+ <Proxy group="sources" name="CSVReader" />
+ <Proxy group="sources" name="MFIXReader" />
+ <Proxy group="sources" name="FLUENTReader" />
+ <Proxy group="sources" name="OpenFOAMReader" />
+ <Proxy group="sources" name="CosmoReader" />
+ <Proxy group="sources" name="SiloReader"/>
+ <Proxy group="sources" name="ExodusIIReader" />
+ <Proxy group="sources" name="ExodusRestartReader" />
+ <Proxy group="sources" name="SLACReader" />
+ <Proxy group="sources" name="SLACParticleReader" />
+ <Proxy group="sources" name="ParticleReader" />
+ <Proxy group="sources" name="VPICReader" />
+ <Proxy group="sources" name="WindBladeReader" />
+ <Proxy group="sources" name="NetCDFCAMReader" />
+ <Proxy group="sources" name="NetCDFPOPReader" />
+ <Proxy group="sources" name="UnstructuredPOPReader" />
+ <Proxy group="sources" name="PNetCDFPOPReader" />
+ <Proxy group="sources" name="MPASReader" />
+ <Proxy group="sources" name="EnzoParticlesReader" />
+ <Proxy group="sources" name="FlashParticlesReader" />
+ <Proxy group="sources" name="CMLMoleculeReader"/>
+</ParaViewReaders>
--- /dev/null
+# Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+#
+# 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, or (at your option) any later version.
+#
+# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author: Adrien Bruneton (CEA)
+
+SET(pl_SOURCES
+ simple_gil.cxx
+ #PyInterp_Interp.cxx
+ #SUITApp_init_python.cxx
+ Container_init_python.cxx
+ )
+
+INCLUDE_DIRECTORIES(
+ ${PARAVIEW_INCLUDE_DIRS}
+ ${PYTHON_INCLUDE_DIRS}
+ ${QT_INCLUDE_DIRS}
+ )
+
+ADD_EXECUTABLE(paraCmdLine ${pl_SOURCES})
+TARGET_LINK_LIBRARIES(paraCmdLine ${PYTHON_LIBRARIES} ${QT_LIBRARIES} pqApplicationComponents)
+
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SALOME Container : implementation of container and engine for Kernel
+// File : Container_init_python.cxx
+// Author : Paul RASCLE, EDF
+// Module : KERNEL
+// $Header$
+//
+#include <time.h>
+#ifndef WIN32
+ #include <sys/time.h>
+#endif
+#include <iostream>
+
+//#include "utilities.h"
+#define MESSAGE(a)
+
+#include "Container_init_python.hxx"
+
+void KERNEL_PYTHON::init_python(int argc, char **argv)
+{
+ if (Py_IsInitialized())
+ {
+ MESSAGE("Python already initialized");
+ return;
+ }
+ MESSAGE("=================================================================");
+ MESSAGE("Python Initialization...");
+ MESSAGE("=================================================================");
+ // set stdout to line buffering (aka C++ std::cout)
+ setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
+ char* salome_python=getenv("SALOME_PYTHON");
+ if(salome_python != 0)
+ Py_SetProgramName(salome_python);
+ Py_Initialize(); // Initialize the interpreter
+ PySys_SetArgv(argc, argv);
+ PyRun_SimpleString("import threading\n");
+ PyEval_InitThreads(); // Create (and acquire) the interpreter lock
+ PyThreadState *pts = PyGILState_GetThisThreadState();
+ PyEval_ReleaseThread(pts);
+}
+
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SALOME Container : implementation of container and engine for Kernel
+// File : Container_init_python.hxx
+// Author : Paul RASCLE, EDF
+// Module : KERNEL
+// $Header$
+//
+#ifndef _CONTAINER_INIT_PYTHON_HXX_
+#define _CONTAINER_INIT_PYTHON_HXX_
+
+//#include "SALOME_Container.hxx"
+//#include <SALOMEconfig.h>
+
+#include <pthread.h> // must be before Python.h !
+
+#ifdef _XOPEN_SOURCE
+#undef _XOPEN_SOURCE
+#endif
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+#include <Python.h>
+
+
+// next two MACRO must be used together only once inside a block
+// -------------------------------------------------------------
+// protect a sequence of Python calls:
+// - Python lock must be acquired for these calls
+// - new Python thread state allows multi thread use of the sequence:
+// - Python may release the lock within the sequence, so multiple
+// thread execution of the sequence may occur.
+// - For that case, each sequence call must use a specific Python
+// thread state.
+// - There is no need of C Lock protection of the sequence.
+
+
+#define Py_ACQUIRE_NEW_THREAD \
+ PyGILState_STATE gil_state = PyGILState_Ensure();
+
+#define Py_RELEASE_NEW_THREAD \
+ PyGILState_Release(gil_state);
+
+struct KERNEL_PYTHON
+{
+ static void init_python(int argc, char **argv);
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : PyInterp.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+#if !defined ( PYINTERP_H )
+#define PYINTERP_H
+
+// ========================================================
+// set dllexport type for Win platform
+#ifdef WIN32
+# if defined PYINTERP_EXPORTS || defined PyInterp_EXPORTS
+# define PYINTERP_EXPORT __declspec(dllexport)
+# else
+# define PYINTERP_EXPORT __declspec(dllimport)
+# endif
+#else // WIN32
+# define PYINTERP_EXPORT
+#endif // WIN32
+
+// ========================================================
+// little trick - if we do not have debug python libraries
+#ifdef _DEBUG
+ #ifndef HAVE_DEBUG_PYTHON
+ #undef _DEBUG
+ #endif
+#endif
+
+#include <Python.h>
+
+#ifdef _DEBUG
+ #ifndef HAVE_DEBUG_PYTHON
+ #define _DEBUG
+ #endif
+#endif
+
+// ========================================================
+// avoid warning messages
+#ifdef WIN32
+#pragma warning (disable : 4786)
+#pragma warning (disable : 4251)
+#endif
+
+#endif // PYINTERP_H
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Adrien BRUNETON
+//
+
+#ifndef PYINTERP_UTILS_H
+#define PYINTERP_UTILS_H
+
+#include "PyInterp.h"
+#include <Python.h>
+#ifdef _DEBUG_
+ #include <iostream>
+#endif
+
+/**
+ * \class PyLockWrapper
+ * \brief Python GIL wrapper.
+ *
+ * Utility class wrapping the Python GIL acquisition. This makes use of the high level
+ * API (PyGILState_Ensure and PyGILState_Release), and is hence compatible with only
+ * one running Python interpreter (no call to Py_NewInterpreter()).
+ * When the class is instanciated the lock is acquired. It is released at destruction time.
+ * Copy construction (and hence assignation) is forbidden.
+ */
+class PYINTERP_EXPORT PyLockWrapper
+{
+
+public:
+ /**
+ * \brief Constructor. Automatically acquires GIL.
+ */
+ PyLockWrapper()
+ {
+ _gil_state = PyGILState_Ensure();
+ // Save current thread state for later comparison
+ _state = PyGILState_GetThisThreadState();
+ }
+
+ /**
+ * \brief Destructor. Automatically releases GIL.
+ */
+ ~PyLockWrapper()
+ {
+ PyThreadState* _currState = PyGILState_GetThisThreadState();
+#ifdef _DEBUG_
+ if (_currState != _state)
+ {
+ std::cout << "!!!!!!!!! PyLockWrapper inconsistency - now entering infinite loop for debugging\n";
+ while(1);
+ }
+#endif
+ PyGILState_Release(_gil_state);
+ }
+
+private:
+ PyGILState_STATE _gil_state;
+ PyThreadState* _state;
+
+ // "Rule of 3" - Forbid usage of copy operator and copy-constructor
+ PyLockWrapper(const PyLockWrapper & another);
+ const PyLockWrapper & operator=(const PyLockWrapper & another);
+};
+
+
+/**
+ * \class PyObjWrapper
+ * \brief Utility class to properly handle the reference counting required on Python objects.
+ */
+class PYINTERP_EXPORT PyObjWrapper
+{
+ PyObject* myObject;
+public:
+ PyObjWrapper(PyObject* theObject) : myObject(theObject) {}
+ PyObjWrapper() : myObject(0) {}
+ virtual ~PyObjWrapper() { Py_XDECREF(myObject); }
+
+ operator PyObject*() { return myObject; }
+ PyObject* operator->() { return myObject; }
+ PyObject* get() { return myObject; }
+ bool operator!() { return !myObject; }
+ bool operator==(PyObject* theObject) { return myObject == theObject; }
+ PyObject** operator&() { return &myObject; }
+ PyObjWrapper& operator=(PyObjWrapper* theObjWrapper)
+ {
+ Py_XDECREF(myObject);
+ myObject = theObjWrapper->myObject;
+ return *this;
+ }
+};
+
+#endif
+
--- /dev/null
+// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Adrien Bruneton (CEA)
+//
+#include <Python.h>
+#include <pqPVApplicationCore.h>
+#include <QApplication>
+#include "PyInterp_Utils.h"
+#include "Container_init_python.hxx"
+
+#include <iostream>
+
+int main(int argc, char ** argv)
+{
+ // Initialize Python in the way SALOME does:
+ KERNEL_PYTHON::init_python(argc,argv);
+
+ // The below should always work (illustration of SALOME lock protection)
+ {
+ PyLockWrapper lock; // if commented, the below will crash:
+
+ // Nothing important, just a bunch of calls to some Py* functions!
+ PyRun_SimpleString("import base64");
+ PyObject * sysmod = PyImport_AddModule("sys");
+ PyObject* sysdict = PyModule_GetDict(sysmod);
+ PyObject* tmp = PyDict_GetItemString(sysdict, "modules");
+ }
+ std::cout << "Done with Py call" << std::endl;
+
+ // Now the Qt part:
+ QApplication qtapp(argc, argv);
+ std::cout << "Done with Qt init" << std::endl;
+
+ // And finally the ParaView part:
+ pqPVApplicationCore* myCoreApp = new pqPVApplicationCore (argc, argv);
+ std::cout << "Done with PV init" << std::endl;
+ // Make sure compilation of ParaView was made with Python support:
+ if (!myCoreApp->pythonManager())
+ return -1;
+ delete myCoreApp;
+
+ std::cout << "Done with PV deletion" << std::endl;
+
+ return 0;
+}
+++ /dev/null
-# Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-#
-# 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, or (at your option) any later version.
-#
-# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# Author: Adrien Bruneton (CEA)
-
-SET(pl_HEADERS
- PLMainWindow.hxx
- PLViewTab.hxx
- PVViewer_Behaviors.h
- PVViewer_GUIElements.h
- )
-
-SET(pl_OTHER_HEADERS
- PVViewer_Core.h
- )
-
-SET(pl_SOURCES
- main.cpp
- PLMainWindow.cxx
- PLViewTab.cxx
- PVViewer_Behaviors.cxx
- PVViewer_GUIElements.cxx
- PVViewer_Core.cxx
- )
-
-SET(pl_FORMS
- ui/light_para.ui
- ui/view_tab.ui
- )
-
-SET(CMAKE_INCLUDE_CURRENT_DIR ON)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
-INCLUDE_DIRECTORIES(${PARAVIEW_INCLUDE_DIRS})
-
-INCLUDE(${QT_USE_FILE})
-ADD_DEFINITIONS(${QT_DEFINITIONS})
-
-# Generate resources that will embedded
-SET(ui_resources
- "${CMAKE_CURRENT_BINARY_DIR}/LightPara_configuration.qrc")
-
-GENERATE_QT_RESOURCE_FROM_FILES(
- "${ui_resources}"
- "/LightPara/Configuration"
- "${PROJECT_SOURCE_DIR}/src/xml/ParaViewReaders.xml")
-
-QT4_ADD_RESOURCES(rcs_sources
- ${ui_resources}
- )
-QT4_WRAP_UI(pl_FORMS_HEADERS ${pl_FORMS})
-QT4_WRAP_CPP(pl_HEADERS_MOC ${pl_HEADERS})
-
-ADD_EXECUTABLE(paraLight
- ${pl_SOURCES}
- ${pl_HEADERS_MOC}
- ${pl_FORMS_HEADERS}
- ${rcs_sources})
-
-TARGET_LINK_LIBRARIES(paraLight ${QT_LIBRARIES} pqApplicationComponents vtkRenderingFreeTypeOpenGL)
-#INSTALL(TARGET paraLight bin)
-
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Adrien Bruneton (CEA)
-
-#include "PVViewer_GUIElements.h"
-#include "PLMainWindow.hxx"
-#include "PVViewer_Core.h"
-#include "PLViewTab.hxx"
-
-#include <iostream>
-#include <QObject>
-#include <QtGui/QFileDialog>
-#include <QMessageBox>
-
-#include <pqTabbedMultiViewWidget.h>
-#include <pqApplicationCore.h>
-#include <pqPVApplicationCore.h>
-#include <pqObjectBuilder.h>
-#include <pqLoadDataReaction.h>
-#include <pqPipelineSource.h>
-#include <pqManagePluginsReaction.h>
-#include <pqPropertiesPanel.h>
-#include <pqPipelineBrowserWidget.h>
-#include <pqServerManagerModel.h>
-#include <pqRenderView.h>
-#include <pqActiveObjects.h>
-#include <pqProxy.h>
-
-#include <vtkSMSourceProxy.h>
-#include <vtkSMProperty.h>
-#include <vtkSMStringVectorProperty.h>
-
-PLMainWindow::PLMainWindow(QWidget *parent) :
- QMainWindow(parent),
- _pAppC(0),
- _simplePipeline(),
- _autoApply(true)
-{
- _mainWindow.setupUi(this);
- _autoApply = _mainWindow.actionAuto_apply->isChecked();
- QObject::connect(this, SIGNAL(apply()), this, SLOT(onApply()));
- QObject::connect(this, SIGNAL(changedCurrentFile(QString)), this, SLOT(onApply()));
- addTab();
-}
-
-// Called after ParaView application initialisation:
-void PLMainWindow::finishUISetup()
-{
- _pAppC = PVViewer_Core::GetPVApplication();
- PVViewer_GUIElements * pvgui = PVViewer_GUIElements::GetInstance(this);
- QWidget * wprop = pvgui->getPropertiesPanel();
- QWidget * wpipe = pvgui->getPipelineBrowserWidget();
- wprop->setParent(_mainWindow.propFrame);
- _mainWindow.verticalLayoutProp->addWidget(wprop);
- wpipe->setParent(_mainWindow.pipelineFrame);
- _mainWindow.verticalLayoutPipe->addWidget(wpipe);
-
- PVViewer_GUIElements * pvge = PVViewer_GUIElements::GetInstance(this);
-// pvge->setToolBarVisible(false);
-
- // In this mockup, we play on the parent widget visibility (a QFrame), so show these:
- pvge->getPipelineBrowserWidget()->show();
- pvge->getPropertiesPanel()->show();
- // and hide these:
- _mainWindow.propFrame->hide();
- _mainWindow.pipelineFrame->hide();
-// pvge->setToolBarEnabled(false);
-// pvge->setToolBarVisible(false);
-
-}
-
-void PLMainWindow::autoApplyCheck(bool isChecked)
-{
- _autoApply = isChecked;
-}
-
-void PLMainWindow::onApply()
-{
- if (_autoApply)
- {
- PVViewer_GUIElements * pvgui = PVViewer_GUIElements::GetInstance(this);
- pqPropertiesPanel * wprop = pvgui->getPropertiesPanel();
- wprop->apply();
- }
-}
-
-void PLMainWindow::showProp(bool isChecked)
-{
- isChecked ? _mainWindow.propFrame->show() : _mainWindow.propFrame->hide();
-}
-
-void PLMainWindow::showPipeline(bool isChecked)
-{
- isChecked ? _mainWindow.pipelineFrame->show() : _mainWindow.pipelineFrame->hide();
-}
-
-void PLMainWindow::addTab()
-{
- int c = _mainWindow.tabWidget->count();
- PLViewTab * newTab = new PLViewTab(_mainWindow.tabWidget);
- int newIdx = _mainWindow.tabWidget->addTab(newTab, QString("Tab %1").arg(c+1));
- _mainWindow.tabWidget->setCurrentIndex(newIdx);
-
- // Connect buttons
- QObject::connect(newTab, SIGNAL(onInsertSingleView(PLViewTab *)), this, SLOT(insertSingleView(PLViewTab *)));
- QObject::connect(newTab, SIGNAL(onInsertMultiView(PLViewTab *)), this, SLOT(insertMultiView(PLViewTab *)));
-}
-
-void PLMainWindow::deleteTab()
-{
- int c = _mainWindow.tabWidget->currentIndex();
- if (c != -1)
- {
- _mainWindow.tabWidget->removeTab(c);
- }
-}
-
-void PLMainWindow::currentTabChanged(int tabIdx)
-{
- QWidget * w = _mainWindow.tabWidget->widget(tabIdx);
- if (w)
- {
- PLViewTab * viewtab = qobject_cast<PLViewTab *>(w);
- if (viewtab && viewtab->getpqView())
- {
- pqActiveObjects::instance().setActiveView(viewtab->getpqView());
- }
- }
-}
-
-void PLMainWindow::doOpenFile()
-{
- // Clean up vizu
-// cleanAll();
-
- // Load the stuff as wireframe in the main view:
- QList<pqPipelineSource *> many = pqLoadDataReaction::loadData();
- if (many.isEmpty())
- {
- std::cout << "no file selected!" << std::endl;
- return;
- }
- if (many.count() > 1)
- {
- QMessageBox msgBox;
- msgBox.setText("Select one file only!");
- msgBox.exec();
- cleanAll();
- return;
- }
-
- pqPipelineSource * src = many.at(0);
- std::cout << "num of out ports: " << src->getNumberOfOutputPorts() << std::endl;
-
- // A cone to start with:
-// pqPipelineSource * src = this->_pAppC->getObjectBuilder()->createSource(QString("sources"), QString("ConeSource"),
-// this->_activeServer);
- if(src)
- _simplePipeline.push(src);
-
- // Retrieve loaded file name
- vtkSMProperty * prop = src->getSourceProxy()->GetProperty("FileName");
- vtkSMStringVectorProperty * prop2 = vtkSMStringVectorProperty::SafeDownCast(prop);
- QString fName(prop2->GetElement(0));
-
- // Emit signal
- emit changedCurrentFile(fName);
-}
-
-void PLMainWindow::insertSingleView(PLViewTab * tab)
-{
- // Create a new view proxy on the server
- pqObjectBuilder* builder = _pAppC->getObjectBuilder();
- pqServer* active_serv = pqActiveObjects::instance().activeServer();
-
- std::cout << "About to create single view ..." << std::endl;
- pqView * pqview = builder->createView(QString("RenderView"), active_serv);
- std::cout << "Created: " << pqview << "!" << std::endl;
-
- // Retrieve its widget and pass it to the Qt tab:
- QWidget* viewWidget = pqview->getWidget();
-
-// QWidget* viewWidget = new QPushButton("toto");
- tab->hideAndReplace(viewWidget, pqview);
-
- pqActiveObjects::instance().setActiveView(pqview);
-}
-
-void PLMainWindow::insertMultiView(PLViewTab * tab)
-{
- // Retrieve TabbedMultiView and see if it is already attached to someone:
- PVViewer_GUIElements * pvgui = PVViewer_GUIElements::GetInstance(this);
- pqTabbedMultiViewWidget * multiv = pvgui->getTabbedMultiViewWidget();
-
- QWidget * parent = multiv->nativeParentWidget();
- if (parent)
- {
- QMessageBox msgBox;
- msgBox.setText("Multi-view already in use in another tab! Close it first.");
- msgBox.exec();
- }
- else
- {
- tab->hideAndReplace(multiv, NULL);
- }
-}
-
-
-void PLMainWindow::doShrink()
-{
- if(!_simplePipeline.isEmpty())
- {
- cleanAllButSource();
-
- pqPipelineSource * src = this->_pAppC->getObjectBuilder()->createFilter(QString("filters"),
- QString("ShrinkFilter"), _simplePipeline.top());
- if(src)
- _simplePipeline.push(src);
-
- // Hit apply
- emit apply();
- }
-}
-
-void PLMainWindow::doSlice()
-{
- if(!_simplePipeline.isEmpty())
- {
- cleanAllButSource();
-
- pqPipelineSource * src = this->_pAppC->getObjectBuilder()->createFilter(QString("filters"),
- QString("Cut"), _simplePipeline.top());
- if(src)
- _simplePipeline.push(src);
-
- // Hit apply
- emit apply();
- }
-}
-
-void PLMainWindow::doManagePlugins()
-{
- pqManagePluginsReaction::managePlugins();
-}
-
-void PLMainWindow::cleanAll()
-{
- this->_pAppC->getObjectBuilder()->destroyPipelineProxies();
- _simplePipeline.resize(0);
-}
-
-void PLMainWindow::cleanAllButSource()
-{
- while(_simplePipeline.size() > 1)
- this->_pAppC->getObjectBuilder()->destroy(_simplePipeline.pop());
-}
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Adrien Bruneton (CEA)
-
-#ifndef PLVIEWWIDGET_H_
-#define PLVIEWWIDGET_H_
-
-#include <QMainWindow>
-#include "ui_light_para.h"
-#include <QStack>
-
-class pqPVApplicationCore;
-class pqPipelineSource;
-class pqServer;
-class pqProxy;
-
-class PLViewTab;
-
-/** Main window of the application.
- */
-class PLMainWindow: public QMainWindow {
- Q_OBJECT
-
-public:
- PLMainWindow(QWidget * parent=0);
- virtual ~PLMainWindow() {}
-
- void finishUISetup();
-
-protected:
- void doOpenFile();
- void doManagePlugins();
-
- void doSlice();
- void doShrink();
-
- void cleanAll();
- void cleanAllButSource();
-
-signals:
- void changedCurrentFile(QString fileName);
- void apply(); // convenience signal to forward to the real ParaView apply
-
-private slots:
- void autoApplyCheck(bool);
- void onApply();
- void showPipeline(bool);
- void showProp(bool);
-
- void addTab();
- void deleteTab();
-
- void onFileOpen() { doOpenFile(); };
- void slice() { doSlice(); };
- void shrink() { doShrink(); };
- void managePlugins() { doManagePlugins(); };
-
- void insertSingleView(PLViewTab *);
- void insertMultiView(PLViewTab *);
-
- void currentTabChanged(int);
-
-private:
- Ui::MainWindow _mainWindow;
-
- pqPVApplicationCore * _pAppC;
- //pqServer * _activeServer;
- //pqPipelineSource * _activeSource; // last pipeline element
- QStack<pqPipelineSource *> _simplePipeline;
-
- bool _autoApply;
-};
-
-#endif /* PLVIEWWIDGET_H_ */
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Adrien Bruneton (CEA)
-
-#include <iostream>
-#include "PLViewTab.hxx"
-
-PLViewTab::PLViewTab(QWidget * parent):
-QWidget(parent),
-_renderView(0)
-{
- _viewTab.setupUi(this);
-}
-
-void PLViewTab::insertSingleView()
-{
- emit onInsertSingleView(this);
-}
-
-void PLViewTab::insertMultiView()
-{
- emit onInsertMultiView(this);
-}
-
-void PLViewTab::hideAndReplace(QWidget * w, pqView * view)
-{
- _viewTab.frameButtons->hide();
- w->setParent(_viewTab.frameView);
- QVBoxLayout * vbox = _viewTab.verticalLayoutView;
- vbox->addWidget(w);
- _renderView = view;
-}
-
-void PLViewTab::viewDestroyed()
-{
- std::cout << "View destroyed!" << std::endl;
-}
-
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Adrien Bruneton (CEA)
-
-#ifndef SRC_PLVIEWTAB_HXX_
-#define SRC_PLVIEWTAB_HXX_
-
-#include "ui_view_tab.h"
-
-class pqView;
-
-/** Widget inserted when a new tab is requested in the application.
- */
-class PLViewTab: public QWidget {
- Q_OBJECT
-
-public:
- PLViewTab(QWidget * parent=0);
- virtual ~PLViewTab() {}
-
- // Hide buttons, and put widget in the QFrame with a vertical layout
- void hideAndReplace(QWidget * w, pqView * view);
-
- pqView * getpqView() { return _renderView; }
-
-private slots:
- void insertSingleView();
- void insertMultiView();
- void viewDestroyed();
-
-signals:
- void onInsertSingleView(PLViewTab *);
- void onInsertMultiView(PLViewTab *);
-
-private:
- Ui::ViewTab _viewTab;
- pqView * _renderView;
-};
-
-#endif /* SRC_PLVIEWTAB_HXX_ */
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Adrien Bruneton (CEA)
-
-#include "PVViewer_Behaviors.h"
-
-#include <QMainWindow>
-
-#include <pqInterfaceTracker.h>
-#include <pqApplicationCore.h>
-#include <pqPluginManager.h>
-#include <pqStandardPropertyWidgetInterface.h>
-#include <pqStandardViewFrameActionsImplementation.h>
-#include <pqPropertiesPanel.h>
-
-#include <pqAlwaysConnectedBehavior.h>
-#include <pqAutoLoadPluginXMLBehavior.h>
-#include <pqCommandLineOptionsBehavior.h>
-#include <pqCrashRecoveryBehavior.h>
-#include <pqDataTimeStepBehavior.h>
-#include <pqDefaultViewBehavior.h>
-#include <pqObjectPickingBehavior.h>
-#include <pqPersistentMainWindowStateBehavior.h>
-#include <pqPipelineContextMenuBehavior.h>
-#include <pqPluginActionGroupBehavior.h>
-#include <pqPluginDockWidgetsBehavior.h>
-#include <pqSpreadSheetVisibilityBehavior.h>
-#include <pqUndoRedoBehavior.h>
-#include <pqViewStreamingBehavior.h>
-#include <pqCollaborationBehavior.h>
-#include <pqVerifyRequiredPluginBehavior.h>
-#include <pqPluginSettingsBehavior.h>
-#include <pqFixPathsInStateFilesBehavior.h>
-#include <pqApplyBehavior.h>
-
-#include <pqPropertiesPanel.h>
-
-int PVViewer_Behaviors::BehaviorLoadingLevel = 0;
-
-PVViewer_Behaviors::PVViewer_Behaviors(QMainWindow * parent)
- : QObject(parent)
-{
-}
-
-/**! Instanciate minimal ParaView behaviors needed when using an instance of PVViewer.
- * This method should be updated at each new version of ParaView with what is found in
- * Qt/ApplicationComponents/pqParaViewBehaviors.cxx
- */
-void PVViewer_Behaviors::instanciateMinimalBehaviors(QMainWindow * desk)
-{
- 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 pqVerifyRequiredPluginBehavior(this);
- new pqPluginSettingsBehavior(this);
- new pqFixPathsInStateFilesBehavior(this);
- new pqCrashRecoveryBehavior(this);
- new pqCommandLineOptionsBehavior(this);
-
- BehaviorLoadingLevel = 1;
- }
-}
-
-/**! Instanciate usual ParaView behaviors.
- * This method should be updated at each new version of ParaView with what is found in
- * Qt/ApplicationComponents/pqParaViewBehaviors.cxx
- */
-void PVViewer_Behaviors::instanciateAllBehaviors(QMainWindow * desk)
-{
- // "new pqParaViewBehaviors(anApp->desktop(), this);"
- // -> (which loads all standard ParaView behaviors at once) has to be replaced in order to
- // exclude using of pqQtMessageHandlerBehaviour
-
- // Define application behaviors.
- if (BehaviorLoadingLevel < 1)
- instanciateMinimalBehaviors(desk);
-
- if (BehaviorLoadingLevel < 2)
- {
- //new pqQtMessageHandlerBehavior(this); // THIS ONE TO EXCLUDE !! see comment above
- new pqDataTimeStepBehavior(this);
- new pqSpreadSheetVisibilityBehavior(this);
- new pqPipelineContextMenuBehavior(this);
- new pqUndoRedoBehavior(this);
- new pqAutoLoadPluginXMLBehavior(this); // auto load plugins GUI stuff
- 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;
- }
-}
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Adrien Bruneton (CEA)
-
-
-#ifndef PVGUIBEHAVIORS_H_
-#define PVGUIBEHAVIORS_H_
-
-#include <QObject>
-
-class QMainWindow;
-class pqPropertiesPanel;
-
-/**!
- * PARAVIS behaviors - mimic what is done in
- * Qt/ApplicationComponents/pqParaViewBehaviors.cxx
- * Except a few ones, behaviors are destroyed when the module is destroyed.
- */
-class PVViewer_Behaviors: public QObject
-{
- Q_OBJECT
-
-public:
- PVViewer_Behaviors(QMainWindow * parent);
-
- void instanciateMinimalBehaviors(QMainWindow * desk);
- void instanciateAllBehaviors(QMainWindow * desk);
-
- virtual ~PVViewer_Behaviors() {}
-
-private:
- static int BehaviorLoadingLevel;
-};
-
-#endif /* PVGUIBEHAVIORS_H_ */
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : Adrien Bruneton (CEA)
-//
-
-#include "PVViewer_Core.h"
-//#include "PVViewer_LogWindowAdapter.h"
-#include "PVViewer_GUIElements.h"
-#include "PVViewer_Behaviors.h"
-#include "PVViewer_Core.h"
-
-#include <QApplication>
-#include <QStringList>
-#include <QDir>
-#include <QMainWindow>
-
-#include <string>
-
-#include <pqOptions.h>
-#include <pqSettings.h>
-#include <pqPVApplicationCore.h>
-#include <pqTabbedMultiViewWidget.h>
-#include <pqParaViewMenuBuilders.h>
-#include <pqActiveObjects.h>
-#include <pqPipelineBrowserWidget.h>
-#include <pqServerDisconnectReaction.h>
-
-
-//---------- Static init -----------------
-pqPVApplicationCore* PVViewer_Core::MyCoreApp = 0;
-bool PVViewer_Core::ConfigLoaded = false;
-PVViewer_Behaviors * PVViewer_Core::ParaviewBehaviors = NULL;
-
-pqPVApplicationCore * PVViewer_Core::GetPVApplication()
-{
- return MyCoreApp;
-}
-
-/*!
- \brief Static method, performs initialization of ParaView session.
- \param fullSetup whether to instanciate all behaviors or just the minimal ones.
- \return \c true if ParaView has been initialized successfully, otherwise false
-*/
-bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop, LogWindow * logWindow)
-{
- if ( ! MyCoreApp) {
- // Obtain command-line arguments
- int argc = 0;
- char** argv = 0;
- QString aOptions = getenv("PARAVIEW_OPTIONS");
- QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts);
- argv = new char*[aOptList.size() + 1];
- QStringList args = QApplication::arguments();
- argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis");
- argc++;
-
- foreach (QString aStr, aOptList) {
- argv[argc] = strdup( aStr.toLatin1().constData() );
- argc++;
- }
- MyCoreApp = new pqPVApplicationCore (argc, argv);
- if (MyCoreApp->getOptions()->GetHelpSelected() ||
- MyCoreApp->getOptions()->GetUnknownArgument() ||
- MyCoreApp->getOptions()->GetErrorMessage() ||
- MyCoreApp->getOptions()->GetTellVersion()) {
- return false;
- }
-
- // Direct VTK log messages to our SALOME window - TODO: review this
-// PVViewer_LogWindowAdapter * w = PVViewer_LogWindowAdapter::New();
-// w->setLogWindow(logWindow);
-// vtkOutputWindow::SetInstance(w);
-
-// new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation
-
- for (int i = 0; i < argc; i++)
- free(argv[i]);
- delete[] argv;
- }
- // Initialize GUI elements if needed:
- PVViewer_GUIElements::GetInstance(aDesktop);
- return true;
-}
-
-void PVViewer_Core::ParaviewInitBehaviors(bool fullSetup, QMainWindow* aDesktop)
-{
- if (!ParaviewBehaviors)
- ParaviewBehaviors = new PVViewer_Behaviors(aDesktop);
-
- if(fullSetup)
- ParaviewBehaviors->instanciateAllBehaviors(aDesktop);
- else
- ParaviewBehaviors->instanciateMinimalBehaviors(aDesktop);
-}
-
-void PVViewer_Core::ParaviewLoadConfigurations(const QString & configPath, bool force)
-{
- if (!ConfigLoaded || force)
- {
- if (!configPath.isNull()) {
- MyCoreApp->loadConfiguration(configPath + QDir::separator() + "ParaViewFilters.xml");
- MyCoreApp->loadConfiguration(configPath + QDir::separator() + "ParaViewSources.xml");
- }
- ConfigLoaded = true;
- }
-}
-
-void PVViewer_Core::ParaviewCleanup()
-{
- // Disconnect from server
- pqServer* server = pqActiveObjects::instance().activeServer();
- if (server && server->isRemote())
- {
- pqServerDisconnectReaction::disconnectFromServer();
- }
-
- pqApplicationCore::instance()->settings()->sync();
-
- pqPVApplicationCore * app = GetPVApplication();
- // Schedule destruction of PVApplication singleton:
- if (app)
- app->deleteLater();
-}
-
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : Adrien Bruneton (CEA)
-
-#ifndef SRC_PVVIEWER_PVVIEWER_CORE_H_
-#define SRC_PVVIEWER_PVVIEWER_CORE_H_
-
-#include <QString>
-
-class PVServer_ServiceWrapper;
-class PVViewer_Behaviors;
-class LogWindow;
-class QMainWindow;
-class pqPVApplicationCore;
-
-/**
- Pure static class gathering most of the interactions with ParaView's API and ParaView's
- start sequence.
- */
-class PVViewer_Core
-{
-public:
- static pqPVApplicationCore * GetPVApplication();
-
-
- //! Initialize ParaView if not yet done (once per session)
- static bool ParaviewInitApp(QMainWindow* aDesktop, LogWindow * w);
- static void ParaviewInitBehaviors(bool fullSetup=false, QMainWindow* aDesktop=0);
- static void ParaviewLoadConfigurations(const QString & configPath, bool force=false);
- static void ParaviewCleanup();
-
-private:
- PVViewer_Core();
- virtual ~PVViewer_Core();
-
- static pqPVApplicationCore* MyCoreApp;
- static bool ConfigLoaded;
- static PVViewer_Behaviors * ParaviewBehaviors;
-};
-
-#endif /* SRC_PVVIEWER_PVVIEWER_CORE_H_ */
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Adrien Bruneton (CEA)
-
-#include <iostream>
-
-#include "PVViewer_GUIElements.h"
-#include "PVViewer_Core.h"
-
-#include <pqPVApplicationCore.h>
-#include <pqActiveObjects.h>
-#include <pqObjectBuilder.h>
-
-#include <pqPropertiesPanel.h>
-#include <pqPipelineBrowserWidget.h>
-#include <pqTabbedMultiViewWidget.h>
-#include <pqParaViewMenuBuilders.h>
-#include <pqMainControlsToolbar.h>
-#include <pqVCRToolbar.h>
-#include <pqAnimationTimeToolbar.h>
-#include <pqColorToolbar.h>
-#include <pqRepresentationToolbar.h>
-#include <pqCameraToolbar.h>
-#include <pqAxesToolbar.h>
-#include <pqSetName.h>
-
-#include <pqPythonManager.h>
-#include <pqApplicationCore.h>
-
-#include <QMainWindow>
-#include <QMenu>
-#include <QList>
-#include <QAction>
-#include <QToolBar>
-#include <QLayout>
-
-#include <QCoreApplication>
-
-PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
-
-PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desk) :
- propertiesPanel(0), pipelineBrowserWidget(0),
- sourcesMenu(0)
-{
- propertiesPanel = new pqPropertiesPanel(desk);
- propertiesPanel->hide();
- pipelineBrowserWidget = new pqPipelineBrowserWidget(desk);
- pipelineBrowserWidget->hide();
-
- sourcesMenu = new QMenu(0);
- pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
- filtersMenu = new QMenu(0);
- pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
- macrosMenu = new QMenu(0);
- pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
-
- //myBuildToolbars(desk);
-}
-
-PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(QMainWindow* desk)
-{
- if (! theInstance)
- theInstance = new PVViewer_GUIElements(desk);
- return theInstance;
-}
-
-
-pqTabbedMultiViewWidget * PVViewer_GUIElements::getTabbedMultiViewWidget()
-{
- pqTabbedMultiViewWidget * multiv =
- qobject_cast<pqTabbedMultiViewWidget*>(PVViewer_Core::GetPVApplication()->manager("MULTIVIEW_WIDGET"));
-
- // If not found, instanciate it. It will then register automatically as a MULTIVIEW_WIDGET.
- // Also create a single view that will be attached by the tabbedMultiView automatically
- // (in PV this is done automatically upon server connection event).
- if (!multiv)
- {
- multiv = new pqTabbedMultiViewWidget();
-
- // Create a new view proxy on the server
- pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
- pqServer* active_serv = pqActiveObjects::instance().activeServer();
- pqView * pqview = builder->createView(QString("RenderView"), active_serv);
- }
-
- return multiv;
-}
-
-
-/**
- * See ParaView source code: pqParaViewMenuBuilders::buildToolbars()
- * to keep this function up to date:
- */
-void PVViewer_GUIElements::myBuildToolbars(QMainWindow* mainWindow)
-{
- mainToolBar = new pqMainControlsToolbar(mainWindow)
- << pqSetName("MainControlsToolbar");
- mainToolBar->layout()->setSpacing(0);
-
- vcrToolbar = new pqVCRToolbar(mainWindow)
- << pqSetName("VCRToolbar");
- vcrToolbar->layout()->setSpacing(0);
-
- timeToolbar = new pqAnimationTimeToolbar(mainWindow)
- << pqSetName("currentTimeToolbar");
- timeToolbar->layout()->setSpacing(0);
-
- colorToolbar = new pqColorToolbar(mainWindow)
- << pqSetName("variableToolbar");
- colorToolbar->layout()->setSpacing(0);
-
- reprToolbar = new pqRepresentationToolbar(mainWindow)
- << pqSetName("representationToolbar");
- reprToolbar->layout()->setSpacing(0);
-
- cameraToolbar = new pqCameraToolbar(mainWindow)
- << pqSetName("cameraToolbar");
- cameraToolbar->layout()->setSpacing(0);
-
- axesToolbar = new pqAxesToolbar(mainWindow)
- << pqSetName("axesToolbar");
- axesToolbar->layout()->setSpacing(0);
-
- // Give the macros menu to the pqPythonMacroSupervisor
- pqPythonManager* manager = qobject_cast<pqPythonManager*>(
- pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
-
- macrosToolbar = new QToolBar("Macros Toolbars", mainWindow)
- << pqSetName("MacrosToolbar");
- manager->addWidgetForRunMacros(macrosToolbar);
-
- commonToolbar = new QToolBar("Common", mainWindow) << pqSetName("Common");
- commonToolbar->layout()->setSpacing(0);
-
- dataToolbar = new QToolBar("DataAnalysis", mainWindow) << pqSetName("DataAnalysis");
- dataToolbar->layout()->setSpacing(0);
-
- //addToolbars(mainWindow);
-}
-
-void PVViewer_GUIElements::setToolBarVisible(bool show)
-{
- QCoreApplication::processEvents();
- mainAction->setChecked(!show);
- mainAction->setVisible(show);
- mainAction->trigger();
- vcrAction->setChecked(!show);
- vcrAction->setVisible(show);
- vcrAction->trigger();
- timeAction->setChecked(!show);
- timeAction->setVisible(show);
- timeAction->trigger();
- colorAction->setChecked(!show);
- colorAction->setVisible(show);
- colorAction->trigger();
- reprAction->setChecked(!show);
- reprAction->setVisible(show);
- reprAction->trigger();
- cameraAction->setChecked(!show);
- cameraAction->setVisible(show);
- cameraAction->trigger();
- axesAction->setChecked(!show);
- axesAction->setVisible(show);
- axesAction->trigger();
- macrosAction->setChecked(!show);
- macrosAction->setVisible(show);
- macrosAction->trigger();
- commonAction->setChecked(!show);
- commonAction->setVisible(show);
- commonAction->trigger();
- dataAction->setChecked(!show);
- dataAction->setVisible(show);
- dataAction->trigger();
-}
-
-void PVViewer_GUIElements::addToolbars(QMainWindow* desk)
-{
- desk->addToolBar(Qt::TopToolBarArea, mainToolBar);
- desk->addToolBar(Qt::TopToolBarArea, vcrToolbar);
- desk->addToolBar(Qt::TopToolBarArea, timeToolbar);
- desk->addToolBar(Qt::TopToolBarArea, colorToolbar);
- desk->insertToolBarBreak(colorToolbar);
- desk->addToolBar(Qt::TopToolBarArea, reprToolbar);
- desk->addToolBar(Qt::TopToolBarArea, cameraToolbar);
- desk->addToolBar(Qt::TopToolBarArea, axesToolbar);
- desk->addToolBar(Qt::TopToolBarArea, macrosToolbar);
- desk->addToolBar(Qt::TopToolBarArea, commonToolbar);
- desk->addToolBar(Qt::TopToolBarArea, dataToolbar);
-
- mainAction = mainToolBar->toggleViewAction();
- vcrAction = vcrToolbar->toggleViewAction();
- timeAction = timeToolbar->toggleViewAction();
- colorAction = colorToolbar->toggleViewAction();
- reprAction = reprToolbar->toggleViewAction();
- cameraAction = cameraToolbar->toggleViewAction();
- axesAction = axesToolbar->toggleViewAction();
- macrosAction = macrosToolbar->toggleViewAction();
- commonAction = commonToolbar->toggleViewAction();
- dataAction = dataToolbar->toggleViewAction();
-}
-
-void PVViewer_GUIElements::onEmulateApply()
-{
- if (propertiesPanel)
- propertiesPanel->apply();
-}
-
-QList<QToolBar*> PVViewer_GUIElements::getToolbars()
-{
- QList<QToolBar*> l;
- l << mainToolBar << vcrToolbar << timeToolbar << colorToolbar
- << reprToolbar << cameraToolbar << axesToolbar << macrosToolbar
- << commonToolbar << dataToolbar;
- return l;
-}
-
-void PVViewer_GUIElements::setToolBarEnabled(bool enabled)
-{
- mainToolBar ->setEnabled(enabled);
- vcrToolbar ->setEnabled(enabled);
- timeToolbar ->setEnabled(enabled);
- colorToolbar ->setEnabled(enabled);
- reprToolbar ->setEnabled(enabled);
- cameraToolbar->setEnabled(enabled);
- axesToolbar ->setEnabled(enabled);
- macrosToolbar->setEnabled(enabled);
- commonToolbar->setEnabled(enabled);
- dataToolbar ->setEnabled(enabled);
-}
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Adrien Bruneton (CEA)
-
-#ifndef PVVIEWERGUIELEMENTS_H_
-#define PVVIEWERGUIELEMENTS_H_
-
-#include <QObject>
-#include <QList>
-
-class pqPropertiesPanel;
-class pqPipelineBrowserWidget;
-class pqTabbedMultiViewWidget;
-class QMainWindow;
-class QMenu;
-class QToolBar;
-class QAction;
-class pqAnimationTimeToolbar;
-class pqVCRToolbar;
-
-/*!
- * Some GUI elements of ParaView need to be instanciated in a proper order. This class
- * holds all of them for the sake of clarity.
- */
-class PVViewer_GUIElements: public QObject
-{
- Q_OBJECT
-
-public:
- static PVViewer_GUIElements * GetInstance(QMainWindow * desk);
-
- pqPropertiesPanel * getPropertiesPanel() { return propertiesPanel; }
- pqPipelineBrowserWidget * getPipelineBrowserWidget() { return pipelineBrowserWidget; }
- pqTabbedMultiViewWidget * getTabbedMultiViewWidget();
-
- QMenu* getFiltersMenu() { return filtersMenu; }
- QMenu* getSourcesMenu() { return sourcesMenu; }
- QMenu* getMacrosMenu() { return macrosMenu; }
-
- pqVCRToolbar* getVCRToolbar() { return vcrToolbar; }
- pqAnimationTimeToolbar* getTimeToolbar() { return timeToolbar; }
-
- void myBuildToolbars(QMainWindow* desk);
- void addToolbars(QMainWindow* desk);
- void setToolBarVisible(bool show);
- void setToolBarEnabled(bool enabled);
- QList<QToolBar*> getToolbars();
-
-public slots:
- void onEmulateApply(); // better use the slot from PVViewer_ViewManager if you want to trigger "Apply"
-
-private:
- PVViewer_GUIElements(QMainWindow* desk);
- virtual ~PVViewer_GUIElements() {}
-
- static PVViewer_GUIElements* theInstance;
-
- // Widgets
- pqPropertiesPanel* propertiesPanel;
- pqPipelineBrowserWidget* pipelineBrowserWidget;
- pqTabbedMultiViewWidget* tabbedMultiViewWidget;
-
- // Dummy QMenus receiving ParaView's reaction for automatic add when new sources are added
- QMenu* sourcesMenu;
- QMenu* filtersMenu;
- QMenu* macrosMenu;
-
- // Toolbars also need to be instanciated early:
- QToolBar* mainToolBar;
- pqVCRToolbar* vcrToolbar;
- pqAnimationTimeToolbar* timeToolbar;
- QToolBar* colorToolbar;
- QToolBar* reprToolbar;
- QToolBar* cameraToolbar;
- QToolBar* axesToolbar;
- QToolBar* macrosToolbar;
- QToolBar* commonToolbar;
- QToolBar* dataToolbar;
-
-public:
- QAction* mainAction;
- QAction* vcrAction;
- QAction* timeAction;
- QAction* colorAction;
- QAction* reprAction;
- QAction* cameraAction;
- QAction* axesAction;
- QAction* macrosAction;
- QAction* commonAction;
- QAction* dataAction;
-};
-
-#endif /* PVVIEWERGUIELEMENTS_H_ */
+++ /dev/null
-This light application was built to mimick the key elements at hand
-when integrating ParaView into SALOME (i.e. when designing PARAVIS).
-
-Notably the following classes are (almost) a copy/paste of what is
-found in the PVViewer subfolder of GUI:
- PVViewer_Core
- PVViewer_GUIElements
- PVViewer_Behaviors
-
-The application should have a boot sequence similar to the start-up
-of the PVViewer in SALOME, or to the activation of the PARAVIS module.
-
-The main executable is called
- paraLight
-and is *not* installed (it can be executed from the build directory).
+++ /dev/null
-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
-//
-// 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Adrien Bruneton (CEA)
-
-#include <iostream>
-
-#include "PVViewer_Core.h"
-#include "PVViewer_Behaviors.h"
-#include "PLMainWindow.hxx"
-
-#include <pqApplicationCore.h>
-#include <pqSettings.h>
-#include <pqParaViewBehaviors.h>
-#include <pqServerResource.h>
-#include <pqServerConnectReaction.h>
-#include <pqServerDisconnectReaction.h>
-
-int main(int argc, char ** argv)
-{
- std::cout << "Starting LightParaView ..." << std::endl;
-
- std::cout << "Init Qt app ..." << std::endl;
- QApplication qtapp(argc, argv);
- QApplication::setApplicationName("LightPara");
-
- std::cout << "Create Qt main window ..." << std::endl;
- PLMainWindow * para_widget = new PLMainWindow();
-
- std::cout << "Init appli core ..." << std::endl;
- PVViewer_Core::ParaviewInitApp(para_widget, NULL);
-
- std::cout << "Binding ParaView widget in QMainWindow ..." << std::endl;
- para_widget->finishUISetup();
-
- /* Install event filter */
-// std::cout << "Install event filter ..." << std::endl;
-// pqPVApplicationCore * plApp = PVViewer_Core::GetPVApplication();
-// QApplication::instance()->installEventFilter(plApp);
-
- std::cout << "Init behaviors ..." << std::endl;
- PVViewer_Core::ParaviewInitBehaviors(true, para_widget);
-
- //para_widget->updateActiveServer();
-
- //std::cout << "Load config ..." << std::endl;
- //PVViewer_Core::ParaviewLoadConfigurations(QString(":/LightPara/Configuration/"));
-
- /* Inspired from ParaView source code:
- * leave time for the GUI to update itself before displaying the main window: */
- QApplication::instance()->processEvents();
-
- // Try to connect
-// std::cout << "about to try to connect ...\n";
-// const char * server_url = "cs://localhost";
-// if (!pqServerConnectReaction::connectToServer(pqServerResource(server_url)))
-// {
-// std::cerr << "Could not connect to requested server \""
-// << server_url << "\". Creating default builtin connection.\n";
-// }
-
- /* ... and GO: */
- std::cout << "Show !" << std::endl;
- para_widget->show();
- int ret_code = qtapp.exec();
-
- /* then disconnect and leave nicely */
- //pqServerDisconnectReaction::disconnectFromServer();
-
- std::cout << "Clean up ..." << std::endl;
- PVViewer_Core::ParaviewCleanup();
-
- delete para_widget;
-
- std::cout << "Done." << std::endl;
- return ret_code;
-}
-
-
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>1010</width>
- <height>678</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>PARAVIS Light!</string>
- </property>
- <widget class="QWidget" name="centralwidget">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QSplitter" name="splitter_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <widget class="QSplitter" name="splitter">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <widget class="QFrame" name="pipelineFrame">
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayoutPipe">
- <item>
- <widget class="QWidget" name="widget" native="true"/>
- </item>
- </layout>
- </widget>
- <widget class="QFrame" name="propFrame">
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayoutProp">
- <item>
- <widget class="QWidget" name="widget_2" native="true"/>
- </item>
- </layout>
- </widget>
- </widget>
- <widget class="QTabWidget" name="tabWidget">
- <property name="currentIndex">
- <number>-1</number>
- </property>
- </widget>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Chosen file:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="currentFileLabel">
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="openButton">
- <property name="text">
- <string>Open ...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <spacer name="horizontalSpacer_6">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="addTabButton">
- <property name="text">
- <string>Add tab ...</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_7">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="detTabButton">
- <property name="text">
- <string>Delete current tab</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_8">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="pluginsButton">
- <property name="text">
- <string>Manage Plugins ...</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_5">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="sliceButton">
- <property name="text">
- <string>Slice</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="shrinkButton">
- <property name="text">
- <string>Shrink</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_4">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="quitButton">
- <property name="text">
- <string> Quit </string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menubar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>1010</width>
- <height>22</height>
- </rect>
- </property>
- <widget class="QMenu" name="menuFile">
- <property name="title">
- <string>File</string>
- </property>
- <addaction name="actionOpen_file"/>
- <addaction name="actionQuit"/>
- </widget>
- <widget class="QMenu" name="menuSimple_actions">
- <property name="title">
- <string>Simple actions</string>
- </property>
- <addaction name="actionSlice"/>
- <addaction name="actionShrink"/>
- </widget>
- <widget class="QMenu" name="menuTabs">
- <property name="title">
- <string>Tabs</string>
- </property>
- <addaction name="actionAdd_tab"/>
- <addaction name="actionDelete_tab"/>
- </widget>
- <widget class="QMenu" name="menuOptions">
- <property name="title">
- <string>Options</string>
- </property>
- <addaction name="actionAuto_apply"/>
- <addaction name="actionShow_prop_widget"/>
- <addaction name="actionShow_pipeline"/>
- </widget>
- <addaction name="menuFile"/>
- <addaction name="menuSimple_actions"/>
- <addaction name="menuOptions"/>
- <addaction name="menuTabs"/>
- </widget>
- <widget class="QStatusBar" name="statusbar"/>
- <action name="actionOpen_file">
- <property name="text">
- <string>Open file ...</string>
- </property>
- </action>
- <action name="actionQuit">
- <property name="text">
- <string>Quit</string>
- </property>
- </action>
- <action name="actionSlice">
- <property name="text">
- <string>Slice</string>
- </property>
- </action>
- <action name="actionShrink">
- <property name="text">
- <string>Shrink</string>
- </property>
- </action>
- <action name="actionAdd_tab">
- <property name="text">
- <string>Add tab</string>
- </property>
- </action>
- <action name="actionDelete_tab">
- <property name="text">
- <string>Delete tab</string>
- </property>
- </action>
- <action name="actionAuto_apply">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Auto apply</string>
- </property>
- </action>
- <action name="actionShow_prop_widget">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Show prop widget</string>
- </property>
- </action>
- <action name="actionShow_pipeline">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Show pipeline</string>
- </property>
- </action>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>quitButton</sender>
- <signal>clicked()</signal>
- <receiver>MainWindow</receiver>
- <slot>close()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>871</x>
- <y>588</y>
- </hint>
- <hint type="destinationlabel">
- <x>439</x>
- <y>210</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>openButton</sender>
- <signal>clicked()</signal>
- <receiver>MainWindow</receiver>
- <slot>onFileOpen()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>1004</x>
- <y>271</y>
- </hint>
- <hint type="destinationlabel">
- <x>456</x>
- <y>258</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>MainWindow</sender>
- <signal>changedCurrentFile(QString)</signal>
- <receiver>currentFileLabel</receiver>
- <slot>setText(QString)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>456</x>
- <y>258</y>
- </hint>
- <hint type="destinationlabel">
- <x>211</x>
- <y>259</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>shrinkButton</sender>
- <signal>clicked()</signal>
- <receiver>MainWindow</receiver>
- <slot>shrink()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>674</x>
- <y>588</y>
- </hint>
- <hint type="destinationlabel">
- <x>456</x>
- <y>258</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>sliceButton</sender>
- <signal>clicked()</signal>
- <receiver>MainWindow</receiver>
- <slot>slice()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>472</x>
- <y>588</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>pluginsButton</sender>
- <signal>clicked()</signal>
- <receiver>MainWindow</receiver>
- <slot>managePlugins()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>279</x>
- <y>588</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionSlice</sender>
- <signal>triggered()</signal>
- <receiver>MainWindow</receiver>
- <slot>slice()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionShrink</sender>
- <signal>triggered()</signal>
- <receiver>MainWindow</receiver>
- <slot>shrink()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionOpen_file</sender>
- <signal>triggered()</signal>
- <receiver>MainWindow</receiver>
- <slot>onFileOpen()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionQuit</sender>
- <signal>triggered()</signal>
- <receiver>MainWindow</receiver>
- <slot>close()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionAdd_tab</sender>
- <signal>triggered()</signal>
- <receiver>MainWindow</receiver>
- <slot>addTab()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionDelete_tab</sender>
- <signal>triggered()</signal>
- <receiver>MainWindow</receiver>
- <slot>deleteTab()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>addTabButton</sender>
- <signal>clicked()</signal>
- <receiver>MainWindow</receiver>
- <slot>addTab()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>350</x>
- <y>430</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>detTabButton</sender>
- <signal>clicked()</signal>
- <receiver>MainWindow</receiver>
- <slot>deleteTab()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>750</x>
- <y>430</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionAuto_apply</sender>
- <signal>toggled(bool)</signal>
- <receiver>MainWindow</receiver>
- <slot>autoApplyCheck(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionShow_pipeline</sender>
- <signal>toggled(bool)</signal>
- <receiver>MainWindow</receiver>
- <slot>showPipeline(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionShow_prop_widget</sender>
- <signal>toggled(bool)</signal>
- <receiver>MainWindow</receiver>
- <slot>showProp(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>tabWidget</sender>
- <signal>currentChanged(int)</signal>
- <receiver>MainWindow</receiver>
- <slot>currentTabChanged(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>894</x>
- <y>101</y>
- </hint>
- <hint type="destinationlabel">
- <x>504</x>
- <y>338</y>
- </hint>
- </hints>
- </connection>
- </connections>
- <slots>
- <signal>changedCurrentFile(QString)</signal>
- <slot>onFileOpen()</slot>
- <slot>slice()</slot>
- <slot>shrink()</slot>
- <slot>managePlugins()</slot>
- <slot>addTab()</slot>
- <slot>deleteTab()</slot>
- <slot>autoApplyCheck(bool)</slot>
- <slot>showPipeline(bool)</slot>
- <slot>showProp(bool)</slot>
- <slot>currentTabChanged(int)</slot>
- </slots>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ViewTab</class>
- <widget class="QWidget" name="ViewTab">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>550</width>
- <height>620</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QFrame" name="frameButtons">
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>243</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="label">
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="layoutDirection">
- <enum>Qt::LeftToRight</enum>
- </property>
- <property name="text">
- <string>Choose what to display:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="showTabbedButton">
- <property name="text">
- <string>Tabbed multi-view widget</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="singleViewButton">
- <property name="text">
- <string>Single render view</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QFrame" name="frameView">
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayoutView">
- <item>
- <widget class="QWidget" name="widget" native="true"/>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>singleViewButton</sender>
- <signal>clicked()</signal>
- <receiver>ViewTab</receiver>
- <slot>insertSingleView()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>170</x>
- <y>262</y>
- </hint>
- <hint type="destinationlabel">
- <x>170</x>
- <y>239</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>showTabbedButton</sender>
- <signal>clicked()</signal>
- <receiver>ViewTab</receiver>
- <slot>insertMultiView()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>170</x>
- <y>234</y>
- </hint>
- <hint type="destinationlabel">
- <x>170</x>
- <y>239</y>
- </hint>
- </hints>
- </connection>
- </connections>
- <slots>
- <slot>insertMultiView()</slot>
- <slot>insertSingleView()</slot>
- </slots>
-</ui>
+++ /dev/null
-<ParaViewReaders>
- <!--
- NOTE: Readers are tried in reverse order that they are present in this
- list i.e. if two readers can read the same extension, then the reader
- apperaring later will be tried first when reading the file.
- -->
- <ProxyManager type="reader" />
- <Proxy group="sources" name="LSDynaReader" />
- <Proxy group="sources" name="PVDReader" />
- <Proxy group="sources" name="XMLHierarchicalBoxDataReader" />
- <Proxy group="sources" name="XMLPolyDataReader"/>
- <Proxy group="sources" name="XMLUnstructuredGridReader" />
- <Proxy group="sources" name="XMLImageDataReader" />
- <Proxy group="sources" name="XMLStructuredGridReader" />
- <Proxy group="sources" name="XMLRectilinearGridReader" />
- <Proxy group="sources" name="XMLPPolyDataReader" />
- <Proxy group="sources" name="XMLPUnstructuredGridReader" />
- <Proxy group="sources" name="XMLPImageDataReader" />
- <Proxy group="sources" name="XMLPStructuredGridReader" />
- <Proxy group="sources" name="XMLPRectilinearGridReader" />
- <Proxy group="sources" name="XMLMultiBlockDataReader" />
- <Proxy group="sources" name="XMLUniformGridAMRReader" />
- <Proxy group="sources" name="LegacyVTKFileReader" />
- <Proxy group="sources" name="pvtkfile" />
- <Proxy group="sources" name="ensight" />
- <Proxy group="sources" name="ensightMS" />
- <Proxy group="sources" name="TecplotReader" />
- <Proxy group="sources" name="netCDFReader" />
- <Proxy group="sources" name="byureader" />
- <Proxy group="sources" name="objreader" />
- <Proxy group="sources" name="ProStarReader" />
- <Proxy group="sources" name="XdmfReader" />
- <Proxy group="sources" name="pdbreader" />
- <Proxy group="sources" name="xyzreader" />
- <Proxy group="sources" name="P3DReader" />
- <Proxy group="sources" name="Plot3DMetaReader"/>
- <Proxy group="sources" name="spcthreader" />
- <Proxy group="sources" name="SPCTHRestartReader" />
- <Proxy group="sources" name="spcthhistoryreader" />
- <Proxy group="sources" name="DEMReader" />
- <Proxy group="sources" name="vrmlreader" />
- <Proxy group="sources" name="plyreader" />
- <Proxy group="sources" name="stlreader" />
- <Proxy group="sources" name="gaussiancubereader" />
- <Proxy group="sources" name="ImageReader" />
- <Proxy group="sources" name="popreader"/>
- <Proxy group="sources" name="AVSucdSeriesReader" />
- <Proxy group="sources" name="MetaImageReader" />
- <Proxy group="sources" name="NrrdReader" />
- <Proxy group="sources" name="FacetReader" />
- <Proxy group="sources" name="PNGSeriesReader" />
- <Proxy group="sources" name="JPEGSeriesReader" />
- <Proxy group="sources" name="TIFFSeriesReader" />
- <Proxy group="sources" name="PhastaReader" />
- <Proxy group="sources" name="EnzoReader" />
- <Proxy group="sources" name="FlashReader" />
- <Proxy group="sources" name="SESAMEReader" />
- <Proxy group="sources" name="CSVReader" />
- <Proxy group="sources" name="MFIXReader" />
- <Proxy group="sources" name="FLUENTReader" />
- <Proxy group="sources" name="OpenFOAMReader" />
- <Proxy group="sources" name="CosmoReader" />
- <Proxy group="sources" name="SiloReader"/>
- <Proxy group="sources" name="ExodusIIReader" />
- <Proxy group="sources" name="ExodusRestartReader" />
- <Proxy group="sources" name="SLACReader" />
- <Proxy group="sources" name="SLACParticleReader" />
- <Proxy group="sources" name="ParticleReader" />
- <Proxy group="sources" name="VPICReader" />
- <Proxy group="sources" name="WindBladeReader" />
- <Proxy group="sources" name="NetCDFCAMReader" />
- <Proxy group="sources" name="NetCDFPOPReader" />
- <Proxy group="sources" name="UnstructuredPOPReader" />
- <Proxy group="sources" name="PNetCDFPOPReader" />
- <Proxy group="sources" name="MPASReader" />
- <Proxy group="sources" name="EnzoParticlesReader" />
- <Proxy group="sources" name="FlashParticlesReader" />
- <Proxy group="sources" name="CMLMoleculeReader"/>
-</ParaViewReaders>