Repository navigation
Expand file tree
/
Copy pathasfactory.cpp
More file actions
302 lines (275 loc) · 8.35 KB
/
Copy pathasfactory.cpp
File metadata and controls
302 lines (275 loc) · 8.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#include "asfactory.h"
#include "io/asnode.h"
#include "objects/asvirtualfolder.h"
#include "objects/asflipchart.h"
#include "objects/asink.h"
#include "objects/asorigin.h"
#include "objects/astransform.h"
#include "objects/astext.h"
#include "objects/astextrun.h"
#include "objects/asimage.h"
#include "objects/asannotation.h"
#include "objects/asbackground.h"
#include "objects/asgrid.h"
#include "objects/aspage.h"
#include "objects/asrenderablegroup.h"
#include "objects/asshape.h"
#include "objects/asmediacontainer.h"
#include "resources/asresource.h"
#include "resources/asresourceregister.h"
#include "resources/asresourcemanager.h"
#include "resources/asannotationres.h"
#include "resources/asimageres.h"
#include "resources/astextres.h"
#include "resources/asshaperes.h"
#include "resources/asmediafileres.h"
#include "util/commonlog.h"
#include "resources/asmotion.h"
#include "objects/asactionmove.h"
#include "objects/asactionontext.h"
#include "objects/asactiononobject.h"
#include "objects/asactionapp.h"
#include "objects/asactionnavigate.h"
#include "objects/asactionopenexternal.h"
#include "objects/asactionlaunchminiapp.h"
#include "objects/asline.h"
AsFactory::AsFactory()
: m_pFlipchart(nullptr),
m_pResourceRegister(nullptr),
m_pResourceManager(nullptr)
{
}
AsFactory::~AsFactory()
{
QList<AsVirtualFolder *> folders = m_VirtualFolders.values();
foreach (AsVirtualFolder *pFolder, folders)
{
delete pFolder;
}
foreach(AsNode *node ,m_Nodes){
delete node;
}
foreach(AsObject *object ,m_Objects){
delete object;
}
// if(m_pResourceManager){
// delete m_pResourceManager;
// }
}
AsResourceManager *AsFactory::getResourceManager()
{
return m_pResourceManager;
}
void AsFactory::setResourceManager(AsResourceManager *pAsResourceManager)
{
m_pResourceManager = pAsResourceManager;
m_pResourceManager->asConfigure(m_pFlipchart);
}
AsObject *AsFactory::asCreateObject(AsObject::AsEnumObjectType tType, quint32 nID)
{
AsObject *pAsObject = nullptr;
if (m_Objects.contains(nID))
{
pAsObject = m_Objects.value(nID);
}
else
{
switch (tType)
{
case AsObject::AS_OBJECT_BACKGROUND:
pAsObject = new AsBackground(this);
break;
case AsObject::AS_OBJECT_FLIPCHART:
m_pFlipchart = new AsFlipchart(this);
pAsObject = m_pFlipchart;
break;
case AsObject::AS_OBJECT_RESOURCEREGISTER:
// m_pFlipchart. ->asSetResourceRegister( *pReg );
pAsObject = new AsResourceRegister();
m_pFlipchart->asSetResourceRegister(static_cast<AsResourceRegister*>(pAsObject));
break;
case AsObject::AS_OBJECT_INK:
pAsObject = new AsInk();
break;
case AsObject::AS_OBJECT_TRANSFORM:
pAsObject = new AsTransform(this);
break;
case AsObject::AS_OBJECT_ORIGIN:
pAsObject = new AsOrigin(this);
break;
case AsObject::AS_OBJECT_TEXTRUN:
pAsObject = new AsTextRun(this);
break;
case AsObject::AS_OBJECT_TEXT:
pAsObject = new AsText(this);
break;
case AsObject::AS_OBJECT_IMAGE:
pAsObject = new AsImage(this);
break;
case AsObject::AS_OBJECT_ANNOTATION:
pAsObject = new AsAnnotation(this);
break;
case AsObject::AS_OBJECT_GRID:
pAsObject = new AsGrid( this );
break;
case AsObject::AS_OBJECT_PAGE:
pAsObject = new AsPage( this );
break;
case AsObject::AS_OBJECT_ANNOTATIONRES:
pAsObject = new AsAnnotationRes( this );
break;
case AsObject::AS_OBJECT_IMAGERES:
pAsObject = new AsImageRes( this );
break;
case AsObject::AS_OBJECT_TEXTRES:
pAsObject = new AsTextRes( this );
break;
case AsObject::AS_OBJECT_SHAPERES:
pAsObject = new AsShapeRes( this );
break;
case AsObject::AS_OBJECT_ASRENDERABLEGROUP:
pAsObject = new AsRenderableGroup(this);
break;
case AsObject::AS_OBJECT_SHAPE:
pAsObject = new AsShape(this);
break;
case AsObject::AS_OBJECT_MEDIAFILERES:
pAsObject = new AsMediaFileRes(this);
break;
case AsObject::AS_OBJECT_MEDIACONTAINER:
pAsObject = new AsMediaContainer(this);
break;
case AsObject::AS_OBJECT_MOTIONRES:
pAsObject = new AsMotion(this);
break;
case AsObject::AS_OBJECT_LINE:
pAsObject = new AsLine(this);
break;
case AsObject::AS_OBJECT_LINERES:
pAsObject = new AsLineRes(this);
break;
case AsObject::AS_OBJECT_MOVEACTION:
pAsObject = new AsActionMove(this);
break;
case AsObject::AS_OBJECT_ACTIONONTEXT:
pAsObject = new AsActionOnText(this);
break;
case AsObject::AS_OBJECT_ACTIONONOBJECT:
pAsObject = new AsActionOnObject(this);
break;
case AsObject::AS_OBJECT_APPACTION:
pAsObject = new AsActionApp(this);
break;
case AsObject::AS_OBJECT_NAVIGATEACTION:
pAsObject = new AsActionNavigate(this);
break;
case AsObject::AS_OBJECT_ACTIONOPENEXTERNAL:
pAsObject = new AsActionOpenExternal(this);
break;
case AsObject::AS_OBJECT_LAUNCH_MINIAPP_ACTION:
pAsObject = new AsActionLaunchMiniApp(this);
break;
default:
pAsObject = new AsObject();
break;
}
// Keep a record of the object on the correct list.
if (nID >= AsFactory::AS_ID_BASE)
{
// Real flipchart objects (renderables and actions etc.).
m_Objects.insert(nID, pAsObject);
}
else if (nID == AsFactory::AS_ID_PROPERTY)
{
// AsObjects that are properties of other AsObjects (exist only while streaming in!).
m_Properties.append(pAsObject);
}
pAsObject->asSetType(tType);
pAsObject->asSetID(nID);
}
return pAsObject;
}
bool AsFactory::asDeleteObject( AsObject *pAsObject )
{
LOGDEBUG("###Delete Object:%d,%d",pAsObject->asGetType(),pAsObject->asGetID());
return true;
}
bool AsFactory::asChangeObjectID( quint32 oldID, quint32 newID )
{
// First, check we have an object with this ID.
AsObject *pObject = m_Objects.value( oldID );
if ( pObject == 0 )
{
return false;
}
// Next, check there are no other objects or nodes with the new ID.
if (( m_Objects.contains( newID )) ||
( m_Nodes.contains( newID )))
{
return false;
}
// Ok, we can update the objects ID.
pObject->asSetID( newID );
m_Objects.remove( oldID );
m_Objects.insert( newID, pObject );
return true;
}
AsNode *AsFactory::asCreateNode(quint32 nID)
{
AsNode *pAsNode = nullptr;
if (m_Nodes.contains(nID))
{
pAsNode = m_Nodes.value(nID);
}
else
{
pAsNode = new AsNode(this);
pAsNode->asSetID(nID);
m_Nodes.insert(nID, pAsNode);
}
LOGDEBUG("CreateNode:%d", nID);
return pAsNode;
}
AsVirtualFolder *AsFactory::asGetVirtualFolder(int id, const QString &path)
{
if (m_VirtualFolders.contains(id))
{
return m_VirtualFolders.value(id);
}
QString thePath = path;
if (path.isEmpty())
{
thePath = this->m_pFlipchart->asGetFlipchartWorkingPath();
}
AsVirtualFolder *pFolder = new AsVirtualFolder(this);
pFolder->asInitialise(thePath, id);
m_VirtualFolders.insert(id, pFolder);
return pFolder;
}
void AsFactory::asRemoveVirtualFolder(AsVirtualFolder *pFolder)
{
int id = pFolder->asGetFolderId();
m_VirtualFolders.remove(id);
delete pFolder;
}
bool AsFactory::asHasVirtualFolder(int id)
{
return m_VirtualFolders.contains(id);
}
void AsFactory::asRemoveVirtualFolder(int id)
{
AsVirtualFolder *pFolder = m_VirtualFolders.value(id);
if (pFolder != NULL)
{
m_VirtualFolders.remove(id);
delete pFolder;
}
}
AsFlipchart *AsFactory::asGetFlipchart(void)
{
return m_pFlipchart;
}
AsResourceRegister *AsFactory::asGetResourceRegister()
{
return m_pResourceRegister;
}