RulerPlugin.hh 5.33 KB
Newer Older
Matthias Möller's avatar
Matthias Möller committed
1 2 3
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
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
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Matthias Möller's avatar
Matthias Möller committed
39 40 41
*                                                                            *
\*===========================================================================*/

Jan Möbius's avatar
Jan Möbius committed
42

Matthias Möller's avatar
Matthias Möller committed
43 44 45 46 47 48 49

#ifndef RULERPLUGIN_HH
#define RULERPLUGIN_HH

#include <QObject>
#include <QString>

50 51
#include <ACG/Utils/SmartPointer.hh>

Matthias Möller's avatar
Matthias Möller committed
52 53 54 55
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/MouseInterface.hh>
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
56
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
Matthias Möller's avatar
Matthias Möller committed
57
#include <OpenFlipper/BasePlugin/OptionsInterface.hh>
Matthias Möller's avatar
Matthias Möller committed
58

59
#include "Ruler.hh"
Matthias Möller's avatar
Matthias Möller committed
60
#include "RulerOptions.hh"
Matthias Möller's avatar
Matthias Möller committed
61

Matthias Möller's avatar
Matthias Möller committed
62
class RulerPlugin : public QObject, BaseInterface, MouseInterface, PickingInterface, ToolbarInterface, LoadSaveInterface, OptionsInterface
Matthias Möller's avatar
Matthias Möller committed
63 64 65 66 67 68
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(MouseInterface)
  Q_INTERFACES(PickingInterface)
  Q_INTERFACES(ToolbarInterface)
69
  Q_INTERFACES(LoadSaveInterface)
Matthias Möller's avatar
Matthias Möller committed
70
  Q_INTERFACES(OptionsInterface)
Matthias Möller's avatar
Matthias Möller committed
71

72 73
  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Ruler")

Matthias Möller's avatar
Matthias Möller committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
signals:
  void addToolbar(QToolBar *_toolbar);

  void addPickMode(const std::string &_mode);

  void updateView();

  void setPickModeMouseTracking  ( const std::string &_mode, bool  _mouseTracking);

public slots:

  void slotPickModeChanged(const std::string& _mode);

  void slotMouseEvent(QMouseEvent* _event);

89
  void slotViewChanged();
Matthias Möller's avatar
Matthias Möller committed
90 91
public:

Matthias Möller's avatar
Matthias Möller committed
92 93 94
  // OptionsInterface
  bool initializeOptionsWidget(QWidget*& _widget);

Matthias Möller's avatar
Matthias Möller committed
95 96 97 98 99 100 101 102
  RulerPlugin();
  ~RulerPlugin();

  QString name(){return QString("RulerPlugin");}
  QString description(){return QString("Measure the distance between two points.");}

private:

103 104
  void reset();

105 106 107
  void enableDragMode(const int _point);

  void disableDragMode();
Matthias Möller's avatar
Matthias Möller committed
108

109
  bool dragModeActive(){return lineDrag_ >= 0;}
110

111
  QAction *buttonAction_;
112

Matthias Möller's avatar
Matthias Möller committed
113 114 115 116 117
  const std::string pickModeName_;

  //saves the index of the dragged point, if no point was dragged, it is -1
  int lineDrag_;

118 119
  //checks if a double click was provided for resetting
  bool dblClickCheck_;
Matthias Möller's avatar
Matthias Möller committed
120

121
  ptr::shared_ptr<Ruler> currentRuler_;
Matthias Möller's avatar
Matthias Möller committed
122 123 124 125

  RulerOptions* optionsWidget_;

  const QString textSizeSettingName_;
Matthias Möller's avatar
Matthias Möller committed
126 127 128 129 130 131 132 133
private slots:

  void initializePlugin();

  void pluginsInitialized();

  void slotChangePickMode();

134
  void slotAllCleared();
Matthias Möller's avatar
Matthias Möller committed
135

136 137
  void objectDeleted(int _id);

Matthias Möller's avatar
Matthias Möller committed
138 139
  // OptionsInterface
  void applyOptions();
Matthias Möller's avatar
Matthias Möller committed
140 141 142 143 144 145 146

public slots:
  QString version(){ return QString("1.0"); }
};


#endif //RULERPLUGIN_HH