Commit 92a22de6 authored by promayon's avatar promayon
Browse files

NEW CEP architecture step #1


git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@733 ec899d31-69d1-42ba-9299-647d76f65fb3
parent ba6ef4d8

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
#
# CamiTK CMakeLists
# CamiTK Open Source CMakeLists
#
# WARNING!
# CamiTK macros (component_extension, application_extension...) use GLOB to collect a
# list of source files from your source tree, which means that if no CMakeLists.txt file changes
# when a new source file is added or removed to your project then the generated build system
# cannot know when to ask CMake to regenerate.
# => DO NOT FORGET to regenerate CMake in case you add/remove a source file to your project
# all CMake project names and variables should be in uppercase
project(CAMITKSDK)
cmake_minimum_required(VERSION 2.6)
# Find Qt (Qt4 without Qt3 support!)
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
set (QT_USE_QT3SUPPORT OFF)
# Find VTK
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
# Configure CamiTK
# update module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
# include CamiTK Internal Build environment
include(CamiTKCoreBuild)
# include CamiTK variables
include(CamiTKVariables)
# include CamiTK generic macros from CMAKE_MODULE_PATH directory
include(CamiTKMacros)
# include CamiTK test macros
include(CamiTKTestMacros)
# include CamiTK log configuration
include(CamiTKLog)
# include CamiTK auto-documentation generation
include(CamiTKApiDoc)
# include CamiTK package generation
include(CamiTKPackaging)
# enables to specify which target to launch to MSVC
include(CreateLaunchers)
# Eeach library compiled in Debug mode are suffixed with an D
set(CMAKE_DEBUG_POSTFIX "D" CACHE TYPE STRING)
# By default, validate all projects are build in the build/bin directory (no subfolders).
# Note that, subfolders for actions / components are added later.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CAMITK_BIN_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CAMITK_BIN_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CAMITK_BIN_DIR})
# Remove the Debug, Release subfolders in build/bin, natively created with Visual Studio
if ( ${CMAKE_GENERATOR} MATCHES "Visual Studio") # MSVC compiler
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CAMITK_BIN_DIR} CACHE TYPE STRING)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CAMITK_BIN_DIR} CACHE TYPE STRING)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CAMITK_BIN_DIR} CACHE TYPE STRING)
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
endif(${CMAKE_GENERATOR} MATCHES "Visual Studio")
# Specific to SDK: control the version (major, minor, default patch and )
set(CAMITK_VERSION_MAJOR "3")
set(CAMITK_VERSION_MINOR "1")
set(CAMITK_VER_NICKNAME "sapphire") # blue, sapphire, azure, indigo, iris, Teal, cyan, turquoise, denim, celeste, zaffre, glaucous, ultramarine, cerulean
set(CAMITK_VERSION_PATCH "1") # patch version for packaging, change when appropriate
# Create the Xml data for Project.xml description, fyi store in the global variable CAMITK_XML_PROJECT_DESCRIPTION
camitk_sub_project_init()
# Specific to SDK: this is the SDK build
set(CAMITK_SDK_BUILD TRUE)
# add all subprojects
add_subdirectory(cmake) # rules for cmake install
add_subdirectory(core)
camitk_add_subdirectory(tools)
camitk_add_subdirectory(components)
camitk_add_subdirectory(actions)
camitk_add_subdirectory(applications)
# Specific to SDK: first compile the SDK (it looks like a CEP but is sooooo special...)
add_subdirectory(sdk)
# Validate and write down the Project.xml file
# This file contains all the CamiTK project description with subprojects and their CMake target dependencies
# This file is needed for CDash to correctly update the Dashboard accordingly to the project
# Thus, CDash continuous integration dashboard is automatically updated when adding a new extension
# to CamiTK, using the corresponding macro
camitk_sub_project_validate(${CMAKE_BINARY_DIR})
#-- This is a CEP set...
set(CAMITK_EXTENSION_PROJECT_SET TRUE CACHE BOOL "Is this a CamiTK Extension Project Set?")
# For Microsoft Visual C++, sets the default application to imp for the "ALL_BUILD" project
# (i.e. launches imp when we you click on "Debug" or "Start Without Debugging" button on Visual)
# In addition, but not the least, sets the environment to the debug dll directory for VTK (and ITK)
# to solve the dll incompatibility between debug and relase version of QVTK.dll and ITKCommon.dll
if ( MSVC )
create_default_target_launcher(
application-imp
RUNTIME_LIBRARY_DIRS "%VTK_DIR%/bin/$(OutDir)" "%ITK_DIR%/bin/$(OutDir)"
)
endif( MSVC )
# ...composed by the following CamiTK Extension Projects
add_subdirectory(imaging)
add_subdirectory(modeling)
\ No newline at end of file
camitk_extension(
ACTION_EXTENSION
DEFAULT
DEFINES COMPILE_LUT_ACTION_API)
\ No newline at end of file
camitk_extension(
ACTION_EXTENSION
DEFAULT
DEFINES COMPILE_MULTIPICKING_ACTION_API
INSTALL_ALL_HEADERS)
\ No newline at end of file
camitk_extension(
ACTION_EXTENSION
DEFAULT
DEFINES COMPILE_RECONSTRUCTION_ACTION_API)
\ No newline at end of file
camitk_extension(
ACTION_EXTENSION
DEFAULT
)
\ No newline at end of file
camitk_extension(
ACTION_EXTENSION
DEFAULT
NEEDS_QTXML
DEFINES COMPILE_VOLUME_RENDERING_ACTION_API)
camitk_extension(ACTION_EXTENSION
DEFAULT
DEFINES COMPILE_BASIC_MESH_ACTION_API)
\ No newline at end of file
camitk_extension(
ACTION_EXTENSION
DEFAULT
DEFINES COMPILE_BASIC_TOPOLOGY_ACTION_API)
\ No newline at end of file
camitk_extension(
ACTION_EXTENSION
DEFAULT
NEEDS_COMPONENT_EXTENSION vtkmesh
DEFINES COMPILE_MESHPROCESSING_ACTION_API
)
......@@ -4,7 +4,7 @@
# To add an application, just add a subdirectory (the application name is the
# directory name). Add all your code there and a text file called
# CMakeLists.txt
# In your CMakeLists.txt, use the application_extension() macro apropriately
# In your CMakeLists.txt, use the camitk_application() macro apropriately
# Find applications
get_subdirectories(APPLICATIONS_LIST)
......
application_extension(DEFAULT)
\ No newline at end of file
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
// -- Application ObjectController stuff
#include "PropertyUI.h"
using namespace camitk;
// -- QT stuff
#include <QTextEdit>
#include <QComboBox>
#include <QVector3D>
PropertyUI::PropertyUI(QWidget *parent) : QWidget(parent) {
// create the UI
theController = new ObjectController(this, ObjectController::TREE );
QPushButton *applyButton = new QPushButton(tr("&Apply"));
connect(applyButton, SIGNAL(clicked()), theController, SLOT(apply()));
connect(applyButton, SIGNAL(clicked()), this, SLOT(print()));
QPushButton *resetButton = new QPushButton(tr("&Revert"));
connect(resetButton, SIGNAL(clicked()), theController, SLOT(revert()));
connect(resetButton, SIGNAL(clicked()), this, SLOT(print()));
QPushButton *printButton = new QPushButton(tr("&Print"));
connect(printButton, SIGNAL(clicked()), this, SLOT(print()));
QComboBox *comboBox = new QComboBox;
comboBox->addItem("Tree");
comboBox->addItem("GroupBox");
comboBox->addItem("Button");
connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeViewMode(QString)));
// plug the console
console = new QTextEdit();
console->setReadOnly(true);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(applyButton);
buttonLayout->addWidget(resetButton);
buttonLayout->addWidget(printButton);
buttonLayout->addWidget(comboBox);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(theController);
mainLayout->addLayout(buttonLayout);
mainLayout->addWidget(console);
setLayout(mainLayout);
}
void PropertyUI::setPropertyObject(QObject* object) {
theController->setObject(object);
print(); // to see the initial values
}
void PropertyUI::changeViewMode(QString mode) {
if (mode=="Tree")
theController->setViewMode(ObjectController::TREE);
else
if (mode=="GroupBox")
theController->setViewMode(ObjectController::GROUPBOX);
else
if (mode=="Button")
theController->setViewMode(ObjectController::BUTTON);
}
QString PropertyUI::propertyToString(QString name, QVariant value) {
QString valueInString = "<li>" + name + ": ";
switch (value.userType()) {
case QMetaType::QVector3D: {
QVector3D val = value.value<QVector3D>();
valueInString += "QVector3D(" + QString::number(val.x()) + "," + QString::number(val.y()) + "," + QString::number(val.z()) + ")";
}
break;
case QMetaType::QColor:
valueInString += "<font color=" + value.toString() + ">" + value.toString() + "</font>";
break;
default:
valueInString += value.toString();
break;
}
valueInString += "</li>";
return valueInString;
}
void PropertyUI::print() {
QString toString;
toString += "Static Properties:<ul>";
const QMetaObject * metaObject = theController->object()->metaObject();
// check all static properties
for (int idx = metaObject->propertyOffset(); idx < metaObject->propertyCount(); idx++) {
QMetaProperty metaProperty = metaObject->property(idx);
QString propName = metaProperty.name();
QVariant propValue = metaProperty.read(theController->object());
// special case for QVariantMap
if (metaProperty.userType() == QMetaType::QVariantMap) {
toString += propertyToString(propName, "group of properties");
toString += "<ul>";
// print the subproperties
QMapIterator<QString, QVariant> it(propValue.toMap());
while (it.hasNext()) {
it.next();
toString += propertyToString(it.key(), it.value());
}
toString += "</ul>";
}
else {
toString += propertyToString(propName, propValue);
}
}
toString += "</ul>";
// check all dynamic properties
toString += "<hr/>Dynamic Properties:<ul>";
QList<QByteArray> dynProp = theController->object()->dynamicPropertyNames();
for ( int idx = 0; idx < dynProp.size(); ++idx ) {
toString += propertyToString(QString ( dynProp.at ( idx ) ), theController->object()->property ( dynProp.at ( idx ) ));
}
toString += "</ul>";
// display
console->setHtml(toString);
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef FORM_H
#define FORM_H
// -- QT stuff
#include <QWidget>
#include <QTextEdit>
// -- Core stuff classes
#include <ObjectController.h>
/** A simple user interface to interact with ObjectController.
* The tricky part of this class is in the print() method (it prints
* all static and dynamic property of any QObject in rich text and
* take into account QVariantMap as property group)
*/
class PropertyUI : public QWidget {
Q_OBJECT
public:
PropertyUI(QWidget *parent = 0);
/// set the property object to edit
void setPropertyObject(QObject *);
private slots:
/// called when the user wants to dynamically change the view mode of the object controller
void changeViewMode(QString);
/// print the currently edited object
void print();
private :
/// return a rich text QString that shows the name and property value
QString propertyToString(QString name, QVariant value);
/// the main object in the UI
camitk::ObjectController *theController;
/// to see the property values
QTextEdit * console;
};
#endif
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
// -- Application ObjectController stuff
#include "TestClass.h"
// -- CamiTK stl stuff
#include <iostream>
// -- QT stuff
#include <QEvent>
#include <QLocale>
#include <QKeySequence>
#include <QRect>
TestClass::TestClass() : QObject() {
// set a new dynamic property
backgroundColor = QColor("wheat");
setProperty("backgroundColor", backgroundColor);
// install a filter to get the modification of the dynamic properties
installEventFilter(this);
// set initial values
myBool = false;
radius = 2.0*3.141592653589;
position = QVector3D(-1.0, 2.0, -4.5);
name = "testing!";
color = QColor("forestgreen");
font = QFont("Times" , 14, QFont::Bold);
time = QTime::currentTime();
yourForm = FEELING_GREAT;
onWindows = true;
someNumber = 42; // the answer!
propertyGroup.insert("subProperty1", "it works!");
propertyGroup.insert("subProperty2", QVector3D(3.0, 4.0, 5.0));
propertyGroup.insert("locale", QLocale::system());
propertyGroup.insert("date", QDate::currentDate());
propertyGroup.insert("keySeq", QKeySequence(Qt::CTRL + Qt::Key_C));
propertyGroup.insert("char", QChar('s'));
propertyGroup.insert("point", QPoint(28, 9));
propertyGroup.insert("rect", QRect(20.0, 10.0, 19., 69.));
}
TestClass::~TestClass() {
}
void TestClass::setBool(bool newValue) {
myBool = newValue;
}
void TestClass::setPosition( QVector3D newValue) {
position = newValue;
}
void TestClass::setLevel( StateLevel newValue) {
yourForm = newValue;
}
void TestClass::setName(const QString &newValue) {
name = newValue;
}
void TestClass::setRadius(double newValue) {
radius = newValue;
}
void TestClass::setColor(const QColor &newValue) {
color = newValue;
}
void TestClass::setFont(const QFont & newValue) {
font = newValue;
}
void TestClass::setTime(const QTime &newValue) {
time = newValue;
}
void TestClass::setGroup(const QVariantMap &newValue) {
propertyGroup = newValue;
}
// ---------------------- event ----------------------------
bool TestClass::event(QEvent * e) {
if (e->type() == QEvent::DynamicPropertyChange) {
e->accept();
QDynamicPropertyChangeEvent *chev = dynamic_cast<QDynamicPropertyChangeEvent *>(e);
if (! chev)
return false;
backgroundColor = property("backgroundColor").value<QColor>();
return true;
}
return QObject::event(e);
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef TESTCLASS_H_
#define TESTCLASS_H_
// -- QT stuff
#include <QObject>
#include <QVariant>
#include <QVector3D>
#include <QColor>
#include <QFont>
#include <QTime>
/** A little class with lots of properties.
* There are static properties declared with Q_PROPERTY and
* dynamic properties created at run-time.
*/
class TestClass : public QObject
{
Q_OBJECT
/// declaration of a boolean property
Q_PROPERTY( bool myBool READ getBool WRITE setBool );
/// declaration of a double property
Q_PROPERTY(double radius READ getRadius WRITE setRadius)
/// A QVector3D property
Q_PROPERTY(QVector3D position READ getPosition WRITE setPosition );
/// declaration of a QString property
Q_PROPERTY(QString name READ getName WRITE setName)
/// declaration of a static QColor property (see also backgroundColor property)
Q_PROPERTY(QColor color READ getColor WRITE setColor)
/// declaration of a QFont property
Q_PROPERTY(QFont font READ getFont WRITE setFont)
/// declaration of a QTime property
Q_PROPERTY(QTime time READ getTime WRITE setTime)
/// declaration of an enum property (a property which value is in a particular set)
Q_PROPERTY( StateLevel yourForm READ getLevel WRITE setLevel )
/// if you declare a enum property, you also have to declare a Q_ENUMS
Q_ENUMS( StateLevel )
/** Group some properties in a specific map. Pro: this allows to show a hierarchy in the properties.
* Cons: you have to manage the map yourself.
* Note that the only supported type of map is QVariantMap which is a typedef
* of QMap<QString, QVariant>.
* In this group all other misc type of supported properties are demonstrated.
* see QVariant
*/
Q_PROPERTY(QVariantMap propertyGroup READ getGroup WRITE setGroup)
/// this is to test a readonly property
Q_PROPERTY(bool onWindows READ getOnWindows)
/// declaration of a readonly int property