Computer Assited Medical Intervention Tool Kit  version 5.0
canvas_typed/mainwindow.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 **
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 **
8 ** This file is part of a Qt Solutions component.
9 **
10 ** You may use this file under the terms of the BSD license as follows:
11 **
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
14 ** met:
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
20 ** distribution.
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
24 ** permission.
25 **
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37 **
38 ****************************************************************************/
39 
40 #ifndef MAINWINDOW_H
41 #define MAINWINDOW_H
42 
43 #include <QtGui/QMainWindow>
44 #include <QtCore/QMap>
45 #include "qtcanvas.h"
46 
47 class QtProperty;
48 
49 class CanvasView : public QtCanvasView {
50  Q_OBJECT
51 public:
52  CanvasView(QWidget* parent = 0)
53  : QtCanvasView(parent), moving(0) { }
54  CanvasView(QtCanvas* canvas, QWidget* parent = 0)
55  : QtCanvasView(canvas, parent), moving(0) { }
56 signals:
57  void itemClicked(QtCanvasItem* item);
58  void itemMoved(QtCanvasItem* item);
59 protected:
60  void contentsMousePressEvent(QMouseEvent* event);
61  void contentsMouseDoubleClickEvent(QMouseEvent* event);
62  void contentsMouseMoveEvent(QMouseEvent* event);
63 private:
64  void handleMouseClickEvent(QMouseEvent* event);
65  QPoint moving_start;
67 };
68 
69 class MainWindow : public QMainWindow {
70  Q_OBJECT
71 public:
72  MainWindow(QWidget* parent = 0);
73 
74 private slots:
75  void newRectangle();
76  void newEllipse();
77  void newLine();
78  void newText();
79  void deleteObject();
80  void clearAll();
81  void fillView();
82 
83  void itemClicked(QtCanvasItem* item);
84  void itemMoved(QtCanvasItem* item);
85  void valueChanged(QtProperty* property, double value);
86  void valueChanged(QtProperty* property, const QString& value);
87  void valueChanged(QtProperty* property, const QColor& value);
88  void valueChanged(QtProperty* property, const QFont& value);
89  void valueChanged(QtProperty* property, const QPoint& value);
90  void valueChanged(QtProperty* property, const QSize& value);
91 private:
92 
97  void addProperty(QtProperty* property, const QString& id);
98  void updateExpandState();
99 
100  QAction* deleteAction;
101 
108 
113  QMap<QtProperty*, QString> propertyToId;
114  QMap<QString, QtProperty*> idToProperty;
115  QMap<QString, bool> idToExpanded;
116 };
117 
118 #endif
QtCanvasLine
Definition: canvas_typed/qtcanvas.h:702
QtAbstractPropertyManager::addProperty
QtProperty * addProperty(const QString &name=QString())
Definition: qtpropertybrowser.cpp:748
MainWindow::colorManager
class QtColorPropertyManager * colorManager
Definition: canvas_typed/mainwindow.h:104
MainWindow::variantManager
class QtVariantPropertyManager * variantManager
Definition: canvas_variant/mainwindow.h:101
QtCanvasItem::setX
void setX(double a)
Definition: canvas_typed/qtcanvas.h:84
QtCanvasEllipse::width
int width() const
Definition: canvas_typed/qtcanvas.cpp:4262
QtCanvasEllipse::height
int height() const
Definition: canvas_typed/qtcanvas.cpp:4269
MainWindow::doubleManager
class QtDoublePropertyManager * doubleManager
Definition: canvas_typed/mainwindow.h:102
QtPointPropertyManager
The QtPointPropertyManager provides and manages QPoint properties.
Definition: qtpropertymanager.h:424
CAMITK_WARNING
#define CAMITK_WARNING(MSG)
Log for warning verbosity (the most common one) Will appear by default.
Definition: Log.h:266
QtTreePropertyBrowser
The description of this class will come soon !
Definition: qttreepropertybrowser.h:60
MainWindow::addProperty
void addProperty(QtProperty *property, const QString &id)
Definition: canvas_typed/mainwindow.cpp:372
QtCanvas::width
int width() const
Definition: canvas_typed/qtcanvas.h:250
MainWindow::addRectangle
QtCanvasItem * addRectangle()
Definition: canvas_typed/mainwindow.cpp:220
QtCanvasItem::show
void show()
Definition: canvas_typed/qtcanvas.cpp:1816
QtSizePropertyManager::subIntPropertyManager
QtIntPropertyManager * subIntPropertyManager() const
Definition: qtpropertymanager.cpp:3328
QtCanvasItemList
QList< QtCanvasItem * > QtCanvasItemList
Definition: canvas_typed/qtcanvas.h:60
MainWindow::clearAll
void clearAll()
Definition: canvas_typed/mainwindow.cpp:203
MainWindow::propertyToId
QMap< QtProperty *, QString > propertyToId
Definition: canvas_typed/mainwindow.h:113
QtSizePropertyManager::setValue
void setValue(QtProperty *property, const QSize &val)
Definition: qtpropertymanager.cpp:3386
QtCanvasItem::Rtti_Text
@ Rtti_Text
Definition: canvas_typed/qtcanvas.h:152
QtCanvasView::inverseWorldMatrix
const QMatrix & inverseWorldMatrix() const
Definition: canvas_typed/qtcanvas.cpp:3251
qteditorfactory.h
MainWindow::updateExpandState
void updateExpandState()
Definition: canvas_typed/mainwindow.cpp:271
MainWindow::canvas
QtCanvas * canvas
Definition: canvas_typed/mainwindow.h:111
MainWindow::idToProperty
QMap< QString, QtProperty * > idToProperty
Definition: canvas_typed/mainwindow.h:114
QtCanvasText::font
QFont font() const
Definition: canvas_typed/qtcanvas.cpp:4469
MainWindow::addLine
QtCanvasItem * addLine()
Definition: canvas_typed/mainwindow.cpp:240
QtCanvasText::setColor
void setColor(const QColor &)
Definition: canvas_typed/qtcanvas.cpp:4501
CAMITK_INFO
#define CAMITK_INFO(MSG)
Log for info verbosity (the second most verbose one) The msg will appear only if the user asked for I...
Definition: Log.h:261
QtCanvasItem::y
double y() const
Definition: canvas_typed/qtcanvas.h:75
qtcanvas.h
QtStringPropertyManager
The QtStringPropertyManager provides and manages QString properties.
Definition: qtpropertymanager.h:207
QtCanvasRectangle::setSize
void setSize(int w, int h)
Definition: canvas_typed/qtcanvas.cpp:4132
QtAbstractPropertyBrowser::addProperty
QtBrowserItem * addProperty(QtProperty *property)
Definition: qtpropertybrowser.cpp:1771
QtBrowserItem
The QtBrowserItem class represents a property in a property browser instance.
Definition: qtpropertybrowser.h:286
PropertyObject.h
QtVariantPropertyManager
The QtVariantPropertyManager class provides and manages QVariant based properties.
Definition: qtvariantproperty.h:119
QtDoubleSpinBoxFactory
The QtDoubleSpinBoxFactory class provides QDoubleSpinBox widgets for properties created by QtDoublePr...
Definition: qteditorfactory.h:167
QtFontPropertyManager::subBoolPropertyManager
QtBoolPropertyManager * subBoolPropertyManager() const
Definition: qtpropertymanager.cpp:6252
QtCanvasView::canvas
QtCanvas * canvas() const
Definition: canvas_typed/qtcanvas.h:374
QtCanvasItem::Rtti_Line
@ Rtti_Line
Definition: canvas_typed/qtcanvas.h:156
QtProperty
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:113
Action.h
QtTreePropertyBrowser::setExpanded
void setExpanded(QtBrowserItem *item, bool expanded)
Definition: qttreepropertybrowser.cpp:888
QtCanvas::allItems
QtCanvasItemList allItems()
Definition: canvas_typed/qtcanvas.cpp:598
CanvasView::contentsMousePressEvent
void contentsMousePressEvent(QMouseEvent *event)
Definition: canvas_typed/mainwindow.cpp:51
QtCanvasItem::x
double x() const
Definition: canvas_typed/qtcanvas.h:72
CanvasView::itemMoved
void itemMoved(QtCanvasItem *item)
camitk::Viewer::setEmbedder
bool setEmbedder(QLayout *)
If the viewer type is EMBEDDED, embed the viewer widget in the given layout (do nothing if the type i...
Definition: Viewer.cpp:181
MainWindow::valueChanged
void valueChanged(QtProperty *property, double value)
Definition: canvas_typed/mainwindow.cpp:381
QtCanvasItem::setZ
void setZ(double a)
Definition: canvas_typed/qtcanvas.h:90
MainWindow::newText
void newText()
Definition: canvas_typed/mainwindow.cpp:187
MainWindow::itemMoved
void itemMoved(QtCanvasItem *item)
Definition: canvas_typed/mainwindow.cpp:261
QtFontPropertyManager::subEnumPropertyManager
QtEnumPropertyManager * subEnumPropertyManager() const
Definition: qtpropertymanager.cpp:6238
QtFontPropertyManager
The QtFontPropertyManager provides and manages QFont properties.
Definition: qtpropertymanager.h:784
QtVariantPropertyManager::addProperty
virtual QtVariantProperty * addProperty(int propertyType, const QString &name=QString())
Definition: qtvariantproperty.cpp:1321
MainWindow::itemClicked
void itemClicked(QtCanvasItem *item)
Definition: canvas_typed/mainwindow.cpp:281
MainWindow::pointManager
class QtPointPropertyManager * pointManager
Definition: canvas_typed/mainwindow.h:106
Log.h
MainWindow::sizeManager
class QtSizePropertyManager * sizeManager
Definition: canvas_typed/mainwindow.h:107
QtSizePropertyManager
The QtSizePropertyManager provides and manages QSize properties.
Definition: qtpropertymanager.h:491
QtAbstractPropertyBrowser::setFactoryForManager
void setFactoryForManager(PropertyManager *manager, QtAbstractEditorFactory< PropertyManager > *factory)
Definition: qtpropertybrowser.h:315
QtPointPropertyManager::subIntPropertyManager
QtIntPropertyManager * subIntPropertyManager() const
Definition: qtpropertymanager.cpp:2795
QtVariantProperty
The QtVariantProperty class is a convenience class handling QVariant based properties.
Definition: qtvariantproperty.h:97
QtCanvasRectangle::size
QSize size() const
Definition: canvas_typed/qtcanvas.h:636
QtCanvasPolygonalItem
Definition: canvas_typed/qtcanvas.h:572
QtCanvasPolygonalItem::brush
QBrush brush() const
Definition: canvas_typed/qtcanvas.h:585
QtSpinBoxFactory
The description of this class will come soon !
Definition: qteditorfactory.h:61
QtCanvasItem::Rtti_Ellipse
@ Rtti_Ellipse
Definition: canvas_typed/qtcanvas.h:155
QtCanvasItem::z
double z() const
Definition: canvas_typed/qtcanvas.h:78
CanvasView::handleMouseClickEvent
void handleMouseClickEvent(QMouseEvent *event)
Definition: canvas_typed/mainwindow.cpp:59
MainWindow::newEllipse
void newEllipse()
Definition: canvas_typed/mainwindow.cpp:175
MainWindow
Definition: canvas_typed/mainwindow.h:69
QtCanvas::height
int height() const
Definition: canvas_typed/qtcanvas.h:253
MainWindow::deleteAction
QAction * deleteAction
Definition: canvas_typed/mainwindow.h:100
QtCanvasRectangle
Definition: canvas_typed/qtcanvas.h:625
QtCanvasItem::setY
void setY(double a)
Definition: canvas_typed/qtcanvas.h:87
QtCanvasEllipse::setSize
void setSize(int w, int h)
Definition: canvas_typed/qtcanvas.cpp:4276
QtVariantPropertyManager::setValue
virtual void setValue(QtProperty *property, const QVariant &val)
Definition: qtvariantproperty.cpp:1654
QtCanvasItem
Definition: canvas_typed/qtcanvas.h:67
QtCanvasItem::moveBy
virtual void moveBy(double dx, double dy)
Definition: canvas_typed/qtcanvas.cpp:1669
QtColorPropertyManager::subIntPropertyManager
QtIntPropertyManager * subIntPropertyManager() const
Definition: qtpropertymanager.cpp:6589
QtDoublePropertyManager
The QtDoublePropertyManager provides and manages double properties.
Definition: qtpropertymanager.h:164
qtvariantproperty.h
QtBrowserItem::property
QtProperty * property() const
Definition: qtpropertybrowser.cpp:1132
QtCanvasText::setText
void setText(const QString &)
Definition: canvas_typed/qtcanvas.cpp:4455
mainwindow.h
CanvasView::contentsMouseDoubleClickEvent
void contentsMouseDoubleClickEvent(QMouseEvent *event)
Definition: canvas_typed/mainwindow.cpp:55
MainWindow::stringManager
class QtStringPropertyManager * stringManager
Definition: canvas_typed/mainwindow.h:103
CanvasView::moving
QtCanvasItem * moving
Definition: canvas_typed/mainwindow.h:66
camitk::MainWindow::MainWindow
MainWindow(QString title)
Constructor, the window title can be changed here, it is inconsistent to use setWindowTitle().
Definition: MainWindow.cpp:75
MainWindow::fillView
void fillView()
Definition: canvas_typed/mainwindow.cpp:210
QtCanvasItem::move
void move(double x, double y)
Definition: canvas_typed/qtcanvas.cpp:1682
CanvasView::CanvasView
CanvasView(QWidget *parent=0)
Definition: canvas_typed/mainwindow.h:52
QtTreePropertyBrowser::isExpanded
bool isExpanded(QtBrowserItem *item) const
Definition: qttreepropertybrowser.cpp:901
QtLineEditFactory
The QtLineEditFactory class provides QLineEdit widgets for properties created by QtStringPropertyMana...
Definition: qteditorfactory.h:195
QtCanvasLine::startPoint
QPoint startPoint() const
Definition: canvas_typed/qtcanvas.h:708
MainWindow::canvasView
CanvasView * canvasView
Definition: canvas_typed/mainwindow.h:110
CanvasView::itemClicked
void itemClicked(QtCanvasItem *item)
QtFontPropertyManager::setValue
void setValue(QtProperty *property, const QFont &val)
Definition: qtpropertymanager.cpp:6301
QtVariantEditorFactory
The QtVariantEditorFactory class provides widgets for properties created by QtVariantPropertyManager ...
Definition: qtvariantproperty.h:212
QtCanvasLine::setPoints
void setPoints(int x1, int y1, int x2, int y2)
Definition: canvas_typed/qtcanvas.cpp:3982
CanvasView
Definition: canvas_typed/mainwindow.h:49
MainWindow::addEllipse
QtCanvasItem * addEllipse()
Definition: canvas_typed/mainwindow.cpp:231
QtCanvasLine::endPoint
QPoint endPoint() const
Definition: canvas_typed/qtcanvas.h:711
MainWindow::idToExpanded
QMap< QString, bool > idToExpanded
Definition: canvas_typed/mainwindow.h:115
MainWindow::MainWindow
MainWindow(QWidget *parent=0)
Definition: canvas_typed/mainwindow.cpp:81
QtDoublePropertyManager::setValue
void setValue(QtProperty *property, double val)
Definition: qtpropertymanager.cpp:1133
MainWindow.h
MainWindow::currentItem
QtCanvasItem * currentItem
Definition: canvas_typed/mainwindow.h:112
QtCanvas
Definition: canvas_typed/qtcanvas.h:213
MainWindow::deleteObject
void deleteObject()
Definition: canvas_typed/mainwindow.cpp:193
QtVariantProperty::setValue
void setValue(const QVariant &value)
Definition: qtvariantproperty.cpp:263
camitk::MainWindow
This class is the base class for your application. It sets up the main window and creates a menubar,...
Definition: MainWindow.h:89
CanvasView::CanvasView
CanvasView(QtCanvas *canvas, QWidget *parent=0)
Definition: canvas_typed/mainwindow.h:54
camitk::Viewer
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:180
qttreepropertybrowser.h
MainWindow::fontManager
class QtFontPropertyManager * fontManager
Definition: canvas_typed/mainwindow.h:105
QtCanvasItem::rtti
virtual int rtti() const
Definition: canvas_typed/qtcanvas.cpp:4604
QtStringPropertyManager::setValue
void setValue(QtProperty *property, const QString &val)
Definition: qtpropertymanager.cpp:1454
MainWindow::propertyEditor
class QtTreePropertyBrowser * propertyEditor
Definition: canvas_typed/mainwindow.h:109
QtDoublePropertyManager::setRange
void setRange(QtProperty *property, double minVal, double maxVal)
Definition: qtpropertymanager.cpp:1278
QtPointPropertyManager::setValue
void setValue(QtProperty *property, const QPoint &val)
Definition: qtpropertymanager.cpp:2832
Viewer.h
QtFontPropertyManager::subIntPropertyManager
QtIntPropertyManager * subIntPropertyManager() const
Definition: qtpropertymanager.cpp:6225
QtCheckBoxFactory
The QtCheckBoxFactory class provides QCheckBox widgets for properties created by QtBoolPropertyManage...
Definition: qteditorfactory.h:142
QtCanvasPolygonalItem::pen
QPen pen() const
Definition: canvas_typed/qtcanvas.h:582
CanvasView::contentsMouseMoveEvent
void contentsMouseMoveEvent(QMouseEvent *event)
Definition: canvas_typed/mainwindow.cpp:70
QtSizePropertyManager::setRange
void setRange(QtProperty *property, const QSize &minVal, const QSize &maxVal)
Definition: qtpropertymanager.cpp:3447
QtCanvasView
Definition: canvas_typed/qtcanvas.h:365
QtVariantProperty::setAttribute
void setAttribute(const QString &attribute, const QVariant &value)
Definition: qtvariantproperty.cpp:276
MainWindow::addText
QtCanvasItem * addText()
Definition: canvas_typed/mainwindow.cpp:251
camitk::refresh
void refresh()
refresh the display
MainWindow::newLine
void newLine()
Definition: canvas_typed/mainwindow.cpp:181
QtCanvasEllipse
Definition: canvas_typed/qtcanvas.h:730
QtCanvasText::setFont
void setFont(const QFont &)
Definition: canvas_typed/qtcanvas.cpp:4478
Core.h
QtCanvasText::text
QString text() const
Definition: canvas_typed/qtcanvas.cpp:4445
QtCanvas::update
virtual void update()
Definition: canvas_typed/qtcanvas.cpp:960
QtCanvasItem::Rtti_Rectangle
@ Rtti_Rectangle
Definition: canvas_typed/qtcanvas.h:154
QtCanvasLine::setPen
void setPen(QPen p)
Definition: canvas_typed/qtcanvas.cpp:3958
MainWindow::newRectangle
void newRectangle()
Definition: canvas_typed/mainwindow.cpp:169
CanvasView::moving_start
QPoint moving_start
Definition: canvas_typed/mainwindow.h:65
QtCanvasText
Definition: canvas_typed/qtcanvas.h:773
QtCanvasPolygonalItem::setPen
virtual void setPen(QPen p)
Definition: canvas_typed/qtcanvas.cpp:3694
mainwindow.h
QtCanvasText::color
QColor color() const
Definition: canvas_typed/qtcanvas.cpp:4492
QtEnumEditorFactory
The QtEnumEditorFactory class provides QComboBox widgets for properties created by QtEnumPropertyMana...
Definition: qteditorfactory.h:349
QtColorPropertyManager::setValue
void setValue(QtProperty *property, const QColor &val)
Definition: qtpropertymanager.cpp:6638
QtAbstractPropertyBrowser::topLevelItems
QList< QtBrowserItem * > topLevelItems() const
Definition: qtpropertybrowser.cpp:1739
QtCanvasPolygonalItem::setBrush
virtual void setBrush(QBrush b)
Definition: canvas_typed/qtcanvas.cpp:3707
Application.h
camitk
Definition: Action.cpp:35
qtpropertymanager.h
QtColorPropertyManager
The QtColorPropertyManager provides and manages QColor properties.
Definition: qtpropertymanager.h:823
QtCanvas::collisions
QtCanvasItemList collisions(const QPoint &) const
Definition: canvas_typed/qtcanvas.cpp:2294