Developer Documentation
BaseObject.hh
Go to the documentation of this file.
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//
45// Types
46//
47//=============================================================================
48
54#pragma once
55
56//== INCLUDES =================================================================
57
60#include <OpenFlipper/common/UpdateType.hh>
61
62#include "perObjectData.hh"
63
64#include <vector>
65
66#include <QObject>
67#include <QString>
68#include <QList>
69#include <QStringList>
70#include <QMap>
71
72
73//== TYPEDEFS =================================================================
74
75
76//== CLASS DEFINITION =========================================================
77
82class DLLEXPORT BaseObject : public QObject {
83
84 Q_OBJECT
85
86 friend class BaseObjectData;
87 friend class Core;
88
89 public :
90
94 BaseObject(const BaseObject& _object);
95
100 explicit BaseObject( BaseObject *_parent = 0);
101
102 virtual ~BaseObject();
103
106 static int NOOBJECT;
107
108 //===========================================================================
111 //===========================================================================
112 public:
116 int id() const;
117
122 int persistentId() const;
123
126 void persistentId( int _id );
127
128 private:
134 int id_;
135
142
143 //===========================================================================
146 //===========================================================================
147
148 public:
152 bool dataType(DataType _type) const;
153
156 DataType dataType() const;
157
161 void setDataType(DataType _type);
162
163 private:
168
171 //===========================================================================
174 //===========================================================================
175
176 public:
180 virtual void cleanup();
181
184 //===========================================================================
187 //===========================================================================
188 public:
190 virtual QString getObjectinfo();
191
193 virtual void printObjectInfo();
194
197 //===========================================================================
200 //===========================================================================
201
202 signals:
203 void objectSelectionChanged(int _objectId);
204
205 public:
211 bool target();
212
215 void target(bool _target);
216
220 bool source();
221
224 void source(bool _source);
225
228 bool flag(QString _flag);
229
232 void setFlag(QString _flag, bool _set);
233
236 QStringList flags();
237
238 private:
239
243 QStringList flags_;
244
245
248 //===========================================================================
251 //===========================================================================
252
253 signals:
259 void visibilityChanged(int _objectId);
260
261
262 public :
264 virtual bool visible();
265
267 virtual void visible(bool _visible);
268
269 protected :
275
278 //===========================================================================
281 //===========================================================================
282
283 public:
284
285
287 void dumpTree();
288
290 virtual BaseObject* copy();
291
292 //===========================================================================
295 //===========================================================================
296
297 protected:
306 virtual void update(UpdateType _type = UPDATE_ALL);
307
311 //===========================================================================
314 //===========================================================================
315
316 public:
317
320 BaseObject* last();
321
324 BaseObject* next();
325
328 int level();
329
330 private:
333
335 QList<BaseObject*> childItems_;
336
337 public:
338 //===========================================================================
341 //===========================================================================
342
343 public:
344
346 int row() const;
347
349 BaseObject *parent();
350 const BaseObject *parent() const;
351
353 void setParent(BaseObject* _parent);
354
357 //===========================================================================
360 //===========================================================================
361
362 public:
363
365 BaseObject* childExists(int _objectId);
366
368 BaseObject* childExists(QString _name);
369
371 void appendChild(BaseObject *child);
372
374 BaseObject *child(int row);
375
377 int childCount() const;
378
380 void removeChild( BaseObject* _item );
381
383 QList< BaseObject* > getLeafs();
384
386 void deleteSubtree();
387
390 //===========================================================================
393 //===========================================================================
394
395 public:
396
402 int group() const;
403
405 bool isGroup() const;
406
411 bool isInGroup( int _id ) const;
412
417 bool isInGroup(const QString &_name ) const;
418
421 std::vector< int > getGroupIds();
422
425 QStringList getGroupNames();
426
427
430 //===========================================================================
433 //===========================================================================
434
439 void setFromFileName(const QString &_filename);
440
441
443 QString path() const;
444
446 void setPath(const QString &_path);
447
449 QString name( ) const;
450
451
452 /* set the name of the object. ( If you overwrite it, call BaseObject::setName(_name ) it in your funtion first)
453 * this is may not the filename of the given object, because one file can have multiple objects
454 */
455 virtual void setName(QString _name );
456
458 QString filename() const;
459
461 void setFileName(const QString &_filename);
462
463 private:
464
466 QString path_;
467 QString filename_;
468
469 signals:
473 void objectPropertiesChanged(int _objectId);
474
475 private:
476
478 QString name_;
479
480
483 //===========================================================================
487 //===========================================================================
488
489 public:
490
498 void setObjectData( QString _dataName , PerObjectData* _data );
499
501 void clearObjectData( QString _dataName );
502
504 bool hasObjectData( QString _dataName );
505
507 PerObjectData* objectData( QString _dataName );
508
510 void deleteData();
511
514 //===========================================================================
517 //===========================================================================
518
524 QMap<QString, PerObjectData*>& getPerObjectDataMap();
525
526
527 private:
528
529 QMap<QString, PerObjectData* > dataMap_;
530
533 //===========================================================================
536 //===========================================================================
537
538 public:
544 QString &getCommentByKey(const QString &key);
545
551 const QString getCommentByKey(const QString &key) const;
552
554 bool hasCommentForKey(const QString &key) const;
555
557 bool hasComments() const;
558
559 void clearComment(const QString &key);
560
561 void clearAllComments();
562
564 const QMap<QString, QString> &getAllComments() const;
565
567 const QString getAllCommentsFlat() const;
568
569 private:
570 QMap<QString, QString> commentsByKey_;
571
574};
575
#define DLLEXPORT
QString path_
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObject.hh:466
static int NOOBJECT
Definition: BaseObject.hh:106
QMap< QString, QString > commentsByKey_
Get comment for the specified key.
Definition: BaseObject.hh:570
int persistentId_
Persistent ID for this Object.
Definition: BaseObject.hh:141
QString filename_
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObject.hh:467
int id_
Unique ID for this Object.
Definition: BaseObject.hh:134
QStringList flags_
Definition: BaseObject.hh:243
BaseObject * parentItem_
Parent item or 0 if rootnode.
Definition: BaseObject.hh:332
void visibilityChanged(int _objectId)
DataType objectType_
Definition: BaseObject.hh:167
QString name_
Object/FileName ( defaults to NONAME )
Definition: BaseObject.hh:478
QList< BaseObject * > childItems_
Children of this node.
Definition: BaseObject.hh:335
bool visible_
Definition: BaseObject.hh:274
void objectSelectionChanged(int _objectId)
void objectPropertiesChanged(int _objectId)
QMap< QString, PerObjectData * > dataMap_
get reference to map of all perObject Datas
Definition: BaseObject.hh:529
Definition: Core.hh:133
void clearAllComments(int objId)
Called when a plugin requests an update in the viewer.
Definition: Core.cc:1907
Predefined datatypes.
Definition: DataTypes.hh:83
Object Payload.
Update type class.
Definition: UpdateType.hh:59
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.