Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PluginFunctions.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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 //=============================================================================
54 //
55 // Standard Functions
56 //
57 //=============================================================================
58 
64 //
65 #ifndef PLUGINFUNCTIONS_HH
66 #define PLUGINFUNCTIONS_HH
67 
69 
70 #include <QPair>
71 #include <QFileDialog>
72 
74 #include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh>
75 
76 //== FORWARDDECLARATIONS ======================================================
77 class ViewObjectMarker;
78 class QGLWidget;
79 
82 namespace PluginFunctions {
83 
84 //=======================================
85 // Get Source/Target objects
88 //=======================================
89 
96 bool getPickedObject(const unsigned int _node_idx , BaseObjectData*& _object);
97 
100 //=======================================
101 // Get Objects by their identifier
104 //=======================================
105 
111 DLLEXPORT
112 bool getSourceIdentifiers( std::vector<int>& _identifiers );
113 
119 DLLEXPORT
120 bool getTargetIdentifiers( std::vector<int>& _identifiers );
121 
127 DLLEXPORT
128 bool getAllObjectIdentifiers( std::vector<int>& _identifiers );
129 
135 DLLEXPORT
136 bool getAllMeshes( std::vector<int>& _identifiers );
137 
148 DLLEXPORT
149 bool getObject( const int _identifier , BaseObject*& _object );
150 
154 DLLEXPORT
155 bool getObject( const int _identifier , BaseObjectData*& _object );
156 
159 DLLEXPORT
160 int getObjectId( const QString& _name );
161 
167 DLLEXPORT
168 bool objectExists( const int _identifier );
169 
171 DLLEXPORT
172 int objectCount();
173 
175 DLLEXPORT
176 int targetCount();
177 
179 DLLEXPORT
180 int sourceCount();
181 
183 DLLEXPORT
184 int visibleCount();
185 
188 //=======================================
189 // Get/set status of examiner
192 //=======================================
193 
194 
196 DLLEXPORT
197 int viewers( );
198 
206 DLLEXPORT
208 
214 DLLEXPORT
215 bool examinerLightHandling();
216 
218 DLLEXPORT
219 void setActiveExaminer( const unsigned int _id );
220 
222 DLLEXPORT
223 unsigned int activeExaminer();
224 
226 DLLEXPORT
227 QString getEncodedExaminerView();
228 
230 DLLEXPORT
231 QString getEncodedExaminerView(int _viewerId);
232 
234 DLLEXPORT
235 void setEncodedExaminerView( QString _view );
236 
238 DLLEXPORT
239 void setEncodedExaminerView(int _viewerId , QString _view );
240 
244 DLLEXPORT
245 void setSceneCenter(const ACG::Vec3d& _center, int _viewer );
246 
252 DLLEXPORT
253 bool scenegraphPick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr );
254 
259 DLLEXPORT
260 bool scenegraphPick( const unsigned int _examiner ,ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr );
261 
268 DLLEXPORT
269 bool scenegraphPick( const unsigned int _examiner ,ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, BaseObjectData*& _object, unsigned int &_targetIdx, const bool _refine ,ACG::Vec3d *_hitPointPtr );
270 
277 DLLEXPORT
278 bool scenegraphPick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, BaseObjectData*& _object, unsigned int &_targetIdx, const bool _refine, ACG::Vec3d *_hitPointPtr );
279 
280 
285 DLLEXPORT
287  const QRegion& _region,
288  QList<QPair<unsigned int, unsigned int> >& _list,
289  QVector<float>* _depths = 0,
290  QVector<ACG::Vec3d>* _points = 0);
291 
295 DLLEXPORT
296 bool scenegraphRegionPick( const unsigned int _examiner,
297  ACG::SceneGraph::PickTarget _pickTarget,
298  const QRegion& _region,
299  QList<QPair<unsigned int, unsigned int> >& _list,
300  QVector<float>* _depths = 0,
301  QVector<ACG::Vec3d>* _points = 0);
302 
307 DLLEXPORT
309 
311 DLLEXPORT
312 const std::string pickMode ();
313 
315 DLLEXPORT
316 void pickMode ( const std::string& _mode);
317 
319 DLLEXPORT
320 void getCurrentViewImage(QImage& _image);
321 
330 DLLEXPORT
332 
338 DLLEXPORT
340 
346 DLLEXPORT
348 
355 
364 DLLEXPORT
366 
368 DLLEXPORT
369 void actionMode ( Viewer::ActionMode _mode);
370 
372 DLLEXPORT
373 Viewer::ActionMode actionMode();
374 
376 DLLEXPORT
377 void shareGLWidget (QGLWidget* _widget);
378 
380 DLLEXPORT
381 QGLWidget* shareGLWidget ();
382 
387 DLLEXPORT
388 void allowRotation(bool _mode);
389 
393 DLLEXPORT
394 QPoint mapToGlobal( const QPoint _point );
395 
399 DLLEXPORT
400 QPoint mapToLocal( const QPoint _point );
401 
406 DLLEXPORT
407 void setViewObjectMarker (ViewObjectMarker *_marker);
408 
413 DLLEXPORT
415 
418 DLLEXPORT
419 QStringList collectObjectComments(bool visibleOnly, bool targetedOnly);
420 
423 DLLEXPORT
424 QStringList collectObjectMaterials(bool visibleOnly, bool targetedOnly);
425 
427 DLLEXPORT
429 
433 //=======================================
434 // Iterators for object Access
437 //=======================================
438 
439 typedef QStringList IteratorRestriction;
440 
441 const QStringList ALL_OBJECTS;
442 const QStringList TARGET_OBJECTS ("target");
443 const QStringList SOURCE_OBJECTS ("source");
444 
453 
454  public :
455 
458 
461 
463  typedef value_type& reference;
464 
466  typedef value_type* pointer;
467 
475  ObjectIterator(IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL );
476 
478  ObjectIterator(BaseObjectData* pos, IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL );
479 
481  operator value_handle() { return pos_; };
482 
484  bool operator==( const ObjectIterator& _rhs) const;
485 
487  bool operator!=( const ObjectIterator& _rhs) const;
488 
490  ObjectIterator& operator=( const ObjectIterator& _rhs);
491 
493  pointer operator->();
494 
496  ObjectIterator& operator++();
497 
499  ObjectIterator& operator--();
500 
502  BaseObjectData* operator*();
503 
505  BaseObjectData* index() { return pos_; };
506 
507  private :
509  BaseObjectData* pos_;
510 
513 
515  IteratorRestriction restriction_;
516 
520  inline void proceedToNextBaseObjectData(BaseObject*& _object);
521 };
522 
523 
528 class DLLEXPORT ObjectReferenceIterator : public std::iterator<std::forward_iterator_tag, BaseObjectData>
529 {
530 public:
531  explicit ObjectReferenceIterator(IteratorRestriction _restriction = ALL_OBJECTS, DataType _dataType = DATA_ALL) :
532  it_(_restriction, _dataType)
533  {
534  }
535 
536  explicit ObjectReferenceIterator(BaseObjectData* _pos, IteratorRestriction _restriction = ALL_OBJECTS, DataType _dataType = DATA_ALL) :
537  it_(_pos, _restriction, _dataType)
538  {
539  }
540 
542  it_(_rhs.it_)
543  {
544  }
545 
546  ObjectReferenceIterator& operator=(const ObjectReferenceIterator& _rhs)
547  {
548  if (this != &_rhs) {
549  it_ = _rhs.it_;
550  }
551  return *this;
552  }
553 
554  ObjectReferenceIterator& operator++() {
555  ++it_;
556  return *this;
557  }
558 
559  ObjectReferenceIterator operator++(int) {
560  ObjectReferenceIterator copy(*this);
561  operator++();
562  return copy;
563  }
564 
565  bool operator==(const ObjectReferenceIterator& _rhs) const {
566  return it_ == _rhs.it_;
567  }
568 
569  bool operator!=(const ObjectReferenceIterator& _rhs) const {
570  return it_ != _rhs.it_;
571  }
572 
573  BaseObjectData& operator*() {
574  return **it_;
575  }
576 
577  BaseObjectData* operator->() {
578  return *it_;
579  }
580 
581 private:
582  ObjectIterator it_;
583 };
584 
585 
595 public:
596  explicit ObjectRange(IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL) :
597  restriction_(_restriction),
598  dataType_(_dataType)
599  {
600  }
601 
602  ObjectIterator begin() const {
603  return ObjectIterator(restriction_, dataType_);
604  }
605 
606  ObjectIterator end() const {
607  return ObjectIterator(0);
608  }
609 
610 private:
611  IteratorRestriction restriction_;
612  DataType dataType_;
613 };
614 
615 
625 public:
626  explicit ObjectReferenceRange(IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL) :
627  restriction_(_restriction),
628  dataType_(_dataType)
629  {
630  }
631 
632  ObjectReferenceIterator begin() const {
633  return ObjectReferenceIterator(restriction_, dataType_);
634  }
635 
636  ObjectReferenceIterator end() const {
637  return ObjectReferenceIterator(0);
638  }
639 
640 private:
641  IteratorRestriction restriction_;
642  DataType dataType_;
643 };
644 
645 
658 DLLEXPORT
659 ObjectReferenceRange objectReferences(IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL);
660 
661 
675 DLLEXPORT
676 ObjectRange objects(IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL);
677 
678 
687 
688  public :
689 
692 
695 
697  typedef value_type& reference;
698 
700  typedef value_type* pointer;
701 
709  BaseObjectIterator(IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL );
710 
712  BaseObjectIterator(BaseObject* pos, IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL );
713 
715  operator value_handle() { return pos_; };
716 
718  bool operator==( const BaseObjectIterator& _rhs);
719 
721  bool operator!=( const BaseObjectIterator& _rhs);
722 
724  BaseObjectIterator& operator=( const BaseObjectIterator& _rhs);
725 
727  pointer operator->();
728 
730  BaseObjectIterator& operator++();
731 
733  BaseObjectIterator& operator--();
734 
736  BaseObject* operator*();
737 
739  BaseObject* index() { return pos_; };
740 
741  private :
743  BaseObject* pos_;
744 
747 
749  IteratorRestriction restriction_;
750 
751 };
752 
753 // /// Return Iterator to Mesh End
754 // MeshIterator meshes_end();
755 
757 DLLEXPORT
759 
761 DLLEXPORT
763 
766 //=======================================
767 // Dont Use functions below!!!
770 //=======================================
771 
773 DLLEXPORT
774 void setDataRoot( BaseObject* _root );
775 
778 //=======================================
781 //=======================================
782 
788 DLLEXPORT
790 
799 DLLEXPORT
800 int viewerId();
801 
803 DLLEXPORT
805 
825 DLLEXPORT
826 QString getOpenFileName(const QString &configProperty,
827  QWidget * parent = 0, const QString & caption = QString(),
828  const QString & defaultDir = QString(), const QString & filter = QString(),
829  QString * selectedFilter = 0, QFileDialog::Options options = 0);
849 DLLEXPORT
850 QString getSaveFileName(const QString &configProperty,
851  QWidget * parent = 0, const QString & caption = QString(),
852  const QString & defaultDir = QString(), const QString & filter = QString(),
853  QString * selectedFilter = 0, QFileDialog::Options options = 0,
854  const QString & defaultSuffix = QString() );
855 
856 } /* namespace PluginFunctions */
857 
858 #endif //PLUGINFUNCTIONS_HH
int viewerId()
Return unique viewer id.
BaseObject * value_handle
handle type (just an int)
const QStringList ALL_OBJECTS
Iterable object range.
void setViewObjectMarker(ViewObjectMarker *_marker)
void allowRotation(bool _mode, int _viewer)
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
int getObjectId(const QString &_name)
void disableExaminerLightHandling()
Disable the core light handling.
int targetCount()
Get the number of target objects.
IteratorRestriction restriction_
Restriction of the iterator.
Helper class that wraps an ObjectIterator to return a reference instead of a pointer.
int visibleCount()
Get the number of visible objects.
bool getObject(int _identifier, BSplineCurveObject *&_object)
value_type & reference
reference type
const QStringList SOURCE_OBJECTS("source")
Iterable object range.
QPoint mapToGlobal(const QPoint _point)
Map coordinates of GL Widget to global coordinates.
bool getSourceIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a source object.
BaseObjectData value_type
type of the Objects the iterator works on
bool getAllObjectIdentifiers(std::vector< int > &_identifiers)
Get identifiers of all objects.
void setEncodedExaminerView(QString _view)
Set the encoded view for the active examiner.
DLLEXPORT BaseObjectIterator baseObjectsEnd()
Return Iterator to Object End.
bool examinerLightHandling()
returns if internal light handling is active.
BaseObjectData * value_handle
handle type (just an int)
ViewObjectMarker * defaultViewObjectMarker()
Get the default ViewObjectMarker.
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void setSceneCenter(const ACG::Vec3d &_center, int _viewer)
QStringList collectObjectComments(bool visibleOnly, bool targetedOnly)
bool scenegraphRegionPick(ACG::SceneGraph::PickTarget _pickTarget, const QRegion &_region, QList< QPair< unsigned int, unsigned int > > &_list, QVector< float > *_depths, QVector< ACG::Vec3d > *_points)
QStringList collectObjectMaterials(bool visibleOnly, bool targetedOnly)
void setActiveExaminer(const unsigned int _id)
Set the active id of the examiner which got the last mouse events.
void getCurrentViewImage(QImage &_image)
Returns a QImage of the current View.
ObjectReferenceRange objectReferences(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
const std::string pickMode()
Get the current Picking mode.
void setDataRoot(BaseObject *_root)
QString getSaveFileName(const QString &configProperty, QWidget *parent, const QString &caption, const QString &defaultDir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QString &defaultSuffix)
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void addGlobalStatusNode(ACG::SceneGraph::BaseNode *_node)
Adds a global status node.
Range adapter for ObjectIterator.
BaseObject *& objectRoot()
Get the root of the object structure.
QString getEncodedExaminerView()
Get the encoded view for the active examiner.
QString getOpenFileName(const QString &configProperty, QWidget *parent, const QString &caption, const QString &defaultDir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
void addGlobalNode(ACG::SceneGraph::BaseNode *_node)
Add a global node.
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
int viewers()
Get the number of viewers.
DataType dataType_
returned data types of the iterator
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
void addObjectRenderingNode(ACG::SceneGraph::BaseNode *_node)
Add scenegraph node modifing object rendering.
void shareGLWidget(QGLWidget *_widget)
Sets the main QGLWidget for gl data sharing.
value_type * pointer
basic pointer type
value_type & reference
reference type
void setDefaultViewObjectMarker(ViewObjectMarker *_marker)
#define DLLEXPORT
bool getAllMeshes(std::vector< int > &_identifiers)
Get identifiers of all meshes.
bool getTargetIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a target object.
int sourceCount()
Get the number of source objects.
QPoint mapToLocal(const QPoint _point)
Map global coordinates to GL Widget local coordinates.
int objectCount()
Get the number of available objects.
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
BaseObjectData * baseObjectData(BaseObject *_object)
Cast an BaseObject to a BaseObjectData if possible.
QStringList IteratorRestriction
Iterable object range.
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
Core Data Iterator used to iterate over all objects (Including groups)
DataType dataType_
returned data types of the iterator
Predefined datatypes.
Definition: DataTypes.hh:96
Viewer::ActionMode actionMode()
Get the current Action mode.
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
bool getPickedObject(const unsigned int _node_idx, BaseObjectData *&_object)
Get the picked mesh.
BaseObject value_type
type of the Objects the iterator works on
value_type * pointer
basic pointer type
Range adapter for ObjectIterator.
IteratorRestriction restriction_
Restriction of the iterator.
void traverse(ACG::SceneGraph::MouseEventAction &_action)
bool objectExists(const int _identifier)
Check if an object with this identifier exists.