From: nds Date: Thu, 12 Apr 2018 03:56:58 +0000 (+0300) Subject: 0029684: Configuration: modification of build Inspector tool standalone on occt X-Git-Tag: V7_3_0_beta~5 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=ae5225dfcd0b947002021138b57c2132658f5d61;p=occt-copy.git 0029684: Configuration: modification of build Inspector tool standalone on occt - samples/tools/TStandalone is removed, to build Inspector out of OCCT, CMake should use tools/CMakeLists.txt fileName - samples/tools/TInspectorEXE is moved to tools/TInspectorEXE - TInspectorAPI_Version.hxx provides compilation inspector with earlier version of OCCT. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 491fa03146..a4f93d3aad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -805,6 +805,8 @@ endif() # list _TOOLKITS is created foreach tool and contains its toolkits # list will contain all tools if (BUILD_Inspector) + add_definitions (-DHAVE_Inspector) + OCCT_MODULES_AND_TOOLKITS (TOOLS "TOOL_TOOLKITS" OCCT_TOOLS) foreach (OCCT_TOOL ${OCCT_TOOLS}) list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS}) @@ -1028,11 +1030,6 @@ if (BUILD_Inspector OR BUILD_MODULE_QtSamples) message (STATUS "Info: qt samples excluded due to BUILD_MODULE_QtSamples is disabled") endif() - if (NOT BUILD_Inspector) - list (REMOVE_ITEM OCCT_SAMPLES tools) - message (STATUS "Info: TInspectorEXE sample excluded due to BUILD_Inspector is disabled") - endif() - foreach (OCCT_SAMPLE ${OCCT_SAMPLES}) list (APPEND BUILD_SAMPLE_TOOLKITS ${${OCCT_SAMPLE}_SAMPLES_TOOLKITS}) @@ -1061,8 +1058,9 @@ if (BUILD_TOOL_TOOLKITS) PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE) endif() + set (OpenCASCADE_BINARY_DIR "${INSTALL_DIR}/${INSTALL_DIR_BIN}") # patch TInspectorEXE - OCCT_CONFIGURE ("adm/templates/TInspectorEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/samples/tools/TInspectorEXE/TInspectorEXE.vcxproj.user") + OCCT_CONFIGURE ("adm/templates/TInspectorEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/tools/TInspectorEXE/TInspectorEXE.vcxproj.user") endif() # Prepare variables for configuration of OpenCASCADE cmake config file diff --git a/adm/SAMPLES b/adm/SAMPLES index d9f7257e5c..d993165b31 100644 --- a/adm/SAMPLES +++ b/adm/SAMPLES @@ -1,2 +1 @@ -qt AndroidQt FuncDemo IESample Tutorial -tools TInspectorEXE \ No newline at end of file +qt AndroidQt FuncDemo IESample Tutorial \ No newline at end of file diff --git a/adm/TOOLS b/adm/TOOLS index aa587f01b0..b106a7c10b 100644 --- a/adm/TOOLS +++ b/adm/TOOLS @@ -1,4 +1,4 @@ TModelingData TKShapeView TVisualization TKView TKVInspector TApplicationFramework TKTreeModel TKTInspectorAPI TKDFBrowser -TTool TKTInspector TKToolsDraw \ No newline at end of file +TTool TKTInspector TKToolsDraw TInspectorEXE \ No newline at end of file diff --git a/adm/templates/TInspectorEXE.vcxproj.user.in b/adm/templates/TInspectorEXE.vcxproj.user.in index 87277f32a4..ff4fa981b7 100644 --- a/adm/templates/TInspectorEXE.vcxproj.user.in +++ b/adm/templates/TInspectorEXE.vcxproj.user.in @@ -4,7 +4,7 @@ CASROOT=@CMAKE_SOURCE_DIR@ CSF_OCCTDataPath=@CMAKE_SOURCE_DIR@/data QTDIR=@3RDPARTY_QT_DIR@ -PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;%PATH% +PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;@OpenCASCADE_BINARY_DIR@;%PATH% WindowsLocalDebugger @CMAKE_BINARY_DIR@ @@ -13,7 +13,7 @@ PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;%PATH% CASROOT=@CMAKE_SOURCE_DIR@ CSF_OCCTDataPath=@CMAKE_SOURCE_DIR@/data QTDIR=@3RDPARTY_QT_DIR@ -PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;%PATH% +PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;@OpenCASCADE_BINARY_DIR@i;%PATH% WindowsLocalDebugger @CMAKE_BINARY_DIR@ @@ -22,7 +22,7 @@ PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;%PATH% CASROOT=@CMAKE_SOURCE_DIR@ CSF_OCCTDataPath=@CMAKE_SOURCE_DIR@/data QTDIR=@3RDPARTY_QT_DIR@ -PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;%PATH% +PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;@OpenCASCADE_BINARY_DIR@d;%PATH% WindowsLocalDebugger @CMAKE_BINARY_DIR@ diff --git a/samples/tools/TInspectorEXE/CMakeLists.txt b/samples/tools/TInspectorEXE/CMakeLists.txt deleted file mode 100644 index f7eb48ea40..0000000000 --- a/samples/tools/TInspectorEXE/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -project(TInspectorEXE) - -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) -set (RELATIVE_DIR "samples/tools") -include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/TInspectorEXE/src") -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) diff --git a/samples/tools/TInspectorEXE/EXTERNLIB b/samples/tools/TInspectorEXE/EXTERNLIB deleted file mode 100644 index 8f800f24cd..0000000000 --- a/samples/tools/TInspectorEXE/EXTERNLIB +++ /dev/null @@ -1 +0,0 @@ -TKTInspector \ No newline at end of file diff --git a/samples/tools/TInspectorEXE/FILES b/samples/tools/TInspectorEXE/FILES deleted file mode 100644 index ca4f0e567b..0000000000 --- a/samples/tools/TInspectorEXE/FILES +++ /dev/null @@ -1,2 +0,0 @@ -EXTERNLIB -PACKAGES diff --git a/samples/tools/TInspectorEXE/PACKAGES b/samples/tools/TInspectorEXE/PACKAGES deleted file mode 100644 index 51a97991c3..0000000000 --- a/samples/tools/TInspectorEXE/PACKAGES +++ /dev/null @@ -1 +0,0 @@ -TInspectorEXE/src diff --git a/samples/tools/TInspectorEXE/icons/folder_export.png b/samples/tools/TInspectorEXE/icons/folder_export.png deleted file mode 100644 index 5f45f993dc..0000000000 Binary files a/samples/tools/TInspectorEXE/icons/folder_export.png and /dev/null differ diff --git a/samples/tools/TInspectorEXE/icons/folder_import.png b/samples/tools/TInspectorEXE/icons/folder_import.png deleted file mode 100644 index 02743abe9b..0000000000 Binary files a/samples/tools/TInspectorEXE/icons/folder_import.png and /dev/null differ diff --git a/samples/tools/TInspectorEXE/icons/folder_open.png b/samples/tools/TInspectorEXE/icons/folder_open.png deleted file mode 100644 index b0a139ebc6..0000000000 Binary files a/samples/tools/TInspectorEXE/icons/folder_open.png and /dev/null differ diff --git a/samples/tools/TInspectorEXE/src/FILES b/samples/tools/TInspectorEXE/src/FILES deleted file mode 100644 index b48157613c..0000000000 --- a/samples/tools/TInspectorEXE/src/FILES +++ /dev/null @@ -1,6 +0,0 @@ -TInspectorEXE.cxx -TInspectorEXE_OpenFileDialog.cxx -TInspectorEXE_OpenFileDialog.hxx -TInspectorEXE_OpenFileViewModel.cxx -TInspectorEXE_OpenFileViewModel.hxx -TInspectorEXE.qrc \ No newline at end of file diff --git a/samples/tools/TInspectorEXE/src/TInspectorEXE.cxx b/samples/tools/TInspectorEXE/src/TInspectorEXE.cxx deleted file mode 100644 index 01963ec2d4..0000000000 --- a/samples/tools/TInspectorEXE/src/TInspectorEXE.cxx +++ /dev/null @@ -1,134 +0,0 @@ -// 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 - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -// ======================================================================= -// function : fileNameInDataDir -// purpose : -// ======================================================================= -TCollection_AsciiString fileNameInDataDir(const TCollection_AsciiString& theEnvironmentDir, - const TCollection_AsciiString& theName) -{ - OSD_Environment anEnvironment(theEnvironmentDir); - - TCollection_AsciiString aFileName = anEnvironment.Value(); - aFileName += TCollection_AsciiString("/") + theName; - - return aFileName; -} - -// ======================================================================= -// function : setPluginSampleDirectory -// purpose : -// ======================================================================= -void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspector_Communicator* theCommunicator, - TInspectorEXE_OpenButton* theButtonControl) -{ - if (theName.IsEqual ("TKDFBrowser")) - { - theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step/screw.step")); - theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step")); - } - else if (theName.IsEqual ("TKShapeView")) - { - theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep")); - theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ")); - } - else if (theName.IsEqual ("TKVInspector")) - { - theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep")); - theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep")); - theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ")); - } -} - -// ======================================================================= -// function : main -// purpose : -// ======================================================================= -int main (int argc, char** argv) -{ -#if QT_VERSION > 0x050000 - TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value(); - if (!aPlugindsDirName.IsEmpty()) - QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins"); -#endif - QApplication anApp (argc, argv); - - std::set aPlugins; - for (int anArgId = 1; anArgId < argc; anArgId++ ) - { - if (!strcmp (argv[anArgId], "dfbrowser")) - aPlugins.insert ("TKDFBrowser"); - - if (!strcmp (argv[anArgId], "shapeview")) - aPlugins.insert ("TKShapeView"); - - if (!strcmp (argv[anArgId], "vinspector")) - aPlugins.insert ("TKVInspector"); - } - NCollection_List aParameters; - - // Create tool communicator - TInspector_Communicator* aCommunicator = TInspectorEXE_OpenFileDialog::Communicator(); - if (!aCommunicator) - { - std::cout << "Communicator can not be created" << std::endl; - return 0; - } - - TInspectorEXE_OpenButton* aButtonControl = new TInspectorEXE_OpenButton (0); - TCollection_AsciiString anActivatedPluginName; - if (aPlugins.empty()) - { - aPlugins.insert("TKDFBrowser"); - aPlugins.insert("TKShapeView"); - aPlugins.insert("TKVInspector"); - - anActivatedPluginName = "TKDFBrowser"; - } - else - anActivatedPluginName = *aPlugins.rbegin(); - - for (std::set::const_iterator aPluginIt = aPlugins.begin(); aPluginIt != aPlugins.end(); aPluginIt++) - { - TCollection_AsciiString aName = *aPluginIt; - aCommunicator->RegisterPlugin (aName); - aCommunicator->Init (aName, aParameters); - setPluginSampleDirectory (aName, aCommunicator, aButtonControl); - } - aCommunicator->Activate (anActivatedPluginName); - - aCommunicator->SetVisible (true); - aCommunicator->SetOpenButton (aButtonControl->StartButton()); - - return anApp.exec(); -} diff --git a/samples/tools/TInspectorEXE/src/TInspectorEXE.qrc b/samples/tools/TInspectorEXE/src/TInspectorEXE.qrc deleted file mode 100644 index b3a84f67dc..0000000000 --- a/samples/tools/TInspectorEXE/src/TInspectorEXE.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - ../icons/folder_open.png - ../icons/folder_import.png - - diff --git a/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.cxx b/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.cxx deleted file mode 100644 index 48edf4155e..0000000000 --- a/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.cxx +++ /dev/null @@ -1,314 +0,0 @@ -// 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 -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -const int FONT_POINT_SIZE = 18; -const int ICON_SIZE = 40; - -const int OPEN_DIALOG_WIDTH = 550; -const int OPEN_DIALOG_HEIGHT = 200; - -const int MARGIN_DIALOG = 4; -const int SPACING_DIALOG = 2; - -TInspector_Communicator* MyCommunicator; - -// ======================================================================= -// function : StartButton -// purpose : -// ======================================================================= -QPushButton* TInspectorEXE_OpenButton::StartButton() -{ - if (!myStartButton) - { - myStartButton = new QPushButton(); - myStartButton->setIcon (QIcon (":folder_open.png")); - connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked())); - } - return myStartButton; -} - -// ======================================================================= -// function : onStartButtonClicked -// purpose : -// ======================================================================= -void TInspectorEXE_OpenButton::onStartButtonClicked() -{ - QPushButton* aButton = (QPushButton*)sender(); - TCollection_AsciiString aPluginName (aButton->objectName().toStdString().c_str()); - if (aPluginName.IsEmpty()) - return; - - QString aDataDirName = QDir::currentPath(); - if (myDefaultDirs.IsBound (aPluginName)) - aDataDirName = myDefaultDirs.Find (aPluginName).ToCString(); - - QString aFileName = TInspectorEXE_OpenFileDialog::OpenFile (0, aDataDirName); - aFileName = QDir().toNativeSeparators (aFileName); - if (!aFileName.isEmpty()) { - QApplication::setOverrideCursor (Qt::WaitCursor); - TInspectorEXE_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data())); - QApplication::restoreOverrideCursor(); - } -} - -// ======================================================================= -// function : changeMargins -// purpose : -// ======================================================================= -void changeMargins (QBoxLayout* theLayout) -{ - theLayout->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG); - theLayout->setSpacing (SPACING_DIALOG); -} - -// ======================================================================= -// function : Constructor -// purpose : -// ======================================================================= -TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName) -: QDialog(theParent), myDataDir (theDataDirName) -{ - setWindowTitle (theDataDirName); - - QVBoxLayout* aDialogLay = new QVBoxLayout (this); - changeMargins (aDialogLay); - - // Title label - QLabel* aTitleLabel = new QLabel (this); - aTitleLabel->setText (tr ("Open File")); - aDialogLay->addWidget (aTitleLabel); - - // Samples View - QGroupBox* aSamplesBox = new QGroupBox (this); - aSamplesBox->setTitle (tr ("Samples")); - aDialogLay->addWidget (aSamplesBox); - QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox); - changeMargins (aSampleLay); - mySamplesView = createTableView (readSampleNames()); - aSampleLay->addWidget (mySamplesView); - - // Select file - QGroupBox* aSelectFileBox = new QGroupBox (this); - aSelectFileBox->setTitle (tr ("Select file")); - aDialogLay->addWidget (aSelectFileBox); - QGridLayout* aSelectFileLay = new QGridLayout (aSelectFileBox); - aSelectFileLay->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG); - - mySelectedName = new QLineEdit (aSelectFileBox); - QCompleter* aCompleter = new QCompleter(); - QFileSystemModel* aFileSystemModel = new QFileSystemModel; - aFileSystemModel->setRootPath (QDir::rootPath()); - aCompleter->setModel (aFileSystemModel); - mySelectedName->setCompleter (aCompleter); - aSelectFileLay->addWidget (mySelectedName, 1, 0); - - QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox); - aSelectFileBtn->setIcon (QIcon (":folder_open.png")); - aSelectFileLay->addWidget (aSelectFileBtn, 1, 1); - - myFolderApplyOpen = new QToolButton (aSelectFileBox); - myFolderApplyOpen->setIcon (QIcon (":folder_import.png")); - myFolderApplyOpen->setIconSize (QSize (ICON_SIZE, ICON_SIZE)); - myFolderApplyOpen->setEnabled (false); - aSelectFileLay->addWidget (myFolderApplyOpen, 0, 2, 2, 1); - - connect (mySelectedName, SIGNAL (textChanged (const QString&)), - this, SLOT (onNameChanged (const QString&))); - connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked())); - connect (myFolderApplyOpen, SIGNAL (clicked()), this, SLOT (onApplySelectClicked())); - - resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT); -} - -// ======================================================================= -// function : OpenFile -// purpose : -// ======================================================================= -QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QString& theDataDirName) -{ - QString aFileName; - TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog(theParent, theDataDirName); - if (aDialog->exec() == QDialog::Accepted) - aFileName = aDialog->GetFileName(); - - return aFileName; -} - -// ======================================================================= -// function : Communicator -// purpose : -// ======================================================================= -TInspector_Communicator* TInspectorEXE_OpenFileDialog::Communicator() -{ - if (!MyCommunicator) - MyCommunicator = new TInspector_Communicator(); - return MyCommunicator; -} - -// ======================================================================= -// function : onSampleSelectionChanged -// purpose : -// ======================================================================= -void TInspectorEXE_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected, - const QItemSelection&) -{ - QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender(); - if (!aSelectionModel) - return; - if (theSelected.isEmpty()) - return; - - QModelIndex anIndex = theSelected.first().indexes().first(); - if (!anIndex.isValid()) - return; - - myFileName = aSelectionModel->model()->data (anIndex, Qt::ToolTipRole).toString(); - accept(); -} - -// ======================================================================= -// function : onNameChanged -// purpose : -// ======================================================================= -void TInspectorEXE_OpenFileDialog::onNameChanged (const QString& theText) -{ - QFileInfo aFileInfo (theText); - bool anExists = aFileInfo.exists() && aFileInfo.isFile(); - myFolderApplyOpen->setEnabled (anExists); -} - -// ======================================================================= -// function : onSelectClicked -// purpose : -// ======================================================================= -void TInspectorEXE_OpenFileDialog::onSelectClicked() -{ - QString anEnteredPath; - QString aDirName = mySelectedName->text(); - if (!aDirName.isEmpty()) - { - QDir aDir (aDirName); - if (aDir.exists()) - anEnteredPath = aDirName; - } - - QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath); - - if (aFileName.isEmpty()) - return; // do nothing, left the previous value - - - myFileName = aFileName; - accept(); -} - -// ======================================================================= -// function : onApplySelectClicked -// purpose : -// ======================================================================= -void TInspectorEXE_OpenFileDialog::onApplySelectClicked() -{ - myFileName = mySelectedName->text(); - accept(); -} - -// ======================================================================= -// function : createTableView -// purpose : -// ======================================================================= -QTableView* TInspectorEXE_OpenFileDialog::createTableView (const QStringList& theFileNames) -{ - QTableView* aTableView = new QTableView (this); - aTableView->setFrameStyle (QFrame::NoFrame); - QPalette aPalette = aTableView->viewport()->palette(); - QColor aWindowColor = aPalette.color (QPalette::Window); - aPalette.setBrush (QPalette::Base, aWindowColor); - aTableView->viewport()->setPalette (aPalette); - - aTableView->horizontalHeader()->setVisible (false); - aTableView->verticalHeader()->setVisible (false); - aTableView->setGridStyle (Qt::NoPen); - aTableView->setModel (createModel (theFileNames)); - aTableView->setItemDelegateForRow (0, new TInspectorEXE_OpenFileItemDelegate (aTableView, - aPalette.color (QPalette::Highlight))); - aTableView->viewport()->setAttribute (Qt::WA_Hover); - int aCellHeight = ICON_SIZE + aTableView->verticalHeader()->defaultSectionSize(); - aTableView->setRowHeight (0, aCellHeight); - int aScrollHeight = aTableView->horizontalScrollBar()->sizeHint().height(); - aTableView->setMinimumHeight (aCellHeight + aScrollHeight); - QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aTableView->model()); - connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), - this, SLOT (onSampleSelectionChanged (const QItemSelection&, const QItemSelection&))); - aTableView->setSelectionModel (aSelectionModel); - - return aTableView; -} - -// ======================================================================= -// function : createModel -// purpose : -// ======================================================================= -QAbstractItemModel* TInspectorEXE_OpenFileDialog::createModel (const QStringList& theFileNames) -{ - TInspectorEXE_OpenFileViewModel* aModel = new TInspectorEXE_OpenFileViewModel (this); - aModel->Init (theFileNames); - return aModel; -} - -// ======================================================================= -// function : readSampleNames -// purpose : -// ======================================================================= -QStringList TInspectorEXE_OpenFileDialog::readSampleNames() -{ - QStringList aNames; - - QDir aDir(myDataDir); - aDir.setSorting(QDir::Name); - - QFileInfoList aDirEntries = aDir.entryInfoList(); - for (int aDirId = 0; aDirId < aDirEntries.size(); ++aDirId) - { - QFileInfo aFileInfo = aDirEntries.at(aDirId); - if (aFileInfo.isFile()) - aNames.append (aFileInfo.absoluteFilePath()); - } - return aNames; -} diff --git a/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.hxx b/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.hxx deleted file mode 100644 index 4afa4491cf..0000000000 --- a/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.hxx +++ /dev/null @@ -1,142 +0,0 @@ -// 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 TInspectorEXE_OpenFileDialog_H -#define TInspectorEXE_OpenFileDialog_H - -#include -#include - -#include -#include -#include -#include -#include - -#include - -class TInspector_Communicator; - -class QAbstractItemModel; -class QLineEdit; -class QPushButton; -class QTableView; -class QToolButton; -class QWidget; - -//! \class TInspectorEXE_OpenButton -//! Class that contains push button and the button processing. It obtains a file name from the default or current -//! directory and gives the name into TInspector communicator -//! Object name of the button is the name of the plugin to get the default directory, or the current directory is used. -class TInspectorEXE_OpenButton : public QObject -{ - Q_OBJECT - -public: - - //! Constructor - TInspectorEXE_OpenButton (QObject* theParent) : QObject (theParent), myStartButton (0) {} - - //! Destructor - virtual ~TInspectorEXE_OpenButton() {} - - //! Returns the start button, if this is the first call, it creates the button and connect it to the slot - QPushButton* StartButton(); - - //! Sets the default directory of plugin. - void SetPluginDir (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theDefaultDir) - { myDefaultDirs.Bind (thePluginName, theDefaultDir); } - -private slots: - - //! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator - void onStartButtonClicked(); - -private: - - QPushButton* myStartButton; //!< processed button - NCollection_DataMap myDefaultDirs; //!< plugins default directories -}; - -//! \class TInspectorEXE_OpenFileDialog -//! Control that contains table view of samples and line to select a file name from other directory. -//! Click on element of samples table view calls this sample opening else after entering(or opening) file name -//! the import becomes active. Click on the button will open selected file if it is possible -class TInspectorEXE_OpenFileDialog : public QDialog -{ - Q_OBJECT -private: - - //! Constructor - TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName); - -public: - - //! Destructor - virtual ~TInspectorEXE_OpenFileDialog() Standard_OVERRIDE {} - - //! Opens this file dialog using for samples view the given directory and try to open new file - //! \param theParent a parent for the new dialog - //! \param theDataDirName path to default samples directory - //! \returns a file name from the open file dialog - static QString OpenFile (QWidget* theParent, const QString& theDataDirName); - - //! Returns selection name from the dialog - QString GetFileName() const { return myFileName; } - - //! Returns communicator, if this is the first call, create a communicator instance - static TInspector_Communicator* Communicator(); - -private slots: - - //! Stores name of selected sample file - void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected); - - //! Updates enabling state of Open file button, it is enabled if the file by the entered path exists - //! \param theText a file name text in line edit - void onNameChanged (const QString& theText); - - //! Open file dialog to select a file name. Fills file name line, enable import button - void onSelectClicked(); - - //! Accepts open file dialog - void onApplySelectClicked(); - -private: - - //! Creates view of file names in samples directory - //! \param theFileNames a container of names - //! \return table view - QTableView* createTableView (const QStringList& theFileNames); - - //! Creates view model and fills it by the file names - //! \param theFileNames a container of names - //! \return model - QAbstractItemModel* createModel (const QStringList& theFileNames); - - //! Generates container of file names in samples directory - //! \return container of names - QStringList readSampleNames(); - -private: - - QString myDataDir; //!< samples directory - QString myFileName; //!< result file name - QTableView* mySamplesView; //! - -#include -#include -#include -#include -#include -#include - -const int ICON_SIZE = 40; - -// ======================================================================= -// function : paint -// purpose : -// ======================================================================= -void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption, - const QModelIndex& theIndex) const -{ - // highlight cell - if (theOption.state & QStyle::State_MouseOver) - thePainter->fillRect (theOption.rect, myColor); - - // action icon for all indices before the last one - QIcon anIcon (":/icons/folder_import.png"); - QSize anIconSize (ICON_SIZE, ICON_SIZE); - int aDX = (theOption.rect.width() - anIconSize.width()) / 2; - int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin); - thePainter->drawPixmap (QRect (theOption.rect.left() + aDX, - theOption.rect.top() + aMargin, - anIconSize.width(), - anIconSize.height()), - anIcon.pixmap(anIconSize.width(), anIconSize.height())); - // default paint - QItemDelegate::paint (thePainter, theOption, theIndex); -} - -// ======================================================================= -// function : Init -// purpose : -// ======================================================================= -void TInspectorEXE_OpenFileViewModel::Init (const QStringList& theValues) -{ - myValues = theValues; -} - -// ======================================================================= -// function : data -// purpose : -// ======================================================================= -QVariant TInspectorEXE_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const -{ - switch (theRole) - { - case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName(); - case Qt::ToolTipRole: return myValues[theIndex.column()]; - case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter); - default: break; - } - return QVariant(); -} diff --git a/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileViewModel.hxx b/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileViewModel.hxx deleted file mode 100644 index 42b6604e07..0000000000 --- a/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileViewModel.hxx +++ /dev/null @@ -1,98 +0,0 @@ -// 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 TInspectorEXE_OpenFileViewModel_H -#define TInspectorEXE_OpenFileViewModel_H - -#include - -#include -#include -#include -#include -#include - -class QObject; -class QPainter; - -//! \class TInspectorEXE_OpenFileItemDelegate -//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button -class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate -{ - -public: - - //! Constructor - TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor) - : QItemDelegate (theParent), myColor(theHighlightColor) {} - - //! Destructor - virtual ~TInspectorEXE_OpenFileItemDelegate() {} - - //! Draw an icon in the cell - //! \param thePainter a painter - //! \param theOption a paint options - //! \param theIndex a view index - virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption, - const QModelIndex& theIndex) const Standard_OVERRIDE; - -private: - - QColor myColor; //!< highlight color -}; - -//! \class TInspectorEXE_OpenFileViewModel -//! Table model that visualizes container of string values (file names) -//! Table orientation is horizontal, it has 1 row, number of columns equals to number of values -class TInspectorEXE_OpenFileViewModel : public QAbstractTableModel -{ - -public: - - //! Constructor - TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {} - - //! Destructor - virtual ~TInspectorEXE_OpenFileViewModel() {} - - //! Store values - //! \param theValues a container of values to fill model - void Init (const QStringList& theValues); - - //! Returns content of the model index for the given role, it is obtained from internal container of values - //! It returns value only for DisplayRole. - //! \param theIndex a model index - //! \param theRole a view role - //! \return value intepreted depending on the given role - virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE; - - //! Returns number of rows - //! \param theParent an index of the parent item - //! \return an integer value - virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE - { (void)theParent; return 1; } - - //! Returns number of columns - //! \param theParent an index of the parent item - //! \return an integer value - virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE - { (void)theParent; return myValues.size(); } - -private: - - QStringList myValues; //!< file names -}; - -#endif diff --git a/samples/tools/TStandalone/CMakeLists.txt b/samples/tools/TStandalone/CMakeLists.txt deleted file mode 100644 index 8810073fe7..0000000000 --- a/samples/tools/TStandalone/CMakeLists.txt +++ /dev/null @@ -1,125 +0,0 @@ -cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) -project (TStandalone) - -set (CASROOT "" CACHE PATH "Third party OpenCascade dir" ) -set (3RDPARTY_DIR "" CACHE PATH "Third party dir" ) -set (INSTALL_DIR "" CACHE PATH "Where to install" ) - -if (NOT "$ENV{CASROOT}" STREQUAL "" AND EXISTS "$ENV{CASROOT}") - set (CASROOT "$ENV{CASROOT}") - #set (3RDPARTY_OCCT_DIR "${CASROOT}") - #message("Environment CASROOT: ${CASROOT}") - #message("Environment 3RDPARTY_OCCT_DIR: ${CASROOT}") -endif() - -if (NOT "$ENV{THIRDPARTY_DIR}" STREQUAL "" AND EXISTS "$ENV{THIRDPARTY_DIR}") - set (3RDPARTY_DIR "$ENV{THIRDPARTY_DIR}") - message("Environment THIRDPARTY_DIR: ${3RDPARTY_DIR}") -endif() - -if (NOT "$ENV{INSTALL_DIR}" STREQUAL "") - set (INSTALL_DIR "$ENV{INSTALL_DIR}") - message("Environment INSTALL_DIR: ${INSTALL_DIR}") -endif() - -# Define the next variable to has defined 3rdParties DLL dir variables -set (BUILD_SHARED_LIBS ON) - -set (CASROOT_SOURCE_FILES "${CMAKE_SOURCE_DIR}/../../.." CACHE PATH "OCCT sources dir to find tools packages" ) -if ("${CASROOT}" STREQUAL "") - set (CASROOT "${CASROOT_SOURCE_FILES}/work/install" CACHE PATH "OCCT sources dir to find tools packages" ) -endif() - -macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE) - include (${CASROOT_SOURCE_FILES}/${BEING_INCLUDED_FILE}.cmake) -endmacro() - -macro (OCCT_INCLUDE_CMAKE_FILE_STANDALONE BEING_INCLUDED_FILE) - include (${CMAKE_SOURCE_DIR}/${BEING_INCLUDED_FILE}.cmake) -endmacro() - -set (ADDITIONAL_DLL_DIR "" CACHE PATH "Additional paths that should be included into PATH" ) -if (NOT "$ENV{ADDITIONAL_DLL_DIR}" STREQUAL "") - set (ADDITIONAL_DLL_DIR "$ENV{ADDITIONAL_DLL_DIR}") - message("Environment ADDITIONAL_DLL_DIR: ${ADDITIONAL_DLL_DIR}") -endif() - -set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE) - -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro") -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE("adm/cmake/occt") -if (OCCT_LIBRARY_NOT_FOUND) - message (FATAL_ERROR "Could NOT find OCCT Library in : ${3RDPARTY_OCCT_LIBRARY_DIR}" ) -endif() - -OCCT_MAKE_OS_WITH_BITNESS() -OCCT_MAKE_COMPILER_SHORT_NAME() - -set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE ) -set (INSTALL_API_DIR "${INSTALL_DIR}/api" CACHE PATH "" FORCE) -set (INSTALL_DIR_BIN "${OS_WITH_BIT}/${COMPILER}/bin" CACHE PATH "" FORCE) -set (INSTALL_DIR_LIB "${OS_WITH_BIT}/${COMPILER}/lib" CACHE PATH "" FORCE) -set (INSTALL_DIR_INCLUDE "inc" CACHE PATH "") - -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype") -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage") -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps") -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb") -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt") -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") - -#include (${CMAKE_SOURCE_DIR}/adm/cmake/3rdparty.cmake) - -set (3RDPARTY_DLL_PATH "${USED_3RDPARTY_OCCT_DIRS};\ -${USED_3RDPARTY_FREETYPE_DIR};\ -${USED_3RDPARTY_FREEIMAGE_DIRS};\ -${USED_3RDPARTY_GL2PS_DIRS};\ -${3RDPARTY_QT_DIR}/bin;\ -${3RDPARTY_TBB_DLL_DIR}") - -if (ADDITIONAL_DLL_DIR) - set (3RDPARTY_DLL_PATH "${3RDPARTY_DLL_PATH};\ -${ADDITIONAL_DLL_DIR}") -endif() - -set (3RDPARTY_DLL_DEB_PATH "${3RDPARTY_DLL_PATH}") - - -set (BUILD_TOOLKITS - TKTInspectorAPI - TKView - TKTreeModel - TKDFBrowser - TKVInspector - TKShapeView - TKTInspector - TKToolsDraw -) - -string(TIMESTAMP CURRENT_TIME "%H:%M:%S") -message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all header files into ${CMAKE_BINARY_DIR}/inc ...") -# collect all the headers to /inc folder -COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "${CASROOT_SOURCE_FILES}/tools" "${INSTALL_DIR_INCLUDE}/inspector") - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/standalone_macros") -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt_macro") - -set (BUILD_PROJECTS - TInspectorAPI - View - TreeModel - DFBrowserPane - DFBrowserPaneXDE - DFBrowser - ShapeView - VInspector - TInspector - TInspectorEXE - ToolsDraw -) -# include patched toolkit projects or original ones -foreach (PROJECT_ITEM ${BUILD_PROJECTS}) - OCCT_ADD_SUBDIRECTORY ("src/${PROJECT_ITEM}") -endforeach() diff --git a/samples/tools/TStandalone/adm/cmake/occt.cmake b/samples/tools/TStandalone/adm/cmake/occt.cmake deleted file mode 100644 index 6bcf11b665..0000000000 --- a/samples/tools/TStandalone/adm/cmake/occt.cmake +++ /dev/null @@ -1,75 +0,0 @@ -#freeimage - -if(NOT "${CASROOT}" STREQUAL "") - #message(FATAL_ERROR, "Empty OCCT dir") - #return() - #set("3RDPARTY_OCCT_DIR ${CASROOT}") -endif() - -#set(3RDPARTY_OCC_DIR ${CASROOT}) -#message("3RDPARTY_OCC_DIR: ${3RDPARTY_OCC_DIR}") -#set("3RDPARTY_OCC_DIR ${3RDPARTY_OCCT_DIR}") -#message("3RDPARTY_OCC_DIR: ${3RDPARTY_OCC_DIR}") - -set(CSF_TKernel "TKernel") -THIRDPARTY_PRODUCT("OCCT" "Standard.hxx" "CSF_TKernel" "") - -set(3RDPARTY_OCCT_DIR ${3RDPARTY_OCC_DIR} CACHE PATH "OCCT dir") - -OCCT_MAKE_OS_WITH_BITNESS() -OCCT_MAKE_COMPILER_SHORT_NAME() - -SET(3RDPARTY_OCCT_INCLUDE_DIR "${3RDPARTY_OCC_INCLUDE_DIR}" CACHE PATH "OCCT include dir") -SET(3RDPARTY_OCCT_LIBRARY_DIR "${3RDPARTY_OCC_LIBRARY_DIR}" CACHE PATH "OCCT library dir") -SET(3RDPARTY_OCCT_DLL_DIR "${3RDPARTY_OCC_DLL_DIR}" CACHE PATH "OCCT dll dir") - -SET(CSF_StandardDefaults_DIR ${CASROOT}/src/StdResource CACHE PATH "OCCT Standard Resource") -SET(CSF_XCAFDefaults_DIR ${CASROOT}/src/StdResource CACHE PATH "OCCT XCAF Defaults") -SET(CSF_PluginDefaults_DIR ${CASROOT}/src/StdResource CACHE PATH "OCCT Plugin Defaults") - -message (STATUS "... OCCT dir: ${3RDPARTY_OCCT_DIR}") -message (STATUS "... OCCT Include dirs: ${3RDPARTY_OCCT_INCLUDE_DIR}") -message (STATUS "... OCCT Library dirs: ${3RDPARTY_OCCT_LIBRARY_DIRS}") -message (STATUS "... OCCT Binary dirs: ${3RDPARTY_OCCT_DLL_DIRS}") - -SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${3RDPARTY_OCCT_LIBRARY_DIRS}") - -find_library(TKernel TKernel PATHS "${3RDPARTY_OCCT_LIBRARY_DIRS}" - PATH_SUFFIXES lib - NO_DEFAULT_PATH) - -if ("${TKernel}" STREQUAL "TKernel-NOTFOUND") - set (OCCT_LIBRARY_NOT_FOUND ON) -endif() - -find_library(TKMath TKMath) - -find_library(TKCAF TKCAF) -find_library(TKCDF TKCDF) -find_library(TKLCAF TKLCAF) -find_library(TKVCAF TKVCAF) - -find_library(TKBRep TKBRep) -find_library(TKService TKService) - -find_library(TKOpenGl TKOpenGl) -find_library(TKV3d TKV3d) - -find_library(TKXCAF TKXCAF) -find_library(TKXSBase TKXSBase) -find_library(TKXDESTEP TKXDESTEP) -find_library(TKXmlXCAF TKXmlXCAF) -find_library(TKXml TKXml) - -find_library(TKBin TKBin) -find_library(TKBinL TKBinL) -find_library(TKBinXCAF TKBinXCAF) - -find_library(TKStd TKStd) -find_library(TKXmlL TKXmlL) -find_library(TKStdL TKStdL) -# VInspector additionally: -find_library(TKBO TKBO) -# ShapeView additionally: -find_library(TKGeomBase TKGeomBase) -find_library(TKG3d TKG3d) diff --git a/samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake b/samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake deleted file mode 100644 index 223c362ca1..0000000000 --- a/samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake +++ /dev/null @@ -1,115 +0,0 @@ -# script for each OCCT toolkit - -#Qt dependencies -#message ("Project is ${PROJECT_NAME}") -if (EXECUTABLE_PROJECT) - set (PACKAGE_PREFIX_DIR "samples/tools") - SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/../${PROJECT_NAME}) - include_directories("${SOURCE_DIR}") - #message("Inc dir: ${CMAKE_SOURCE_DIR}/../${PROJECT_NAME}") -else() - set (PACKAGE_PREFIX_DIR "tools") - SET(SOURCE_DIR ${CASROOT_SOURCE_FILES}/${PACKAGE_PREFIX_DIR}/${PROJECT_NAME}) -endif() - -FIND_SOURCES_AND_HEADERS_FILES(${SOURCE_DIR} SOURCE_FILES HEADER_FILES) - -#message ("Source dir is ${SOURCE_DIR}") -#message ("Sources are ${SOURCE_FILES}") - -unset(RCC_FILES) -if (USE_QT) - FIND_QT_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES) - - FIND_AND_WRAP_MOC_FILES("${SOURCE_FILES}") - FIND_AND_WRAP_RESOURCE_FILE("${SOURCE_DIR}/${PROJECT_NAME}.qrc" RCC_FILES) - -endif() - -if (TOOLKIT_NAME) - set(TARGET_NAME TK${PROJECT_NAME}) -else () - set(TARGET_NAME ${PROJECT_NAME}) -endif() - -if (EXECUTABLE_PROJECT) - add_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES}) -else() - add_library(${TARGET_NAME} SHARED ${SOURCE_FILES} ${HEADER_FILES}) -endif() - - -include_directories( - ${PROJECT_INCLUDES} - ${SOURCE_DIR} - ${3RDPARTY_OCCT_INCLUDE_DIR} - "${CMAKE_BINARY_DIR}/inc") - -add_definitions(-D__WIN32__) -add_definitions(-DWNT) -add_definitions(-D__${PROJECT_NAME}_DLL) - -# parce EXTERNLIB file -FILE_TO_LIST ("src/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS) -foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) - string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM}) - if (NOT COMMENT_FOUND) - set (LIB_ITEM ${USED_ITEM}) - set (LIB_PARSED_ITEM ${${USED_ITEM}}) - - if (LIB_PARSED_ITEM) - list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${${USED_ITEM}}) - #message("Append external lib: ${${USED_ITEM}}") - else () - list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM}) - #message("Append lib: ${USED_ITEM}") - endif() - - endif() -endforeach() - - -target_link_libraries (${TARGET_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT}) - -if (USE_QT) - target_link_libraries (${TARGET_NAME} debug ${PROJECT_LIBRARIES_DEBUG}) - target_link_libraries (${TARGET_NAME} optimized ${PROJECT_LIBRARIES_RELEASE}) - - if (NOT "${RCC_FILES}" STREQUAL "") - #message("RCC files: ${RCC_FILES}") - target_sources(${TARGET_NAME} PRIVATE ${RCC_FILES}) - endif() -endif() - -if (EXECUTABLE_PROJECT) - INSTALL(TARGETS ${TARGET_NAME} DESTINATION "${INSTALL_DIR_BIN}") -else() - if (MSVC) - install (DIRECTORY ${PROJECT_BINARY_DIR}/Debug/ - DESTINATION "${INSTALL_DIR_BIN}" - FILES_MATCHING PATTERN *.pdb) - if (INSTALL_API_DIR) - install (DIRECTORY ${PROJECT_BINARY_DIR}/Debug/ - DESTINATION "${INSTALL_API_DIR}/bin" - FILES_MATCHING PATTERN *.pdb) - endif() - endif() - install (TARGETS ${TARGET_NAME} - RUNTIME DESTINATION "${INSTALL_DIR_BIN}" - ARCHIVE DESTINATION "${INSTALL_DIR_LIB}" - LIBRARY DESTINATION "${INSTALL_DIR_LIB}") - - if (INSTALL_API_DIR) - install (TARGETS ${TARGET_NAME} - RUNTIME DESTINATION "${INSTALL_API_DIR}/bin") - - if (INSTALL_API) - INSTALL(FILES ${HEADER_FILES} DESTINATION "${INSTALL_API_DIR}/${INSTALL_DIR_INCLUDE}") - - install (DIRECTORY ${PROJECT_BINARY_DIR}/Debug/ - DESTINATION "${INSTALL_API_DIR}/lib" - FILES_MATCHING PATTERN *.lib) - endif() - endif() - -endif() diff --git a/samples/tools/TStandalone/adm/cmake/standalone_macros.cmake b/samples/tools/TStandalone/adm/cmake/standalone_macros.cmake deleted file mode 100644 index 531a0e36e0..0000000000 --- a/samples/tools/TStandalone/adm/cmake/standalone_macros.cmake +++ /dev/null @@ -1,33 +0,0 @@ -#freeimage - -macro (FIND_SOURCES_AND_HEADERS_FILES CURRENT_SOURCES_DIR SOURCE_FILES HEADER_FILES) - if (EXISTS "${CURRENT_SOURCES_DIR}/FILES") - file (STRINGS "${CURRENT_SOURCES_DIR}/FILES" HEADER_FILES_H REGEX ".+[.]h") - file (STRINGS "${CURRENT_SOURCES_DIR}/FILES" SOURCE_FILES_C REGEX ".+[.]c") - - if (NOT "${HEADER_FILES_H}" STREQUAL "") - foreach (ORIGIN_FILE ${HEADER_FILES_H}) - list (APPEND HEADER_FILES_ ${CURRENT_SOURCES_DIR}/${ORIGIN_FILE}) - endforeach() - - #message("${HEADER_FILES_}") - set(${HEADER_FILES} ${HEADER_FILES_}) - endif() - - if(NOT "${SOURCE_FILES_C}" STREQUAL "") - foreach (ORIGIN_FILE ${SOURCE_FILES_C}) - list (APPEND SOURCE_FILES_ ${CURRENT_SOURCES_DIR}/${ORIGIN_FILE}) - endforeach() - - #message("${SOURCE_FILES_}") - set(${SOURCE_FILES} ${SOURCE_FILES_}) - endif() - - #set(${HEADER_FILES} ${HEADER_FILES_H}) - #set(${SOURCE_FILES} ${SOURCE_FILES_C}) - - else() - message(WARNING "file FILES is absent in $TARGET") - endif() - -endmacro() diff --git a/samples/tools/TStandalone/adm/templates/TInspectorEXE.vcxproj.user.in b/samples/tools/TStandalone/adm/templates/TInspectorEXE.vcxproj.user.in deleted file mode 100644 index b79bb66ae3..0000000000 --- a/samples/tools/TStandalone/adm/templates/TInspectorEXE.vcxproj.user.in +++ /dev/null @@ -1,27 +0,0 @@ - - - - PATH=@3RDPARTY_DLL_DEB_PATH@;@CMAKE_INSTALL_PREFIX@/@INSTALL_DIR_BIN@;%PATH% -DATA_DIR=@INSTALL_DIR@/data -QTDIR=@3RDPARTY_QT_DIR@ -CSF_OCCTDataPath=@3RDPARTY_OCCT_DIR@/data - - - - PATH=@3RDPARTY_DLL_DEB_PATH@;@CMAKE_INSTALL_PREFIX@/@INSTALL_DIR_BIN@;%PATH% -DATA_DIR=@INSTALL_DIR@/data -QTDIR=@3RDPARTY_QT_DIR@ -CSF_OCCTDataPath=@3RDPARTY_OCCT_DIR@/data - - - - PATH=@3RDPARTY_DLL_DEB_PATH@;@CMAKE_INSTALL_PREFIX@/@INSTALL_DIR_BIN@;%PATH% -DATA_DIR=@INSTALL_DIR@/data -QTDIR=@3RDPARTY_QT_DIR@ -CSF_OCCTDataPath=@3RDPARTY_OCCT_DIR@/data -CSF_ShadersDirectory=@CASROOT@/src/Shaders - - - - - diff --git a/samples/tools/TStandalone/adm/templates/header.in b/samples/tools/TStandalone/adm/templates/header.in deleted file mode 100644 index 80c75f9cb8..0000000000 --- a/samples/tools/TStandalone/adm/templates/header.in +++ /dev/null @@ -1 +0,0 @@ -@OCCT_HEADER_FILE_CONTENT@ diff --git a/samples/tools/TStandalone/src/DFBrowser/CMakeLists.txt b/samples/tools/TStandalone/src/DFBrowser/CMakeLists.txt deleted file mode 100644 index 629286c9a1..0000000000 --- a/samples/tools/TStandalone/src/DFBrowser/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project(DFBrowser) - -ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) - -set (USE_QT ON) -set (TOOLKIT_NAME ON) - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") - -unset (USE_QT) -unset (TOOLKIT_NAME) diff --git a/samples/tools/TStandalone/src/DFBrowser/EXTERNLIB b/samples/tools/TStandalone/src/DFBrowser/EXTERNLIB deleted file mode 100644 index 0a28f95964..0000000000 --- a/samples/tools/TStandalone/src/DFBrowser/EXTERNLIB +++ /dev/null @@ -1,29 +0,0 @@ -DFBrowserPane -DFBrowserPaneXDE -TKBRep -TKMath -TKV3d -TKBRep -TKBin -TKBinL -TKBinXCAF -TKCAF -TKCDF -TKernel -TKLCAF -TKMath -TKOpenGl -TKService -TKStd -TKStdL -TKTInspector -TKTInspectorAPI -TKTreeModel -TKV3d -TKView -TKXSBase -TKXCAF -TKXDESTEP -TKXmlXCAF -TKXml -TKXmlL diff --git a/samples/tools/TStandalone/src/DFBrowserPane/CMakeLists.txt b/samples/tools/TStandalone/src/DFBrowserPane/CMakeLists.txt deleted file mode 100644 index e1b116a01e..0000000000 --- a/samples/tools/TStandalone/src/DFBrowserPane/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -project(DFBrowserPane) - -set (USE_QT ON) -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") -unset (USE_QT) diff --git a/samples/tools/TStandalone/src/DFBrowserPane/EXTERNLIB b/samples/tools/TStandalone/src/DFBrowserPane/EXTERNLIB deleted file mode 100644 index 87ffbccaba..0000000000 --- a/samples/tools/TStandalone/src/DFBrowserPane/EXTERNLIB +++ /dev/null @@ -1,12 +0,0 @@ -TKG3d -TKTInspectorAPI -TKTreeModel -TKernel -TKMath -TKService -TKV3d -TKVCAF -TKCDF -TKCAF -TKLCAF -TKBRep diff --git a/samples/tools/TStandalone/src/DFBrowserPaneXDE/CMakeLists.txt b/samples/tools/TStandalone/src/DFBrowserPaneXDE/CMakeLists.txt deleted file mode 100644 index 3d26d54355..0000000000 --- a/samples/tools/TStandalone/src/DFBrowserPaneXDE/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -project(DFBrowserPaneXDE) - -set (USE_QT ON) -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") -unset (USE_QT) diff --git a/samples/tools/TStandalone/src/DFBrowserPaneXDE/EXTERNLIB b/samples/tools/TStandalone/src/DFBrowserPaneXDE/EXTERNLIB deleted file mode 100644 index 768a730d1f..0000000000 --- a/samples/tools/TStandalone/src/DFBrowserPaneXDE/EXTERNLIB +++ /dev/null @@ -1,7 +0,0 @@ -DFBrowserPane -TKernel -TKTInspectorAPI -TKXSBase -TKXDESTEP -TKBRep -TKXCAF diff --git a/samples/tools/TStandalone/src/ShapeView/CMakeLists.txt b/samples/tools/TStandalone/src/ShapeView/CMakeLists.txt deleted file mode 100644 index 110bcfe13e..0000000000 --- a/samples/tools/TStandalone/src/ShapeView/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project(ShapeView) - -set (USE_QT ON) -set (TOOLKIT_NAME ON) - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") - -unset (USE_QT) -unset (TOOLKIT_NAME) - - diff --git a/samples/tools/TStandalone/src/ShapeView/EXTERNLIB b/samples/tools/TStandalone/src/ShapeView/EXTERNLIB deleted file mode 100644 index ea9431eab0..0000000000 --- a/samples/tools/TStandalone/src/ShapeView/EXTERNLIB +++ /dev/null @@ -1,8 +0,0 @@ -TKBRep -TKGeomBase -TKG3d -TKMath -TKTInspectorAPI -TKTreeModel -TKService -TKView diff --git a/samples/tools/TStandalone/src/TInspector/CMakeLists.txt b/samples/tools/TStandalone/src/TInspector/CMakeLists.txt deleted file mode 100644 index 4161561086..0000000000 --- a/samples/tools/TStandalone/src/TInspector/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project(TInspector) - -set (USE_QT ON) -set (TOOLKIT_NAME ON) -set (INSTALL_API ON) - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") - -unset (USE_QT) -unset (TOOLKIT_NAME) -unset (INSTALL_API) diff --git a/samples/tools/TStandalone/src/TInspector/EXTERNLIB b/samples/tools/TStandalone/src/TInspector/EXTERNLIB deleted file mode 100644 index 5df40d3849..0000000000 --- a/samples/tools/TStandalone/src/TInspector/EXTERNLIB +++ /dev/null @@ -1,2 +0,0 @@ -TKernel -TKTInspectorAPI diff --git a/samples/tools/TStandalone/src/TInspectorAPI/CMakeLists.txt b/samples/tools/TStandalone/src/TInspectorAPI/CMakeLists.txt deleted file mode 100644 index 1f2f7aa485..0000000000 --- a/samples/tools/TStandalone/src/TInspectorAPI/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -project(TInspectorAPI) - -set (TOOLKIT_NAME ON) -set (INSTALL_API ON) - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") - -unset (TOOLKIT_NAME) -unset (INSTALL_API) - diff --git a/samples/tools/TStandalone/src/TInspectorAPI/EXTERNLIB b/samples/tools/TStandalone/src/TInspectorAPI/EXTERNLIB deleted file mode 100644 index b15d5ec8db..0000000000 --- a/samples/tools/TStandalone/src/TInspectorAPI/EXTERNLIB +++ /dev/null @@ -1,2 +0,0 @@ -TKernel -TKLCAF diff --git a/samples/tools/TStandalone/src/TInspectorEXE/CMakeLists.txt b/samples/tools/TStandalone/src/TInspectorEXE/CMakeLists.txt deleted file mode 100644 index eaa3ac2eaf..0000000000 --- a/samples/tools/TStandalone/src/TInspectorEXE/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -project(TInspectorEXE) - -set (USE_QT ON) -set (EXECUTABLE_PROJECT ON) - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") - -unset (USE_QT) -unset (EXECUTABLE_PROJECT) - -configure_file(${CMAKE_SOURCE_DIR}/adm/templates/${PROJECT_NAME}.vcxproj.user.in - ${${PROJECT_NAME}_BINARY_DIR}/${PROJECT_NAME}.vcxproj.user @ONLY) - diff --git a/samples/tools/TStandalone/src/TInspectorEXE/EXTERNLIB b/samples/tools/TStandalone/src/TInspectorEXE/EXTERNLIB deleted file mode 100644 index dcd41c98f9..0000000000 --- a/samples/tools/TStandalone/src/TInspectorEXE/EXTERNLIB +++ /dev/null @@ -1,8 +0,0 @@ -TKBRep -TKG3d -TKService -TKTInspector -TKXCAF -TKXDESTEP -TKXSBase -TKView diff --git a/samples/tools/TStandalone/src/TreeModel/CMakeLists.txt b/samples/tools/TStandalone/src/TreeModel/CMakeLists.txt deleted file mode 100644 index a3c9117537..0000000000 --- a/samples/tools/TStandalone/src/TreeModel/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -project(TreeModel) - -set (USE_QT ON) -set (TOOLKIT_NAME ON) - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") - -unset (USE_QT) - - diff --git a/samples/tools/TStandalone/src/TreeModel/EXTERNLIB b/samples/tools/TStandalone/src/TreeModel/EXTERNLIB deleted file mode 100644 index 8b13789179..0000000000 --- a/samples/tools/TStandalone/src/TreeModel/EXTERNLIB +++ /dev/null @@ -1 +0,0 @@ - diff --git a/samples/tools/TStandalone/src/VInspector/CMakeLists.txt b/samples/tools/TStandalone/src/VInspector/CMakeLists.txt deleted file mode 100644 index c9b7c9cc45..0000000000 --- a/samples/tools/TStandalone/src/VInspector/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(VInspector) - -set (USE_QT ON) -set (TOOLKIT_NAME ON) - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") - -unset (USE_QT) -unset (TOOLKIT_NAME) diff --git a/samples/tools/TStandalone/src/VInspector/EXTERNLIB b/samples/tools/TStandalone/src/VInspector/EXTERNLIB deleted file mode 100644 index db9a9030bb..0000000000 --- a/samples/tools/TStandalone/src/VInspector/EXTERNLIB +++ /dev/null @@ -1,10 +0,0 @@ -TKBO -TKBRep -TKG3d -TKernel -TKMath -TKTInspectorAPI -TKTreeModel -TKService -TKV3d -TKView diff --git a/samples/tools/TStandalone/src/View/CMakeLists.txt b/samples/tools/TStandalone/src/View/CMakeLists.txt deleted file mode 100644 index ec98bc17f2..0000000000 --- a/samples/tools/TStandalone/src/View/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(View) - -set (USE_QT ON) -set (TOOLKIT_NAME ON) - -OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone") - -unset (USE_QT) - diff --git a/samples/tools/TStandalone/src/View/EXTERNLIB b/samples/tools/TStandalone/src/View/EXTERNLIB deleted file mode 100644 index 2075d7c4a0..0000000000 --- a/samples/tools/TStandalone/src/View/EXTERNLIB +++ /dev/null @@ -1,5 +0,0 @@ -TKernel -TKMath -TKService -TKOpenGl -TKV3d diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 0000000000..e22c877da1 --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,401 @@ +cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) + +set (ADDITIONAL_INLCUDE_DIR_DESCR "Additional directory to be added in the projects include section") +if (NOT DEFINED ADDITIONAL_INLCUDE_DIR) + set (ADDITIONAL_INLCUDE_DIR "" CACHE PATH ${ADDITIONAL_INLCUDE_DIR_DESCR}) + get_filename_component (ADDITIONAL_INLCUDE_DIR "${ADDITIONAL_INLCUDE_DIR}" ABSOLUTE) +else() + file (TO_CMAKE_PATH "${ADDITIONAL_INLCUDE_DIR}" ADDITIONAL_INLCUDE_DIR) + set (ADDITIONAL_INLCUDE_DIR "${ADDITIONAL_INLCUDE_DIR}" CACHE PATH "${ADDITIONAL_INLCUDE_DIR_DESCR}" FORCE) +endif() + +set (ADDITIONAL_DLL_DIR_DESCR "Additional directories that should be included into PATH") +if (NOT DEFINED ADDITIONAL_DLL_DIR) + set (ADDITIONAL_DLL_DIR "" CACHE PATH ${ADDITIONAL_DLL_DIR_DESCR}) + get_filename_component (ADDITIONAL_DLL_DIR "${ADDITIONAL_DLL_DIR}" ABSOLUTE) +else() + file (TO_CMAKE_PATH "${ADDITIONAL_DLL_DIR}" ADDITIONAL_DLL_DIR) + set (ADDITIONAL_DLL_DIR "${ADDITIONAL_DLL_DIR}" CACHE PATH "${ADDITIONAL_DLL_DIR_DESCR}" FORCE) +endif() + +set (CURRENT_DIR "${CMAKE_SOURCE_DIR}") +set (CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/.." CACHE INTERNAL "" FORCE) +set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/adm/cmake") + +set (CMAKE_SUPPRESS_REGENERATION TRUE) + +set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE) + +# macro: include patched file if it exists +macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE) + if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake") + include (${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake) + else() + include (${CMAKE_SOURCE_DIR}/${BEING_INCLUDED_FILE}.cmake) + endif() +endmacro() + +macro (OCCT_INCLUDE_3RDPARTY_PRODUCT USE_PRODUCT PRODUCT_CONFIG_FILE) + if (${USE_PRODUCT}) + OCCT_INCLUDE_CMAKE_FILE ("${PRODUCT_CONFIG_FILE}") + endif (${USE_PRODUCT}) +endmacro() + +# include variable description +OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vardescr") + +# set type of OCCT libraries +if (NOT BUILD_LIBRARY_TYPE) + set (BUILD_LIBRARY_TYPE "Shared" CACHE STRING "${BUILD_LIBRARY_TYPE_DESCR}" FORCE) + SET_PROPERTY(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS Shared Static) +endif() + +if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared") + set (BUILD_SHARED_LIBS ON) + + if (NOT DEFINED BUILD_SHARED_LIBRARY_NAME_POSTFIX) + set (BUILD_SHARED_LIBRARY_NAME_POSTFIX "" CACHE STRING "${BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR}" FORCE) + endif() +else() + unset (BUILD_SHARED_LIBS) + unset (BUILD_SHARED_LIBRARY_NAME_POSTFIX) +endif() + +# the name of the project +project (Inspector) + +if (WIN32) + add_definitions(-DUNICODE) + add_definitions(-D_UNICODE) +endif() + +# include occt macros +OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") + +# Solution folder property +set_property (GLOBAL PROPERTY USE_FOLDERS ON) + +# a single-configuration generator like the Makefile generator defines CMAKE_BUILD_TYPE variable +# check this variable and set if it's required +if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE) # single-configuration generator. + set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) +endif() + +if (BUILD_WITH_DEBUG) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:OCCT_DEBUG>) +endif() + +# install dir of the project +if (NOT DEFINED INSTALL_DIR) + # set default install directory for Windows + if (WIN32 AND NOT DEFINED CMAKE_INSTALL_PREFIX) + set (CMAKE_INSTALL_PREFIX "C:/opencascade-${OCC_VERSION_STRING_EXT}/inspector") + endif() + set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}") +else() + file (TO_CMAKE_PATH "${INSTALL_DIR}" INSTALL_DIR) + set (INSTALL_DIR "${INSTALL_DIR}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE) +endif() + +# choose a variant of the layout of the install paths +if (NOT INSTALL_DIR_LAYOUT) + if (WIN32) + set (INSTALL_DIR_LAYOUT "Windows" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE) + else() + set (INSTALL_DIR_LAYOUT "Unix" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE) + endif() + SET_PROPERTY(CACHE INSTALL_DIR_LAYOUT PROPERTY STRINGS Windows Unix) +endif() + +# check INSTALL_DIR_LAYOUT changes and update INSTALL_DIR_* paths if necessary +if (NOT DEFINED INSTALL_DIR_LAYOUT_PREV) + set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE) +elseif (NOT "${INSTALL_DIR_LAYOUT_PREV}" STREQUAL "${INSTALL_DIR_LAYOUT}") + set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE) + # The structure of install folder should be reset due to changed layout + OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS () + + # Unset INSTALL_DIR_WITH_VERSION on windows + if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Windows") + OCCT_CHECK_AND_UNSET (INSTALL_DIR_WITH_VERSION) + else() + if (NOT DEFINED INSTALL_DIR_WITH_VERSION) + set (INSTALL_DIR_WITH_VERSION OFF CACHE BOOL "${INSTALL_DIR_WITH_VERSION_DESCR}") + endif() + endif() +endif() + +# check CMAKE_INSTALL_PREFIX changes and update INSTALL_DIR if necessary +if (NOT DEFINED CMAKE_INSTALL_PREFIX_PREV) + set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE) +elseif (NOT "${CMAKE_INSTALL_PREFIX_PREV}" STREQUAL "${CMAKE_INSTALL_PREFIX}") + # CMAKE_INSTALL_PREFIX has been changed at previous step + set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE) + + # INSTALL_DIR is required to be updated + set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE) +endif() + +# check INSTALL_DIR changes and update CMAKE_INSTALL_PREFIX if necessary +if (NOT DEFINED INSTALL_DIR_PREV) + set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) +elseif (NOT "${INSTALL_DIR_PREV}" STREQUAL "${INSTALL_DIR}") + # INSTALL_DIR has been changed at previous step + set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) + + # sync CMAKE_INSTALL_PREFIX with INSTALL_DIR + set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) + + # set CMAKE_INSTALL_PREFIX_PREV to avoid the reset of structure of the install folder + set (CMAKE_INSTALL_PREFIX_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) +endif() + +if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") + if (NOT DEFINED INSTALL_DIR_WITH_VERSION_PREV) + set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE) + elseif (NOT "${INSTALL_DIR_WITH_VERSION_PREV}" STREQUAL "${INSTALL_DIR_WITH_VERSION}") + # INSTALL_DIR_WITH_VERSION has been changed at previous step + set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE) + + OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS () + endif() +endif() + +# hide CMAKE_INSTALL_PREFIX from a user +set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) + +set (BIN_LETTER "") +if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + set (BIN_LETTER "d") +elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") + set (BIN_LETTER "i") +endif() + +# Get all used variables: OS_WITH_BIT, COMPILER +OCCT_MAKE_OS_WITH_BITNESS() +OCCT_MAKE_COMPILER_SHORT_NAME() + +# do not define INSTALL_DIR_BIN for win. +# Leave library structure for win: /win64/vc10/bin(d) +if (NOT DEFINED INSTALL_DIR_BIN) + if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") + set (INSTALL_DIR_BIN "bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}") + else() + set (INSTALL_DIR_BIN "${OS_WITH_BIT}/${COMPILER}/bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}") + endif() +endif() + +# define folder contaning all shell/batch scripts +if (NOT DEFINED INSTALL_DIR_SCRIPT) + if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") + set (INSTALL_DIR_SCRIPT "${INSTALL_DIR_BIN}" CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}") + else() + set (INSTALL_DIR_SCRIPT "." CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}") + endif() +endif() + +# place the libraries to /lib folder for unix and leave old structure for windows +if (NOT DEFINED INSTALL_DIR_LIB) + if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") + set (INSTALL_DIR_LIB "lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}") + else() + set (INSTALL_DIR_LIB "${OS_WITH_BIT}/${COMPILER}/lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}") + endif() +endif() + +# OCCT headers: /inc for windows, +# /include/opencascade-7.0.0 for unix +if (NOT DEFINED INSTALL_DIR_INCLUDE) + if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") + set (INSTALL_DIR_INCLUDE "include/opencascade" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}") + if (INSTALL_DIR_WITH_VERSION) + set (INSTALL_DIR_INCLUDE "include/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}" FORCE) + endif() + else() + set (INSTALL_DIR_INCLUDE "inc" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}") + endif() +endif() + +# OCCT resources: /src for windows, +# /share/opencascade-7.0.0/resources for unix +if (NOT DEFINED INSTALL_DIR_RESOURCE) + if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") + set (INSTALL_DIR_RESOURCE "share/opencascade/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}") + if (INSTALL_DIR_WITH_VERSION) + set (INSTALL_DIR_RESOURCE "share/opencascade-${OCC_VERSION_STRING_EXT}/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}" FORCE) + endif() + else() + set (INSTALL_DIR_RESOURCE "src" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}") + endif() +endif() + +# OCCT data +if (NOT DEFINED INSTALL_DIR_DATA) + if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") + set (INSTALL_DIR_DATA "share/opencascade/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}") + if (INSTALL_DIR_WITH_VERSION) + set (INSTALL_DIR_DATA "share/opencascade-${OCC_VERSION_STRING_EXT}/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}" FORCE) + endif() + else() + set (INSTALL_DIR_DATA "data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}") + endif() +endif() + +# include the patched or original list of definitions and flags +OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags") + +OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro") + +if (NOT DEFINED 3RDPARTY_DIR) + set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR}) + get_filename_component (3RDPARTY_DIR "${3RDPARTY_DIR}" ABSOLUTE) +else() + file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR) + set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH "${3RDPARTY_DIR_DESCR}" FORCE) +endif() + +find_package(OpenCASCADE QUIET PATHS "${OpenCASCADE_DIR}" "${OpenCASCADE_INSTALL_PREFIX}" NO_DEFAULT_PATH) +# include OCCT headers +include_directories ("${OpenCASCADE_INCLUDE_DIR}") + +if (NOT OpenCASCADE_FOUND) + message (FATAL_ERROR "coult not find OpenCASCADE, please set OpenCASCADE_DIR variable" ) +else() + set (OpenCASCADE_DIR "${OpenCASCADE_INSTALL_PREFIX}" CACHE PATH "OpenCASCADE directory" FORCE) + message (STATUS "Using OpenCASCADE from \"${OpenCASCADE_DIR}\"" ) +endif() + +set (USE_TCL "${OpenCASCADE_WITH_TCL}") +set (USE_FREETYPE "${OpenCASCADE_WITH_FREETYPE}") +set (USE_FREEIMAGE "${OpenCASCADE_WITH_FREEIMAGE}") +set (USE_GL2PS "${OpenCASCADE_WITH_GL2PS}") +set (USE_TBB "${OpenCASCADE_WITH_TBB}") +set (USE_VTK "${OpenCASCADE_WITH_VTK}") +set (USE_FFMPEG "${OpenCASCADE_WITH_FFMPEG}") +set (USE_GLES2 "${OpenCASCADE_WITH_GLES2}") +set (USE_GLX "${OpenCASCADE_WITH_GLX}") + + +# define CSF variable +OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf") + +# custom definitions (CMakeConfig of OCCT) +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_TCL "adm/cmake/tcl") +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_FREETYPE "adm/cmake/freetype") +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_FREEIMAGE "adm/cmake/freeimage") +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_GL2PS "adm/cmake/gl2ps") +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_TBB "adm/cmake/tbb") +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_VTK "adm/cmake/vtk") +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_FFMPEG "adm/cmake/ffmpeg") +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_GLES2 "adm/cmake/egl") +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_GLES2 "adm/cmake/gles2") +OCCT_INCLUDE_3RDPARTY_PRODUCT (USE_GLX "adm/cmake/glx") + + +OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt") +OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") + +#include (${CMAKE_SOURCE_DIR}/adm/cmake/3rdparty.cmake) + +set (3RDPARTY_DLL_DEB_PATH "${3RDPARTY_DLL_PATH}") + +# build directories +if (SINGLE_GENERATOR) + set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}") + set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}") + set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}") + if (WIN32) + set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}") + endif() +endif() + +set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib") +set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin") +set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib") + +set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi") +set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini") +set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi") + +set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd") +set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind") +set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd") + +if (WIN32) + set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin") + set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini") + set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind") +endif() + +# OCCT tools +# include the patched or original list of tools +# list _TOOLKITS is created foreach tool and contains its toolkits +# list will contain all tools +#if (BUILD_Inspector) + OCCT_MODULES_AND_TOOLKITS (TOOLS "TOOL_TOOLKITS" OCCT_TOOLS) + foreach (OCCT_TOOL ${OCCT_TOOLS}) + list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS}) + endforeach() + + # collect all the headers to /inc/inspector folder + string(TIMESTAMP CURRENT_TIME "%H:%M:%S") + message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT tool header files into ${CMAKE_BINARY_DIR}/inc/inspector ...") + COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOL_TOOLKITS}" "${CMAKE_SOURCE_DIR}/tools" "${INSTALL_DIR_INCLUDE}/inspector") +#endif() + +# include /inc +include_directories (${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}) + +include_directories (${ADDITIONAL_INLCUDE_DIR}) + +if (3RDPARTY_INCLUDE_DIRS) + list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS) + string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}") + message (STATUS "Info: The directories of 3rdparty headers: \n\t${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}") + include_directories (${3RDPARTY_INCLUDE_DIRS}) +endif() + +if (3RDPARTY_LIBRARY_DIRS) + list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS) + string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}") + message (STATUS "Info: The directories of 3rdparty libraries: \n\t${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}") + link_directories (${3RDPARTY_LIBRARY_DIRS}) +endif() + +# include patched toolkit projects or original ones +if (BUILD_TOOL_TOOLKITS) + foreach (BUILD_TOOL_TOOLKIT ${BUILD_TOOL_TOOLKITS}) + OCCT_ADD_SUBDIRECTORY ("tools/${BUILD_TOOL_TOOLKIT}") + endforeach() +endif() + +message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed") + +OCCT_MODULES_AND_TOOLKITS (SAMPLES "SAMPLES_TOOLKITS" OCCT_SAMPLES) + +# patch TInspectorEXE +if (MSVC AND 3RDPARTY_DLL_DIRS) + list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS) + set (3RDPARTY_DLL_DIRS_FOR_PATH "") + + foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS}) + set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}") + endforeach() + + if (ADDITIONAL_DLL_DIR) + foreach (3RDPARTY_DLL_DIR ${ADDITIONAL_DLL_DIR}) + set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}") + endforeach() + endif (ADDITIONAL_DLL_DIR) + + OCCT_MAKE_COMPILER_BITNESS() + set (X_COMPILER_BITNESS "x64") + if ("${COMPILER_BITNESS}" STREQUAL "32") + set (X_COMPILER_BITNESS "Win32") + endif() + + # patch TInspectorEXE + OCCT_CONFIGURE ("adm/templates/TInspectorEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/TInspectorEXE/TInspectorEXE.vcxproj.user") +endif() + +message (STATUS "Info: \(${CURRENT_TIME}\) Inspector configuration files prepared") diff --git a/tools/TInspectorAPI/FILES b/tools/TInspectorAPI/FILES index 63cf600d14..dcb881a01b 100644 --- a/tools/TInspectorAPI/FILES +++ b/tools/TInspectorAPI/FILES @@ -3,3 +3,4 @@ TInspectorAPI_Communicator.hxx TInspectorAPI_PluginParameters.cxx TInspectorAPI_PluginParameters.hxx TInspectorAPI_PreferencesDataMap.hxx +TInspectorAPI_Version.hxx diff --git a/tools/TInspectorAPI/TInspectorAPI_PluginParameters.cxx b/tools/TInspectorAPI/TInspectorAPI_PluginParameters.cxx index baafa43fe6..9393949faf 100644 --- a/tools/TInspectorAPI/TInspectorAPI_PluginParameters.cxx +++ b/tools/TInspectorAPI/TInspectorAPI_PluginParameters.cxx @@ -14,6 +14,7 @@ // commercial license or contractual agreement. #include +#include #if OCC_VERSION_HEX <= 0x060901 IMPLEMENT_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient) @@ -274,6 +275,7 @@ void TInspectorAPI_PluginParameters::ParametersToShape (const TCollection_AsciiS return; anOrientationStr.Split (anOrientationStr.Length() - 1); +#if TINSPECTORAPI_VERSION_HEX > 0x070200 TopAbs_Orientation anOrientation; if (!TopAbs::ShapeOrientationFromString (anOrientationStr.ToCString(), anOrientation)) return; @@ -282,4 +284,7 @@ void TInspectorAPI_PluginParameters::ParametersToShape (const TCollection_AsciiS theShape.Location (aLocation); theShape.Orientation (anOrientation); +#else + (void)theValue; (void)theShape; +#endif } diff --git a/tools/TInspectorAPI/TInspectorAPI_Version.hxx b/tools/TInspectorAPI/TInspectorAPI_Version.hxx new file mode 100644 index 0000000000..88bcc115a3 --- /dev/null +++ b/tools/TInspectorAPI/TInspectorAPI_Version.hxx @@ -0,0 +1,41 @@ +// Copyright (c) 2018 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. + +/*====================================================================== +// +// Purpose: Defines macros identifying current version of Inspector +// The version is equal to current OCCT version and used to support compile compatibility +// to previous OCCT versions interface. +// To compile Inspector with earlier version of OCCT, change version variable here to needed OCCT version. +// +// TINSPECTORAPI_VERSION_MAJOR : (integer) number identifying major version +// TINSPECTORAPI_VERSION_MINOR : (integer) number identifying minor version +// TINSPECTORAPI_VERSION_MAINTENANCE : (integer) number identifying maintenance version +// TINSPECTORAPI_VERSION_HEX : (hex) complete number as hex, two positions per each of major, minor, and patch number +// +//======================================================================*/ + +#ifndef _TInspectorAPI_Version_HeaderFile +#define _TInspectorAPI_Version_HeaderFile + +#include + +// Primary definitions +#define TINSPECTORAPI_VERSION_MAJOR OCC_VERSION_MAJOR +#define TINSPECTORAPI_VERSION_MINOR OCC_VERSION_MINOR +#define TINSPECTORAPI_VERSION_MAINTENANCE 0//OCC_VERSION_MAINTENANCE + +// Derived: complete version as hex (0x0'major'0'minor'0'maintenance') +#define TINSPECTORAPI_VERSION_HEX (TINSPECTORAPI_VERSION_MAJOR << 16 | TINSPECTORAPI_VERSION_MINOR << 8 | TINSPECTORAPI_VERSION_MAINTENANCE) + +#endif /* _TInspectorAPI_Version_HeaderFile */ diff --git a/tools/TInspectorEXE/CMakeLists.txt b/tools/TInspectorEXE/CMakeLists.txt new file mode 100644 index 0000000000..3aa2537e2f --- /dev/null +++ b/tools/TInspectorEXE/CMakeLists.txt @@ -0,0 +1,7 @@ +project(TInspectorEXE) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +set (EXECUTABLE_PROJECT ON) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +unset (EXECUTABLE_PROJECT) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TInspectorEXE/EXTERNLIB b/tools/TInspectorEXE/EXTERNLIB new file mode 100644 index 0000000000..8f800f24cd --- /dev/null +++ b/tools/TInspectorEXE/EXTERNLIB @@ -0,0 +1 @@ +TKTInspector \ No newline at end of file diff --git a/tools/TInspectorEXE/FILES b/tools/TInspectorEXE/FILES new file mode 100644 index 0000000000..68b0c79ed5 --- /dev/null +++ b/tools/TInspectorEXE/FILES @@ -0,0 +1,7 @@ +TInspectorEXE.cxx +TInspectorEXE_OpenFileDialog.cxx +TInspectorEXE_OpenFileDialog.hxx +TInspectorEXE_OpenFileViewModel.cxx +TInspectorEXE_OpenFileViewModel.hxx +TInspectorEXE.qrc +EXTERNLIB diff --git a/tools/TInspectorEXE/PACKAGES b/tools/TInspectorEXE/PACKAGES new file mode 100644 index 0000000000..1736c7de1e --- /dev/null +++ b/tools/TInspectorEXE/PACKAGES @@ -0,0 +1 @@ +TInspectorEXE diff --git a/tools/TInspectorEXE/TInspectorEXE.cxx b/tools/TInspectorEXE/TInspectorEXE.cxx new file mode 100644 index 0000000000..9a65a561b4 --- /dev/null +++ b/tools/TInspectorEXE/TInspectorEXE.cxx @@ -0,0 +1,134 @@ +// 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 + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// ======================================================================= +// function : fileNameInDataDir +// purpose : +// ======================================================================= +TCollection_AsciiString fileNameInDataDir(const TCollection_AsciiString& theEnvironmentDir, + const TCollection_AsciiString& theName) +{ + OSD_Environment anEnvironment(theEnvironmentDir); + + TCollection_AsciiString aFileName = anEnvironment.Value(); + aFileName += TCollection_AsciiString("/") + theName; + + return aFileName; +} + +// ======================================================================= +// function : setPluginSampleDirectory +// purpose : +// ======================================================================= +void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspector_Communicator* theCommunicator, + TInspectorEXE_OpenButton* theButtonControl) +{ + if (theName.IsEqual ("TKDFBrowser")) + { + theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step/screw.step")); + theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step")); + } + else if (theName.IsEqual ("TKShapeView")) + { + theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep")); + theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ")); + } + else if (theName.IsEqual ("TKVInspector")) + { + theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep")); + theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep")); + theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ")); + } +} + +// ======================================================================= +// function : main +// purpose : +// ======================================================================= +int main (int argc, char** argv) +{ +#if QT_VERSION > 0x050000 + TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value(); + if (!aPlugindsDirName.IsEmpty()) + QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins"); +#endif + QApplication anApp (argc, argv); + + std::set aPlugins; + for (int anArgId = 1; anArgId < argc; anArgId++ ) + { + if (!strcmp (argv[anArgId], "dfbrowser")) + aPlugins.insert ("TKDFBrowser"); + + if (!strcmp (argv[anArgId], "shapeview")) + aPlugins.insert ("TKShapeView"); + + if (!strcmp (argv[anArgId], "vinspector")) + aPlugins.insert ("TKVInspector"); + } + NCollection_List aParameters; + + // Create tool communicator + TInspector_Communicator* aCommunicator = TInspectorEXE_OpenFileDialog::Communicator(); + if (!aCommunicator) + { + std::cout << "Communicator can not be created" << std::endl; + return 0; + } + + TInspectorEXE_OpenButton* aButtonControl = new TInspectorEXE_OpenButton (0); + TCollection_AsciiString anActivatedPluginName; + if (aPlugins.empty()) + { + aPlugins.insert("TKDFBrowser"); + aPlugins.insert("TKShapeView"); + aPlugins.insert("TKVInspector"); + + anActivatedPluginName = "TKDFBrowser"; + } + else + anActivatedPluginName = *aPlugins.rbegin(); + + for (std::set::const_iterator aPluginIt = aPlugins.begin(); aPluginIt != aPlugins.end(); aPluginIt++) + { + TCollection_AsciiString aName = *aPluginIt; + aCommunicator->RegisterPlugin (aName); + aCommunicator->Init (aName, aParameters); + setPluginSampleDirectory (aName, aCommunicator, aButtonControl); + } + aCommunicator->Activate (anActivatedPluginName); + + aCommunicator->SetVisible (true); + aCommunicator->SetOpenButton (aButtonControl->StartButton()); + + return anApp.exec(); +} diff --git a/tools/TInspectorEXE/TInspectorEXE.qrc b/tools/TInspectorEXE/TInspectorEXE.qrc new file mode 100644 index 0000000000..5b8eac8911 --- /dev/null +++ b/tools/TInspectorEXE/TInspectorEXE.qrc @@ -0,0 +1,6 @@ + + + icons/folder_open.png + icons/folder_import.png + + diff --git a/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx b/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx new file mode 100644 index 0000000000..618f16a648 --- /dev/null +++ b/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx @@ -0,0 +1,314 @@ +// 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 +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const int FONT_POINT_SIZE = 18; +const int ICON_SIZE = 40; + +const int OPEN_DIALOG_WIDTH = 550; +const int OPEN_DIALOG_HEIGHT = 200; + +const int MARGIN_DIALOG = 4; +const int SPACING_DIALOG = 2; + +TInspector_Communicator* MyCommunicator; + +// ======================================================================= +// function : StartButton +// purpose : +// ======================================================================= +QPushButton* TInspectorEXE_OpenButton::StartButton() +{ + if (!myStartButton) + { + myStartButton = new QPushButton(); + myStartButton->setIcon (QIcon (":folder_open.png")); + connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked())); + } + return myStartButton; +} + +// ======================================================================= +// function : onStartButtonClicked +// purpose : +// ======================================================================= +void TInspectorEXE_OpenButton::onStartButtonClicked() +{ + QPushButton* aButton = (QPushButton*)sender(); + TCollection_AsciiString aPluginName (aButton->objectName().toStdString().c_str()); + if (aPluginName.IsEmpty()) + return; + + QString aDataDirName = QDir::currentPath(); + if (myDefaultDirs.IsBound (aPluginName)) + aDataDirName = myDefaultDirs.Find (aPluginName).ToCString(); + + QString aFileName = TInspectorEXE_OpenFileDialog::OpenFile (0, aDataDirName); + aFileName = QDir().toNativeSeparators (aFileName); + if (!aFileName.isEmpty()) { + QApplication::setOverrideCursor (Qt::WaitCursor); + TInspectorEXE_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data())); + QApplication::restoreOverrideCursor(); + } +} + +// ======================================================================= +// function : changeMargins +// purpose : +// ======================================================================= +void changeMargins (QBoxLayout* theLayout) +{ + theLayout->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG); + theLayout->setSpacing (SPACING_DIALOG); +} + +// ======================================================================= +// function : Constructor +// purpose : +// ======================================================================= +TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName) +: QDialog(theParent), myDataDir (theDataDirName) +{ + setWindowTitle (theDataDirName); + + QVBoxLayout* aDialogLay = new QVBoxLayout (this); + changeMargins (aDialogLay); + + // Title label + QLabel* aTitleLabel = new QLabel (this); + aTitleLabel->setText (tr ("Open File")); + aDialogLay->addWidget (aTitleLabel); + + // Samples View + QGroupBox* aSamplesBox = new QGroupBox (this); + aSamplesBox->setTitle (tr ("Samples")); + aDialogLay->addWidget (aSamplesBox); + QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox); + changeMargins (aSampleLay); + mySamplesView = createTableView (readSampleNames()); + aSampleLay->addWidget (mySamplesView); + + // Select file + QGroupBox* aSelectFileBox = new QGroupBox (this); + aSelectFileBox->setTitle (tr ("Select file")); + aDialogLay->addWidget (aSelectFileBox); + QGridLayout* aSelectFileLay = new QGridLayout (aSelectFileBox); + aSelectFileLay->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG); + + mySelectedName = new QLineEdit (aSelectFileBox); + QCompleter* aCompleter = new QCompleter(); + QFileSystemModel* aFileSystemModel = new QFileSystemModel; + aFileSystemModel->setRootPath (QDir::rootPath()); + aCompleter->setModel (aFileSystemModel); + mySelectedName->setCompleter (aCompleter); + aSelectFileLay->addWidget (mySelectedName, 1, 0); + + QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox); + aSelectFileBtn->setIcon (QIcon (":folder_open.png")); + aSelectFileLay->addWidget (aSelectFileBtn, 1, 1); + + myFolderApplyOpen = new QToolButton (aSelectFileBox); + myFolderApplyOpen->setIcon (QIcon (":folder_import.png")); + myFolderApplyOpen->setIconSize (QSize (ICON_SIZE, ICON_SIZE)); + myFolderApplyOpen->setEnabled (false); + aSelectFileLay->addWidget (myFolderApplyOpen, 0, 2, 2, 1); + + connect (mySelectedName, SIGNAL (textChanged (const QString&)), + this, SLOT (onNameChanged (const QString&))); + connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked())); + connect (myFolderApplyOpen, SIGNAL (clicked()), this, SLOT (onApplySelectClicked())); + + resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT); +} + +// ======================================================================= +// function : OpenFile +// purpose : +// ======================================================================= +QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QString& theDataDirName) +{ + QString aFileName; + TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog(theParent, theDataDirName); + if (aDialog->exec() == QDialog::Accepted) + aFileName = aDialog->GetFileName(); + + return aFileName; +} + +// ======================================================================= +// function : Communicator +// purpose : +// ======================================================================= +TInspector_Communicator* TInspectorEXE_OpenFileDialog::Communicator() +{ + if (!MyCommunicator) + MyCommunicator = new TInspector_Communicator(); + return MyCommunicator; +} + +// ======================================================================= +// function : onSampleSelectionChanged +// purpose : +// ======================================================================= +void TInspectorEXE_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected, + const QItemSelection&) +{ + QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender(); + if (!aSelectionModel) + return; + if (theSelected.isEmpty()) + return; + + QModelIndex anIndex = theSelected.first().indexes().first(); + if (!anIndex.isValid()) + return; + + myFileName = aSelectionModel->model()->data (anIndex, Qt::ToolTipRole).toString(); + accept(); +} + +// ======================================================================= +// function : onNameChanged +// purpose : +// ======================================================================= +void TInspectorEXE_OpenFileDialog::onNameChanged (const QString& theText) +{ + QFileInfo aFileInfo (theText); + bool anExists = aFileInfo.exists() && aFileInfo.isFile(); + myFolderApplyOpen->setEnabled (anExists); +} + +// ======================================================================= +// function : onSelectClicked +// purpose : +// ======================================================================= +void TInspectorEXE_OpenFileDialog::onSelectClicked() +{ + QString anEnteredPath; + QString aDirName = mySelectedName->text(); + if (!aDirName.isEmpty()) + { + QDir aDir (aDirName); + if (aDir.exists()) + anEnteredPath = aDirName; + } + + QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath); + + if (aFileName.isEmpty()) + return; // do nothing, left the previous value + + + myFileName = aFileName; + accept(); +} + +// ======================================================================= +// function : onApplySelectClicked +// purpose : +// ======================================================================= +void TInspectorEXE_OpenFileDialog::onApplySelectClicked() +{ + myFileName = mySelectedName->text(); + accept(); +} + +// ======================================================================= +// function : createTableView +// purpose : +// ======================================================================= +QTableView* TInspectorEXE_OpenFileDialog::createTableView (const QStringList& theFileNames) +{ + QTableView* aTableView = new QTableView (this); + aTableView->setFrameStyle (QFrame::NoFrame); + QPalette aPalette = aTableView->viewport()->palette(); + QColor aWindowColor = aPalette.color (QPalette::Window); + aPalette.setBrush (QPalette::Base, aWindowColor); + aTableView->viewport()->setPalette (aPalette); + + aTableView->horizontalHeader()->setVisible (false); + aTableView->verticalHeader()->setVisible (false); + aTableView->setGridStyle (Qt::NoPen); + aTableView->setModel (createModel (theFileNames)); + aTableView->setItemDelegateForRow (0, new TInspectorEXE_OpenFileItemDelegate (aTableView, + aPalette.color (QPalette::Highlight))); + aTableView->viewport()->setAttribute (Qt::WA_Hover); + int aCellHeight = ICON_SIZE + aTableView->verticalHeader()->defaultSectionSize(); + aTableView->setRowHeight (0, aCellHeight); + int aScrollHeight = aTableView->horizontalScrollBar()->sizeHint().height(); + aTableView->setMinimumHeight (aCellHeight + aScrollHeight); + QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aTableView->model()); + connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), + this, SLOT (onSampleSelectionChanged (const QItemSelection&, const QItemSelection&))); + aTableView->setSelectionModel (aSelectionModel); + + return aTableView; +} + +// ======================================================================= +// function : createModel +// purpose : +// ======================================================================= +QAbstractItemModel* TInspectorEXE_OpenFileDialog::createModel (const QStringList& theFileNames) +{ + TInspectorEXE_OpenFileViewModel* aModel = new TInspectorEXE_OpenFileViewModel (this); + aModel->Init (theFileNames); + return aModel; +} + +// ======================================================================= +// function : readSampleNames +// purpose : +// ======================================================================= +QStringList TInspectorEXE_OpenFileDialog::readSampleNames() +{ + QStringList aNames; + + QDir aDir(myDataDir); + aDir.setSorting(QDir::Name); + + QFileInfoList aDirEntries = aDir.entryInfoList(); + for (int aDirId = 0; aDirId < aDirEntries.size(); ++aDirId) + { + QFileInfo aFileInfo = aDirEntries.at(aDirId); + if (aFileInfo.isFile()) + aNames.append (aFileInfo.absoluteFilePath()); + } + return aNames; +} diff --git a/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx b/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx new file mode 100644 index 0000000000..4afa4491cf --- /dev/null +++ b/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx @@ -0,0 +1,142 @@ +// 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 TInspectorEXE_OpenFileDialog_H +#define TInspectorEXE_OpenFileDialog_H + +#include +#include + +#include +#include +#include +#include +#include + +#include + +class TInspector_Communicator; + +class QAbstractItemModel; +class QLineEdit; +class QPushButton; +class QTableView; +class QToolButton; +class QWidget; + +//! \class TInspectorEXE_OpenButton +//! Class that contains push button and the button processing. It obtains a file name from the default or current +//! directory and gives the name into TInspector communicator +//! Object name of the button is the name of the plugin to get the default directory, or the current directory is used. +class TInspectorEXE_OpenButton : public QObject +{ + Q_OBJECT + +public: + + //! Constructor + TInspectorEXE_OpenButton (QObject* theParent) : QObject (theParent), myStartButton (0) {} + + //! Destructor + virtual ~TInspectorEXE_OpenButton() {} + + //! Returns the start button, if this is the first call, it creates the button and connect it to the slot + QPushButton* StartButton(); + + //! Sets the default directory of plugin. + void SetPluginDir (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theDefaultDir) + { myDefaultDirs.Bind (thePluginName, theDefaultDir); } + +private slots: + + //! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator + void onStartButtonClicked(); + +private: + + QPushButton* myStartButton; //!< processed button + NCollection_DataMap myDefaultDirs; //!< plugins default directories +}; + +//! \class TInspectorEXE_OpenFileDialog +//! Control that contains table view of samples and line to select a file name from other directory. +//! Click on element of samples table view calls this sample opening else after entering(or opening) file name +//! the import becomes active. Click on the button will open selected file if it is possible +class TInspectorEXE_OpenFileDialog : public QDialog +{ + Q_OBJECT +private: + + //! Constructor + TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName); + +public: + + //! Destructor + virtual ~TInspectorEXE_OpenFileDialog() Standard_OVERRIDE {} + + //! Opens this file dialog using for samples view the given directory and try to open new file + //! \param theParent a parent for the new dialog + //! \param theDataDirName path to default samples directory + //! \returns a file name from the open file dialog + static QString OpenFile (QWidget* theParent, const QString& theDataDirName); + + //! Returns selection name from the dialog + QString GetFileName() const { return myFileName; } + + //! Returns communicator, if this is the first call, create a communicator instance + static TInspector_Communicator* Communicator(); + +private slots: + + //! Stores name of selected sample file + void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected); + + //! Updates enabling state of Open file button, it is enabled if the file by the entered path exists + //! \param theText a file name text in line edit + void onNameChanged (const QString& theText); + + //! Open file dialog to select a file name. Fills file name line, enable import button + void onSelectClicked(); + + //! Accepts open file dialog + void onApplySelectClicked(); + +private: + + //! Creates view of file names in samples directory + //! \param theFileNames a container of names + //! \return table view + QTableView* createTableView (const QStringList& theFileNames); + + //! Creates view model and fills it by the file names + //! \param theFileNames a container of names + //! \return model + QAbstractItemModel* createModel (const QStringList& theFileNames); + + //! Generates container of file names in samples directory + //! \return container of names + QStringList readSampleNames(); + +private: + + QString myDataDir; //!< samples directory + QString myFileName; //!< result file name + QTableView* mySamplesView; //! + +#include +#include +#include +#include +#include +#include + +const int ICON_SIZE = 40; + +// ======================================================================= +// function : paint +// purpose : +// ======================================================================= +void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption, + const QModelIndex& theIndex) const +{ + // highlight cell + if (theOption.state & QStyle::State_MouseOver) + thePainter->fillRect (theOption.rect, myColor); + + // action icon for all indices before the last one + QIcon anIcon (":/icons/folder_import.png"); + QSize anIconSize (ICON_SIZE, ICON_SIZE); + int aDX = (theOption.rect.width() - anIconSize.width()) / 2; + int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin); + thePainter->drawPixmap (QRect (theOption.rect.left() + aDX, + theOption.rect.top() + aMargin, + anIconSize.width(), + anIconSize.height()), + anIcon.pixmap(anIconSize.width(), anIconSize.height())); + // default paint + QItemDelegate::paint (thePainter, theOption, theIndex); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void TInspectorEXE_OpenFileViewModel::Init (const QStringList& theValues) +{ + myValues = theValues; +} + +// ======================================================================= +// function : data +// purpose : +// ======================================================================= +QVariant TInspectorEXE_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const +{ + switch (theRole) + { + case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName(); + case Qt::ToolTipRole: return myValues[theIndex.column()]; + case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter); + default: break; + } + return QVariant(); +} diff --git a/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx b/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx new file mode 100644 index 0000000000..42b6604e07 --- /dev/null +++ b/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx @@ -0,0 +1,98 @@ +// 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 TInspectorEXE_OpenFileViewModel_H +#define TInspectorEXE_OpenFileViewModel_H + +#include + +#include +#include +#include +#include +#include + +class QObject; +class QPainter; + +//! \class TInspectorEXE_OpenFileItemDelegate +//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button +class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate +{ + +public: + + //! Constructor + TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor) + : QItemDelegate (theParent), myColor(theHighlightColor) {} + + //! Destructor + virtual ~TInspectorEXE_OpenFileItemDelegate() {} + + //! Draw an icon in the cell + //! \param thePainter a painter + //! \param theOption a paint options + //! \param theIndex a view index + virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption, + const QModelIndex& theIndex) const Standard_OVERRIDE; + +private: + + QColor myColor; //!< highlight color +}; + +//! \class TInspectorEXE_OpenFileViewModel +//! Table model that visualizes container of string values (file names) +//! Table orientation is horizontal, it has 1 row, number of columns equals to number of values +class TInspectorEXE_OpenFileViewModel : public QAbstractTableModel +{ + +public: + + //! Constructor + TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {} + + //! Destructor + virtual ~TInspectorEXE_OpenFileViewModel() {} + + //! Store values + //! \param theValues a container of values to fill model + void Init (const QStringList& theValues); + + //! Returns content of the model index for the given role, it is obtained from internal container of values + //! It returns value only for DisplayRole. + //! \param theIndex a model index + //! \param theRole a view role + //! \return value intepreted depending on the given role + virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE; + + //! Returns number of rows + //! \param theParent an index of the parent item + //! \return an integer value + virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE + { (void)theParent; return 1; } + + //! Returns number of columns + //! \param theParent an index of the parent item + //! \return an integer value + virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE + { (void)theParent; return myValues.size(); } + +private: + + QStringList myValues; //!< file names +}; + +#endif diff --git a/tools/TInspectorEXE/icons/folder_export.png b/tools/TInspectorEXE/icons/folder_export.png new file mode 100644 index 0000000000..5f45f993dc Binary files /dev/null and b/tools/TInspectorEXE/icons/folder_export.png differ diff --git a/tools/TInspectorEXE/icons/folder_import.png b/tools/TInspectorEXE/icons/folder_import.png new file mode 100644 index 0000000000..02743abe9b Binary files /dev/null and b/tools/TInspectorEXE/icons/folder_import.png differ diff --git a/tools/TInspectorEXE/icons/folder_open.png b/tools/TInspectorEXE/icons/folder_open.png new file mode 100644 index 0000000000..b0a139ebc6 Binary files /dev/null and b/tools/TInspectorEXE/icons/folder_open.png differ diff --git a/tools/TKToolsDraw/EXTERNLIB b/tools/TKToolsDraw/EXTERNLIB index c2788c3da2..62a89ecedf 100644 --- a/tools/TKToolsDraw/EXTERNLIB +++ b/tools/TKToolsDraw/EXTERNLIB @@ -1,3 +1,4 @@ +TKDraw TKDCAF TKTInspector TKTInspectorAPI diff --git a/tools/TKView/EXTERNLIB b/tools/TKView/EXTERNLIB index 530f29276b..b5f64414c0 100644 --- a/tools/TKView/EXTERNLIB +++ b/tools/TKView/EXTERNLIB @@ -1,3 +1,4 @@ +TKG3d TKernel TKMath TKService diff --git a/tools/View/View_Window.cxx b/tools/View/View_Window.cxx index 2976b9cc9d..98edc7485c 100644 --- a/tools/View/View_Window.cxx +++ b/tools/View/View_Window.cxx @@ -19,6 +19,8 @@ #include +#include + #include #include #include @@ -156,6 +158,7 @@ void View_Window::onCheckedStateChanged (int theActionId, bool theState) // ======================================================================= void View_Window::onViewContextMenuRequested (const QPoint& thePosition) { +#if TINSPECTORAPI_VERSION_HEX > 0x070200 QMenu* aMenu = new QMenu (this); QMenu* anOrientationSubMenu = aMenu->addMenu ("Set View Orientation"); @@ -169,6 +172,9 @@ void View_Window::onViewContextMenuRequested (const QPoint& thePosition) QPoint aPoint = myView->mapToGlobal (thePosition); aMenu->exec (aPoint); +#else + (void)thePosition; +#endif } // ======================================================================= @@ -177,6 +183,7 @@ void View_Window::onViewContextMenuRequested (const QPoint& thePosition) // ======================================================================= void View_Window::onSetOrientation() { +#if TINSPECTORAPI_VERSION_HEX > 0x070200 QAction* anAction = (QAction*)(sender()); TCollection_AsciiString anOrientationStr (anAction->text().toStdString().c_str()); @@ -192,6 +199,7 @@ void View_Window::onSetOrientation() aView->SetProj (anOrientationType); aView->FitAll(); aView->Redraw(); +#endif } // ======================================================================= diff --git a/tools/adm/cmake/occt_toolkit_prepare_tool.cmake b/tools/adm/cmake/occt_toolkit_prepare_tool.cmake new file mode 100644 index 0000000000..86e6851fee --- /dev/null +++ b/tools/adm/cmake/occt_toolkit_prepare_tool.cmake @@ -0,0 +1,5 @@ +if ("${TARGET_FOLDER}" STREQUAL "") + set (CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/..") +endif("${TARGET_FOLDER}" STREQUAL "") + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)