Developer Documentation

baseWidget.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44 #ifndef BASEWIDGET_HH
45 #define BASEWIDGET_HH
46
47 //== INCLUDES =================================================================
48
49 #include <QMainWindow>
50 #include <QSplitter>
51 #include <QStackedWidget>
52 #include <QToolBox>
53 #include <QStack>
54
55 #include "scene/graphicsView.hh"
56 #include "scene/graphicsScene.hh"
57
58
59 //== NAMESPACES ===============================================================
60 namespace VSI {
61
62 //== FORWARDDECLARATIONS ======================================================
63 class Context;
64
65 //== CLASS DEFINITION =========================================================
66
69 class BaseWidget : public QMainWindow
70 {
71 Q_OBJECT
72
73 public:
74
76 static BaseWidget *createBaseWidget (Context *_ctx, QWidget *_parent = NULL);
77 static BaseWidget *getBaseWidget ();
78
80 ~BaseWidget ();
81
82 signals:
83 void codeToScriptEditor (QString _code);
84
85 public slots:
86
88 void executeCode ();
89
91 void codeToScript ();
92
94 bool save (bool _newName = false);
95
97 bool saveAs ();
98
100 void load ();
101
103 void newFile ();
104
106 void contentChanged ();
107
109 void pushScene (GraphicsScene *_scene);
110
112 void popScene ();
113
115 void addScene (GraphicsScene *_scene);
116
118 void removeScene (GraphicsScene *_scene);
119
120 private:
121
122 // constructor
123 BaseWidget (Context *_ctx, QWidget *_parent);
124
125 // initalize widgets
126 void setupUi ();
127
128 // update window title bar
129 void updateTitle ();
130
131 // asks the user to save his changes
132 bool saveIfChanged ();
133
134 // catch window close
135 void closeEvent (QCloseEvent *_event);
136
137 private:
138
139 Context *ctx_;
140
141 GraphicsScene *mainScene_;
142 QStack<GraphicsScene *> scenes_;
143
144 QSplitter *splitter_;
145 QToolBox *toolbox_;
146 QStackedWidget *views_;
147
148 QString fileName_;
149 bool changedContent_;
150
151 static BaseWidget *base_;
152 };
153
154 //=============================================================================
155 }
156 //=============================================================================
157
158 #endif
VSI::BaseWidget::~BaseWidget
~BaseWidget()
Destructor.
Definition: baseWidget.cc:167
VSI::BaseWidget::updateTitle
void updateTitle()
Update window title.
Definition: baseWidget.cc:385
VSI::BaseWidget::popScene
void popScene()
go back to last scene (function)
Definition: baseWidget.cc:482
VSI::BaseWidget::pushScene
void pushScene(GraphicsScene *_scene)
show a new scene (function) in editor
Definition: baseWidget.cc:473
VSI::BaseWidget::saveAs
bool saveAs()
save to file
Definition: baseWidget.cc:244
VSI::BaseWidget::getBaseWidget
static BaseWidget * getBaseWidget()
Returns singleton.
Definition: baseWidget.cc:465
VSI::BaseWidget
Definition: baseWidget.hh:69
VSI::BaseWidget::removeScene
void removeScene(GraphicsScene *_scene)
remove a scene
Definition: baseWidget.cc:504
VSI::BaseWidget::codeToScript
void codeToScript()
converts visual script to textual script
Definition: baseWidget.cc:222
VSI::Context
Definition: context.hh:70
VSI::BaseWidget::contentChanged
void contentChanged()
used changed something
Definition: baseWidget.cc:396
VSI::BaseWidget::save
bool save(bool _newName=false)
save to file
Definition: baseWidget.cc:311
VSI::BaseWidget::createBaseWidget
static BaseWidget * createBaseWidget(Context *_ctx, QWidget *_parent=NULL)
Singleton constructor.
Definition: baseWidget.cc:455
VSI::BaseWidget::load
void load()
load file
Definition: baseWidget.cc:252
VSI::BaseWidget::executeCode
void executeCode()
executes current script
Definition: baseWidget.cc:199
VSI::BaseWidget::newFile
void newFile()
new empty file
Definition: baseWidget.cc:367
VSI
Definition: baseWidget.cc:72
VSI::BaseWidget::setupUi
void setupUi()
Adds element widgets to toolbox.
Definition: baseWidget.cc:175
VSI::GraphicsScene
Definition: graphicsScene.hh:80
VSI::BaseWidget::addScene
void addScene(GraphicsScene *_scene)
add a new scene
Definition: baseWidget.cc:496
VSI::BaseWidget::closeEvent
void closeEvent(QCloseEvent *_event)
Chatch close event.
Definition: baseWidget.cc:444
VSI::BaseWidget::saveIfChanged
bool saveIfChanged()
Asks the user if he want to save his changes.
Definition: baseWidget.cc:408