21
#include "PreCompiled.h"
24
# include <QApplication>
25
# include <QMessageBox>
28
#include <App/DocumentObject.h>
29
#include <Base/Console.h>
30
#include <Gui/Action.h>
31
#include <Gui/Application.h>
32
#include <Gui/BitmapFactory.h>
33
#include <Gui/Command.h>
34
#include <Gui/Control.h>
35
#include <Gui/Document.h>
36
#include <Gui/MainWindow.h>
37
#include <Gui/Selection.h>
38
#include <Gui/ViewProvider.h>
39
#include <Mod/TechDraw/App/DrawPage.h>
40
#include <Mod/TechDraw/App/DrawView.h>
42
#include "DrawGuiUtil.h"
43
#include "ViewProviderDrawingView.h"
46
using namespace TechDrawGui;
47
using namespace TechDraw;
49
void execStackTop(Gui::Command* cmd);
50
void execStackBottom(Gui::Command* cmd);
51
void execStackUp(Gui::Command* cmd);
52
void execStackDown(Gui::Command* cmd);
58
DEF_STD_CMD_ACL(CmdTechDrawStackGroup)
60
CmdTechDrawStackGroup::CmdTechDrawStackGroup()
61
: Command("TechDraw_StackGroup")
63
sAppModule = "TechDraw";
64
sGroup = QT_TR_NOOP("TechDraw");
65
sMenuText = QT_TR_NOOP("Adjust stacking order of views");
66
sToolTipText = sMenuText;
67
sWhatsThis = "TechDraw_StackGroup";
68
sStatusTip = sToolTipText;
71
void CmdTechDrawStackGroup::activated(int iMsg)
73
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
75
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
76
QObject::tr("Close active task dialog and try again."));
80
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
81
pcAction->setIcon(pcAction->actions().at(iMsg)->icon());
87
execStackBottom(this);
96
Base::Console().Message("CMD::StackGrp - invalid iMsg: %d\n",iMsg);
100
Gui::Action * CmdTechDrawStackGroup::createAction(void)
102
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
103
pcAction->setDropDownMenu(true);
104
applyCommandData(this->className(), pcAction);
106
QAction* p1 = pcAction->addAction(QString());
107
p1->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackTop"));
108
p1->setObjectName(QString::fromLatin1("TechDraw_StackTop"));
109
p1->setWhatsThis(QString::fromLatin1("TechDraw_StackTop"));
110
QAction* p2 = pcAction->addAction(QString());
111
p2->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackBottom"));
112
p2->setObjectName(QString::fromLatin1("TechDraw_StackBottom"));
113
p2->setWhatsThis(QString::fromLatin1("TechDraw_StackBottom"));
114
QAction* p3 = pcAction->addAction(QString());
115
p3->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackUp"));
116
p3->setObjectName(QString::fromLatin1("TechDraw_StackUp"));
117
p3->setWhatsThis(QString::fromLatin1("TechDraw_StackUp"));
118
QAction* p4 = pcAction->addAction(QString());
119
p4->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackDown"));
120
p4->setObjectName(QString::fromLatin1("TechDraw_StackDown"));
121
p4->setWhatsThis(QString::fromLatin1("TechDraw_StackDown"));
123
_pcAction = pcAction;
126
pcAction->setIcon(p1->icon());
128
pcAction->setProperty("defaultAction", QVariant(defaultId));
133
void CmdTechDrawStackGroup::languageChange()
135
Command::languageChange();
139
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
140
QList<QAction*> a = pcAction->actions();
142
QAction* arc1 = a[0];
143
arc1->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Top"));
144
arc1->setToolTip(QApplication::translate("TechDraw_StackTop","Move view to top of stack"));
145
arc1->setStatusTip(arc1->toolTip());
146
QAction* arc2 = a[1];
147
arc2->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Bottom"));
148
arc2->setToolTip(QApplication::translate("TechDraw_StackBottom","Move view to bottom of stack"));
149
arc2->setStatusTip(arc2->toolTip());
150
QAction* arc3 = a[2];
151
arc3->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Up"));
152
arc3->setToolTip(QApplication::translate("TechDraw_StackUp","Move view up one level"));
153
arc3->setStatusTip(arc3->toolTip());
154
QAction* arc4 = a[3];
155
arc4->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Down"));
156
arc4->setToolTip(QApplication::translate("TechDraw_StackDown","Move view down one level"));
157
arc4->setStatusTip(arc4->toolTip());
160
bool CmdTechDrawStackGroup::isActive(void)
162
bool havePage = DrawGuiUtil::needPage(this);
163
bool haveView = DrawGuiUtil::needView(this, false);
164
return (havePage && haveView);
171
DEF_STD_CMD_A(CmdTechDrawStackTop)
173
CmdTechDrawStackTop::CmdTechDrawStackTop()
174
: Command("TechDraw_StackTop")
176
sAppModule = "TechDraw";
177
sGroup = QT_TR_NOOP("TechDraw");
178
sMenuText = QT_TR_NOOP("Move view to top of stack");
179
sToolTipText = sMenuText;
180
sWhatsThis = "TechDraw_StackTop";
181
sStatusTip = sToolTipText;
182
sPixmap = "actions/TechDraw_StackTop";
185
void CmdTechDrawStackTop::activated(int iMsg)
189
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
191
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
192
QObject::tr("Close active task dialog and try again."));
199
bool CmdTechDrawStackTop::isActive(void)
201
bool havePage = DrawGuiUtil::needPage(this);
202
bool haveView = DrawGuiUtil::needView(this, false);
203
return (havePage && haveView);
206
void execStackTop(Gui::Command* cmd)
208
TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd);
213
std::vector<App::DocumentObject*> views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId());
214
if (!views.empty()) {
215
for (auto& v: views) {
216
TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(v);
217
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(
218
cmd->getDocument())->getViewProvider(dv);
219
ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp);
231
DEF_STD_CMD_A(CmdTechDrawStackBottom)
233
CmdTechDrawStackBottom::CmdTechDrawStackBottom()
234
: Command("TechDraw_StackBottom")
236
sAppModule = "TechDraw";
237
sGroup = QT_TR_NOOP("TechDraw");
238
sMenuText = QT_TR_NOOP("Move view to bottom of stack");
239
sToolTipText = sMenuText;
240
sWhatsThis = "TechDraw_StackBottom";
241
sStatusTip = sToolTipText;
242
sPixmap = "actions/TechDraw_StackBottom";
245
void CmdTechDrawStackBottom::activated(int iMsg)
249
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
251
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
252
QObject::tr("Close active task dialog and try again."));
256
execStackBottom(this);
259
bool CmdTechDrawStackBottom::isActive(void)
261
bool havePage = DrawGuiUtil::needPage(this);
262
bool haveView = DrawGuiUtil::needView(this, false);
263
return (havePage && haveView);
266
void execStackBottom(Gui::Command* cmd)
268
TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd);
273
std::vector<App::DocumentObject*> views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId());
274
if (!views.empty()) {
275
for (auto& v: views) {
276
TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(v);
277
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(
278
cmd->getDocument())->getViewProvider(dv);
279
ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp);
291
DEF_STD_CMD_A(CmdTechDrawStackUp)
293
CmdTechDrawStackUp::CmdTechDrawStackUp()
294
: Command("TechDraw_StackUp")
296
sAppModule = "TechDraw";
297
sGroup = QT_TR_NOOP("TechDraw");
298
sMenuText = QT_TR_NOOP("Move view up one level");
299
sToolTipText = sMenuText;
300
sWhatsThis = "TechDraw_StackUp";
301
sStatusTip = sToolTipText;
302
sPixmap = "actions/TechDraw_StackUp";
305
void CmdTechDrawStackUp::activated(int iMsg)
309
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
311
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
312
QObject::tr("Close active task dialog and try again."));
319
bool CmdTechDrawStackUp::isActive(void)
321
bool havePage = DrawGuiUtil::needPage(this);
322
bool haveView = DrawGuiUtil::needView(this, false);
323
return (havePage && haveView);
326
void execStackUp(Gui::Command* cmd)
328
TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd);
333
std::vector<App::DocumentObject*> views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId());
334
if (!views.empty()) {
335
for (auto& v: views) {
336
TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(v);
337
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(
338
cmd->getDocument())->getViewProvider(dv);
339
ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp);
351
DEF_STD_CMD_A(CmdTechDrawStackDown)
353
CmdTechDrawStackDown::CmdTechDrawStackDown()
354
: Command("TechDraw_StackDown")
356
sAppModule = "TechDraw";
357
sGroup = QT_TR_NOOP("TechDraw");
358
sMenuText = QT_TR_NOOP("Move view down one level");
359
sToolTipText = sMenuText;
360
sWhatsThis = "TechDraw_StackDown";
361
sStatusTip = sToolTipText;
362
sPixmap = "actions/TechDraw_StackDown";
365
void CmdTechDrawStackDown::activated(int iMsg)
369
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
371
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
372
QObject::tr("Close active task dialog and try again."));
379
bool CmdTechDrawStackDown::isActive(void)
381
bool havePage = DrawGuiUtil::needPage(this);
382
bool haveView = DrawGuiUtil::needView(this, false);
383
return (havePage && haveView);
386
void execStackDown(Gui::Command* cmd)
388
TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd);
393
std::vector<App::DocumentObject*> views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId());
394
if (!views.empty()) {
395
for (auto& v: views) {
396
TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(v);
397
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(
398
cmd->getDocument())->getViewProvider(dv);
399
ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp);
407
void CreateTechDrawCommandsStack(void)
409
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
411
rcCmdMgr.addCommand(new CmdTechDrawStackGroup());
412
rcCmdMgr.addCommand(new CmdTechDrawStackTop());
413
rcCmdMgr.addCommand(new CmdTechDrawStackBottom());
414
rcCmdMgr.addCommand(new CmdTechDrawStackUp());
415
rcCmdMgr.addCommand(new CmdTechDrawStackDown());