mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
0027398: Integrate Qt Browser Widget to Open CASCADE Technology
The following implementation has been made: - CMake procedure is extended to compile Qt tools. This is optional and is handled by USE_QT_TOOLS option(OFF by default) - It is possible to build Qt tools using Qt5 or Qt4, it is settled with USE_QT4 option. - Sample of DFBrowser tool is available in samples/tools/TInspectorEXE. It is build with tools, executable is placed in binaries. To start the sample, use dfbrowser.bat command. - DFBrowser tool may be started from DRAW
This commit is contained in:
4
tools/TInspectorAPI/FILES
Normal file
4
tools/TInspectorAPI/FILES
Normal file
@@ -0,0 +1,4 @@
|
||||
TInspectorAPI_Communicator.cxx
|
||||
TInspectorAPI_Communicator.hxx
|
||||
TInspectorAPI_PluginParameters.cxx
|
||||
TInspectorAPI_PluginParameters.hxx
|
68
tools/TInspectorAPI/TInspectorAPI_Communicator.cxx
Normal file
68
tools/TInspectorAPI/TInspectorAPI_Communicator.cxx
Normal file
@@ -0,0 +1,68 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <TInspectorAPI_Communicator.hxx>
|
||||
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#define LIB_HANDLE HINSTANCE
|
||||
|
||||
// =======================================================================
|
||||
// function : LoadPluginLibrary
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TInspectorAPI_Communicator* TInspectorAPI_Communicator::LoadPluginLibrary
|
||||
(const TCollection_AsciiString& thePluginName)
|
||||
{
|
||||
if (thePluginName.IsEmpty())
|
||||
std::cout << thePluginName.ToCString() << "%s plugin could not be loaded." << std::endl;
|
||||
TCollection_AsciiString aPluginLibraryName = thePluginName;
|
||||
#ifdef _WIN32
|
||||
aPluginLibraryName += ".dll";
|
||||
#else
|
||||
aPluginLibraryName.Prepend ("lib");
|
||||
aPluginLibraryName += ".so";
|
||||
#endif
|
||||
|
||||
COMMUNICATOR_INSTANCE crtInst = 0;
|
||||
#ifdef _WIN32
|
||||
HINSTANCE modLib = ::LoadLibraryA((LPCSTR)aPluginLibraryName.ToCString());
|
||||
#else
|
||||
void* modLib = dlopen(aPluginLibraryName.ToCString(), RTLD_LAZY | RTLD_GLOBAL);
|
||||
#endif
|
||||
|
||||
if (!modLib)
|
||||
std::cout << "Failed to load plugin." << aPluginLibraryName.ToCString() << std::endl;
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
crtInst = (COMMUNICATOR_INSTANCE)::GetProcAddress(modLib, CREATE_COMMUNICATOR_FUNCTION_NAME);
|
||||
#else
|
||||
crtInst = (COMMUNICATOR_INSTANCE)dlsym(modLib, CREATE_COMMUNICATOR_FUNCTION_NAME);
|
||||
#endif
|
||||
if (!crtInst)
|
||||
std::cout << "Failed to find " << CREATE_COMMUNICATOR_FUNCTION_NAME << " function." << std::endl;
|
||||
}
|
||||
TInspectorAPI_Communicator* aModule = crtInst ? crtInst() : 0;
|
||||
return aModule;
|
||||
}
|
73
tools/TInspectorAPI/TInspectorAPI_Communicator.hxx
Normal file
73
tools/TInspectorAPI/TInspectorAPI_Communicator.hxx
Normal file
@@ -0,0 +1,73 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef TInspectorAPI_Communicator_H
|
||||
#define TInspectorAPI_Communicator_H
|
||||
|
||||
#include <NCollection_List.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#if OCC_VERSION_HEX > 0x060901
|
||||
#include <Standard_Handle.hxx>
|
||||
#endif
|
||||
#include <TInspectorAPI_PluginParameters.hxx>
|
||||
|
||||
//! The Communicator is an interface that should be implemented for a separate plugin
|
||||
//! It will be placed in layout of the given parent. After the plugin is created, it is possible to
|
||||
//! set container of parameters into plugin to provide the plugin's initialization by some external
|
||||
//! objects(e.g. Interactive Context or OCAF Application). If the parameters are changed, it may be
|
||||
//! applyed in UpdateContent function. The communicator can change parameters in the following cases:
|
||||
//! - the plugin removes own processed parameters (e.g. file names, that was opened by the plugin)
|
||||
//! - the plugin sends some parameters to another plugin(by name) (e.g. shape to be analized)
|
||||
//! (at the same time we should be careful here to do not change essential parameters of other plugins)
|
||||
class TInspectorAPI_Communicator
|
||||
{
|
||||
public:
|
||||
|
||||
//! Loads the plugin library
|
||||
//! \param thePluginName the name of the library
|
||||
//! \return an instance of the communicator or NULL
|
||||
static Standard_EXPORT TInspectorAPI_Communicator* LoadPluginLibrary (const TCollection_AsciiString& thePluginName);
|
||||
|
||||
//! Sets parameters container, it should be used when the plugin is initialized or in update content
|
||||
//! \param theParameters a parameters container
|
||||
Standard_EXPORT virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) = 0;
|
||||
|
||||
//! Provides the container with a parent where this container should be inserted.
|
||||
//! If Qt implementation, it should be QWidget with QLayout set inside
|
||||
//! \param theParent a parent class
|
||||
Standard_EXPORT virtual void SetParent (void* theParent) = 0;
|
||||
|
||||
//! Calls update of the plugin's content
|
||||
Standard_EXPORT virtual void UpdateContent() = 0;
|
||||
|
||||
//! Constructs the communicator.
|
||||
TInspectorAPI_Communicator() {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~TInspectorAPI_Communicator() {}
|
||||
};
|
||||
|
||||
//! Declare plugin method
|
||||
extern "C"
|
||||
{
|
||||
//! Declares function to create an instance of communicator
|
||||
//! It should be implemented in a child plugin
|
||||
typedef TInspectorAPI_Communicator* (*COMMUNICATOR_INSTANCE)();
|
||||
}
|
||||
//! Defines name of the function that should be implemented in a child plugin
|
||||
#define CREATE_COMMUNICATOR_FUNCTION_NAME "CreateCommunicator"
|
||||
|
||||
#endif
|
113
tools/TInspectorAPI/TInspectorAPI_PluginParameters.cxx
Normal file
113
tools/TInspectorAPI/TInspectorAPI_PluginParameters.cxx
Normal file
@@ -0,0 +1,113 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <TInspectorAPI_PluginParameters.hxx>
|
||||
|
||||
#if OCC_VERSION_HEX <= 0x060901
|
||||
IMPLEMENT_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
|
||||
IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
|
||||
#else
|
||||
IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
|
||||
#endif
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TInspectorAPI_PluginParameters::TInspectorAPI_PluginParameters()
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetParameters
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorAPI_PluginParameters::SetParameters (const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters)
|
||||
{
|
||||
if (theParameters.Size() > 0)
|
||||
myParameters.Bind (thePluginName, theParameters);
|
||||
else
|
||||
myParameters.UnBind (thePluginName);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddFileName
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorAPI_PluginParameters::AddFileName (const TCollection_AsciiString& thePluginName,
|
||||
const TCollection_AsciiString& theFileName)
|
||||
{
|
||||
if (myFileNames.IsBound(thePluginName))
|
||||
myFileNames.ChangeFind(thePluginName).Append (theFileName);
|
||||
else
|
||||
{
|
||||
NCollection_List<TCollection_AsciiString> aNames;
|
||||
aNames.Append (theFileName);
|
||||
myFileNames.Bind (thePluginName, aNames);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetFileNames
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorAPI_PluginParameters::SetFileNames (const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<TCollection_AsciiString>& theFileNames)
|
||||
{
|
||||
if (theFileNames.Size() > 0)
|
||||
myFileNames.Bind (thePluginName, theFileNames);
|
||||
else
|
||||
myFileNames.UnBind(thePluginName);
|
||||
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FindParameters
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool TInspectorAPI_PluginParameters::FindParameters (const TCollection_AsciiString& thePluginName)
|
||||
{
|
||||
return myParameters.IsBound(thePluginName);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Parameters
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const NCollection_List<Handle(Standard_Transient)>& TInspectorAPI_PluginParameters::Parameters
|
||||
(const TCollection_AsciiString& thePluginName)
|
||||
{
|
||||
return myParameters.Find (thePluginName);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FindFileNames
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool TInspectorAPI_PluginParameters::FindFileNames (const TCollection_AsciiString& thePluginName)
|
||||
{
|
||||
return myFileNames.IsBound(thePluginName);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FileNames
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const NCollection_List<TCollection_AsciiString>& TInspectorAPI_PluginParameters::FileNames
|
||||
(const TCollection_AsciiString& thePluginName)
|
||||
{
|
||||
return myFileNames.Find (thePluginName);
|
||||
}
|
96
tools/TInspectorAPI/TInspectorAPI_PluginParameters.hxx
Normal file
96
tools/TInspectorAPI/TInspectorAPI_PluginParameters.hxx
Normal file
@@ -0,0 +1,96 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef TInspectorAPI_PluginParameters_H
|
||||
#define TInspectorAPI_PluginParameters_H
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <NCollection_List.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
class TInspectorAPI_PluginParameters;
|
||||
DEFINE_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
|
||||
|
||||
//! The container of parameters for all possible plugins. It stores list of parameters for each plugin, even
|
||||
//! it was not be loaded yet. There is a map of plugin name into plugin parameters.
|
||||
//! The parameters may be:
|
||||
//! - child of Standard_Transient
|
||||
//! - file name to be opened by the plugin
|
||||
class TInspectorAPI_PluginParameters : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructs the container.
|
||||
Standard_EXPORT TInspectorAPI_PluginParameters();
|
||||
|
||||
//! Destructor
|
||||
Standard_EXPORT virtual ~TInspectorAPI_PluginParameters() Standard_OVERRIDE {}
|
||||
|
||||
//! Stores the parameters for plugin
|
||||
//! \param thePluginName a plugin name
|
||||
//! \param theParameters a list of parameters
|
||||
Standard_EXPORT void SetParameters (const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters);
|
||||
|
||||
//! Add a file name for the plugin
|
||||
//! \param thePluginName a plugin name
|
||||
//! \param theFileName a name
|
||||
Standard_EXPORT void AddFileName (const TCollection_AsciiString& thePluginName,
|
||||
const TCollection_AsciiString& theFileName);
|
||||
|
||||
//! Set file names for the plugin
|
||||
//! \param thePluginName a plugin name
|
||||
//! \param theFileNames container of names
|
||||
Standard_EXPORT void SetFileNames (const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<TCollection_AsciiString>& theFileNames);
|
||||
|
||||
//! Returns true if there are parameters set for the given plugin
|
||||
//! \param thePluginName a plugin name
|
||||
//! \return boolean result
|
||||
Standard_EXPORT bool FindParameters (const TCollection_AsciiString& thePluginName);
|
||||
|
||||
//! Returns parameters set for the given plugin
|
||||
//! \param thePluginName a plugin name
|
||||
//! \return container of objects
|
||||
Standard_EXPORT const NCollection_List<Handle(Standard_Transient)>& Parameters (
|
||||
const TCollection_AsciiString& thePluginName);
|
||||
|
||||
//! Returns true if there are file names set for the given plugin
|
||||
//! \param thePluginName a plugin name
|
||||
//! \return boolean result
|
||||
Standard_EXPORT bool FindFileNames (const TCollection_AsciiString& thePluginName);
|
||||
|
||||
//! Returns file names set for the given plugin
|
||||
//! \param thePluginName a plugin name
|
||||
//! \return container of names
|
||||
Standard_EXPORT const NCollection_List<TCollection_AsciiString>& FileNames(
|
||||
const TCollection_AsciiString& thePluginName);
|
||||
|
||||
#if OCC_VERSION_HEX <= 0x060901
|
||||
DEFINE_STANDARD_RTTI (TInspectorAPI_PluginParameters)
|
||||
#else
|
||||
DEFINE_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
|
||||
#endif
|
||||
private:
|
||||
//! container of parameters
|
||||
NCollection_DataMap<TCollection_AsciiString, NCollection_List<Handle(Standard_Transient)> > myParameters;
|
||||
//! container of names
|
||||
NCollection_DataMap<TCollection_AsciiString, NCollection_List<TCollection_AsciiString> > myFileNames;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user