Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef BASEWIDGET_HH
51 #define BASEWIDGET_HH
52 
53 //== INCLUDES =================================================================
54 
55 #include <QMainWindow>
56 #include <QSplitter>
57 #include <QStackedWidget>
58 #include <QToolBox>
59 #include <QStack>
60 
61 #include "scene/graphicsView.hh"
62 #include "scene/graphicsScene.hh"
63 
64 
65 //== NAMESPACES ===============================================================
66 namespace VSI {
67 
68 //== FORWARDDECLARATIONS ======================================================
69 class Context;
70 
71 //== CLASS DEFINITION =========================================================
72 
75 class BaseWidget : public QMainWindow
76 {
77  Q_OBJECT
78 
79  public:
80 
82  static BaseWidget *createBaseWidget (Context *_ctx, QWidget *_parent = NULL);
83  static BaseWidget *getBaseWidget ();
84 
86  ~BaseWidget ();
87 
88  signals:
89  void codeToScriptEditor (QString _code);
90 
91  public slots:
92 
94  void executeCode ();
95 
97  void codeToScript ();
98 
100  bool save (bool _newName = false);
101 
103  bool saveAs ();
104 
106  void load ();
107 
109  void newFile ();
110 
112  void contentChanged ();
113 
115  void pushScene (GraphicsScene *_scene);
116 
118  void popScene ();
119 
121  void addScene (GraphicsScene *_scene);
122 
124  void removeScene (GraphicsScene *_scene);
125 
126  private:
127 
128  // constructor
129  BaseWidget (Context *_ctx, QWidget *_parent);
130 
131  // initalize widgets
132  void setupUi ();
133 
134  // update window title bar
135  void updateTitle ();
136 
137  // asks the user to save his changes
138  bool saveIfChanged ();
139 
140  // catch window close
141  void closeEvent (QCloseEvent *_event);
142 
143  private:
144 
145  Context *ctx_;
146 
147  GraphicsScene *mainScene_;
148  QStack<GraphicsScene *> scenes_;
149 
150  QSplitter *splitter_;
151  QToolBox *toolbox_;
152  QStackedWidget *views_;
153 
154  QString fileName_;
155  bool changedContent_;
156 
157  static BaseWidget *base_;
158 };
159 
160 //=============================================================================
161 }
162 //=============================================================================
163 
164 #endif
void updateTitle()
Update window title.
Definition: baseWidget.cc:391
void newFile()
new empty file
Definition: baseWidget.cc:373
bool saveIfChanged()
Asks the user if he want to save his changes.
Definition: baseWidget.cc:414
static BaseWidget * getBaseWidget()
Returns singleton.
Definition: baseWidget.cc:471
void contentChanged()
used changed something
Definition: baseWidget.cc:402
void executeCode()
executes current script
Definition: baseWidget.cc:205
~BaseWidget()
Destructor.
Definition: baseWidget.cc:173
void addScene(GraphicsScene *_scene)
add a new scene
Definition: baseWidget.cc:502
void load()
load file
Definition: baseWidget.cc:258
static BaseWidget * createBaseWidget(Context *_ctx, QWidget *_parent=NULL)
Singleton constructor.
Definition: baseWidget.cc:461
bool saveAs()
save to file
Definition: baseWidget.cc:250
void closeEvent(QCloseEvent *_event)
Chatch close event.
Definition: baseWidget.cc:450
void codeToScript()
converts visual script to textual script
Definition: baseWidget.cc:228
void pushScene(GraphicsScene *_scene)
show a new scene (function) in editor
Definition: baseWidget.cc:479
void setupUi()
Adds element widgets to toolbox.
Definition: baseWidget.cc:181
bool save(bool _newName=false)
save to file
Definition: baseWidget.cc:317
void removeScene(GraphicsScene *_scene)
remove a scene
Definition: baseWidget.cc:510
void popScene()
go back to last scene (function)
Definition: baseWidget.cc:488