Computer Assited Medical Intervention Tool Kit  version 4.1
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 
93  QtCanvasItem* addRectangle();
94  QtCanvasItem* addEllipse();
95  QtCanvasItem* addLine();
96  QtCanvasItem* addText();
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
The QtDoublePropertyManager provides and manages double properties.
Definition: qtpropertymanager.h:155
QtCanvas * canvas
Definition: canvas_typed/mainwindow.h:111
void itemClicked(QtCanvasItem *item)
QtCanvasItem * currentItem
Definition: canvas_typed/mainwindow.h:112
class QtTreePropertyBrowser * propertyEditor
Definition: canvas_typed/mainwindow.h:109
Definition: canvas_typed/qtcanvas.h:213
Definition: canvas_typed/mainwindow.h:49
CanvasView(QtCanvas *canvas, QWidget *parent=0)
Definition: canvas_typed/mainwindow.h:54
QMap< QString, bool > idToExpanded
Definition: canvas_typed/mainwindow.h:115
QtCanvasItem * moving
Definition: canvas_typed/mainwindow.h:66
CanvasView(QWidget *parent=0)
Definition: canvas_typed/mainwindow.h:52
The description of this class will come soon !
Definition: qttreepropertybrowser.h:60
The QtPointPropertyManager provides and manages QPoint properties.
Definition: qtpropertymanager.h:383
class QtColorPropertyManager * colorManager
Definition: canvas_typed/mainwindow.h:104
class QtStringPropertyManager * stringManager
Definition: canvas_typed/mainwindow.h:103
The QtStringPropertyManager provides and manages QString properties.
Definition: qtpropertymanager.h:194
The QtFontPropertyManager provides and manages QFont properties.
Definition: qtpropertymanager.h:703
QPoint moving_start
Definition: canvas_typed/mainwindow.h:65
void contentsMouseMoveEvent(QMouseEvent *event)
Definition: canvas_typed/mainwindow.cpp:70
class QtFontPropertyManager * fontManager
Definition: canvas_typed/mainwindow.h:105
The QtSizePropertyManager provides and manages QSize properties.
Definition: qtpropertymanager.h:442
The QtColorPropertyManager provides and manages QColor properties.
Definition: qtpropertymanager.h:738
QMap< QtProperty *, QString > propertyToId
Definition: canvas_typed/mainwindow.h:113
QAction * deleteAction
Definition: canvas_typed/mainwindow.h:100
class QtSizePropertyManager * sizeManager
Definition: canvas_typed/mainwindow.h:107
void contentsMousePressEvent(QMouseEvent *event)
Definition: canvas_typed/mainwindow.cpp:51
Definition: canvas_typed/qtcanvas.h:365
QtCanvas * canvas() const
Definition: canvas_typed/qtcanvas.h:374
class QtPointPropertyManager * pointManager
Definition: canvas_typed/mainwindow.h:106
Definition: canvas_typed/qtcanvas.h:67
CanvasView * canvasView
Definition: canvas_typed/mainwindow.h:110
void handleMouseClickEvent(QMouseEvent *event)
Definition: canvas_typed/mainwindow.cpp:59
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:113
QMap< QString, QtProperty * > idToProperty
Definition: canvas_typed/mainwindow.h:114
class QtDoublePropertyManager * doubleManager
Definition: canvas_typed/mainwindow.h:102
void contentsMouseDoubleClickEvent(QMouseEvent *event)
Definition: canvas_typed/mainwindow.cpp:55
Definition: canvas_typed/mainwindow.h:69
void itemMoved(QtCanvasItem *item)