Commit 8f432f30 authored by Cedric Robert's avatar Cedric Robert
Browse files

init: merge client server + standalone

parent bccb1893
......@@ -25,16 +25,16 @@ ENDIF (UNIX)
# checking for required dependencies
# ============================================================================
# -- Fesapi --
# path to custom find_package modules
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
# -- FESAPI --
SET(FESAPI_DIR "FESAPI_DIR-NOTFOUND" CACHE PATH "Fesapi install PATH")
find_package(Fesapi REQUIRED)
mark_as_advanced(FESAPI_INCLUDE_DIRS)
mark_as_advanced(FESAPI_LIBRARY)
# -- ParaView --
# -- ParaView --
IF (ParaView_SOURCE_DIR)
# we are building from within ParaView Source. The environment is already set.
# Nothing more to do.
......@@ -47,6 +47,7 @@ ELSE (ParaView_SOURCE_DIR)
pv_setup_module_environment("Fespp")
ENDIF (ParaView_SOURCE_DIR)
# -----------------------------------------------------------------------------
# Process all vtk-modules defined in this plugin. This generates the necessary
# wrappings for all these modules as well.
......
# Locate Fesapi
#
# This module defines the following CMake variables:
#
# FESAPI_FOUND - True if Fesapi is found
# FESAPI_LIBRARY - A variable pointing to the Fesapi library
# FESAPI_INCLUDE_DIRS - Where to find the headers
IF(NOT FESAPI_FOUND)
find_path(FESAPI_INCLUDE NAMES EpcDocument.h
PATHS $ENV{FESAPI_DIR}/include
${FESAPI_DIR}/include)
find_path(FESAPI_RESQML2_INCLUDE NAMES AbstractObject.h
PATHS $ENV{FESAPI_DIR}/include/resqml2
${FESAPI_DIR}/include/resqml2)
find_path(FESAPI_RESQML2_0_1_INCLUDE NAMES Fault.h
PATHS $ENV{FESAPI_DIR}/include/resqml2_0_1
${FESAPI_DIR}/include/resqml2_0_1)
find_path(FESAPI_EPC_INCLUDE NAMES Package.h
PATHS $ENV{FESAPI_DIR}/include/epc
${FESAPI_DIR}/include/epc)
find_path(FESAPI_PROXIES_INCLUDE NAMES envH.h
PATHS $ENV{FESAPI_DIR}/include/proxies
${FESAPI_DIR}/include/proxies)
find_path(FESAPI_TOOLS_INCLUDE NAMES GuidTools.h
PATHS $ENV{FESAPI_DIR}/include/tools
${FESAPI_DIR}/include/tools)
find_path(FESAPI_WITSML1_4_1_1_INCLUDE NAMES AbstractObject.h
PATHS $ENV{FESAPI_DIR}/include/witsml1_4_1_1
${FESAPI_DIR}/include/witsml1_4_1_1)
find_library(FESAPI_LIBRARY NAMES FesapiCpp
PATHS $ENV{FESAPI_DIR}/lib
${FESAPI_DIR}/lib)
set(FESAPI_INCLUDE_DIRS
${FESAPI_INCLUDE}
${FESAPI_RESQML2_INCLUDE}
${FESAPI_RESQML2_0_1_INCLUDE}
${FESAPI_EPC_INCLUDE}
${FESAPI_PROXIES_INCLUDE}
${FESAPI_TOOLS_INCLUDE}
${FESAPI_WITSML1_4_1_1_INCLUDE}
)
Set(FESAPI_FOUND "NO")
IF(FESAPI_LIBRARY AND FESAPI_INCLUDE_DIRS)
Set(FESAPI_FOUND "YES")
link_directories(${FESAPI_LIBRARY})
ADD_DEFINITIONS(-DOSGEARTH_HAVE_FESAPI)
ENDIF(FESAPI_LIBRARY AND FESAPI_INCLUDE_DIRS)
ENDIF(NOT FESAPI_FOUND)
# - Try to find the LM_SENSORS library.
#
# The following are set after configuration is done:
# FESAPI_DIR
IF(NOT FESAPI_FOUND)
find_path(FESAPI_INCLUDE NAMES common/EpcDocument.h
PATHS ${FESAPI_DIR}/include/)
find_library(FESAPI_LIBRARY NAMES libFesapiCppUnderDev.so
PATHS ${FESAPI_DIR}/lib/)
mark_as_advanced(FESAPI_INCLUDE FESAPI_LIBRARY)
Set(FESAPI_FOUND "NO")
IF(FESAPI_LIBRARY AND FESAPI_INCLUDE)
Set(FESAPI_FOUND "YES")
link_directories(${FESAPI_LIBRARY})
ADD_DEFINITIONS(-DOSGEARTH_HAVE_FESAPI)
ENDIF(FESAPI_LIBRARY AND FESAPI_INCLUDE)
ENDIF(NOT FESAPI_FOUND)
pv_plugin(Fespp
DESCRIPTION "F2i-consulting Energistics Standard Paraview Plugin Reader"
DEFAULT_ENABLED
PLUGIN_NAMES "Fespp"
pv_plugin(Fespp
DESCRIPTION "F2i-consulting Energistics Standard Paraview Plugin Reader"
DEFAULT_ENABLED
PLUGIN_NAMES "Fespp"
)
\ No newline at end of file
#--------------------------------------------------
SET (FESPP_ROOT_DIR ${CMAKE_SOURCE_DIR})
IF (ParaView_SOURCE_DIR)
INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS})
ELSE (ParaView_SOURCE_DIR)
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
ENDIF (ParaView_SOURCE_DIR)
FILE (GLOB FESPP_SOURCES ${FESPP_ROOT_DIR}/src/*.cxx)
FILE (GLOB FESPP_HEADERS ${FESPP_ROOT_DIR}/src/*.h)
FILE (GLOB FESPP_FORMS ${FESPP_ROOT_DIR}/src/Resources/*.ui)
FILE (GLOB FESPP_RESOURCES ${FESPP_ROOT_DIR}/src/Resources/*.qrc)
FILE (GLOB FESPP_VTK_SOURCES ${FESPP_ROOT_DIR}/src/VTK/*.cxx)
FILE (GLOB FESPP_VTK_HEADERS ${FESPP_ROOT_DIR}/src/VTK/*.h)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${FESPP_ROOT_DIR}/cmake/modules)
pv_process_modules()
FIND_PACKAGE(Fesapi REQUIRED)
mark_as_advanced(FESAPI_INCLUDE_DIRS)
mark_as_advanced(FESAPI_LIBRARY)
INCLUDE_DIRECTORIES(${FESAPI_INCLUDE_DIRS})
set(LIBS ${LIBS} ${FESAPI_LIBRARY})
IF(PARAVIEW_BUILD_QT_GUI)
IF(PARAVIEW_QT_VERSION VERSION_GREATER "4")
SET (Qt5_FIND_COMPONENTS Widgets)
INCLUDE(ParaViewQt5)
QT5_WRAP_CPP(MOC_SRCS ${FESPP_HEADERS})
QT5_WRAP_UI(UI_SRCS ${FESPP_FORMS})
ELSE()
INCLUDE(${QT_USE_FILE})
QT4_WRAP_CPP(MOC_SRCS ${FESPP_HEADERS})
QT4_WRAP_UI(UI_SRCS ${FESPP_FORMS})
ENDIF()
ADD_PARAVIEW_DOCK_WINDOW(
IFACES
IFACE_SRCS
CLASS_NAME PQSelectionPanel)
ADD_PARAVIEW_DOCK_WINDOW(
IFACES2
IFACE2_SRCS
CLASS_NAME PQMetaDataPanel)
# create a plugin for this panel
ADD_PARAVIEW_PLUGIN(Fespp "1.4.0"
DOCUMENTATION_DIR "${FESPP_ROOT_DIR}/FESPPdoc"
SERVER_MANAGER_SOURCES Fespp.cxx
SERVER_MANAGER_XML Fespp.xml
GUI_INTERFACES ${IFACES} ${IFACES2}
GUI_RESOURCES ${FESPP_RESOURCES}
SOURCES ${FESPP_SOURCES}
${FESPP_VTK_SOURCES}
${FESPP_HEADERS}
${FESPP_VTK_HEADERS}
${FESPP_FORMS}
${FESPP_RESOURCES}
${MOC_SRCS}
${UI_SRCS}
${IFACE_SRCS}
${IFACE2_SRCS}
)
target_link_libraries(Fespp
LINK_PRIVATE
${FESAPI_LIBRARY})
ENDIF(PARAVIEW_BUILD_QT_GUI)
#--------------------------------------------------
SET (PLUGIN_NAME Fespp)
SET (PLUGIN_VERSION "2.0.0")
#--------------------------------------------------
SET (FESPP_ROOT_DIR ${CMAKE_SOURCE_DIR})
IF (ParaView_SOURCE_DIR)
INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS})
ELSE (ParaView_SOURCE_DIR)
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
ENDIF (ParaView_SOURCE_DIR)
FILE (GLOB FESPP_READER_SOURCES ${FESPP_ROOT_DIR}/src/Fespp.cxx)
FILE (GLOB FESPP_READER_HEADERS ${FESPP_ROOT_DIR}/src/Fespp.h)
FILE (GLOB FESPP_READER_XML ${FESPP_ROOT_DIR}/src/Fespp.xml)
FILE (GLOB FESPP_VTK_SOURCES ${FESPP_ROOT_DIR}/src/VTK/*.cxx)
FILE (GLOB FESPP_VTK_HEADERS ${FESPP_ROOT_DIR}/src/VTK/*.h)
FILE (GLOB FESPP_PQ_SOURCES ${FESPP_ROOT_DIR}/src/PQ*.cxx)
FILE (GLOB FESPP_PQ_HEADERS ${FESPP_ROOT_DIR}/src/PQ*.h)
FILE (GLOB FESPP_FORMS ${FESPP_ROOT_DIR}/src/Resources/*.ui)
FILE (GLOB FESPP_RESOURCES ${FESPP_ROOT_DIR}/src/Resources/*.qrc)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${FESPP_ROOT_DIR}/cmake/modules)
pv_process_modules()
INCLUDE_DIRECTORIES(${FESAPI_INCLUDE})
IF(PARAVIEW_BUILD_QT_GUI)
IF(PARAVIEW_QT_VERSION VERSION_GREATER "4")
SET (Qt5_FIND_COMPONENTS Widgets)
# INCLUDE(ParaViewQt5)
QT5_WRAP_CPP(MOC_SRCS ${FESPP_PQ_HEADERS})
QT5_WRAP_UI(UI_SRCS ${FESPP_FORMS})
ELSE()
INCLUDE(${QT_USE_FILE})
QT4_WRAP_CPP(MOC_SRCS ${FESPP_PQ_HEADERS})
QT4_WRAP_UI(UI_SRCS ${FESPP_FORMS})
ENDIF()
ADD_PARAVIEW_DOCK_WINDOW(
IFACES
IFACE_SRCS
CLASS_NAME PQSelectionPanel)
ADD_PARAVIEW_DOCK_WINDOW(
IFACES2
IFACE2_SRCS
CLASS_NAME PQMetaDataPanel)
ADD_PARAVIEW_ACTION_GROUP(
IFACES3
IFACE3_SRCS
CLASS_NAME PQToolsActionGroup
GROUP_NAME "ToolBar/EPC")
# create a plugin for this panel
ADD_PARAVIEW_PLUGIN(${PLUGIN_NAME} ${PLUGIN_VERSION}
DOCUMENTATION_DIR "${FESPP_ROOT_DIR}/doc"
SERVER_MANAGER_SOURCES ${FESPP_READER_SOURCES}
SERVER_MANAGER_XML ${FESPP_READER_XML}
GUI_INTERFACES ${IFACES} ${IFACES2} ${IFACES3}
GUI_RESOURCES ${FESPP_RESOURCES}
SOURCES ${FESPP_PQ_SOURCES}
${MOC_SRCS}
${UI_SRCS}
${IFACE_SRCS}
${IFACE2_SRCS}
${IFACE3_SRCS}
${FESPP_VTK_SOURCES}
${FESPP_VTK_HEADERS}
)
ELSE(PARAVIEW_BUILD_QT_GUI)
# create a Server plugin
ADD_PARAVIEW_PLUGIN(${PLUGIN_NAME} ${PLUGIN_VERSION}
SERVER_MANAGER_SOURCES ${FESPP_READER_SOURCES}
SERVER_MANAGER_XML ${FESPP_READER_XML}
REQUIRED_ON_SERVER
SOURCES ${FESPP_VTK_SOURCES}
${FESPP_VTK_HEADERS}
)
ENDIF(PARAVIEW_BUILD_QT_GUI)
target_link_libraries(Fespp
LINK_PRIVATE
${FESAPI_LIBRARY})
#include "Fespp.h"
#include "VTK/VtkEpcDocument.h"
#include "PQSelectionPanel.h"
#include "vtkObjectFactory.h"
#include "vtkInformation.h"
#include "vtkInformationRequestKey.h"
#include "vtkInformationVector.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkSMProxy.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkDataArraySelection.h"
#include "vtkCallbackCommand.h"
#include <QApplication>
#include <pqPropertiesPanel.h>
#include <pqView.h>
#include <pqPVApplicationCore.h>
#include <sstream>
#include <qmessagebox.h>
namespace
{
PQSelectionPanel* getPanelSelection()
{
// get Selection panel
PQSelectionPanel *panel = 0;
foreach(QWidget *widget, qApp->topLevelWidgets())
{
panel = widget->findChild<PQSelectionPanel *>();
if (panel)
{
break;
}
}
return panel;
}
pqPropertiesPanel* getpqPropertiesPanel()
{
// get multi-block inspector panel
pqPropertiesPanel *panel = 0;
foreach(QWidget *widget, qApp->topLevelWidgets())
{
panel = widget->findChild<pqPropertiesPanel *>();
if (panel)
{
break;
}
}
return panel;
}
}
vtkStandardNewMacro(Fespp);
//----------------------------------------------------------------------------
Fespp::Fespp()
{
FileName = NULL;
this->uuidPropertys = vtkDataArraySelection::New();
SetNumberOfInputPorts(0);
SetNumberOfOutputPorts(1);
treeWidgetSelection = getPanelSelection();
loadedFile = false;
}
//----------------------------------------------------------------------------
Fespp::~Fespp()
{
//deleting object variables
if (this->uuidPropertys != NULL)
{
this->uuidPropertys = nullptr;
}
SetFileName(0);
}
char* Fespp::whatFile()
{
return FileName;
}
//----------------------------------------------------------------------------
void Fespp::visualize(std::string file, std::string uuid)
{
if (this->uuidPropertys != NULL){
if (uuid != "first")
{
this->change("Fisrt", 0);
}
this->change(uuid, 1);
}
}
void Fespp::change(std::string uuid, unsigned int status)
{
this->SetupOutputInformation(this->GetOutputPortInformation(0));
this->SetuuidPropertysArrayStatus(uuid.c_str(), status);
this->SetupOutputInformation(this->GetOutputPortInformation(0));
}
void Fespp::displayError(std::string msg)
{
vtkErrorMacro(<< msg.c_str());
}
void Fespp::displayWarning(std::string msg)
{
vtkWarningMacro(<< msg.c_str());
}
//----------------------------------------------------------------------------
void Fespp::RemoveUuid(std::string uuid)
{
this->change(uuid, 0);
}
//----------------------------------------------------------------------------
int Fespp::CanReadFile(const char* name)
{
if (treeWidgetSelection->canAddFile(name))
return 1;
return 0;
}
//----------------------------------------------------------------------------
int Fespp::RequestInformation(
vtkInformation *request,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
if (!loadedFile)
{
try{
common::EpcDocument *pck = new common::EpcDocument(FileName);
std::string result = pck->deserialize();
if (result.empty())
{
auto warnings = pck->getWarnings();
for (const auto& warning : warnings)
{
vtkWarningMacro("Deserialization warning : " + warning);
}
treeWidgetSelection->addFileName(FileName, this, pck);
loadedFile = true;
}
else
{
vtkErrorMacro("XML validation error : " + result);
pck->close();
}
}
catch (const std::exception & e)
{
vtkErrorMacro("EXCEPTION in fesapi when reading file " << FileName << " : " << e.what());
}
}
return 1;
}
//----------------------------------------------------------------------------
int Fespp::RequestData(vtkInformation *request,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
// get the info object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the output
vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT()));
if (loadedFile)
{
try{
std::string StrFileName(FileName);
output->DeepCopy(treeWidgetSelection->getOutput(StrFileName));
}
catch (const std::exception & e)
{
vtkErrorMacro("EXCEPTION fesapi.dll:" << e.what());
}
}
return 1;
}
//----------------------------------------------------------------------------
void Fespp::PrintSelf(ostream& os, vtkIndent indent)
{
Superclass::PrintSelf(os, indent);
os << indent << "File Name: " << (FileName ? FileName : "(none)") << "\n";
}
//----------------------------------------------------------------------------
int Fespp::GetuuidPropertysArrayStatus(const char* name)
{
// if 'name' not found, it is treated as 'disabled'
return (this->uuidPropertys->ArrayIsEnabled(name));
}
//----------------------------------------------------------------------------
void Fespp::SetuuidPropertysArrayStatus(const char* name, int status)
{
if (status)
{
this->uuidPropertys->EnableArray(name);
}
else
{
int nbProperty = uuidPropertys->GetNumberOfArrays();
if (this->uuidPropertys != nullptr)
{
int test = this->uuidPropertys->GetNumberOfArrays();
this->uuidPropertys->EnableArray(name);
this->uuidPropertys->RemoveArrayByName(name);
}
else
this->uuidPropertys = vtkDataArraySelection::New();
}
this->uuidPropertys->Modified();
}
//----------------------------------------------------------------------------
void Fespp::SetupOutputInformation(vtkInformation *outInfo)
{
this->Modified();
pqApplicationCore::instance()->render();
getpqPropertiesPanel()->updateGeometry();
getpqPropertiesPanel()->show();
getpqPropertiesPanel()->view()->forceRender();
getpqPropertiesPanel()->view()->render();
getpqPropertiesPanel()->setUpdatesEnabled(true);
emit getpqPropertiesPanel()->apply();
}
//----------------------------------------------------------------------------
int Fespp::GetNumberOfuuidPropertysArrays()
{
return this->uuidPropertys->GetNumberOfArrays();
}
//----------------------------------------------------------------------------
const char* Fespp::GetuuidPropertysArrayName(int index)
{
return this->uuidPropertys->GetArrayName(index);
}
#include <Fespp.h>
#include <vtkDataArraySelection.h>
#include <vtkIndent.h>
#include <vtkInformation.h>
#include <vtkInformationVector.h>
#include <vtkMPI.h>
#include <vtkMPICommunicator.h>
#include <vtkMPIController.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkMultiProcessController.h>
#include <vtkObjectFactory.h>
#include <vtkOStreamWrapper.h>
#include <vtkSetGet.h>
#include <vtkSmartPointer.h>
#include <VTK/VtkEpcDocument.h>
#include <VTK/VtkEpcDocumentSet.h>
#include <exception>
#include <iostream>
#include <utility>
#include <vector>
#ifndef MPICH_IGNORE_CXX_SEEK
#define MPICH_IGNORE_CXX_SEEK
#endif
vtkStandardNewMacro(Fespp);
vtkCxxSetObjectMacro(Fespp, Controller, vtkMultiProcessController);
//----------------------------------------------------------------------------
Fespp::Fespp()
{
FileName = NULL;
SetNumberOfInputPorts(0);
SetNumberOfOutputPorts(1);
loadedFile = false;
this->subFileList = vtkDataArraySelection::New();
this->uuidList = vtkDataArraySelection::New();
this->Controller = NULL;
this->SetController(vtkMultiProcessController::GetGlobalController());
auto comm = GetMPICommunicator();
this->idProc =0;
this->nbProc =0;
if (comm != MPI_COMM_NULL)
{
MPI_Comm_rank(comm, &this->idProc);
MPI_Comm_size(comm, &this->nbProc);
}
countTest = 0;
}
//----------------------------------------------------------------------------
Fespp::~Fespp()
{
SetFileName(NULL);
this->SetController(NULL);
for (std::pair<std::string, VtkEpcDocument*> element : vtkEpcDocuments)
delete element.second;
}
//----------------------------------------------------------------------------
int Fespp::GetsubFileListArrayStatus(const char* name)
{
return (this->subFileList->ArrayIsEnabled(name));
}
//----------------------------------------------------------------------------
void Fespp::SetSubFileList(const char* name, int status)
{
if (status)
{
this->subFileList->EnableArray(name);
}
else
{
if (this->subFileList != nullptr)
{
this->subFileList->EnableArray(name);
}
else
this->subFileList = vtkDataArraySelection::New();
}
this->subFileList->Modified();
openEpcDocument(name);
this->Modified();
}
//----------------------------------------------------------------------------
int Fespp::GetNumberOfsubFileListArrays()
{
return this->subFileList->GetNumberOfArrays();
}