RulerPlugin.hh 5.81 KB
Newer Older
Matthias Möller's avatar
Matthias Möller committed
1 2 3
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
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 42 43
*                                                                            *
\*===========================================================================*/

/*===========================================================================*\
*                                                                            *
Matthias Möller's avatar
Matthias Möller committed
44 45 46
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
Matthias Möller's avatar
Matthias Möller committed
47 48 49 50 51 52 53 54 55
*                                                                            *
\*===========================================================================*/

#ifndef RULERPLUGIN_HH
#define RULERPLUGIN_HH

#include <QObject>
#include <QString>

56 57
#include <ACG/Utils/SmartPointer.hh>

Matthias Möller's avatar
Matthias Möller committed
58 59 60 61
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/MouseInterface.hh>
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
62
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
Matthias Möller's avatar
Matthias Möller committed
63
#include <OpenFlipper/BasePlugin/OptionsInterface.hh>
Matthias Möller's avatar
Matthias Möller committed
64

65
#include "Ruler.hh"
Matthias Möller's avatar
Matthias Möller committed
66
#include "RulerOptions.hh"
Matthias Möller's avatar
Matthias Möller committed
67

Matthias Möller's avatar
Matthias Möller committed
68
class RulerPlugin : public QObject, BaseInterface, MouseInterface, PickingInterface, ToolbarInterface, LoadSaveInterface, OptionsInterface
Matthias Möller's avatar
Matthias Möller committed
69 70 71 72 73 74
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(MouseInterface)
  Q_INTERFACES(PickingInterface)
  Q_INTERFACES(ToolbarInterface)
75
  Q_INTERFACES(LoadSaveInterface)
Matthias Möller's avatar
Matthias Möller committed
76
  Q_INTERFACES(OptionsInterface)
Matthias Möller's avatar
Matthias Möller committed
77

Matthias Möller's avatar
Matthias Möller committed
78 79
  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Ruler")

Matthias Möller's avatar
Matthias Möller committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
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);

95
  void slotViewChanged();
Matthias Möller's avatar
Matthias Möller committed
96 97
public:

Matthias Möller's avatar
Matthias Möller committed
98 99 100
  // OptionsInterface
  bool initializeOptionsWidget(QWidget*& _widget);

Matthias Möller's avatar
Matthias Möller committed
101 102 103 104 105 106 107 108
  RulerPlugin();
  ~RulerPlugin();

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

private:

109 110
  void reset();

111 112 113
  void enableDragMode(const int _point);

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

115
  bool dragModeActive(){return lineDrag_ >= 0;}
116

117
  QAction *buttonAction_;
118

Matthias Möller's avatar
Matthias Möller committed
119 120 121 122 123
  const std::string pickModeName_;

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

124 125
  //checks if a double click was provided for resetting
  bool dblClickCheck_;
Matthias Möller's avatar
Matthias Möller committed
126

127
  ptr::shared_ptr<Ruler> currentRuler_;
Matthias Möller's avatar
Matthias Möller committed
128 129 130 131

  RulerOptions* optionsWidget_;

  const QString textSizeSettingName_;
Matthias Möller's avatar
Matthias Möller committed
132 133 134 135 136 137 138 139
private slots:

  void initializePlugin();

  void pluginsInitialized();

  void slotChangePickMode();

140
  void slotAllCleared();
Matthias Möller's avatar
Matthias Möller committed
141

142 143
  void objectDeleted(int _id);

Matthias Möller's avatar
Matthias Möller committed
144 145
  // OptionsInterface
  void applyOptions();
Matthias Möller's avatar
Matthias Möller committed
146 147 148 149 150 151 152

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


#endif //RULERPLUGIN_HH