GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoTabElementBase.cxx
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 
35 #include "QGoTabElementBase.h"
36 
37 #include <QApplication>
38 #include <QAction>
39 #include <QMenu>
40 #include <QToolBar>
41 #include <QDockWidget>
42 #include <QPluginLoader>
43 
44 #include <iostream>
45 
46 //--------------------------------------------------------------------------
48  : QMainWindow(iParent),
49  m_StatusBar(NULL)
50  //m_TracesActions(NULL),
51  //m_TraceSettingsToolBar(NULL),
52 {
53  //this->m_TracesActions = new QGoToolBarStatus;
54 }
55 
56 //--------------------------------------------------------------------------
57 
58 //--------------------------------------------------------------------------
60 {
61 }
62 
63 //--------------------------------------------------------------------------
64 
65 //--------------------------------------------------------------------------
66 std::vector< QAction * > QGoTabElementBase::ViewActions()
67 {
68  return m_ViewActions;
69 }
70 
71 //--------------------------------------------------------------------------
72 
73 //--------------------------------------------------------------------------
74 std::vector< QAction * > QGoTabElementBase::ViewNoToolBarActions()
75 {
76  return this->m_ViewNoToolBarActions;
77 }
78 //--------------------------------------------------------------------------
79 
80 //--------------------------------------------------------------------------
81 std::vector< QAction * > QGoTabElementBase::SegmentationActions()
82 {
83  return m_SegmentationActions;
84 }
85 
86 //--------------------------------------------------------------------------
87 
88 //--------------------------------------------------------------------------
89 std::vector< QAction * > QGoTabElementBase::ToolsActions()
90 {
91  return m_ToolsActions;
92 }
93 
94 //--------------------------------------------------------------------------
95 
96 //--------------------------------------------------------------------------
97 std::vector< QAction * > QGoTabElementBase::BookmarkActions()
98 {
99  return m_BookmarkActions;
100 }
101 
102 //--------------------------------------------------------------------------
103 
104 //--------------------------------------------------------------------------
105 //std::vector< QAction * > QGoTabElementBase::ModeActions()
106 //{
107 // return m_ModeActions;
108 //}
109 
110 //--------------------------------------------------------------------------
111 
112 //--------------------------------------------------------------------------
113 //std::vector< QAction * > QGoTabElementBase::TracesActions()
114 //QGoToolBarStatus* QGoTabElementBase::TracesActions()
115 //{
116 // return m_TracesActions;
117 //}
118 
120 
122 //QGoTraceSettingsWidget* QGoTabElementBase::TraceSettingsWidget()
123 //{
124 // return m_TraceSettingsWidgetForToolBar;
125 //}
127 
129 //void QGoTabElementBase::SetTraceSettingsToolBar(
130 // QToolBar* iToolBar)
131 //{
132 // this->m_TraceSettingsToolBar = iToolBar;
133 //}
134 //--------------------------------------------------------------------------
135 
136 //--------------------------------------------------------------------------
137 std::list< QGoTabElementBase::QGoDockWidgetStatusPair > &
139 {
140  return m_DockWidgetList;
141 }
142 
143 //--------------------------------------------------------------------------
144 
145 //--------------------------------------------------------------------------
146 std::list< QAction * > QGoTabElementBase::GetPluginActions()
147 {
148  return m_PluginActionList;
149 }
150 
151 //--------------------------------------------------------------------------
152 
153 //--------------------------------------------------------------------------
154 void QGoTabElementBase::SetPluginActions(std::list< QAction * > iList)
155 {
156  m_PluginActionList = iList;
157 }
158 
159 //--------------------------------------------------------------------------
160 
161 //-------------------------------------------------------------------------
163  QMenu* iMenu, QToolBar* iToolBar)
164 {
165  QActionGroup* ModeGroup = new QActionGroup(this);
166  ModeGroup->setObjectName("ModeGroup");
167 
168  this->m_ModeToolBar = new QGoToolBarStatus(iToolBar, iMenu, Qt::TopToolBarArea,
169  true, true, this);
170  //---------------------------------//
171  // default mode //
172  //---------------------------------//
173 
174  // Create/initialize the default action
175  QAction *DefaultAction = new QAction(tr("Default"), this);
176  DefaultAction->setShortcut(tr("1", "Default Mode"));
177  DefaultAction->setObjectName("DefaultMode");
178 
179  DefaultAction->setCheckable(true);
180  DefaultAction->setChecked(true);
181 
182  QIcon DefaultIcon;
183  DefaultIcon.addPixmap(QPixmap( QString::fromUtf8(":/fig/mouse-cursor.png") ),
184  QIcon::Normal, QIcon::Off);
185  DefaultAction->setIcon(DefaultIcon);
186 
187  ModeGroup->addAction(DefaultAction);
188 
189  // it also updates the interactor behaviour
190  QObject::connect( DefaultAction, SIGNAL( toggled(bool) ),
191  this, SLOT( DefaultInteractorBehavior(bool) ) );
192 
193  this->m_ModeToolBar->m_VectorAction.push_back(DefaultAction);
194 
195  //---------------------------------//
196  // Zoom mode //
197  //---------------------------------//
198 
199  QAction *ZoomAction = new QAction(tr("Zoom"), this);
200  ZoomAction->setShortcut(tr("Z", "Zoom Mode"));
201  ZoomAction->setCheckable(true);
202  ZoomAction->setChecked(false);
203 
204  QIcon ZoomIcon;
205  ZoomIcon.addPixmap(QPixmap( QString::fromUtf8(":/fig/zoom.png") ),
206  QIcon::Normal, QIcon::Off);
207  ZoomAction->setIcon(ZoomIcon);
208 
209  ModeGroup->addAction(ZoomAction);
210 
211  this->m_ModeToolBar->m_VectorAction.push_back(ZoomAction);
212  // it also updates the interactor behaviour
213  QObject::connect( ZoomAction, SIGNAL( toggled(bool) ),
214  this, SLOT( ZoomInteractorBehavior(bool) ) );
215 
216  //---------------------------------//
217  // Translate mode //
218  //---------------------------------//
219 
220  QAction *TranslateAction = new QAction(tr("Translate"), this);
221  TranslateAction->setShortcut(tr("T", "Translate Mode"));
222  TranslateAction->setCheckable(true);
223  TranslateAction->setChecked(false);
224 
225  QIcon TranslateIcon;
226  TranslateIcon.addPixmap(QPixmap( QString::fromUtf8(":/fig/Hand.png") ),
227  QIcon::Normal, QIcon::Off);
228  TranslateAction->setIcon(TranslateIcon);
229 
230  ModeGroup->addAction(TranslateAction);
231 
232  this->m_ModeToolBar->m_VectorAction.push_back(TranslateAction);
233  // it also updates the interactor behaviour
234  QObject::connect( TranslateAction, SIGNAL( toggled(bool) ),
235  this, SLOT( TranslateInteractorBehavior(bool) ) );
236 
237  this->m_ToolBarList.push_back(this->m_ModeToolBar);
238 }
239 
240 //--------------------------------------------------------------------------
241 
242 //-------------------------------------------------------------------------
244 {
245 }
246 //--------------------------------------------------------------------------
247 
248 //-------------------------------------------------------------------------
250 {
251  this->m_StatusBar = iStatusbar;
252 }
253 //--------------------------------------------------------------------------
254 
255 //-------------------------------------------------------------------------
256 std::list< QGoToolBarStatus* > QGoTabElementBase::GetToolBarsStatus()
257 {
258  return this->m_ToolBarList;
259 }
virtual void CreateViewToolBar(QMenu *iMenu, QToolBar *iToolBar)
virtual std::vector< QAction * > ViewActions()
Get all actions belonging to View Menu and Toolbar.
void SetStatusBarPointer(QStatusBar *iStatusbar)
std::list< QGoDockWidgetStatusPair > m_DockWidgetList
void setChecked(bool)
virtual void TranslateInteractorBehavior(bool)
Mouse interaction style allows user to Translate volume with all buttons.
void setIcon(const QIcon &icon)
QAction * addAction(QAction *action)
QGoTabElementBase(QWidget *parent=0)
Constructor.
QString tr(const char *sourceText, const char *disambiguation, int n)
virtual void ZoomInteractorBehavior(bool)
Mouse interaction style allows user to zoom in/out volume with all buttons.
std::vector< QAction * > m_VectorAction
virtual ~QGoTabElementBase()
Destructor.
QString fromUtf8(const char *str, int size)
std::vector< QAction * > m_SegmentationActions
virtual std::list< QGoDockWidgetStatusPair > & DockWidget()
Get all actions belonging to Mode Menu and Toolbar.
virtual void CreateModeToolBar(QMenu *iMenu, QToolBar *iToolBar)
virtual void SetPluginActions(std::list< QAction * > iList)
void setObjectName(const QString &name)
virtual std::list< QAction * > GetPluginActions()
virtual void DefaultInteractorBehavior(bool)
Mouse interaction style set as default.
void addPixmap(const QPixmap &pixmap, Mode mode, State state)
std::vector< QAction * > m_ToolsActions
virtual std::list< QGoToolBarStatus * > GetToolBarsStatus()
virtual std::vector< QAction * > ViewNoToolBarActions()
Get all actions belonging to View Menu only.
virtual std::vector< QAction * > BookmarkActions()
Get all actions belonging to Bookmark Menu and Toolbar.
void setShortcut(const QKeySequence &shortcut)
std::list< QGoToolBarStatus * > m_ToolBarList
void setCheckable(bool)
std::vector< QAction * > m_ViewNoToolBarActions
QStatusBar * m_StatusBar
std::vector< QAction * > m_ViewActions
std::list< QAction * > m_PluginActionList
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
std::vector< QAction * > m_BookmarkActions
virtual std::vector< QAction * > ToolsActions()
Get all actions belonging to Tools Menu and Toolbar.
QGoToolBarStatus * m_ModeToolBar
virtual std::vector< QAction * > SegmentationActions()
Get all actions belonging to Segmentation Menu and Toolbar.