1
/***************************************************************************
2
* Copyright (c) 2002 Jļæ½rgen Riegel <juergen.riegel@web.de> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
24
#include "PreCompiled.h"
32
#include "Application.h"
33
#include "BitmapFactory.h"
34
#include "FileDialog.h"
35
#include "MainWindow.h"
40
#include "DlgDisplayPropertiesImp.h"
41
#include "DlgSettingsImageImp.h"
42
#include "Selection.h"
43
#include "SoFCOffscreenRenderer.h"
44
#include "View3DInventor.h"
45
#include "View3DInventorViewer.h"
46
#include "WaitCursor.h"
47
#include "ViewProviderMeasureDistance.h"
48
#include "SceneInspector.h"
50
#include <Base/Console.h>
51
#include <Base/Exception.h>
52
#include <Base/FileInfo.h>
53
#include <Base/Reader.h>
54
#include <App/Document.h>
55
#include <App/GeoFeature.h>
56
#include <App/MeasureDistance.h>
57
#include <App/Feature.h>
59
#include <QDomDocument>
60
#include <QDomElement>
63
using Gui::Dialog::DlgSettingsImageImp;
65
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67
DEF_STD_CMD_AC(StdOrthographicCamera);
69
StdOrthographicCamera::StdOrthographicCamera()
70
: Command("Std_OrthographicCamera")
72
sGroup = QT_TR_NOOP("Standard-View");
73
sMenuText = QT_TR_NOOP("Orthographic view");
74
sToolTipText = QT_TR_NOOP("Switches to orthographic view mode");
75
sWhatsThis = "Std_OrthographicCamera";
76
sStatusTip = QT_TR_NOOP("Switches to orthographic view mode");
80
void StdOrthographicCamera::activated(int iMsg)
83
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
84
if (view->getViewer()->getCameraType() != SoOrthographicCamera::getClassTypeId())
85
doCommand(Command::Gui,"Gui.activeDocument().activeView().setCameraType(\"Orthographic\")");
89
bool StdOrthographicCamera::isActive(void)
91
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
94
// update the action group if needed
95
bool check = _pcAction->isChecked();
96
bool mode = view->getViewer()->getCameraType() == SoOrthographicCamera::getClassTypeId();
98
_pcAction->setChecked(mode);
106
Action * StdOrthographicCamera::createAction(void)
108
Action *pcAction = Command::createAction();
109
pcAction->setCheckable( true );
113
DEF_STD_CMD_AC(StdPerspectiveCamera);
115
StdPerspectiveCamera::StdPerspectiveCamera()
116
: Command("Std_PerspectiveCamera")
118
sGroup = QT_TR_NOOP("Standard-View");
119
sMenuText = QT_TR_NOOP("Perspective view");
120
sToolTipText = QT_TR_NOOP("Switches to perspective view mode");
121
sWhatsThis = "Std_PerspectiveCamera";
122
sStatusTip = QT_TR_NOOP("Switches to perspective view mode");
126
void StdPerspectiveCamera::activated(int iMsg)
129
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
130
if (view->getViewer()->getCameraType() != SoPerspectiveCamera::getClassTypeId())
131
doCommand(Command::Gui,"Gui.activeDocument().activeView().setCameraType(\"Perspective\")");
135
bool StdPerspectiveCamera::isActive(void)
137
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
140
// update the action group if needed
141
bool check = _pcAction->isChecked();
142
bool mode = view->getViewer()->getCameraType() == SoPerspectiveCamera::getClassTypeId();
144
_pcAction->setChecked(mode);
152
Action * StdPerspectiveCamera::createAction(void)
154
Action *pcAction = Command::createAction();
155
pcAction->setCheckable( true );
159
//===========================================================================
161
//===========================================================================
162
class StdCmdFreezeViews : public Gui::Command
166
virtual ~StdCmdFreezeViews(){}
169
virtual void activated(int iMsg);
170
virtual bool isActive(void);
171
virtual Action * createAction(void);
172
virtual void languageChange();
176
void onRestoreViews();
188
StdCmdFreezeViews::StdCmdFreezeViews()
189
: Command("Std_FreezeViews"), maxViews(50), savedViews(0)
191
sGroup = QT_TR_NOOP("Standard-View");
192
sMenuText = QT_TR_NOOP("Freeze display");
193
sToolTipText = QT_TR_NOOP("Freezes the current view position");
194
sWhatsThis = "Std_FreezeViews";
195
sStatusTip = QT_TR_NOOP("Freezes the current view position");
196
iAccel = Qt::SHIFT+Qt::Key_F;
199
Action * StdCmdFreezeViews::createAction(void)
201
ActionGroup* pcAction = new ActionGroup(this, getMainWindow());
202
pcAction->setDropDownMenu(true);
203
pcAction->setText(QObject::tr(sMenuText));
204
pcAction->setToolTip(QObject::tr(sToolTipText));
205
pcAction->setStatusTip(QObject::tr(sStatusTip));
206
pcAction->setWhatsThis(QObject::tr(sWhatsThis));
208
// add the action items
209
saveView = pcAction->addAction(QObject::tr("Save views..."));
210
pcAction->addAction(QObject::tr("Load views..."));
211
pcAction->addAction(QString::fromAscii(""))->setSeparator(true);
212
freezeView = pcAction->addAction(QObject::tr("Freeze view"));
213
freezeView->setShortcut(iAccel);
214
clearView = pcAction->addAction(QObject::tr("Clear views"));
215
separator = pcAction->addAction(QString::fromAscii(""));
216
separator->setSeparator(true);
217
offset = pcAction->actions().count();
219
// allow up to 50 views
220
for (int i=0; i<maxViews; i++)
221
pcAction->addAction(QString::fromAscii(""))->setVisible(false);
226
void StdCmdFreezeViews::activated(int iMsg)
228
ActionGroup* pcAction = qobject_cast<ActionGroup*>(_pcAction);
232
} else if ( iMsg == 1 ) {
234
} else if ( iMsg == 3 ) {
236
const char* ppReturn=0;
237
getGuiApplication()->sendMsgToActiveView("GetCamera",&ppReturn);
239
QList<QAction*> acts = pcAction->actions();
241
for (QList<QAction*>::ConstIterator it = acts.begin()+offset; it != acts.end(); ++it, index++) {
242
if ( !(*it)->isVisible() ) {
244
QString viewnr = QString(QObject::tr("Restore view &%1")).arg(index+1);
245
(*it)->setText(viewnr);
246
(*it)->setToolTip(QString::fromAscii(ppReturn));
247
(*it)->setVisible(true);
249
int accel = Qt::CTRL+Qt::Key_1;
250
(*it)->setShortcut(accel+index);
255
} else if ( iMsg == 4 ) {
257
QList<QAction*> acts = pcAction->actions();
258
for (QList<QAction*>::ConstIterator it = acts.begin()+offset; it != acts.end(); ++it)
259
(*it)->setVisible(false);
260
} else if ( iMsg >= offset ) {
262
QList<QAction*> acts = pcAction->actions();
263
QString data = acts[iMsg]->toolTip();
264
QString send = QString::fromAscii("SetCamera %1").arg(data);
265
getGuiApplication()->sendMsgToActiveView(send.toAscii());
269
void StdCmdFreezeViews::onSaveViews()
271
// Save the views to an XML file
272
QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save frozen views"),
273
QString(), QObject::tr("Frozen views (*.cam)"));
277
if (file.open(QFile::WriteOnly))
279
QTextStream str(&file);
280
ActionGroup* pcAction = qobject_cast<ActionGroup*>(_pcAction);
281
QList<QAction*> acts = pcAction->actions();
282
str << "<?xml version='1.0' encoding='utf-8'?>" << endl
283
<< "<FrozenViews SchemaVersion=\"1\">" << endl;
284
str << " <Views Count=\"" << savedViews <<"\">" << endl;
286
for (QList<QAction*>::ConstIterator it = acts.begin()+offset; it != acts.end(); ++it) {
287
if ( !(*it)->isVisible() )
289
QString data = (*it)->toolTip();
291
// remove the first line because it's a comment like '#Inventor V2.1 ascii'
293
if ( !data.isEmpty() ) {
294
QStringList lines = data.split(QString::fromAscii("\n"));
295
if ( lines.size() > 1 ) {
297
viewPos = lines.join(QString::fromAscii(" "));
301
str << " <Camera settings=\"" << viewPos.toAscii().constData() << "\"/>" << endl;
304
str << " </Views>" << endl;
305
str << "</FrozenViews>" << endl;
309
void StdCmdFreezeViews::onRestoreViews()
311
// Should we clear the already saved views
312
if ( savedViews > 0 ) {
313
int ret = QMessageBox::question(getMainWindow(), QObject::tr("Restore views"),
314
QObject::tr("Importing the restored views would clear the already stored views.\n"
315
"Do you want to continue?"), QMessageBox::Yes|QMessageBox::Default,
316
QMessageBox::No|QMessageBox::Escape);
317
if (ret!=QMessageBox::Yes)
321
// Restore the views from an XML file
322
QString fn = FileDialog::getOpenFileName(getMainWindow(), QObject::tr("Restore frozen views"),
323
QString(), QObject::tr("Frozen views (*.cam)"));
327
if (!file.open(QFile::ReadOnly)) {
328
QMessageBox::critical(getMainWindow(), QObject::tr("Restore views"),
329
QObject::tr("Cannot open file '%1'.").arg(fn));
333
QDomDocument xmlDocument;
338
// evaluate the XML content
339
if (!xmlDocument.setContent(&file, true, &errorStr, &errorLine, &errorColumn)) {
340
std::cerr << "Parse error in XML content at line " << errorLine
341
<< ", column " << errorColumn << ": "
342
<< (const char*)errorStr.toAscii() << std::endl;
346
// get the root element
347
QDomElement root = xmlDocument.documentElement();
348
if (root.tagName() != QLatin1String("FrozenViews")) {
349
std::cerr << "Unexpected XML structure" << std::endl;
354
int scheme = root.attribute(QString::fromAscii("SchemaVersion")).toInt(&ok);
358
// read the views, ignore the attribute 'Count'
359
QDomElement child = root.firstChildElement(QString::fromAscii("Views"));
360
QDomElement views = child.firstChildElement(QString::fromAscii("Camera"));
362
while (!views.isNull()) {
363
QString setting = views.attribute(QString::fromAscii("settings"));
365
views = views.nextSiblingElement(QString::fromAscii("Camera"));
368
// use this rather than the attribute 'Count' because it could be
369
// changed from outside
370
int ct = cameras.count();
371
ActionGroup* pcAction = qobject_cast<ActionGroup*>(_pcAction);
372
QList<QAction*> acts = pcAction->actions();
374
int numRestoredViews = std::min<int>(ct, acts.size()-offset);
375
savedViews = numRestoredViews;
377
if (numRestoredViews > 0)
378
separator->setVisible(true);
379
for(int i=0; i<numRestoredViews; i++) {
380
QString setting = cameras[i];
381
QString viewnr = QString(QObject::tr("Restore view &%1")).arg(i+1);
382
acts[i+offset]->setText(viewnr);
383
acts[i+offset]->setToolTip(setting);
384
acts[i+offset]->setVisible(true);
386
int accel = Qt::CTRL+Qt::Key_1;
387
acts[i+offset]->setShortcut(accel+i);
391
// if less views than actions
392
for (int index = numRestoredViews+offset; index < acts.count(); index++)
393
acts[index]->setVisible(false);
397
bool StdCmdFreezeViews::isActive(void)
399
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
401
saveView->setEnabled(savedViews > 0);
402
freezeView->setEnabled(savedViews < maxViews);
403
clearView->setEnabled(savedViews > 0);
404
separator->setVisible(savedViews > 0);
407
separator->setVisible(savedViews > 0);
413
void StdCmdFreezeViews::languageChange()
415
Command::languageChange();
419
ActionGroup* pcAction = qobject_cast<ActionGroup*>(_pcAction);
420
QList<QAction*> acts = pcAction->actions();
421
acts[0]->setText(QObject::tr("Save views..."));
422
acts[1]->setText(QObject::tr("Load views..."));
423
acts[3]->setText(QObject::tr("Freeze view"));
424
acts[4]->setText(QObject::tr("Clear views"));
426
for (QList<QAction*>::ConstIterator it = acts.begin()+5; it != acts.end(); ++it, index++) {
427
if ( (*it)->isVisible() ) {
428
QString viewnr = QString(QObject::tr("Restore view &%1")).arg(index);
429
(*it)->setText(viewnr);
434
//===========================================================================
435
// Std_ToggleClipPlane
436
//===========================================================================
438
DEF_STD_CMD_AC(StdCmdToggleClipPlane);
440
StdCmdToggleClipPlane::StdCmdToggleClipPlane()
441
: Command("Std_ToggleClipPlane")
443
sGroup = QT_TR_NOOP("Standard-View");
444
sMenuText = QT_TR_NOOP("Clipping plane");
445
sToolTipText = QT_TR_NOOP("Toggles clipping plane for active view");
446
sWhatsThis = "Std_ToggleClipPlane";
447
sStatusTip = QT_TR_NOOP("Toggles clipping plane for active view");
450
Action * StdCmdToggleClipPlane::createAction(void)
452
Action *pcAction = (Action*)Command::createAction();
453
pcAction->setCheckable( true );
457
void StdCmdToggleClipPlane::activated(int iMsg)
459
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
461
if (iMsg > 0 && !view->hasClippingPlane())
462
view->toggleClippingPlane();
463
else if (iMsg == 0 && view->hasClippingPlane())
464
view->toggleClippingPlane();
468
bool StdCmdToggleClipPlane::isActive(void)
470
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
472
Action* action = qobject_cast<Action*>(_pcAction);
473
if (action->isChecked() != view->hasClippingPlane())
474
action->setChecked(view->hasClippingPlane());
477
Action* action = qobject_cast<Action*>(_pcAction);
478
if (action->isChecked())
479
action->setChecked(false);
484
//===========================================================================
485
// Std_ToggleVisibility
486
//===========================================================================
487
DEF_STD_CMD_A(StdCmdToggleVisibility);
489
StdCmdToggleVisibility::StdCmdToggleVisibility()
490
: Command("Std_ToggleVisibility")
492
sGroup = QT_TR_NOOP("Standard-View");
493
sMenuText = QT_TR_NOOP("Toggle visibility");
494
sToolTipText = QT_TR_NOOP("Toggles visibility");
495
sStatusTip = QT_TR_NOOP("Toggles visibility");
496
sWhatsThis = "Std_ToggleVisibility";
497
iAccel = Qt::Key_Space;
500
void StdCmdToggleVisibility::activated(int iMsg)
502
// go through all documents
503
const std::vector<App::Document*> docs = App::GetApplication().getDocuments();
504
for (std::vector<App::Document*>::const_iterator it = docs.begin(); it != docs.end(); ++it) {
505
Document *pcDoc = Application::Instance->getDocument(*it);
506
const std::vector<App::DocumentObject*> sel = Selection().getObjectsOfType
507
(App::DocumentObject::getClassTypeId(), (*it)->getName());
508
for(std::vector<App::DocumentObject*>::const_iterator ft=sel.begin();ft!=sel.end();ft++) {
509
if (pcDoc && pcDoc->isShow((*ft)->getNameInDocument()))
510
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False"
511
, (*it)->getName(), (*ft)->getNameInDocument());
513
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True"
514
, (*it)->getName(), (*ft)->getNameInDocument());
519
bool StdCmdToggleVisibility::isActive(void)
521
return (Gui::Selection().size() != 0);
524
//===========================================================================
526
//===========================================================================
527
DEF_STD_CMD_A(StdCmdShowSelection);
529
StdCmdShowSelection::StdCmdShowSelection()
530
: Command("Std_ShowSelection")
532
sGroup = QT_TR_NOOP("Standard-View");
533
sMenuText = QT_TR_NOOP("Show selection");
534
sToolTipText = QT_TR_NOOP("Show all selected objects");
535
sStatusTip = QT_TR_NOOP("Show all selected objects");
536
sWhatsThis = "Std_ShowSelection";
539
void StdCmdShowSelection::activated(int iMsg)
541
// go through all documents
542
const std::vector<App::Document*> docs = App::GetApplication().getDocuments();
543
for (std::vector<App::Document*>::const_iterator it = docs.begin(); it != docs.end(); ++it) {
544
const std::vector<App::DocumentObject*> sel = Selection().getObjectsOfType
545
(App::DocumentObject::getClassTypeId(), (*it)->getName());
546
for(std::vector<App::DocumentObject*>::const_iterator ft=sel.begin();ft!=sel.end();ft++) {
547
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True"
548
, (*it)->getName(), (*ft)->getNameInDocument());
553
bool StdCmdShowSelection::isActive(void)
555
return (Gui::Selection().size() != 0);
558
//===========================================================================
560
//===========================================================================
561
DEF_STD_CMD_A(StdCmdHideSelection);
563
StdCmdHideSelection::StdCmdHideSelection()
564
: Command("Std_HideSelection")
566
sGroup = QT_TR_NOOP("Standard-View");
567
sMenuText = QT_TR_NOOP("Hide selection");
568
sToolTipText = QT_TR_NOOP("Hide all selected objects");
569
sStatusTip = QT_TR_NOOP("Hide all selected objects");
570
sWhatsThis = "Std_HideSelection";
573
void StdCmdHideSelection::activated(int iMsg)
575
// go through all documents
576
const std::vector<App::Document*> docs = App::GetApplication().getDocuments();
577
for (std::vector<App::Document*>::const_iterator it = docs.begin(); it != docs.end(); ++it) {
578
const std::vector<App::DocumentObject*> sel = Selection().getObjectsOfType
579
(App::DocumentObject::getClassTypeId(), (*it)->getName());
580
for(std::vector<App::DocumentObject*>::const_iterator ft=sel.begin();ft!=sel.end();ft++) {
581
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False"
582
, (*it)->getName(), (*ft)->getNameInDocument());
587
bool StdCmdHideSelection::isActive(void)
589
return (Gui::Selection().size() != 0);
592
//===========================================================================
594
//===========================================================================
595
DEF_STD_CMD_A(StdCmdToggleObjects);
597
StdCmdToggleObjects::StdCmdToggleObjects()
598
: Command("Std_ToggleObjects")
600
sGroup = QT_TR_NOOP("Standard-View");
601
sMenuText = QT_TR_NOOP("Toggle all objects");
602
sToolTipText = QT_TR_NOOP("Toggles visibility of all objects in the active document");
603
sStatusTip = QT_TR_NOOP("Toggles visibility of all objects in the active document");
604
sWhatsThis = "Std_ToggleObjects";
607
void StdCmdToggleObjects::activated(int iMsg)
609
// go through active document
610
Gui::Document* doc = Application::Instance->activeDocument();
611
App::Document* app = doc->getDocument();
612
const std::vector<App::DocumentObject*> obj = app->getObjectsOfType
613
(App::DocumentObject::getClassTypeId());
615
for (std::vector<App::DocumentObject*>::const_iterator it=obj.begin();it!=obj.end();++it) {
616
if (doc && doc->isShow((*it)->getNameInDocument()))
617
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False"
618
, app->getName(), (*it)->getNameInDocument());
620
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True"
621
, app->getName(), (*it)->getNameInDocument());
625
bool StdCmdToggleObjects::isActive(void)
627
return App::GetApplication().getActiveDocument();
630
//===========================================================================
632
//===========================================================================
633
DEF_STD_CMD_A(StdCmdShowObjects);
635
StdCmdShowObjects::StdCmdShowObjects()
636
: Command("Std_ShowObjects")
638
sGroup = QT_TR_NOOP("Standard-View");
639
sMenuText = QT_TR_NOOP("Show all objects");
640
sToolTipText = QT_TR_NOOP("Show all objects in the document");
641
sStatusTip = QT_TR_NOOP("Show all objects in the document");
642
sWhatsThis = "Std_ShowObjects";
645
void StdCmdShowObjects::activated(int iMsg)
647
// go through active document
648
Gui::Document* doc = Application::Instance->activeDocument();
649
App::Document* app = doc->getDocument();
650
const std::vector<App::DocumentObject*> obj = app->getObjectsOfType
651
(App::DocumentObject::getClassTypeId());
653
for (std::vector<App::DocumentObject*>::const_iterator it=obj.begin();it!=obj.end();++it) {
654
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True"
655
, app->getName(), (*it)->getNameInDocument());
659
bool StdCmdShowObjects::isActive(void)
661
return App::GetApplication().getActiveDocument();
664
//===========================================================================
666
//===========================================================================
667
DEF_STD_CMD_A(StdCmdHideObjects);
669
StdCmdHideObjects::StdCmdHideObjects()
670
: Command("Std_HideObjects")
672
sGroup = QT_TR_NOOP("Standard-View");
673
sMenuText = QT_TR_NOOP("Hide all objects");
674
sToolTipText = QT_TR_NOOP("Hide all objects in the document");
675
sStatusTip = QT_TR_NOOP("Hide all objects in the document");
676
sWhatsThis = "Std_HideObjects";
679
void StdCmdHideObjects::activated(int iMsg)
681
// go through active document
682
Gui::Document* doc = Application::Instance->activeDocument();
683
App::Document* app = doc->getDocument();
684
const std::vector<App::DocumentObject*> obj = app->getObjectsOfType
685
(App::DocumentObject::getClassTypeId());
687
for (std::vector<App::DocumentObject*>::const_iterator it=obj.begin();it!=obj.end();++it) {
688
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False"
689
, app->getName(), (*it)->getNameInDocument());
693
bool StdCmdHideObjects::isActive(void)
695
return App::GetApplication().getActiveDocument();
698
//===========================================================================
700
//===========================================================================
701
DEF_STD_CMD_A(StdCmdSetAppearance);
703
StdCmdSetAppearance::StdCmdSetAppearance()
704
: Command("Std_SetAppearance")
706
sGroup = QT_TR_NOOP("Standard-View");
707
sMenuText = QT_TR_NOOP("Appearance...");
708
sToolTipText = QT_TR_NOOP("Sets the display properties of the selected object");
709
sWhatsThis = "Std_SetAppearance";
710
sStatusTip = QT_TR_NOOP("Sets the display properties of the selected object");
711
sPixmap = "Std_Tool1";
712
iAccel = Qt::CTRL+Qt::Key_D;
715
void StdCmdSetAppearance::activated(int iMsg)
717
static QPointer<QDialog> dlg = 0;
719
dlg = new Gui::Dialog::DlgDisplayPropertiesImp(getMainWindow());
720
dlg->setModal(false);
721
dlg->setAttribute(Qt::WA_DeleteOnClose);
725
bool StdCmdSetAppearance::isActive(void)
727
return Gui::Selection().size() != 0;
730
//===========================================================================
732
//===========================================================================
733
DEF_3DV_CMD(StdCmdViewBottom)
735
StdCmdViewBottom::StdCmdViewBottom()
736
: Command("Std_ViewBottom")
738
sGroup = QT_TR_NOOP("Standard-View");
739
sMenuText = QT_TR_NOOP("Bottom");
740
sToolTipText = QT_TR_NOOP("Set to bottom view");
741
sWhatsThis = "Std_ViewXX";
742
sStatusTip = QT_TR_NOOP("Set to bottom view");
743
sPixmap = "view-bottom";
747
void StdCmdViewBottom::activated(int iMsg)
749
doCommand(Command::Gui,"Gui.activeDocument().activeView().viewBottom()");
752
//===========================================================================
754
//===========================================================================
755
DEF_3DV_CMD(StdCmdViewFront);
757
StdCmdViewFront::StdCmdViewFront()
758
: Command("Std_ViewFront")
760
sGroup = QT_TR_NOOP("Standard-View");
761
sMenuText = QT_TR_NOOP("Front");
762
sToolTipText = QT_TR_NOOP("Set to front view");
763
sWhatsThis = "Std_ViewXX";
764
sStatusTip = QT_TR_NOOP("Set to front view");
765
sPixmap = "view-front";
769
void StdCmdViewFront::activated(int iMsg)
771
doCommand(Command::Gui,"Gui.activeDocument().activeView().viewFront()");
774
//===========================================================================
776
//===========================================================================
777
DEF_3DV_CMD(StdCmdViewLeft);
779
StdCmdViewLeft::StdCmdViewLeft()
780
: Command("Std_ViewLeft")
782
sGroup = QT_TR_NOOP("Standard-View");
783
sMenuText = QT_TR_NOOP("Left");
784
sToolTipText = QT_TR_NOOP("Set to left view");
785
sWhatsThis = "Std_ViewXX";
786
sStatusTip = QT_TR_NOOP("Set to left view");
787
sPixmap = "view-left";
791
void StdCmdViewLeft::activated(int iMsg)
793
doCommand(Command::Gui,"Gui.activeDocument().activeView().viewLeft()");
796
//===========================================================================
798
//===========================================================================
799
DEF_3DV_CMD(StdCmdViewRear);
801
StdCmdViewRear::StdCmdViewRear()
802
: Command("Std_ViewRear")
804
sGroup = QT_TR_NOOP("Standard-View");
805
sMenuText = QT_TR_NOOP("Rear");
806
sToolTipText = QT_TR_NOOP("Set to rear view");
807
sWhatsThis = "Std_ViewXX";
808
sStatusTip = QT_TR_NOOP("Set to rear view");
809
sPixmap = "view-rear";
813
void StdCmdViewRear::activated(int iMsg)
815
doCommand(Command::Gui,"Gui.activeDocument().activeView().viewRear()");
818
//===========================================================================
820
//===========================================================================
821
DEF_3DV_CMD(StdCmdViewRight);
823
StdCmdViewRight::StdCmdViewRight()
824
: Command("Std_ViewRight")
826
sGroup = QT_TR_NOOP("Standard-View");
827
sMenuText = QT_TR_NOOP("Right");
828
sToolTipText = QT_TR_NOOP("Set to right view");
829
sWhatsThis = "Std_ViewXX";
830
sStatusTip = QT_TR_NOOP("Set to right view");
831
sPixmap = "view-right";
835
void StdCmdViewRight::activated(int iMsg)
837
doCommand(Command::Gui,"Gui.activeDocument().activeView().viewRight()");
840
//===========================================================================
842
//===========================================================================
843
DEF_3DV_CMD(StdCmdViewTop);
845
StdCmdViewTop::StdCmdViewTop()
846
: Command("Std_ViewTop")
848
sGroup = QT_TR_NOOP("Standard-View");
849
sMenuText = QT_TR_NOOP("Top");
850
sToolTipText = QT_TR_NOOP("Set to top view");
851
sWhatsThis = "Std_ViewXX";
852
sStatusTip = QT_TR_NOOP("Set to top view");
853
sPixmap = "view-top";
857
void StdCmdViewTop::activated(int iMsg)
859
doCommand(Command::Gui,"Gui.activeDocument().activeView().viewTop()");
862
//===========================================================================
864
//===========================================================================
865
DEF_3DV_CMD(StdCmdViewAxo);
867
StdCmdViewAxo::StdCmdViewAxo()
868
: Command("Std_ViewAxo")
870
sGroup = QT_TR_NOOP("Standard-View");
871
sMenuText = QT_TR_NOOP("Axometric");
872
sToolTipText= QT_TR_NOOP("Set to axometric view");
873
sWhatsThis = "Std_ViewXX";
874
sStatusTip = QT_TR_NOOP("Set to axometric view");
875
sPixmap = "view-axometric";
879
void StdCmdViewAxo::activated(int iMsg)
881
doCommand(Command::Gui,"Gui.activeDocument().activeView().viewAxometric()");
884
//===========================================================================
886
//===========================================================================
887
DEF_STD_CMD_A(StdCmdViewFitAll);
889
StdCmdViewFitAll::StdCmdViewFitAll()
890
: Command("Std_ViewFitAll")
892
sGroup = QT_TR_NOOP("Standard-View");
893
sMenuText = QT_TR_NOOP("Fit all");
894
sToolTipText = QT_TR_NOOP("Fits the whole content on the screen");
895
sWhatsThis = "Std_ViewFitAll";
896
sStatusTip = QT_TR_NOOP("Fits the whole content on the screen");
897
sPixmap = "view-zoom-all";
901
void StdCmdViewFitAll::activated(int iMsg)
903
//doCommand(Command::Gui,"Gui.activeDocument().activeView().fitAll()");
904
doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"ViewFit\")");
907
bool StdCmdViewFitAll::isActive(void)
909
//return isViewOfType(Gui::View3DInventor::getClassTypeId());
910
return getGuiApplication()->sendHasMsgToActiveView("ViewFit");
913
//===========================================================================
914
// Std_ViewFitSelection
915
//===========================================================================
916
DEF_STD_CMD_A(StdCmdViewFitSelection);
918
StdCmdViewFitSelection::StdCmdViewFitSelection()
919
: Command("Std_ViewFitSelection")
921
sGroup = QT_TR_NOOP("Standard-View");
922
sMenuText = QT_TR_NOOP("Fit selection");
923
sToolTipText = QT_TR_NOOP("Fits the selected content on the screen");
924
sWhatsThis = "Std_ViewFitSelection";
925
sStatusTip = QT_TR_NOOP("Fits the selected content on the screen");
926
#if QT_VERSION >= 0x040200
927
sPixmap = "view-zoom-selection";
932
void StdCmdViewFitSelection::activated(int iMsg)
934
//doCommand(Command::Gui,"Gui.activeDocument().activeView().fitAll()");
935
doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"ViewSelection\")");
938
bool StdCmdViewFitSelection::isActive(void)
940
//return isViewOfType(Gui::View3DInventor::getClassTypeId());
941
return getGuiApplication()->sendHasMsgToActiveView("ViewSelection");
944
//===========================================================================
945
// Std_ViewDockUndockFullscreen
946
//===========================================================================
947
DEF_STD_CMD_AC(StdViewDockUndockFullscreen);
949
StdViewDockUndockFullscreen::StdViewDockUndockFullscreen()
950
: Command("Std_ViewDockUndockFullscreen")
952
sGroup = QT_TR_NOOP("Standard-View");
953
sMenuText = QT_TR_NOOP("Display mode");
954
sToolTipText= QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
955
sWhatsThis = "Std_ViewDockUndockFullscreen";
956
sStatusTip = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
959
Action * StdViewDockUndockFullscreen::createAction(void)
961
ActionGroup* pcAction = new ActionGroup(this, getMainWindow());
962
pcAction->setDropDownMenu(true);
963
pcAction->setText(QObject::tr(sMenuText));
965
QAction* docked = pcAction->addAction(QObject::tr(QT_TR_NOOP("Docked")));
966
docked->setToolTip(QObject::tr(sToolTipText));
967
docked->setStatusTip(QObject::tr(sStatusTip));
968
docked->setWhatsThis(QObject::tr(sWhatsThis));
969
docked->setShortcut(Qt::Key_D);
970
docked->setCheckable(true);
972
QAction* undocked = pcAction->addAction(QObject::tr(QT_TR_NOOP("Undocked")));
973
undocked->setToolTip(QObject::tr(sToolTipText));
974
undocked->setStatusTip(QObject::tr(sStatusTip));
975
undocked->setWhatsThis(QObject::tr(sWhatsThis));
976
undocked->setShortcut(Qt::Key_U);
977
undocked->setCheckable(true);
979
QAction* fullscr = pcAction->addAction(QObject::tr(QT_TR_NOOP("Fullscreen")));
980
fullscr->setToolTip(QObject::tr(sToolTipText));
981
fullscr->setStatusTip(QObject::tr(sStatusTip));
982
fullscr->setWhatsThis(QObject::tr(sWhatsThis));
983
fullscr->setShortcut(Qt::Key_F11);
984
fullscr->setCheckable(true);
985
fullscr->setIcon(Gui::BitmapFactory().pixmap("view-fullscreen"));
990
void StdViewDockUndockFullscreen::activated(int iMsg)
992
MDIView* view = getMainWindow()->activeWindow();
993
if ( !view ) return; // no active view
994
if ( iMsg == (int)(view->currentViewMode()) )
995
return; // nothing to do
999
view->setCurrentViewMode( MDIView::Child );
1003
view->setCurrentViewMode( MDIView::TopLevel );
1007
view->setCurrentViewMode( MDIView::FullScreen );
1011
bool StdViewDockUndockFullscreen::isActive(void)
1013
MDIView* view = getMainWindow()->activeWindow();
1016
// update the action group if needed
1017
ActionGroup* pActGrp = qobject_cast<ActionGroup*>(_pcAction);
1020
int index = pActGrp->checkedAction();
1021
int mode = (int)(view->currentViewMode());
1022
if ( index != mode )
1024
// active window has changed with another view mode
1025
pActGrp->setCheckedAction( mode );
1035
//===========================================================================
1036
// Std_ViewScreenShot
1037
//===========================================================================
1038
DEF_STD_CMD_A(StdViewScreenShot);
1040
StdViewScreenShot::StdViewScreenShot()
1041
: Command("Std_ViewScreenShot")
1043
sGroup = QT_TR_NOOP("Standard-View");
1044
sMenuText = QT_TR_NOOP("Save picture...");
1045
sToolTipText= QT_TR_NOOP("Creates a screenshot of the active view");
1046
sWhatsThis = "Std_ViewScreenShot";
1047
sStatusTip = QT_TR_NOOP("Creates a screenshot of the active view");
1049
sPixmap = "camera-photo";
1052
void StdViewScreenShot::activated(int iMsg)
1054
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
1056
QStringList formats;
1057
SbViewportRegion vp(view->getViewer()->getViewportRegion());
1059
SoFCOffscreenRenderer& rd = SoFCOffscreenRenderer::instance();
1060
formats = rd.getWriteImageFiletypeInfo();
1065
for (QStringList::Iterator it = formats.begin(); it != formats.end(); ++it) {
1066
filter << QString::fromAscii("%1 %2 (*.%3)").arg((*it).toUpper()).
1067
arg(QObject::tr("files")).arg((*it).toLower());
1070
FileOptionsDialog fd(getMainWindow(), 0);
1071
fd.setFileMode(QFileDialog::AnyFile);
1072
fd.setAcceptMode(QFileDialog::AcceptSave);
1073
fd.setWindowTitle(QObject::tr("Save picture"));
1074
fd.setFilters(filter);
1076
// create the image options widget
1077
DlgSettingsImageImp* opt = new DlgSettingsImageImp(&fd);
1078
SbVec2s sz = vp.getWindowSize();
1079
opt->setImageSize((int)sz[0], (int)sz[1]);
1081
fd.setOptionsWidget(FileOptionsDialog::ExtensionRight, opt);
1082
fd.setConfirmOverwrite(true);
1083
opt->onSelectedFilter(fd.selectedFilter());
1084
QObject::connect(&fd, SIGNAL(filterSelected(const QString&)),
1085
opt, SLOT(onSelectedFilter(const QString&)));
1087
if (fd.exec() == QDialog::Accepted) {
1088
selFilter = fd.selectedFilter();
1089
QString fn = fd.selectedFiles().front();
1090
// We must convert '\' path separators to '/' before otherwise
1091
// Python would interpret them as escape sequences.
1092
fn.replace(QLatin1Char('\\'), QLatin1Char('/'));
1096
// get the defined values
1097
int w = opt->imageWidth();
1098
int h = opt->imageHeight();
1100
// search for the matching format
1101
QString format = formats.front(); // take the first as default
1102
for (QStringList::Iterator it = formats.begin(); it != formats.end(); ++it) {
1103
if (selFilter.startsWith((*it).toUpper())) {
1109
// which background chosen
1110
const char* background;
1111
switch(opt->backgroundType()){
1112
case 0: background="Current"; break;
1113
case 1: background="White"; break;
1114
case 2: background="Black"; break;
1115
case 3: background="Transparent"; break;
1116
default: background="Current"; break;
1119
QString comment = opt->comment();
1120
if (!comment.isEmpty()) {
1121
// Replace newline escape sequence trough '\\n' string to build one big string,
1122
// otherwise Python would interpret it as an invalid command.
1123
// Python does the decoding for us.
1124
QStringList lines = comment.split(QLatin1String("\n"), QString::KeepEmptyParts );
1125
comment = lines.join(QLatin1String("\\n"));
1126
doCommand(Gui,"Gui.activeDocument().activeView().saveImage('%s',%d,%d,'%s','%s')",
1127
fn.toUtf8().constData(),w,h,background,comment.toUtf8().constData());
1130
doCommand(Gui,"Gui.activeDocument().activeView().saveImage('%s',%d,%d,'%s')",
1131
fn.toUtf8().constData(),w,h,background);
1137
bool StdViewScreenShot::isActive(void)
1139
return isViewOfType(Gui::View3DInventor::getClassTypeId());
1143
//===========================================================================
1145
//===========================================================================
1146
DEF_STD_CMD_A(StdCmdViewCreate);
1148
StdCmdViewCreate::StdCmdViewCreate()
1149
: Command("Std_ViewCreate")
1151
sGroup = QT_TR_NOOP("Standard-View");
1152
sMenuText = QT_TR_NOOP("Create new view");
1153
sToolTipText= QT_TR_NOOP("Creates a new view window for the active document");
1154
sWhatsThis = "Std_ViewCreate";
1155
sStatusTip = QT_TR_NOOP("Creates a new view window for the active document");
1156
sPixmap = "window-new";
1160
void StdCmdViewCreate::activated(int iMsg)
1162
getActiveGuiDocument()->createView("View3DIv");
1165
bool StdCmdViewCreate::isActive(void)
1167
return (getActiveGuiDocument()!=NULL);
1170
//===========================================================================
1172
//===========================================================================
1173
DEF_STD_CMD_A(StdCmdViewExample1);
1175
StdCmdViewExample1::StdCmdViewExample1()
1176
: Command("Std_ViewExample1")
1178
sGroup = QT_TR_NOOP("Standard-View");
1179
sMenuText = QT_TR_NOOP("Inventor example #1");
1180
sToolTipText = QT_TR_NOOP("Shows a 3D texture with manipulator");
1181
sWhatsThis = "Std_ViewExamples";
1182
sStatusTip = QT_TR_NOOP("Shows a 3D texture with manipulator");
1183
sPixmap = "Std_Tool1";
1187
void StdCmdViewExample1::activated(int iMsg)
1189
doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"Example1\")");
1192
bool StdCmdViewExample1::isActive(void)
1194
return getGuiApplication()->sendHasMsgToActiveView("Example1");
1196
//===========================================================================
1198
//===========================================================================
1199
DEF_STD_CMD_A(StdCmdViewExample2);
1201
StdCmdViewExample2::StdCmdViewExample2()
1202
: Command("Std_ViewExample2")
1204
sGroup = QT_TR_NOOP("Standard-View");
1205
sMenuText = QT_TR_NOOP("Inventor example #2");
1206
sToolTipText = QT_TR_NOOP("Shows spheres an dragglights");
1207
sWhatsThis = "Std_ViewExamples";
1208
sStatusTip = QT_TR_NOOP("Shows spheres an dragglights");
1209
sPixmap = "Std_Tool2";
1213
void StdCmdViewExample2::activated(int iMsg)
1215
doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"Example2\")");
1218
bool StdCmdViewExample2::isActive(void)
1220
return getGuiApplication()->sendHasMsgToActiveView("Example2");
1223
//===========================================================================
1225
//===========================================================================
1226
DEF_STD_CMD_A(StdCmdViewExample3);
1228
StdCmdViewExample3::StdCmdViewExample3()
1229
: Command("Std_ViewExample3")
1231
sGroup = QT_TR_NOOP("Standard-View");
1232
sMenuText = QT_TR_NOOP("Inventor example #3");
1233
sToolTipText = QT_TR_NOOP("Shows a animated texture");
1234
sWhatsThis = "Std_ViewExamples";
1235
sStatusTip = QT_TR_NOOP("Shows a animated texture");
1236
sPixmap = "Std_Tool3";
1240
void StdCmdViewExample3::activated(int iMsg)
1242
doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"Example3\")");
1245
bool StdCmdViewExample3::isActive(void)
1247
return getGuiApplication()->sendHasMsgToActiveView("Example3");
1251
//===========================================================================
1252
// Std_ViewIvStereoOff
1253
//===========================================================================
1254
DEF_STD_CMD_A(StdCmdViewIvStereoOff);
1256
StdCmdViewIvStereoOff::StdCmdViewIvStereoOff()
1257
: Command("Std_ViewIvStereoOff")
1259
sGroup = QT_TR_NOOP("Standard-View");
1260
sMenuText = QT_TR_NOOP("Stereo Off");
1261
sToolTipText = QT_TR_NOOP("Switch stereo viewing off");
1262
sWhatsThis = "Std_ViewIvStereo";
1263
sStatusTip = QT_TR_NOOP("Switch stereo viewing off");
1264
sPixmap = "Std_Tool6";
1268
void StdCmdViewIvStereoOff::activated(int iMsg)
1270
doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"None\")");
1273
bool StdCmdViewIvStereoOff::isActive(void)
1275
return getGuiApplication()->sendHasMsgToActiveView("SetStereoOff");
1279
//===========================================================================
1280
// Std_ViewIvStereoRedGreen
1281
//===========================================================================
1282
DEF_STD_CMD_A(StdCmdViewIvStereoRedGreen);
1284
StdCmdViewIvStereoRedGreen::StdCmdViewIvStereoRedGreen()
1285
: Command("Std_ViewIvStereoRedGreen")
1287
sGroup = QT_TR_NOOP("Standard-View");
1288
sMenuText = QT_TR_NOOP("Stereo red/green");
1289
sToolTipText = QT_TR_NOOP("Switch stereo viewing to red/green");
1290
sWhatsThis = "Std_ViewIvStereo";
1291
sStatusTip = QT_TR_NOOP("Switch stereo viewing to red/green");
1292
sPixmap = "Std_Tool7";
1296
void StdCmdViewIvStereoRedGreen::activated(int iMsg)
1298
doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"Anaglyph\")");
1301
bool StdCmdViewIvStereoRedGreen::isActive(void)
1303
return getGuiApplication()->sendHasMsgToActiveView("SetStereoRedGreen");
1306
//===========================================================================
1307
// Std_ViewIvStereoQuadBuff
1308
//===========================================================================
1309
DEF_STD_CMD_A(StdCmdViewIvStereoQuadBuff);
1311
StdCmdViewIvStereoQuadBuff::StdCmdViewIvStereoQuadBuff()
1312
: Command("Std_ViewIvStereoQuadBuff")
1314
sGroup = QT_TR_NOOP("Standard-View");
1315
sMenuText = QT_TR_NOOP("Stereo quad buffer");
1316
sToolTipText = QT_TR_NOOP("Switch stereo viewing to quad buffer");
1317
sWhatsThis = "Std_ViewIvStereo";
1318
sStatusTip = QT_TR_NOOP("Switch stereo viewing to quad buffer");
1319
sPixmap = "Std_Tool7";
1323
void StdCmdViewIvStereoQuadBuff::activated(int iMsg)
1325
doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"QuadBuffer\")");
1328
bool StdCmdViewIvStereoQuadBuff::isActive(void)
1330
return getGuiApplication()->sendHasMsgToActiveView("SetStereoQuadBuff");
1333
//===========================================================================
1334
// Std_ViewIvStereoInterleavedRows
1335
//===========================================================================
1336
DEF_STD_CMD_A(StdCmdViewIvStereoInterleavedRows);
1338
StdCmdViewIvStereoInterleavedRows::StdCmdViewIvStereoInterleavedRows()
1339
: Command("Std_ViewIvStereoInterleavedRows")
1341
sGroup = QT_TR_NOOP("Standard-View");
1342
sMenuText = QT_TR_NOOP("Stereo Interleaved Rows");
1343
sToolTipText = QT_TR_NOOP("Switch stereo viewing to Interleaved Rows");
1344
sWhatsThis = "Std_ViewIvStereo";
1345
sStatusTip = QT_TR_NOOP("Switch stereo viewing to Interleaved Rows");
1346
sPixmap = "Std_Tool7";
1350
void StdCmdViewIvStereoInterleavedRows::activated(int iMsg)
1352
doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"InterleavedRows\")");
1355
bool StdCmdViewIvStereoInterleavedRows::isActive(void)
1357
return getGuiApplication()->sendHasMsgToActiveView("SetStereoInterleavedRows");
1360
//===========================================================================
1361
// Std_ViewIvStereoInterleavedColumns
1362
//===========================================================================
1363
DEF_STD_CMD_A(StdCmdViewIvStereoInterleavedColumns);
1365
StdCmdViewIvStereoInterleavedColumns::StdCmdViewIvStereoInterleavedColumns()
1366
: Command("Std_ViewIvStereoInterleavedColumns")
1368
sGroup = QT_TR_NOOP("Standard-View");
1369
sMenuText = QT_TR_NOOP("Stereo Interleaved Columns");
1370
sToolTipText = QT_TR_NOOP("Switch stereo viewing to Interleaved Columns");
1371
sWhatsThis = "Std_ViewIvStereo";
1372
sStatusTip = QT_TR_NOOP("Switch stereo viewing to Interleaved Columns");
1373
sPixmap = "Std_Tool7";
1377
void StdCmdViewIvStereoInterleavedColumns::activated(int iMsg)
1379
doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"InterleavedColumns\")");
1382
bool StdCmdViewIvStereoInterleavedColumns::isActive(void)
1384
return getGuiApplication()->sendHasMsgToActiveView("SetStereoInterleavedColumns");
1388
//===========================================================================
1389
// Std_ViewIvIssueCamPos
1390
//===========================================================================
1391
DEF_STD_CMD_A(StdCmdViewIvIssueCamPos);
1393
StdCmdViewIvIssueCamPos::StdCmdViewIvIssueCamPos()
1394
: Command("Std_ViewIvIssueCamPos")
1396
sGroup = QT_TR_NOOP("Standard-View");
1397
sMenuText = QT_TR_NOOP("Issue camera position");
1398
sToolTipText = QT_TR_NOOP("Issue the camera position to the console and to a macro, to easily recall this position");
1399
sWhatsThis = "Std_ViewIvIssueCamPos";
1400
sStatusTip = QT_TR_NOOP("Issue the camera position to the console and to a macro, to easily recall this position");
1401
sPixmap = "Std_Tool8";
1405
void StdCmdViewIvIssueCamPos::activated(int iMsg)
1407
std::string Temp,Temp2;
1408
std::string::size_type pos;
1410
const char* ppReturn=0;
1411
getGuiApplication()->sendMsgToActiveView("GetCamera",&ppReturn);
1413
// remove the #inventor line...
1415
pos = Temp2.find_first_of("\n");
1418
// remove all returns
1419
while((pos=Temp2.find('\n')) != std::string::npos)
1420
Temp2.replace(pos,1," ");
1422
// build up the command string
1423
Temp += "Gui.SendMsgToActiveView(\"SetCamera ";
1427
Base::Console().Message("%s\n",Temp2.c_str());
1428
getGuiApplication()->macroManager()->addLine(MacroManager::Gui,Temp.c_str());
1431
bool StdCmdViewIvIssueCamPos::isActive(void)
1433
return getGuiApplication()->sendHasMsgToActiveView("GetCamera");
1437
//===========================================================================
1439
//===========================================================================
1440
DEF_STD_CMD_A(StdViewZoomIn);
1442
StdViewZoomIn::StdViewZoomIn()
1443
: Command("Std_ViewZoomIn")
1445
sGroup = QT_TR_NOOP("Standard-View");
1446
sMenuText = QT_TR_NOOP("Zoom In");
1447
sToolTipText = QT_TR_NOOP("Zoom In");
1448
sWhatsThis = "Std_ViewZoom";
1449
sStatusTip = QT_TR_NOOP("Zoom In");
1450
#if QT_VERSION >= 0x040200
1451
sPixmap = "view-zoom-in";
1453
iAccel = Qt::Key_Plus;
1456
void StdViewZoomIn::activated(int iMsg)
1458
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
1460
View3DInventorViewer* viewer = view->getViewer();
1462
// send an event to the GL widget to use the internal View3DInventorViewer::zoom() method
1463
// do only one step to zoom in
1464
SoMouseButtonEvent e;
1465
e.setButton(SoMouseButtonEvent::BUTTON5);
1466
e.setState(SoMouseButtonEvent::DOWN);
1467
viewer->sendSoEvent(&e);
1471
bool StdViewZoomIn::isActive(void)
1473
return (qobject_cast<View3DInventor*>(getMainWindow()->activeWindow()));
1476
//===========================================================================
1478
//===========================================================================
1479
DEF_STD_CMD_A(StdViewZoomOut);
1481
StdViewZoomOut::StdViewZoomOut()
1482
: Command("Std_ViewZoomOut")
1484
sGroup = QT_TR_NOOP("Standard-View");
1485
sMenuText = QT_TR_NOOP("Zoom Out");
1486
sToolTipText = QT_TR_NOOP("Zoom Out");
1487
sWhatsThis = "Std_ViewZoom";
1488
sStatusTip = QT_TR_NOOP("Zoom Out");
1489
#if QT_VERSION >= 0x040200
1490
sPixmap = "view-zoom-out";
1492
iAccel = Qt::Key_Minus;
1495
void StdViewZoomOut::activated(int iMsg)
1497
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
1499
View3DInventorViewer* viewer = view->getViewer();
1500
// send an event to the GL widget to use the internal View3DInventorViewer::zoom() method
1501
// do only one step to zoom out
1502
SoMouseButtonEvent e;
1503
e.setButton(SoMouseButtonEvent::BUTTON4);
1504
e.setState(SoMouseButtonEvent::DOWN);
1505
viewer->sendSoEvent(&e);
1509
bool StdViewZoomOut::isActive(void)
1511
return (qobject_cast<View3DInventor*>(getMainWindow()->activeWindow()));
1514
//===========================================================================
1516
//===========================================================================
1517
DEF_3DV_CMD(StdViewBoxZoom);
1519
StdViewBoxZoom::StdViewBoxZoom()
1520
: Command("Std_ViewBoxZoom")
1522
sGroup = QT_TR_NOOP("Standard-View");
1523
sMenuText = QT_TR_NOOP("Box zoom");
1524
sToolTipText = QT_TR_NOOP("Box zoom");
1525
sWhatsThis = "Std_ViewBoxZoom";
1526
sStatusTip = QT_TR_NOOP("Box zoom");
1527
#if QT_VERSION >= 0x040200
1528
sPixmap = "view-zoom-border";
1530
iAccel = Qt::CTRL+Qt::Key_B;
1533
void StdViewBoxZoom::activated(int iMsg)
1535
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
1537
View3DInventorViewer* viewer = view->getViewer();
1538
if (!viewer->isPicking())
1539
viewer->startPicking(View3DInventorViewer::BoxZoom);
1543
//===========================================================================
1544
// Std_TreeSelection
1545
//===========================================================================
1547
DEF_STD_CMD(StdCmdTreeSelection);
1549
StdCmdTreeSelection::StdCmdTreeSelection()
1550
: Command("Std_TreeSelection")
1552
sGroup = QT_TR_NOOP("View");
1553
sMenuText = QT_TR_NOOP("Go to selection");
1554
sToolTipText = QT_TR_NOOP("Scroll to first selected item");
1555
sWhatsThis = "Std_TreeSelection";
1556
sStatusTip = QT_TR_NOOP("Scroll to first selected item");
1560
void StdCmdTreeSelection::activated(int iMsg)
1562
QList<TreeWidget*> tree = Gui::getMainWindow()->findChildren<TreeWidget*>();
1563
for (QList<TreeWidget*>::iterator it = tree.begin(); it != tree.end(); ++it) {
1564
Gui::Document* doc = Gui::Application::Instance->activeDocument();
1565
(*it)->scrollItemToTop(doc);
1569
//===========================================================================
1570
// Std_MeasureDistance
1571
//===========================================================================
1573
DEF_STD_CMD_A(StdCmdMeasureDistance);
1575
StdCmdMeasureDistance::StdCmdMeasureDistance()
1576
: Command("Std_MeasureDistance")
1578
sGroup = QT_TR_NOOP("View");
1579
sMenuText = QT_TR_NOOP("Measure distance");
1580
sToolTipText = QT_TR_NOOP("Measure distance");
1581
sWhatsThis = "Std_MeasureDistance";
1582
sStatusTip = QT_TR_NOOP("Measure distance");
1586
void StdCmdMeasureDistance::activated(int iMsg)
1588
Gui::Document* doc = Gui::Application::Instance->activeDocument();
1589
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
1591
App::DocumentObject* obj = doc->getDocument()->addObject(App::MeasureDistance::getClassTypeId().getName(),"Distance");
1592
Gui::View3DInventorViewer* viewer = view->getViewer();
1593
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), ViewProviderMeasureDistance::measureDistanceCallback, obj);
1597
bool StdCmdMeasureDistance::isActive(void)
1599
App::Document* doc = App::GetApplication().getActiveDocument();
1600
if (doc && doc->countObjectsOfType(App::GeoFeature::getClassTypeId()) > 0)
1605
//===========================================================================
1606
// Std_SceneInspector
1607
//===========================================================================
1609
DEF_3DV_CMD(StdCmdSceneInspector);
1611
StdCmdSceneInspector::StdCmdSceneInspector()
1612
: Command("Std_SceneInspector")
1615
sGroup = QT_TR_NOOP("Tools");
1616
sMenuText = QT_TR_NOOP("Scene inspector...");
1617
sToolTipText = QT_TR_NOOP("Scene inspector");
1618
sWhatsThis = "Std_SceneInspector";
1619
sStatusTip = QT_TR_NOOP("Scene inspector");
1622
void StdCmdSceneInspector::activated(int iMsg)
1624
View3DInventor* child = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
1626
View3DInventorViewer* viewer = child->getViewer();
1627
Gui::Dialog::DlgInspector dlg(getMainWindow());
1628
dlg.setNode(viewer->getSceneGraph());
1634
//===========================================================================
1636
//===========================================================================
1641
void CreateViewStdCommands(void)
1643
CommandManager &rcCmdMgr = Application::Instance->commandManager();
1646
rcCmdMgr.addCommand(new StdCmdViewBottom());
1647
rcCmdMgr.addCommand(new StdCmdViewFront());
1648
rcCmdMgr.addCommand(new StdCmdViewLeft());
1649
rcCmdMgr.addCommand(new StdCmdViewRear());
1650
rcCmdMgr.addCommand(new StdCmdViewRight());
1651
rcCmdMgr.addCommand(new StdCmdViewTop());
1652
rcCmdMgr.addCommand(new StdCmdViewAxo());
1653
rcCmdMgr.addCommand(new StdCmdViewFitAll());
1654
rcCmdMgr.addCommand(new StdCmdViewFitSelection());
1656
rcCmdMgr.addCommand(new StdCmdViewExample1());
1657
rcCmdMgr.addCommand(new StdCmdViewExample2());
1658
rcCmdMgr.addCommand(new StdCmdViewExample3());
1660
rcCmdMgr.addCommand(new StdCmdViewIvStereoQuadBuff());
1661
rcCmdMgr.addCommand(new StdCmdViewIvStereoRedGreen());
1662
rcCmdMgr.addCommand(new StdCmdViewIvStereoInterleavedColumns());
1663
rcCmdMgr.addCommand(new StdCmdViewIvStereoInterleavedRows());
1664
rcCmdMgr.addCommand(new StdCmdViewIvStereoOff());
1666
rcCmdMgr.addCommand(new StdCmdViewIvIssueCamPos());
1668
rcCmdMgr.addCommand(new StdCmdViewCreate());
1669
rcCmdMgr.addCommand(new StdViewScreenShot());
1671
rcCmdMgr.addCommand(new StdViewDockUndockFullscreen());
1672
rcCmdMgr.addCommand(new StdCmdSetAppearance());
1673
rcCmdMgr.addCommand(new StdCmdToggleVisibility());
1674
rcCmdMgr.addCommand(new StdCmdShowSelection());
1675
rcCmdMgr.addCommand(new StdCmdHideSelection());
1676
rcCmdMgr.addCommand(new StdCmdToggleObjects());
1677
rcCmdMgr.addCommand(new StdCmdShowObjects());
1678
rcCmdMgr.addCommand(new StdCmdHideObjects());
1679
rcCmdMgr.addCommand(new StdOrthographicCamera());
1680
rcCmdMgr.addCommand(new StdPerspectiveCamera());
1681
rcCmdMgr.addCommand(new StdCmdToggleClipPlane());
1682
rcCmdMgr.addCommand(new StdCmdFreezeViews());
1683
rcCmdMgr.addCommand(new StdViewZoomIn());
1684
rcCmdMgr.addCommand(new StdViewZoomOut());
1685
rcCmdMgr.addCommand(new StdViewBoxZoom());
1686
rcCmdMgr.addCommand(new StdCmdTreeSelection());
1687
rcCmdMgr.addCommand(new StdCmdMeasureDistance());
1688
rcCmdMgr.addCommand(new StdCmdSceneInspector());