OSDN Git Service

[denncoCreator] save functionality in progress
[dennco/denncoCreator.git] / Source / visualizer / dcscene.h
1 //  Copyright (c) 2012 Dennco Project
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 //
17 //  Created by tkawata on Sep-30, 2012.
18 //
19 #ifndef DCSCENE_H
20 #define DCSCENE_H
21
22 #include <QObject>
23 #include <QString>
24 #include <QMap>
25 #include <QList>
26 #include <QMutex>
27
28 class DCContent;
29 class DCVComponent;
30 class DCVCPage;
31 class DCVCEditModeCursor;
32 class DCContainer;
33 class DCCellCode;
34 class DCCell;
35 class DCAxon;
36 class DCReceptor;
37
38 class DCScene : public QObject
39 {
40     Q_OBJECT
41
42 public:
43     enum DCVPersMode { DCV_PERSMODE_NAVIGATION, DCV_PERSMODE_PAGEEDIT };
44     enum DCVEditMode { DCV_EDITMODE_LAYOUT, DCV_EDITMODE_TERMINAL_FROM_AXON, DCV_EDITMODE_TERMINAL_FROM_RECEPTOR, DCV_EDITMODE_CELLCODE };
45
46 private:
47     DCContainer             *d_owner;
48     QMap<QString,DCVCPage*> d_pages;
49     static bool             sShouldContinueAnimation;
50
51     DCVPersMode             d_vpMode;
52     DCVEditMode             d_veMode;
53
54     enum DCSceneTransition { DC_TRANS_NONE,
55                              DC_TRANS_TO_PAGEEDIT,
56                              DC_TRANS_TO_NAVIGATION
57                            };
58     DCSceneTransition       d_transition;
59
60     float                   d_scale;
61     float                   d_xAngle;
62     float                   d_yAngle;
63     float                   d_centerX;
64     float                   d_centerBrowsModeY;
65     float                   d_centerEditModeY;
66
67     float                   d_navigationModeSelectedPageAlpha;
68     float                   d_navigationModeAboveAlpha;
69     float                   d_navigationModeBelowAlpha;
70     float                   d_pageEditModeSelectedPageAlpha;
71
72     bool                    d_navigationModeSelectedCellMovable;
73     bool                    d_navigationModeOtherCellSelectable;
74     bool                    d_navigationModeOtherCellVisible;
75     bool                    d_navigationModeOtherCellRenderFull;
76
77     bool                    d_pageEditModeOtherSamePageRenderFull;
78     bool                    d_pageEditModeLinkedOtherPageVisible;
79     bool                    d_pageEditModeLinkedOtherPageRenderFull;
80     bool                    d_pageEditModeOtherOtherPageVisible;
81     bool                    d_pageEditModeOtherOtherPageRenderFull;
82
83     DCVCEditModeCursor      *d_terminalEditCursor;
84     DCAxon                  *d_editAxon;
85     DCReceptor              *d_editReceptor;
86
87     DCCell                  *d_editCellCodeCell;
88
89 public:
90     DCScene(DCContainer *owner);
91     virtual ~DCScene();
92
93     void initMode(DCVPersMode persMode, DCVEditMode editMode);
94     //
95     static QMutex*          getSceneLock();
96     static bool             getShouldContinueAnimation();
97
98     DCContainer*            getContainer() const { return d_owner; }
99     float                   getScale() const { return d_scale; }
100     float                   getXAngle() const { return d_xAngle; }
101     float                   getYAngle() const { return d_yAngle; }
102     float                   getCenterX() const { return d_centerX; }
103     float                   getCenterBrowsModeY() const { return d_centerBrowsModeY; }
104     float                   getCenterEditModeY() const { return d_centerEditModeY; }
105     int                     getNumberOfSelectedPages() const;
106     QList<DCVCPage*>        getSelectedPages() const;
107     QList<DCVComponent*>    getSelectedCellObjects() const;
108     DCVPersMode             getPersMode() const { return d_vpMode; }
109     DCVEditMode             getEditMode() const { return d_veMode; }
110     bool                    getIsInModeTransition() const { return d_transition != DC_TRANS_NONE; }
111
112     float                   getNavModeSelectedPageAlpha() const { return d_navigationModeSelectedPageAlpha; }
113     float                   getNavModeAboveAlpha() const { return d_navigationModeAboveAlpha; }
114     float                   getNavModeBelowAlpha() const { return d_navigationModeBelowAlpha; }
115     float                   getPageModeSelectedAlpha() const { return d_pageEditModeSelectedPageAlpha; }
116
117     bool                    getNavModeSelectedCellMovable() const { return d_navigationModeSelectedCellMovable; }
118     bool                    getNavModeOtherCellSelectable() const { return d_navigationModeOtherCellSelectable; }
119     bool                    getNavModeOtherCellVisible() const { return d_navigationModeOtherCellVisible; }
120     bool                    getNavModeOtherCellRenderFull() const { return d_navigationModeOtherCellRenderFull; }
121
122     bool                    getPageModeOtherSamePageRenderFull() const { return d_pageEditModeOtherSamePageRenderFull; }
123     bool                    getPageModeLinkedOtherPageVisible() const { return d_pageEditModeLinkedOtherPageVisible; }
124     bool                    getPageModeLinkedOtherPageRenderFull() const { return d_pageEditModeLinkedOtherPageRenderFull; }
125     bool                    getPageModeOtherOtherPageVisible() const { return d_pageEditModeOtherOtherPageVisible; }
126     bool                    getPageModeOtherOtherPageRenderFull() const { return d_pageEditModeOtherOtherPageRenderFull; }
127
128     DCVCEditModeCursor *    getTerminalEditCursor() const { return d_terminalEditCursor; }
129     DCAxon*                 getEditAxon() const { return d_editAxon; }
130     DCReceptor*             getEditReceptor() const { return d_editReceptor; }
131     QString                 getTerminalEditCursorLocationString() const;
132     DCVComponent*           getTerminalEditCursorDropTarget() const;
133
134     DCCell*                 getEditCellCodeCell() const { return d_editCellCodeCell; }
135
136     const QMap<QString,DCVCPage*> getPages() const { return d_pages; }
137     bool                    getIsPageExist(const std::string& location) const;
138
139     //
140     void                    setNavModeSelectedPageAlpha(const void *requester, float alpha);
141     void                    setNavModeAboveAlpha(const void *requester, float alpha);
142     void                    setNavModeBelowAlpha(const void *requester, float alpha);
143     void                    setPageModeSelectedAlpha(const void *requester, float alpha);
144
145     void                    setNavModeSelectedCellMovable(const void *requester, bool b);
146     void                    setNavModeOtherCellSelectable(const void *requester, bool b);
147     void                    setNavModeOtherCellVisible(const void *requester, bool b);
148     void                    setNavModeOtherCellRenderFull(const void *requester, bool b);
149
150     void                    setPageModeOtherSamePageRenderFull(const void *requester, bool b);
151     void                    setPageModeLinkedOtherPageVisible(const void *requester, bool b);
152     void                    setPageModeLinkedOtherPageRenderFull(const void *requester, bool b);
153     void                    setPageModeOtherOtherPageVisible(const void *requester, bool b);
154     void                    setPageModeOtherOtherPageRenderFull(const void *requester, bool b);
155
156     void draw(bool isAnimationInterval);
157     void drawForSelection(QList<DCVComponent*> *itemList);
158     bool doAnimation();
159     void updateVisiblity();
160
161     DCVCPage* findPage(const std::string& location);
162
163     DCVCPage* addPage(const std::string& location);
164     void setScale(const void *requester, float scale);
165     void setAngle(const void *requester, float xangle, float yangle);
166     void setBrowsModeCenter(const void *requester, float cx, float cy);
167     void setPageModeCenter(const void *requester, float cx, float cy);
168
169     bool selectPage(const void *requester, const DCVCPage *page, bool multipleSelection);
170     bool unselectPage(const void *requester, const DCVCPage *page);
171     bool selectPage(const void *requester, const QString &locationPath, bool multipleSelection);
172     bool unselectPage(const void *requester, const QString &locationPath);
173     bool unselectPageAll(const void *requester);
174
175     void selectCellObject(const void *requester, DCVComponent *object, bool multipleSelection = false);
176     void unselectCellObject(const void *requester, DCVComponent *object);
177     void unselectCellObjectAll(const void *requester);
178
179     bool changePersMode(const void *requester, DCVPersMode mode);
180     bool startTerminalEditForAxon(const void *requester, DCAxon *ownerAxon);
181     bool startTerminalEditForReceptor(const void *requester, DCReceptor *ownerReceptor);
182     bool startCellCodeEdit(const void *requester, DCCell *cell);
183     bool finishTerminalEdit(const void *requester);
184     bool finishCellCodeEdit(const void *requester);
185
186     bool loadAllViewAttributes();
187     bool loadViewAttributeForPage(DCVCPage *page);
188
189     bool saveAllViewAttributes();
190     bool saveViewAttributesForPage(DCVCPage *page);
191
192     static void     lockScene();
193     static void     unlockScene();
194     static void     setShouldContinueAnimation(bool shouldContinue);
195
196 signals:
197     void selectedPageChanged(const void *requester);
198     void selectedCellObjectChanged(const void *requester);
199     void viewScaleChanged(const void *requester);
200     void viewAngleChanged(const void *requester);
201     void viewCenterChanged(const void *requester);
202     void viewSettingChanged(const void *requester);
203     void viewPersModeChanged(const void* requester);
204     void viewEditModeChanged(const void *requester);
205
206     void modeInitialized();
207
208     void terminalEditCursorBelongingPageChagend(DCVCPage *newPage);
209     void terminalEditCursorDropTargetChanged(DCVComponent *newTarget);
210
211 private slots:
212     void slotTerminalEditCursorBelongingPageChagend(DCVCPage *newPage);
213     void slotTerminalEditCursorDropTargetChanged(DCVComponent *newTarget);
214
215 };
216
217 #endif // DCSCENE_H