SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Note.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2012 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9  License for the specific language governing rights and limitations under
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 #ifndef INTERFACE_APPLICATION_NOTE_H
30 #define INTERFACE_APPLICATION_NOTE_H
31 
33 #include <boost/shared_ptr.hpp>
34 #include <QString>
35 #include <QFont>
36 #include <QColor>
37 #include <QPointF>
38 
39 class QAction;
40 class QGraphicsItem;
41 class QGraphicsTextItem;
42 class QGraphicsScene;
43 
44 namespace SCIRun {
45 namespace Gui {
46 
48  {
52  Top,
53  Left,
56  };
57 
58  struct Note
59  {
60  QString html_;
62  };
63 
64  class HasNotes
65  {
66  public:
67  HasNotes(const std::string& name, bool positionAdjustable);
68  virtual ~HasNotes();
69  void connectNoteEditorToAction(QAction* action);
70  void connectUpdateNote(QObject* obj);
71  void setCurrentNote(const Note& note) { currentNote_ = note; }
72  protected:
73  void destroy();
74  private:
75  class NoteEditor* noteEditor_;
76  Note currentNote_;
77  /// @todo: extract and make atomic
78  bool destroyed_;
79  };
80 
82  {
83  public:
84  virtual ~NoteDisplayStrategy() {}
85  virtual QPointF relativeNotePosition(QGraphicsItem* item, const QGraphicsTextItem* note, NotePosition position) const = 0;
86  };
87 
88  typedef boost::shared_ptr<NoteDisplayStrategy> NoteDisplayStrategyPtr;
90  class ConnectionNoteDisplayStrategy;
91 
93  {
94  public:
95  virtual ~NoteDisplayHelper();
96  protected:
97  explicit NoteDisplayHelper(NoteDisplayStrategyPtr display);
98  virtual void setNoteGraphicsContext() = 0;
99  void updateNoteImpl(const Note& note);
100  void updateNotePosition();
102  QGraphicsItem* item_;
103  QGraphicsScene* scene_;
105  void destroy();
106  private:
107  QGraphicsTextItem* note_;
108  NotePosition notePosition_, defaultNotePosition_;
109  NoteDisplayStrategyPtr displayStrategy_;
110  bool destroyed_;
111 
112  QPointF relativeNotePosition();
113  };
114 }
115 }
116 
117 #endif
Definition: Note.h:58
Definition: Note.h:51
QGraphicsItem * item_
Definition: Note.h:102
Definition: Note.h:50
Definition: Note.h:54
Definition: Note.h:55
void updateNotePosition()
Definition: Note.cc:132
NotePosition
Definition: Note.h:47
virtual ~NoteDisplayStrategy()
Definition: Note.h:84
virtual void setNoteGraphicsContext()=0
virtual ~NoteDisplayHelper()
Definition: Note.cc:79
virtual ~HasNotes()
Definition: Note.cc:45
boost::shared_ptr< PositionProvider > PositionProviderPtr
Definition: PositionProvider.h:47
const char * name[]
Definition: BoostGraphExampleTests.cc:87
Definition: Note.h:52
void connectUpdateNote(QObject *obj)
Definition: Note.cc:65
Definition: Note.h:64
Definition: Note.h:53
PositionProviderPtr positioner_
Definition: Note.h:104
NotePosition position_
Definition: Note.h:61
void connectNoteEditorToAction(QAction *action)
Definition: Note.cc:59
HasNotes(const std::string &name, bool positionAdjustable)
Definition: Note.cc:40
void destroy()
Definition: Note.cc:50
void setDefaultNotePositionImpl(NotePosition position)
Definition: Note.cc:126
QString html_
Definition: Note.h:60
NoteDisplayHelper(NoteDisplayStrategyPtr display)
Definition: Note.cc:70
boost::shared_ptr< NoteDisplayStrategy > NoteDisplayStrategyPtr
Definition: Note.h:88
Definition: Note.h:49
void destroy()
Definition: Note.cc:84
Definition: NoteEditor.h:40
virtual QPointF relativeNotePosition(QGraphicsItem *item, const QGraphicsTextItem *note, NotePosition position) const =0
void setCurrentNote(const Note &note)
Definition: Note.h:71
Definition: Note.h:92
void updateNoteImpl(const Note &note)
Definition: Note.cc:97
QGraphicsScene * scene_
Definition: Note.h:103
Definition: ModuleProxyWidget.cc:48