00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #ifndef _PreComp_
00027 # include <sstream>
00028 # include <Inventor/events/SoMouseButtonEvent.h>
00029 # include <Inventor/nodes/SoOrthographicCamera.h>
00030 # include <Inventor/nodes/SoPerspectiveCamera.h>
00031 # include <QFile>
00032 # include <QMessageBox>
00033 # include <QTextStream>
00034 #endif
00035
00036 #include "Command.h"
00037 #include "Action.h"
00038 #include "Application.h"
00039 #include "BitmapFactory.h"
00040 #include "Control.h"
00041 #include "FileDialog.h"
00042 #include "MainWindow.h"
00043 #include "Tree.h"
00044 #include "View.h"
00045 #include "Document.h"
00046 #include "Macro.h"
00047 #include "DlgDisplayPropertiesImp.h"
00048 #include "DlgSettingsImageImp.h"
00049 #include "Selection.h"
00050 #include "SoFCOffscreenRenderer.h"
00051 #include "SoFCBoundingBox.h"
00052 #include "SoAxisCrossKit.h"
00053 #include "View3DInventor.h"
00054 #include "View3DInventorViewer.h"
00055 #include "WaitCursor.h"
00056 #include "ViewProviderMeasureDistance.h"
00057 #include "ViewProviderGeometryObject.h"
00058 #include "SceneInspector.h"
00059 #include "DemoMode.h"
00060 #include "TextureMapping.h"
00061
00062 #include <Base/Console.h>
00063 #include <Base/Exception.h>
00064 #include <Base/FileInfo.h>
00065 #include <Base/Reader.h>
00066 #include <App/Document.h>
00067 #include <App/GeoFeature.h>
00068 #include <App/DocumentObjectGroup.h>
00069 #include <App/MeasureDistance.h>
00070 #include <App/DocumentObject.h>
00071
00072 #include <QDomDocument>
00073 #include <QDomElement>
00074
00075 using namespace Gui;
00076 using Gui::Dialog::DlgSettingsImageImp;
00077
00078
00079
00080 DEF_STD_CMD_AC(StdOrthographicCamera);
00081
00082 StdOrthographicCamera::StdOrthographicCamera()
00083 : Command("Std_OrthographicCamera")
00084 {
00085 sGroup = QT_TR_NOOP("Standard-View");
00086 sMenuText = QT_TR_NOOP("Orthographic view");
00087 sToolTipText = QT_TR_NOOP("Switches to orthographic view mode");
00088 sWhatsThis = "Std_OrthographicCamera";
00089 sStatusTip = QT_TR_NOOP("Switches to orthographic view mode");
00090 sPixmap = "view-isometric";
00091 sAccel = "O";
00092 eType = Alter3DView;
00093 }
00094
00095 void StdOrthographicCamera::activated(int iMsg)
00096 {
00097 if (iMsg == 1) {
00098 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
00099 if (view->getViewer()->getCameraType() != SoOrthographicCamera::getClassTypeId())
00100 doCommand(Command::Gui,"Gui.activeDocument().activeView().setCameraType(\"Orthographic\")");
00101 }
00102 }
00103
00104 bool StdOrthographicCamera::isActive(void)
00105 {
00106 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
00107 if (view) {
00108
00109 bool check = _pcAction->isChecked();
00110 bool mode = view->getViewer()->getCameraType() == SoOrthographicCamera::getClassTypeId();
00111 if (mode != check)
00112 _pcAction->setChecked(mode);
00113 return true;
00114 }
00115
00116 return false;
00117 }
00118
00119 Action * StdOrthographicCamera::createAction(void)
00120 {
00121 Action *pcAction = Command::createAction();
00122 pcAction->setCheckable(true);
00123 return pcAction;
00124 }
00125
00126 DEF_STD_CMD_AC(StdPerspectiveCamera);
00127
00128 StdPerspectiveCamera::StdPerspectiveCamera()
00129 : Command("Std_PerspectiveCamera")
00130 {
00131 sGroup = QT_TR_NOOP("Standard-View");
00132 sMenuText = QT_TR_NOOP("Perspective view");
00133 sToolTipText = QT_TR_NOOP("Switches to perspective view mode");
00134 sWhatsThis = "Std_PerspectiveCamera";
00135 sStatusTip = QT_TR_NOOP("Switches to perspective view mode");
00136 sPixmap = "view-perspective";
00137 sAccel = "P";
00138 eType = Alter3DView;
00139 }
00140
00141 void StdPerspectiveCamera::activated(int iMsg)
00142 {
00143 if (iMsg == 1) {
00144 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
00145 if (view->getViewer()->getCameraType() != SoPerspectiveCamera::getClassTypeId())
00146 doCommand(Command::Gui,"Gui.activeDocument().activeView().setCameraType(\"Perspective\")");
00147 }
00148 }
00149
00150 bool StdPerspectiveCamera::isActive(void)
00151 {
00152 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
00153 if (view) {
00154
00155 bool check = _pcAction->isChecked();
00156 bool mode = view->getViewer()->getCameraType() == SoPerspectiveCamera::getClassTypeId();
00157 if (mode != check)
00158 _pcAction->setChecked(mode);
00159
00160 return true;
00161 }
00162
00163 return false;
00164 }
00165
00166 Action * StdPerspectiveCamera::createAction(void)
00167 {
00168 Action *pcAction = Command::createAction();
00169 pcAction->setCheckable(true);
00170 return pcAction;
00171 }
00172
00173
00174
00175
00176 class StdCmdFreezeViews : public Gui::Command
00177 {
00178 public:
00179 StdCmdFreezeViews();
00180 virtual ~StdCmdFreezeViews(){}
00181 const char* className() const
00182 { return "StdCmdFreezeViews"; }
00183
00184 protected:
00185 virtual void activated(int iMsg);
00186 virtual bool isActive(void);
00187 virtual Action * createAction(void);
00188 virtual void languageChange();
00189
00190 private:
00191 void onSaveViews();
00192 void onRestoreViews();
00193
00194 private:
00195 const int maxViews;
00196 int savedViews;
00197 int offset;
00198 QAction* saveView;
00199 QAction* freezeView;
00200 QAction* clearView;
00201 QAction* separator;
00202 };
00203
00204 StdCmdFreezeViews::StdCmdFreezeViews()
00205 : Command("Std_FreezeViews"), maxViews(50), savedViews(0)
00206 {
00207 sGroup = QT_TR_NOOP("Standard-View");
00208 sMenuText = QT_TR_NOOP("Freeze display");
00209 sToolTipText = QT_TR_NOOP("Freezes the current view position");
00210 sWhatsThis = "Std_FreezeViews";
00211 sStatusTip = QT_TR_NOOP("Freezes the current view position");
00212 sAccel = "Shift+F";
00213 eType = Alter3DView;
00214 }
00215
00216 Action * StdCmdFreezeViews::createAction(void)
00217 {
00218 ActionGroup* pcAction = new ActionGroup(this, getMainWindow());
00219 pcAction->setDropDownMenu(true);
00220 applyCommandData(pcAction);
00221
00222
00223 saveView = pcAction->addAction(QObject::tr("Save views..."));
00224 pcAction->addAction(QObject::tr("Load views..."));
00225 pcAction->addAction(QString::fromAscii(""))->setSeparator(true);
00226 freezeView = pcAction->addAction(QObject::tr("Freeze view"));
00227 freezeView->setShortcut(QString::fromAscii(sAccel));
00228 clearView = pcAction->addAction(QObject::tr("Clear views"));
00229 separator = pcAction->addAction(QString::fromAscii(""));
00230 separator->setSeparator(true);
00231 offset = pcAction->actions().count();
00232
00233
00234 for (int i=0; i<maxViews; i++)
00235 pcAction->addAction(QString::fromAscii(""))->setVisible(false);
00236
00237 return pcAction;
00238 }
00239
00240 void StdCmdFreezeViews::activated(int iMsg)
00241 {
00242 ActionGroup* pcAction = qobject_cast<ActionGroup*>(_pcAction);
00243
00244 if (iMsg == 0) {
00245 onSaveViews();
00246 }
00247 else if (iMsg == 1) {
00248 onRestoreViews();
00249 }
00250 else if (iMsg == 3) {
00251
00252 const char* ppReturn=0;
00253 getGuiApplication()->sendMsgToActiveView("GetCamera",&ppReturn);
00254
00255 QList<QAction*> acts = pcAction->actions();
00256 int index = 0;
00257 for (QList<QAction*>::ConstIterator it = acts.begin()+offset; it != acts.end(); ++it, index++) {
00258 if (!(*it)->isVisible()) {
00259 savedViews++;
00260 QString viewnr = QString(QObject::tr("Restore view &%1")).arg(index+1);
00261 (*it)->setText(viewnr);
00262 (*it)->setToolTip(QString::fromAscii(ppReturn));
00263 (*it)->setVisible(true);
00264 if (index < 9) {
00265 int accel = Qt::CTRL+Qt::Key_1;
00266 (*it)->setShortcut(accel+index);
00267 }
00268 break;
00269 }
00270 }
00271 }
00272 else if (iMsg == 4) {
00273 savedViews = 0;
00274 QList<QAction*> acts = pcAction->actions();
00275 for (QList<QAction*>::ConstIterator it = acts.begin()+offset; it != acts.end(); ++it)
00276 (*it)->setVisible(false);
00277 }
00278 else if (iMsg >= offset) {
00279
00280 QList<QAction*> acts = pcAction->actions();
00281 QString data = acts[iMsg]->toolTip();
00282 QString send = QString::fromAscii("SetCamera %1").arg(data);
00283 getGuiApplication()->sendMsgToActiveView(send.toAscii());
00284 }
00285 }
00286
00287 void StdCmdFreezeViews::onSaveViews()
00288 {
00289
00290 QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save frozen views"),
00291 QString(), QObject::tr("Frozen views (*.cam)"));
00292 if (fn.isEmpty())
00293 return;
00294 QFile file(fn);
00295 if (file.open(QFile::WriteOnly))
00296 {
00297 QTextStream str(&file);
00298 ActionGroup* pcAction = qobject_cast<ActionGroup*>(_pcAction);
00299 QList<QAction*> acts = pcAction->actions();
00300 str << "<?xml version='1.0' encoding='utf-8'?>" << endl
00301 << "<FrozenViews SchemaVersion=\"1\">" << endl;
00302 str << " <Views Count=\"" << savedViews <<"\">" << endl;
00303
00304 for (QList<QAction*>::ConstIterator it = acts.begin()+offset; it != acts.end(); ++it) {
00305 if ( !(*it)->isVisible() )
00306 break;
00307 QString data = (*it)->toolTip();
00308
00309
00310 QString viewPos;
00311 if ( !data.isEmpty() ) {
00312 QStringList lines = data.split(QString::fromAscii("\n"));
00313 if ( lines.size() > 1 ) {
00314 lines.pop_front();
00315 viewPos = lines.join(QString::fromAscii(" "));
00316 }
00317 }
00318
00319 str << " <Camera settings=\"" << viewPos.toAscii().constData() << "\"/>" << endl;
00320 }
00321
00322 str << " </Views>" << endl;
00323 str << "</FrozenViews>" << endl;
00324 }
00325 }
00326
00327 void StdCmdFreezeViews::onRestoreViews()
00328 {
00329
00330 if (savedViews > 0) {
00331 int ret = QMessageBox::question(getMainWindow(), QObject::tr("Restore views"),
00332 QObject::tr("Importing the restored views would clear the already stored views.\n"
00333 "Do you want to continue?"), QMessageBox::Yes|QMessageBox::Default,
00334 QMessageBox::No|QMessageBox::Escape);
00335 if (ret!=QMessageBox::Yes)
00336 return;
00337 }
00338
00339
00340 QString fn = FileDialog::getOpenFileName(getMainWindow(), QObject::tr("Restore frozen views"),
00341 QString(), QObject::tr("Frozen views (*.cam)"));
00342 if (fn.isEmpty())
00343 return;
00344 QFile file(fn);
00345 if (!file.open(QFile::ReadOnly)) {
00346 QMessageBox::critical(getMainWindow(), QObject::tr("Restore views"),
00347 QObject::tr("Cannot open file '%1'.").arg(fn));
00348 return;
00349 }
00350
00351 QDomDocument xmlDocument;
00352 QString errorStr;
00353 int errorLine;
00354 int errorColumn;
00355
00356
00357 if (!xmlDocument.setContent(&file, true, &errorStr, &errorLine, &errorColumn)) {
00358 std::cerr << "Parse error in XML content at line " << errorLine
00359 << ", column " << errorColumn << ": "
00360 << (const char*)errorStr.toAscii() << std::endl;
00361 return;
00362 }
00363
00364
00365 QDomElement root = xmlDocument.documentElement();
00366 if (root.tagName() != QLatin1String("FrozenViews")) {
00367 std::cerr << "Unexpected XML structure" << std::endl;
00368 return;
00369 }
00370
00371 bool ok;
00372 int scheme = root.attribute(QString::fromAscii("SchemaVersion")).toInt(&ok);
00373 if (!ok) return;
00374
00375 if (scheme == 1) {
00376
00377 QDomElement child = root.firstChildElement(QString::fromAscii("Views"));
00378 QDomElement views = child.firstChildElement(QString::fromAscii("Camera"));
00379 QStringList cameras;
00380 while (!views.isNull()) {
00381 QString setting = views.attribute(QString::fromAscii("settings"));
00382 cameras << setting;
00383 views = views.nextSiblingElement(QString::fromAscii("Camera"));
00384 }
00385
00386
00387
00388 int ct = cameras.count();
00389 ActionGroup* pcAction = qobject_cast<ActionGroup*>(_pcAction);
00390 QList<QAction*> acts = pcAction->actions();
00391
00392 int numRestoredViews = std::min<int>(ct, acts.size()-offset);
00393 savedViews = numRestoredViews;
00394
00395 if (numRestoredViews > 0)
00396 separator->setVisible(true);
00397 for(int i=0; i<numRestoredViews; i++) {
00398 QString setting = cameras[i];
00399 QString viewnr = QString(QObject::tr("Restore view &%1")).arg(i+1);
00400 acts[i+offset]->setText(viewnr);
00401 acts[i+offset]->setToolTip(setting);
00402 acts[i+offset]->setVisible(true);
00403 if ( i < 9 ) {
00404 int accel = Qt::CTRL+Qt::Key_1;
00405 acts[i+offset]->setShortcut(accel+i);
00406 }
00407 }
00408
00409
00410 for (int index = numRestoredViews+offset; index < acts.count(); index++)
00411 acts[index]->setVisible(false);
00412 }
00413 }
00414
00415 bool StdCmdFreezeViews::isActive(void)
00416 {
00417 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
00418 if (view) {
00419 saveView->setEnabled(savedViews > 0);
00420 freezeView->setEnabled(savedViews < maxViews);
00421 clearView->setEnabled(savedViews > 0);
00422 separator->setVisible(savedViews > 0);
00423 return true;
00424 }
00425 else {
00426 separator->setVisible(savedViews > 0);
00427 }
00428
00429 return false;
00430 }
00431
00432 void StdCmdFreezeViews::languageChange()
00433 {
00434 Command::languageChange();
00435
00436 if (!_pcAction)
00437 return;
00438 ActionGroup* pcAction = qobject_cast<ActionGroup*>(_pcAction);
00439 QList<QAction*> acts = pcAction->actions();
00440 acts[0]->setText(QObject::tr("Save views..."));
00441 acts[1]->setText(QObject::tr("Load views..."));
00442 acts[3]->setText(QObject::tr("Freeze view"));
00443 acts[4]->setText(QObject::tr("Clear views"));
00444 int index=1;
00445 for (QList<QAction*>::ConstIterator it = acts.begin()+5; it != acts.end(); ++it, index++) {
00446 if ((*it)->isVisible()) {
00447 QString viewnr = QString(QObject::tr("Restore view &%1")).arg(index);
00448 (*it)->setText(viewnr);
00449 }
00450 }
00451 }
00452
00453
00454
00455
00456
00457 DEF_STD_CMD_AC(StdCmdToggleClipPlane);
00458
00459 StdCmdToggleClipPlane::StdCmdToggleClipPlane()
00460 : Command("Std_ToggleClipPlane")
00461 {
00462 sGroup = QT_TR_NOOP("Standard-View");
00463 sMenuText = QT_TR_NOOP("Clipping plane");
00464 sToolTipText = QT_TR_NOOP("Toggles clipping plane for active view");
00465 sWhatsThis = "Std_ToggleClipPlane";
00466 sStatusTip = QT_TR_NOOP("Toggles clipping plane for active view");
00467 eType = Alter3DView;
00468 }
00469
00470 Action * StdCmdToggleClipPlane::createAction(void)
00471 {
00472 Action *pcAction = (Action*)Command::createAction();
00473 pcAction->setCheckable(true);
00474 return pcAction;
00475 }
00476
00477 void StdCmdToggleClipPlane::activated(int iMsg)
00478 {
00479 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
00480 if (view) {
00481 if (iMsg > 0 && !view->hasClippingPlane())
00482 view->toggleClippingPlane();
00483 else if (iMsg == 0 && view->hasClippingPlane())
00484 view->toggleClippingPlane();
00485 }
00486 }
00487
00488 bool StdCmdToggleClipPlane::isActive(void)
00489 {
00490 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
00491 if (view) {
00492 Action* action = qobject_cast<Action*>(_pcAction);
00493 if (action->isChecked() != view->hasClippingPlane())
00494 action->setChecked(view->hasClippingPlane());
00495 return true;
00496 }
00497 else {
00498 Action* action = qobject_cast<Action*>(_pcAction);
00499 if (action->isChecked())
00500 action->setChecked(false);
00501 return false;
00502 }
00503 }
00504
00505 DEF_STD_CMD_ACL(StdCmdDrawStyle);
00506
00507 StdCmdDrawStyle::StdCmdDrawStyle()
00508 : Command("Std_DrawStyle")
00509 {
00510 sGroup = QT_TR_NOOP("Standard-View");
00511 sMenuText = QT_TR_NOOP("Draw style");
00512 sToolTipText = QT_TR_NOOP("Draw style");
00513 sStatusTip = QT_TR_NOOP("Draw style");
00514 eType = Alter3DView;
00515 }
00516
00517 Gui::Action * StdCmdDrawStyle::createAction(void)
00518 {
00519 Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
00520 pcAction->setDropDownMenu(true);
00521 applyCommandData(pcAction);
00522
00523 QAction* a0 = pcAction->addAction(QString());
00524 QAction* a1 = pcAction->addAction(QString());
00525 _pcAction = pcAction;
00526 languageChange();
00527 return pcAction;
00528 }
00529
00530 void StdCmdDrawStyle::languageChange()
00531 {
00532 Command::languageChange();
00533
00534 if (!_pcAction)
00535 return;
00536 Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
00537 QList<QAction*> a = pcAction->actions();
00538
00539 a[0]->setText(QCoreApplication::translate(
00540 "Std_DrawStyle", "As is", 0,
00541 QCoreApplication::CodecForTr));
00542 a[0]->setToolTip(QCoreApplication::translate(
00543 "Std_DrawStyle", "Normal mode", 0,
00544 QCoreApplication::CodecForTr));
00545
00546 a[1]->setText(QCoreApplication::translate(
00547 "Std_DrawStyle", "Wireframe", 0,
00548 QCoreApplication::CodecForTr));
00549 a[1]->setToolTip(QCoreApplication::translate(
00550 "Std_DrawStyle", "Wireframe mode", 0,
00551 QCoreApplication::CodecForTr));
00552 }
00553
00554 void StdCmdDrawStyle::activated(int iMsg)
00555 {
00556 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
00557 if (view) {
00558 SoQtViewer::DrawStyle style = SoQtViewer::VIEW_AS_IS;
00559 if (iMsg == 0)
00560 style = SoQtViewer::VIEW_AS_IS;
00561 else if (iMsg == 1)
00562 style = SoQtViewer::VIEW_LINE;
00563 view->getViewer()->setDrawStyle(SoQtViewer::STILL, style);
00564 }
00565 }
00566
00567 bool StdCmdDrawStyle::isActive(void)
00568 {
00569 return Gui::Application::Instance->activeDocument();
00570 }
00571
00572
00573
00574
00575 DEF_STD_CMD_A(StdCmdToggleVisibility);
00576
00577 StdCmdToggleVisibility::StdCmdToggleVisibility()
00578 : Command("Std_ToggleVisibility")
00579 {
00580 sGroup = QT_TR_NOOP("Standard-View");
00581 sMenuText = QT_TR_NOOP("Toggle visibility");
00582 sToolTipText = QT_TR_NOOP("Toggles visibility");
00583 sStatusTip = QT_TR_NOOP("Toggles visibility");
00584 sWhatsThis = "Std_ToggleVisibility";
00585 sAccel = "Space";
00586 eType = Alter3DView;
00587 }
00588
00589 void StdCmdToggleVisibility::activated(int iMsg)
00590 {
00591
00592 const std::vector<App::Document*> docs = App::GetApplication().getDocuments();
00593 for (std::vector<App::Document*>::const_iterator it = docs.begin(); it != docs.end(); ++it) {
00594 Document *pcDoc = Application::Instance->getDocument(*it);
00595 std::vector<App::DocumentObject*> sel = Selection().getObjectsOfType
00596 (App::DocumentObject::getClassTypeId(), (*it)->getName());
00597
00598
00599 std::vector<App::DocumentObject*> ignore;
00600 for (std::vector<App::DocumentObject*>::iterator ft=sel.begin();ft!=sel.end();ft++) {
00601 if ((*ft)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) {
00602 App::DocumentObjectGroup* grp = static_cast<App::DocumentObjectGroup*>(*ft);
00603 std::vector<App::DocumentObject*> sub = grp->Group.getValues();
00604 for (std::vector<App::DocumentObject*>::iterator st = sub.begin(); st != sub.end(); ++st) {
00605 if (std::find(sel.begin(), sel.end(), *st) != sel.end()) {
00606 ignore.push_back(*ft);
00607 break;
00608 }
00609 }
00610 }
00611 }
00612
00613 if (!ignore.empty()) {
00614 std::sort(sel.begin(), sel.end());
00615 std::sort(ignore.begin(), ignore.end());
00616 std::vector<App::DocumentObject*> diff;
00617 std::back_insert_iterator<std::vector<App::DocumentObject*> > biit(diff);
00618 std::set_difference(sel.begin(), sel.end(), ignore.begin(), ignore.end(), biit);
00619 sel = diff;
00620 }
00621
00622 for (std::vector<App::DocumentObject*>::const_iterator ft=sel.begin();ft!=sel.end();ft++) {
00623 if (pcDoc && pcDoc->isShow((*ft)->getNameInDocument()))
00624 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False"
00625 , (*it)->getName(), (*ft)->getNameInDocument());
00626 else
00627 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True"
00628 , (*it)->getName(), (*ft)->getNameInDocument());
00629 }
00630 }
00631 }
00632
00633 bool StdCmdToggleVisibility::isActive(void)
00634 {
00635 return (Gui::Selection().size() != 0);
00636 }
00637
00638
00639
00640
00641 DEF_STD_CMD_A(StdCmdToggleSelectability);
00642
00643 StdCmdToggleSelectability::StdCmdToggleSelectability()
00644 : Command("Std_ToggleSelectability")
00645 {
00646 sGroup = QT_TR_NOOP("Standard-View");
00647 sMenuText = QT_TR_NOOP("Toggle selectability");
00648 sToolTipText = QT_TR_NOOP("Toggles the property of the objects to get selected in the 3D-View");
00649 sStatusTip = QT_TR_NOOP("Toggles the property of the objects to get selected in the 3D-View");
00650 sWhatsThis = "Std_ToggleSelectability";
00651 sPixmap = "view-unselectable";
00652 eType = Alter3DView;
00653 }
00654
00655 void StdCmdToggleSelectability::activated(int iMsg)
00656 {
00657
00658 const std::vector<App::Document*> docs = App::GetApplication().getDocuments();
00659 for (std::vector<App::Document*>::const_iterator it = docs.begin(); it != docs.end(); ++it) {
00660 Document *pcDoc = Application::Instance->getDocument(*it);
00661 std::vector<App::DocumentObject*> sel = Selection().getObjectsOfType
00662 (App::DocumentObject::getClassTypeId(), (*it)->getName());
00663
00664
00665 for (std::vector<App::DocumentObject*>::const_iterator ft=sel.begin();ft!=sel.end();ft++) {
00666 ViewProvider *pr = pcDoc->getViewProviderByName((*ft)->getNameInDocument());
00667 if(pr->isDerivedFrom(ViewProviderGeometryObject::getClassTypeId())){
00668 if (dynamic_cast<ViewProviderGeometryObject*>(pr)->Selectable.getValue())
00669 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Selectable=False"
00670 , (*it)->getName(), (*ft)->getNameInDocument());
00671 else
00672 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Selectable=True"
00673 , (*it)->getName(), (*ft)->getNameInDocument());
00674 }
00675 }
00676 }
00677 }
00678
00679 bool StdCmdToggleSelectability::isActive(void)
00680 {
00681 return (Gui::Selection().size() != 0);
00682 }
00683
00684
00685
00686
00687 DEF_STD_CMD_A(StdCmdShowSelection);
00688
00689 StdCmdShowSelection::StdCmdShowSelection()
00690 : Command("Std_ShowSelection")
00691 {
00692 sGroup = QT_TR_NOOP("Standard-View");
00693 sMenuText = QT_TR_NOOP("Show selection");
00694 sToolTipText = QT_TR_NOOP("Show all selected objects");
00695 sStatusTip = QT_TR_NOOP("Show all selected objects");
00696 sWhatsThis = "Std_ShowSelection";
00697 eType = Alter3DView;
00698 }
00699
00700 void StdCmdShowSelection::activated(int iMsg)
00701 {
00702
00703 const std::vector<App::Document*> docs = App::GetApplication().getDocuments();
00704 for (std::vector<App::Document*>::const_iterator it = docs.begin(); it != docs.end(); ++it) {
00705 const std::vector<App::DocumentObject*> sel = Selection().getObjectsOfType
00706 (App::DocumentObject::getClassTypeId(), (*it)->getName());
00707 for(std::vector<App::DocumentObject*>::const_iterator ft=sel.begin();ft!=sel.end();ft++) {
00708 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True"
00709 , (*it)->getName(), (*ft)->getNameInDocument());
00710 }
00711 }
00712 }
00713
00714 bool StdCmdShowSelection::isActive(void)
00715 {
00716 return (Gui::Selection().size() != 0);
00717 }
00718
00719
00720
00721
00722 DEF_STD_CMD_A(StdCmdHideSelection);
00723
00724 StdCmdHideSelection::StdCmdHideSelection()
00725 : Command("Std_HideSelection")
00726 {
00727 sGroup = QT_TR_NOOP("Standard-View");
00728 sMenuText = QT_TR_NOOP("Hide selection");
00729 sToolTipText = QT_TR_NOOP("Hide all selected objects");
00730 sStatusTip = QT_TR_NOOP("Hide all selected objects");
00731 sWhatsThis = "Std_HideSelection";
00732 eType = Alter3DView;
00733 }
00734
00735 void StdCmdHideSelection::activated(int iMsg)
00736 {
00737
00738 const std::vector<App::Document*> docs = App::GetApplication().getDocuments();
00739 for (std::vector<App::Document*>::const_iterator it = docs.begin(); it != docs.end(); ++it) {
00740 const std::vector<App::DocumentObject*> sel = Selection().getObjectsOfType
00741 (App::DocumentObject::getClassTypeId(), (*it)->getName());
00742 for(std::vector<App::DocumentObject*>::const_iterator ft=sel.begin();ft!=sel.end();ft++) {
00743 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False"
00744 , (*it)->getName(), (*ft)->getNameInDocument());
00745 }
00746 }
00747 }
00748
00749 bool StdCmdHideSelection::isActive(void)
00750 {
00751 return (Gui::Selection().size() != 0);
00752 }
00753
00754
00755
00756
00757 DEF_STD_CMD_A(StdCmdToggleObjects);
00758
00759 StdCmdToggleObjects::StdCmdToggleObjects()
00760 : Command("Std_ToggleObjects")
00761 {
00762 sGroup = QT_TR_NOOP("Standard-View");
00763 sMenuText = QT_TR_NOOP("Toggle all objects");
00764 sToolTipText = QT_TR_NOOP("Toggles visibility of all objects in the active document");
00765 sStatusTip = QT_TR_NOOP("Toggles visibility of all objects in the active document");
00766 sWhatsThis = "Std_ToggleObjects";
00767 eType = Alter3DView;
00768 }
00769
00770 void StdCmdToggleObjects::activated(int iMsg)
00771 {
00772
00773 Gui::Document* doc = Application::Instance->activeDocument();
00774 App::Document* app = doc->getDocument();
00775 const std::vector<App::DocumentObject*> obj = app->getObjectsOfType
00776 (App::DocumentObject::getClassTypeId());
00777
00778 for (std::vector<App::DocumentObject*>::const_iterator it=obj.begin();it!=obj.end();++it) {
00779 if (doc && doc->isShow((*it)->getNameInDocument()))
00780 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False"
00781 , app->getName(), (*it)->getNameInDocument());
00782 else
00783 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True"
00784 , app->getName(), (*it)->getNameInDocument());
00785 }
00786 }
00787
00788 bool StdCmdToggleObjects::isActive(void)
00789 {
00790 return App::GetApplication().getActiveDocument();
00791 }
00792
00793
00794
00795
00796 DEF_STD_CMD_A(StdCmdShowObjects);
00797
00798 StdCmdShowObjects::StdCmdShowObjects()
00799 : Command("Std_ShowObjects")
00800 {
00801 sGroup = QT_TR_NOOP("Standard-View");
00802 sMenuText = QT_TR_NOOP("Show all objects");
00803 sToolTipText = QT_TR_NOOP("Show all objects in the document");
00804 sStatusTip = QT_TR_NOOP("Show all objects in the document");
00805 sWhatsThis = "Std_ShowObjects";
00806 eType = Alter3DView;
00807 }
00808
00809 void StdCmdShowObjects::activated(int iMsg)
00810 {
00811
00812 Gui::Document* doc = Application::Instance->activeDocument();
00813 App::Document* app = doc->getDocument();
00814 const std::vector<App::DocumentObject*> obj = app->getObjectsOfType
00815 (App::DocumentObject::getClassTypeId());
00816
00817 for (std::vector<App::DocumentObject*>::const_iterator it=obj.begin();it!=obj.end();++it) {
00818 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=True"
00819 , app->getName(), (*it)->getNameInDocument());
00820 }
00821 }
00822
00823 bool StdCmdShowObjects::isActive(void)
00824 {
00825 return App::GetApplication().getActiveDocument();
00826 }
00827
00828
00829
00830
00831 DEF_STD_CMD_A(StdCmdHideObjects);
00832
00833 StdCmdHideObjects::StdCmdHideObjects()
00834 : Command("Std_HideObjects")
00835 {
00836 sGroup = QT_TR_NOOP("Standard-View");
00837 sMenuText = QT_TR_NOOP("Hide all objects");
00838 sToolTipText = QT_TR_NOOP("Hide all objects in the document");
00839 sStatusTip = QT_TR_NOOP("Hide all objects in the document");
00840 sWhatsThis = "Std_HideObjects";
00841 eType = Alter3DView;
00842 }
00843
00844 void StdCmdHideObjects::activated(int iMsg)
00845 {
00846
00847 Gui::Document* doc = Application::Instance->activeDocument();
00848 App::Document* app = doc->getDocument();
00849 const std::vector<App::DocumentObject*> obj = app->getObjectsOfType
00850 (App::DocumentObject::getClassTypeId());
00851
00852 for (std::vector<App::DocumentObject*>::const_iterator it=obj.begin();it!=obj.end();++it) {
00853 doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Visibility=False"
00854 , app->getName(), (*it)->getNameInDocument());
00855 }
00856 }
00857
00858 bool StdCmdHideObjects::isActive(void)
00859 {
00860 return App::GetApplication().getActiveDocument();
00861 }
00862
00863
00864
00865
00866 DEF_STD_CMD_A(StdCmdSetAppearance);
00867
00868 StdCmdSetAppearance::StdCmdSetAppearance()
00869 : Command("Std_SetAppearance")
00870 {
00871 sGroup = QT_TR_NOOP("Standard-View");
00872 sMenuText = QT_TR_NOOP("Appearance...");
00873 sToolTipText = QT_TR_NOOP("Sets the display properties of the selected object");
00874 sWhatsThis = "Std_SetAppearance";
00875 sStatusTip = QT_TR_NOOP("Sets the display properties of the selected object");
00876 sPixmap = "Std_Tool1";
00877 sAccel = "Ctrl+D";
00878 eType = Alter3DView;
00879 }
00880
00881 void StdCmdSetAppearance::activated(int iMsg)
00882 {
00883 static QPointer<QDialog> dlg = 0;
00884 if (!dlg)
00885 dlg = new Gui::Dialog::DlgDisplayPropertiesImp(getMainWindow());
00886 dlg->setModal(false);
00887 dlg->setAttribute(Qt::WA_DeleteOnClose);
00888 dlg->show();
00889 }
00890
00891 bool StdCmdSetAppearance::isActive(void)
00892 {
00893 return Gui::Selection().size() != 0;
00894 }
00895
00896
00897
00898
00899 DEF_3DV_CMD(StdCmdViewBottom)
00900
00901 StdCmdViewBottom::StdCmdViewBottom()
00902 : Command("Std_ViewBottom")
00903 {
00904 sGroup = QT_TR_NOOP("Standard-View");
00905 sMenuText = QT_TR_NOOP("Bottom");
00906 sToolTipText = QT_TR_NOOP("Set to bottom view");
00907 sWhatsThis = "Std_ViewXX";
00908 sStatusTip = QT_TR_NOOP("Set to bottom view");
00909 sPixmap = "view-bottom";
00910 sAccel = "5";
00911 eType = Alter3DView;
00912 }
00913
00914 void StdCmdViewBottom::activated(int iMsg)
00915 {
00916 doCommand(Command::Gui,"Gui.activeDocument().activeView().viewBottom()");
00917 }
00918
00919
00920
00921
00922 DEF_3DV_CMD(StdCmdViewFront);
00923
00924 StdCmdViewFront::StdCmdViewFront()
00925 : Command("Std_ViewFront")
00926 {
00927 sGroup = QT_TR_NOOP("Standard-View");
00928 sMenuText = QT_TR_NOOP("Front");
00929 sToolTipText = QT_TR_NOOP("Set to front view");
00930 sWhatsThis = "Std_ViewXX";
00931 sStatusTip = QT_TR_NOOP("Set to front view");
00932 sPixmap = "view-front";
00933 sAccel = "1";
00934 eType = Alter3DView;
00935 }
00936
00937 void StdCmdViewFront::activated(int iMsg)
00938 {
00939 doCommand(Command::Gui,"Gui.activeDocument().activeView().viewFront()");
00940 }
00941
00942
00943
00944
00945 DEF_3DV_CMD(StdCmdViewLeft);
00946
00947 StdCmdViewLeft::StdCmdViewLeft()
00948 : Command("Std_ViewLeft")
00949 {
00950 sGroup = QT_TR_NOOP("Standard-View");
00951 sMenuText = QT_TR_NOOP("Left");
00952 sToolTipText = QT_TR_NOOP("Set to left view");
00953 sWhatsThis = "Std_ViewXX";
00954 sStatusTip = QT_TR_NOOP("Set to left view");
00955 sPixmap = "view-left";
00956 sAccel = "6";
00957 eType = Alter3DView;
00958 }
00959
00960 void StdCmdViewLeft::activated(int iMsg)
00961 {
00962 doCommand(Command::Gui,"Gui.activeDocument().activeView().viewLeft()");
00963 }
00964
00965
00966
00967
00968 DEF_3DV_CMD(StdCmdViewRear);
00969
00970 StdCmdViewRear::StdCmdViewRear()
00971 : Command("Std_ViewRear")
00972 {
00973 sGroup = QT_TR_NOOP("Standard-View");
00974 sMenuText = QT_TR_NOOP("Rear");
00975 sToolTipText = QT_TR_NOOP("Set to rear view");
00976 sWhatsThis = "Std_ViewXX";
00977 sStatusTip = QT_TR_NOOP("Set to rear view");
00978 sPixmap = "view-rear";
00979 sAccel = "4";
00980 eType = Alter3DView;
00981 }
00982
00983 void StdCmdViewRear::activated(int iMsg)
00984 {
00985 doCommand(Command::Gui,"Gui.activeDocument().activeView().viewRear()");
00986 }
00987
00988
00989
00990
00991 DEF_3DV_CMD(StdCmdViewRight);
00992
00993 StdCmdViewRight::StdCmdViewRight()
00994 : Command("Std_ViewRight")
00995 {
00996 sGroup = QT_TR_NOOP("Standard-View");
00997 sMenuText = QT_TR_NOOP("Right");
00998 sToolTipText = QT_TR_NOOP("Set to right view");
00999 sWhatsThis = "Std_ViewXX";
01000 sStatusTip = QT_TR_NOOP("Set to right view");
01001 sPixmap = "view-right";
01002 sAccel = "3";
01003 eType = Alter3DView;
01004 }
01005
01006 void StdCmdViewRight::activated(int iMsg)
01007 {
01008 doCommand(Command::Gui,"Gui.activeDocument().activeView().viewRight()");
01009 }
01010
01011
01012
01013
01014 DEF_3DV_CMD(StdCmdViewTop);
01015
01016 StdCmdViewTop::StdCmdViewTop()
01017 : Command("Std_ViewTop")
01018 {
01019 sGroup = QT_TR_NOOP("Standard-View");
01020 sMenuText = QT_TR_NOOP("Top");
01021 sToolTipText = QT_TR_NOOP("Set to top view");
01022 sWhatsThis = "Std_ViewXX";
01023 sStatusTip = QT_TR_NOOP("Set to top view");
01024 sPixmap = "view-top";
01025 sAccel = "2";
01026 eType = Alter3DView;
01027 }
01028
01029 void StdCmdViewTop::activated(int iMsg)
01030 {
01031 doCommand(Command::Gui,"Gui.activeDocument().activeView().viewTop()");
01032 }
01033
01034
01035
01036
01037 DEF_3DV_CMD(StdCmdViewAxo);
01038
01039 StdCmdViewAxo::StdCmdViewAxo()
01040 : Command("Std_ViewAxo")
01041 {
01042 sGroup = QT_TR_NOOP("Standard-View");
01043 sMenuText = QT_TR_NOOP("Axometric");
01044 sToolTipText= QT_TR_NOOP("Set to axometric view");
01045 sWhatsThis = "Std_ViewXX";
01046 sStatusTip = QT_TR_NOOP("Set to axometric view");
01047 sPixmap = "view-axometric";
01048 sAccel = "0";
01049 eType = Alter3DView;
01050 }
01051
01052 void StdCmdViewAxo::activated(int iMsg)
01053 {
01054 doCommand(Command::Gui,"Gui.activeDocument().activeView().viewAxometric()");
01055 }
01056
01057
01058
01059
01060 DEF_STD_CMD_A(StdCmdViewFitAll);
01061
01062 StdCmdViewFitAll::StdCmdViewFitAll()
01063 : Command("Std_ViewFitAll")
01064 {
01065 sGroup = QT_TR_NOOP("Standard-View");
01066 sMenuText = QT_TR_NOOP("Fit all");
01067 sToolTipText = QT_TR_NOOP("Fits the whole content on the screen");
01068 sWhatsThis = "Std_ViewFitAll";
01069 sStatusTip = QT_TR_NOOP("Fits the whole content on the screen");
01070 sPixmap = "view-zoom-all";
01071 eType = Alter3DView;
01072 }
01073
01074 void StdCmdViewFitAll::activated(int iMsg)
01075 {
01076
01077 doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"ViewFit\")");
01078 }
01079
01080 bool StdCmdViewFitAll::isActive(void)
01081 {
01082
01083 return getGuiApplication()->sendHasMsgToActiveView("ViewFit");
01084 }
01085
01086
01087
01088
01089 DEF_STD_CMD_A(StdCmdViewFitSelection);
01090
01091 StdCmdViewFitSelection::StdCmdViewFitSelection()
01092 : Command("Std_ViewFitSelection")
01093 {
01094 sGroup = QT_TR_NOOP("Standard-View");
01095 sMenuText = QT_TR_NOOP("Fit selection");
01096 sToolTipText = QT_TR_NOOP("Fits the selected content on the screen");
01097 sWhatsThis = "Std_ViewFitSelection";
01098 sStatusTip = QT_TR_NOOP("Fits the selected content on the screen");
01099 #if QT_VERSION >= 0x040200
01100 sPixmap = "view-zoom-selection";
01101 #endif
01102 eType = Alter3DView;
01103 }
01104
01105 void StdCmdViewFitSelection::activated(int iMsg)
01106 {
01107
01108 doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"ViewSelection\")");
01109 }
01110
01111 bool StdCmdViewFitSelection::isActive(void)
01112 {
01113
01114 return getGuiApplication()->sendHasMsgToActiveView("ViewSelection");
01115 }
01116
01117
01118
01119
01120 DEF_STD_CMD_AC(StdViewDockUndockFullscreen);
01121
01122 StdViewDockUndockFullscreen::StdViewDockUndockFullscreen()
01123 : Command("Std_ViewDockUndockFullscreen")
01124 {
01125 sGroup = QT_TR_NOOP("Standard-View");
01126 sMenuText = QT_TR_NOOP("Display mode");
01127 sToolTipText= QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
01128 sWhatsThis = "Std_ViewDockUndockFullscreen";
01129 sStatusTip = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
01130 eType = Alter3DView;
01131 }
01132
01133 Action * StdViewDockUndockFullscreen::createAction(void)
01134 {
01135 ActionGroup* pcAction = new ActionGroup(this, getMainWindow());
01136 pcAction->setDropDownMenu(true);
01137 pcAction->setText(QCoreApplication::translate(
01138 this->className(), sMenuText, 0,
01139 QCoreApplication::CodecForTr));
01140
01141 QAction* docked = pcAction->addAction(QObject::tr(QT_TR_NOOP("Docked")));
01142 docked->setToolTip(QCoreApplication::translate(
01143 this->className(), sToolTipText, 0,
01144 QCoreApplication::CodecForTr));
01145 docked->setStatusTip(QCoreApplication::translate(
01146 this->className(), sStatusTip, 0,
01147 QCoreApplication::CodecForTr));
01148 docked->setWhatsThis(QCoreApplication::translate(
01149 this->className(), sWhatsThis, 0,
01150 QCoreApplication::CodecForTr));
01151 docked->setShortcut(Qt::Key_D);
01152 docked->setCheckable(true);
01153
01154 QAction* undocked = pcAction->addAction(QObject::tr(QT_TR_NOOP("Undocked")));
01155 undocked->setToolTip(QCoreApplication::translate(
01156 this->className(), sToolTipText, 0,
01157 QCoreApplication::CodecForTr));
01158 undocked->setStatusTip(QCoreApplication::translate(
01159 this->className(), sStatusTip, 0,
01160 QCoreApplication::CodecForTr));
01161 undocked->setWhatsThis(QCoreApplication::translate(
01162 this->className(), sWhatsThis, 0,
01163 QCoreApplication::CodecForTr));
01164 undocked->setShortcut(Qt::Key_U);
01165 undocked->setCheckable(true);
01166
01167 QAction* fullscr = pcAction->addAction(QObject::tr(QT_TR_NOOP("Fullscreen")));
01168 fullscr->setToolTip(QCoreApplication::translate(
01169 this->className(), sToolTipText, 0,
01170 QCoreApplication::CodecForTr));
01171 fullscr->setStatusTip(QCoreApplication::translate(
01172 this->className(), sStatusTip, 0,
01173 QCoreApplication::CodecForTr));
01174 fullscr->setWhatsThis(QCoreApplication::translate(
01175 this->className(), sWhatsThis, 0,
01176 QCoreApplication::CodecForTr));
01177 fullscr->setShortcut(Qt::Key_F11);
01178 fullscr->setCheckable(true);
01179 fullscr->setIcon(Gui::BitmapFactory().pixmap("view-fullscreen"));
01180
01181 return pcAction;
01182 }
01183
01184 void StdViewDockUndockFullscreen::activated(int iMsg)
01185 {
01186 MDIView* view = getMainWindow()->activeWindow();
01187 if (!view) return;
01188 if (iMsg == (int)(view->currentViewMode()))
01189 return;
01190
01191 if (iMsg==0) {
01192 view->setCurrentViewMode( MDIView::Child );
01193 }
01194 else if (iMsg==1) {
01195 view->setCurrentViewMode( MDIView::TopLevel );
01196 }
01197 else if (iMsg==2) {
01198 view->setCurrentViewMode( MDIView::FullScreen );
01199 }
01200 }
01201
01202 bool StdViewDockUndockFullscreen::isActive(void)
01203 {
01204 MDIView* view = getMainWindow()->activeWindow();
01205 if (qobject_cast<View3DInventor*>(view)) {
01206
01207 ActionGroup* pActGrp = qobject_cast<ActionGroup*>(_pcAction);
01208 if (pActGrp) {
01209 int index = pActGrp->checkedAction();
01210 int mode = (int)(view->currentViewMode());
01211 if (index != mode) {
01212
01213 pActGrp->setCheckedAction(mode);
01214 }
01215 }
01216
01217 return true;
01218 }
01219
01220 return false;
01221 }
01222
01223
01224
01225
01226 DEF_STD_CMD_A(StdViewScreenShot);
01227
01228 StdViewScreenShot::StdViewScreenShot()
01229 : Command("Std_ViewScreenShot")
01230 {
01231 sGroup = QT_TR_NOOP("Standard-View");
01232 sMenuText = QT_TR_NOOP("Save picture...");
01233 sToolTipText= QT_TR_NOOP("Creates a screenshot of the active view");
01234 sWhatsThis = "Std_ViewScreenShot";
01235 sStatusTip = QT_TR_NOOP("Creates a screenshot of the active view");
01236 sPixmap = "camera-photo";
01237 eType = Alter3DView;
01238 }
01239
01240 void StdViewScreenShot::activated(int iMsg)
01241 {
01242 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
01243 if (view) {
01244 QStringList formats;
01245 SbViewportRegion vp(view->getViewer()->getViewportRegion());
01246 {
01247 SoFCOffscreenRenderer& rd = SoFCOffscreenRenderer::instance();
01248 formats = rd.getWriteImageFiletypeInfo();
01249 }
01250
01251 QStringList filter;
01252 QString selFilter;
01253 for (QStringList::Iterator it = formats.begin(); it != formats.end(); ++it) {
01254 filter << QString::fromAscii("%1 %2 (*.%3)").arg((*it).toUpper()).
01255 arg(QObject::tr("files")).arg((*it).toLower());
01256 }
01257
01258 FileOptionsDialog fd(getMainWindow(), 0);
01259 fd.setFileMode(QFileDialog::AnyFile);
01260 fd.setAcceptMode(QFileDialog::AcceptSave);
01261 fd.setWindowTitle(QObject::tr("Save picture"));
01262 fd.setFilters(filter);
01263
01264
01265 DlgSettingsImageImp* opt = new DlgSettingsImageImp(&fd);
01266 SbVec2s sz = vp.getWindowSize();
01267 opt->setImageSize((int)sz[0], (int)sz[1]);
01268
01269 fd.setOptionsWidget(FileOptionsDialog::ExtensionRight, opt);
01270 fd.setConfirmOverwrite(true);
01271 opt->onSelectedFilter(fd.selectedFilter());
01272 QObject::connect(&fd, SIGNAL(filterSelected(const QString&)),
01273 opt, SLOT(onSelectedFilter(const QString&)));
01274
01275 if (fd.exec() == QDialog::Accepted) {
01276 selFilter = fd.selectedFilter();
01277 QString fn = fd.selectedFiles().front();
01278
01279
01280 fn.replace(QLatin1Char('\\'), QLatin1Char('/'));
01281
01282 Gui::WaitCursor wc;
01283
01284
01285 int w = opt->imageWidth();
01286 int h = opt->imageHeight();
01287
01288
01289 QString format = formats.front();
01290 for (QStringList::Iterator it = formats.begin(); it != formats.end(); ++it) {
01291 if (selFilter.startsWith((*it).toUpper())) {
01292 format = *it;
01293 break;
01294 }
01295 }
01296
01297
01298 const char* background;
01299 switch(opt->backgroundType()){
01300 case 0: background="Current"; break;
01301 case 1: background="White"; break;
01302 case 2: background="Black"; break;
01303 case 3: background="Transparent"; break;
01304 default: background="Current"; break;
01305 }
01306
01307 QString comment = opt->comment();
01308 if (!comment.isEmpty()) {
01309
01310
01311
01312 QStringList lines = comment.split(QLatin1String("\n"), QString::KeepEmptyParts );
01313 comment = lines.join(QLatin1String("\\n"));
01314 doCommand(Gui,"Gui.activeDocument().activeView().saveImage('%s',%d,%d,'%s','%s')",
01315 fn.toUtf8().constData(),w,h,background,comment.toUtf8().constData());
01316 }
01317 else {
01318 doCommand(Gui,"Gui.activeDocument().activeView().saveImage('%s',%d,%d,'%s')",
01319 fn.toUtf8().constData(),w,h,background);
01320 }
01321 }
01322 }
01323 }
01324
01325 bool StdViewScreenShot::isActive(void)
01326 {
01327 return isViewOfType(Gui::View3DInventor::getClassTypeId());
01328 }
01329
01330
01331
01332
01333
01334 DEF_STD_CMD_A(StdCmdViewCreate);
01335
01336 StdCmdViewCreate::StdCmdViewCreate()
01337 : Command("Std_ViewCreate")
01338 {
01339 sGroup = QT_TR_NOOP("Standard-View");
01340 sMenuText = QT_TR_NOOP("Create new view");
01341 sToolTipText= QT_TR_NOOP("Creates a new view window for the active document");
01342 sWhatsThis = "Std_ViewCreate";
01343 sStatusTip = QT_TR_NOOP("Creates a new view window for the active document");
01344 sPixmap = "window-new";
01345 eType = Alter3DView;
01346 }
01347
01348 void StdCmdViewCreate::activated(int iMsg)
01349 {
01350 getActiveGuiDocument()->createView("View3DIv");
01351 getActiveGuiDocument()->getActiveView()->viewAll();
01352 }
01353
01354 bool StdCmdViewCreate::isActive(void)
01355 {
01356 return (getActiveGuiDocument()!=NULL);
01357 }
01358
01359
01360
01361
01362 DEF_STD_CMD_A(StdCmdToggleNavigation);
01363
01364 StdCmdToggleNavigation::StdCmdToggleNavigation()
01365 : Command("Std_ToggleNavigation")
01366 {
01367 sGroup = QT_TR_NOOP("Standard-View");
01368 sMenuText = QT_TR_NOOP("Toggle navigation/Edit mode");
01369 sToolTipText = QT_TR_NOOP("Toggle between navigation and edit mode");
01370 sStatusTip = QT_TR_NOOP("Toggle between navigation and edit mode");
01371 sWhatsThis = "Std_ToggleNavigation";
01372
01373 sAccel = "Esc";
01374 eType = Alter3DView;
01375 }
01376
01377 void StdCmdToggleNavigation::activated(int iMsg)
01378 {
01379 Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
01380 if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
01381 Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
01382 SbBool toggle = viewer->isRedirectedToSceneGraph();
01383 viewer->setRedirectToSceneGraph(!toggle);
01384 }
01385 }
01386
01387 bool StdCmdToggleNavigation::isActive(void)
01388 {
01389 Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
01390 if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
01391 Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
01392 return viewer->isEditing();
01393 }
01394 return false;
01395 }
01396
01397
01398 class StdCmdAxisCross : public Gui::Command
01399 {
01400 private:
01401 SoShapeScale* axisCross;
01402 SoGroup* axisGroup;
01403 public:
01404 StdCmdAxisCross() : Command("Std_AxisCross"), axisCross(0), axisGroup(0)
01405 {
01406 sGroup = QT_TR_NOOP("Standard-View");
01407 sMenuText = QT_TR_NOOP("Toggle axis cross");
01408 sToolTipText = QT_TR_NOOP("Toggle axis cross");
01409 sStatusTip = QT_TR_NOOP("Toggle axis cross");
01410 sWhatsThis = "Std_AxisCross";
01411 }
01412 ~StdCmdAxisCross()
01413 {
01414 if (axisGroup)
01415 axisGroup->unref();
01416 if (axisCross)
01417 axisCross->unref();
01418 }
01419 const char* className() const
01420 { return "StdCmdAxisCross"; }
01421
01422 Action * createAction(void)
01423 {
01424 axisCross = new Gui::SoShapeScale;
01425 axisCross->ref();
01426 Gui::SoAxisCrossKit* axisKit = new Gui::SoAxisCrossKit();
01427 axisKit->set("xAxis.appearance.drawStyle", "lineWidth 2");
01428 axisKit->set("yAxis.appearance.drawStyle", "lineWidth 2");
01429 axisKit->set("zAxis.appearance.drawStyle", "lineWidth 2");
01430 axisCross->setPart("shape", axisKit);
01431 axisGroup = new SoSkipBoundingGroup;
01432 axisGroup->ref();
01433 axisGroup->addChild(axisCross);
01434
01435 Action *pcAction = Gui::Command::createAction();
01436 pcAction->setCheckable(true);
01437 return pcAction;
01438 }
01439
01440 protected:
01441 void activated(int iMsg)
01442 {
01443 float scale = 1.0f;
01444
01445 Gui::View3DInventor* view = qobject_cast<Gui::View3DInventor*>
01446 (getMainWindow()->activeWindow());
01447 if (view) {
01448 SoNode* scene = view->getViewer()->getSceneGraph();
01449 SoSeparator* sep = static_cast<SoSeparator*>(scene);
01450 bool hasaxis = (sep->findChild(axisGroup) != -1);
01451 if (iMsg > 0 && !hasaxis) {
01452 axisCross->scaleFactor = scale;
01453 sep->addChild(axisGroup);
01454 }
01455 else if (iMsg == 0 && hasaxis) {
01456 sep->removeChild(axisGroup);
01457 }
01458 }
01459 }
01460
01461 bool isActive(void)
01462 {
01463 Gui::View3DInventor* view = qobject_cast<View3DInventor*>(Gui::getMainWindow()->activeWindow());
01464 if (view) {
01465 SoGroup* group = static_cast<SoGroup*>(view->getViewer()->getSceneGraph());
01466 bool hasaxis = group->findChild(axisGroup) != -1;
01467 if (_pcAction->isChecked() != hasaxis)
01468 _pcAction->setChecked(hasaxis);
01469 return true;
01470 }
01471 else {
01472 if (_pcAction->isChecked())
01473 _pcAction->setChecked(false);
01474 return false;
01475 }
01476 }
01477 };
01478
01479
01480
01481
01482 DEF_STD_CMD_A(StdCmdViewExample1);
01483
01484 StdCmdViewExample1::StdCmdViewExample1()
01485 : Command("Std_ViewExample1")
01486 {
01487 sGroup = QT_TR_NOOP("Standard-View");
01488 sMenuText = QT_TR_NOOP("Inventor example #1");
01489 sToolTipText = QT_TR_NOOP("Shows a 3D texture with manipulator");
01490 sWhatsThis = "Std_ViewExamples";
01491 sStatusTip = QT_TR_NOOP("Shows a 3D texture with manipulator");
01492 sPixmap = "Std_Tool1";
01493 eType = Alter3DView;
01494 }
01495
01496 void StdCmdViewExample1::activated(int iMsg)
01497 {
01498 doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"Example1\")");
01499 }
01500
01501 bool StdCmdViewExample1::isActive(void)
01502 {
01503 return getGuiApplication()->sendHasMsgToActiveView("Example1");
01504 }
01505
01506
01507
01508 DEF_STD_CMD_A(StdCmdViewExample2);
01509
01510 StdCmdViewExample2::StdCmdViewExample2()
01511 : Command("Std_ViewExample2")
01512 {
01513 sGroup = QT_TR_NOOP("Standard-View");
01514 sMenuText = QT_TR_NOOP("Inventor example #2");
01515 sToolTipText = QT_TR_NOOP("Shows spheres and drag-lights");
01516 sWhatsThis = "Std_ViewExamples";
01517 sStatusTip = QT_TR_NOOP("Shows spheres and drag-lights");
01518 sPixmap = "Std_Tool2";
01519 eType = Alter3DView;
01520 }
01521
01522 void StdCmdViewExample2::activated(int iMsg)
01523 {
01524 doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"Example2\")");
01525 }
01526
01527 bool StdCmdViewExample2::isActive(void)
01528 {
01529 return getGuiApplication()->sendHasMsgToActiveView("Example2");
01530 }
01531
01532
01533
01534
01535 DEF_STD_CMD_A(StdCmdViewExample3);
01536
01537 StdCmdViewExample3::StdCmdViewExample3()
01538 : Command("Std_ViewExample3")
01539 {
01540 sGroup = QT_TR_NOOP("Standard-View");
01541 sMenuText = QT_TR_NOOP("Inventor example #3");
01542 sToolTipText = QT_TR_NOOP("Shows a animated texture");
01543 sWhatsThis = "Std_ViewExamples";
01544 sStatusTip = QT_TR_NOOP("Shows a animated texture");
01545 sPixmap = "Std_Tool3";
01546 eType = Alter3DView;
01547 }
01548
01549 void StdCmdViewExample3::activated(int iMsg)
01550 {
01551 doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"Example3\")");
01552 }
01553
01554 bool StdCmdViewExample3::isActive(void)
01555 {
01556 return getGuiApplication()->sendHasMsgToActiveView("Example3");
01557 }
01558
01559
01560
01561
01562
01563 DEF_STD_CMD_A(StdCmdViewIvStereoOff);
01564
01565 StdCmdViewIvStereoOff::StdCmdViewIvStereoOff()
01566 : Command("Std_ViewIvStereoOff")
01567 {
01568 sGroup = QT_TR_NOOP("Standard-View");
01569 sMenuText = QT_TR_NOOP("Stereo Off");
01570 sToolTipText = QT_TR_NOOP("Switch stereo viewing off");
01571 sWhatsThis = "Std_ViewIvStereo";
01572 sStatusTip = QT_TR_NOOP("Switch stereo viewing off");
01573 sPixmap = "Std_Tool6";
01574 eType = Alter3DView;
01575 }
01576
01577 void StdCmdViewIvStereoOff::activated(int iMsg)
01578 {
01579 doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"None\")");
01580 }
01581
01582 bool StdCmdViewIvStereoOff::isActive(void)
01583 {
01584 return getGuiApplication()->sendHasMsgToActiveView("SetStereoOff");
01585 }
01586
01587
01588
01589
01590
01591 DEF_STD_CMD_A(StdCmdViewIvStereoRedGreen);
01592
01593 StdCmdViewIvStereoRedGreen::StdCmdViewIvStereoRedGreen()
01594 : Command("Std_ViewIvStereoRedGreen")
01595 {
01596 sGroup = QT_TR_NOOP("Standard-View");
01597 sMenuText = QT_TR_NOOP("Stereo red/green");
01598 sToolTipText = QT_TR_NOOP("Switch stereo viewing to red/green");
01599 sWhatsThis = "Std_ViewIvStereo";
01600 sStatusTip = QT_TR_NOOP("Switch stereo viewing to red/green");
01601 sPixmap = "Std_Tool7";
01602 eType = Alter3DView;
01603 }
01604
01605 void StdCmdViewIvStereoRedGreen::activated(int iMsg)
01606 {
01607 doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"Anaglyph\")");
01608 }
01609
01610 bool StdCmdViewIvStereoRedGreen::isActive(void)
01611 {
01612 return getGuiApplication()->sendHasMsgToActiveView("SetStereoRedGreen");
01613 }
01614
01615
01616
01617
01618 DEF_STD_CMD_A(StdCmdViewIvStereoQuadBuff);
01619
01620 StdCmdViewIvStereoQuadBuff::StdCmdViewIvStereoQuadBuff()
01621 : Command("Std_ViewIvStereoQuadBuff")
01622 {
01623 sGroup = QT_TR_NOOP("Standard-View");
01624 sMenuText = QT_TR_NOOP("Stereo quad buffer");
01625 sToolTipText = QT_TR_NOOP("Switch stereo viewing to quad buffer");
01626 sWhatsThis = "Std_ViewIvStereo";
01627 sStatusTip = QT_TR_NOOP("Switch stereo viewing to quad buffer");
01628 sPixmap = "Std_Tool7";
01629 eType = Alter3DView;
01630 }
01631
01632 void StdCmdViewIvStereoQuadBuff::activated(int iMsg)
01633 {
01634 doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"QuadBuffer\")");
01635 }
01636
01637 bool StdCmdViewIvStereoQuadBuff::isActive(void)
01638 {
01639 return getGuiApplication()->sendHasMsgToActiveView("SetStereoQuadBuff");
01640 }
01641
01642
01643
01644
01645 DEF_STD_CMD_A(StdCmdViewIvStereoInterleavedRows);
01646
01647 StdCmdViewIvStereoInterleavedRows::StdCmdViewIvStereoInterleavedRows()
01648 : Command("Std_ViewIvStereoInterleavedRows")
01649 {
01650 sGroup = QT_TR_NOOP("Standard-View");
01651 sMenuText = QT_TR_NOOP("Stereo Interleaved Rows");
01652 sToolTipText = QT_TR_NOOP("Switch stereo viewing to Interleaved Rows");
01653 sWhatsThis = "Std_ViewIvStereo";
01654 sStatusTip = QT_TR_NOOP("Switch stereo viewing to Interleaved Rows");
01655 sPixmap = "Std_Tool7";
01656 eType = Alter3DView;
01657 }
01658
01659 void StdCmdViewIvStereoInterleavedRows::activated(int iMsg)
01660 {
01661 doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"InterleavedRows\")");
01662 }
01663
01664 bool StdCmdViewIvStereoInterleavedRows::isActive(void)
01665 {
01666 return getGuiApplication()->sendHasMsgToActiveView("SetStereoInterleavedRows");
01667 }
01668
01669
01670
01671
01672 DEF_STD_CMD_A(StdCmdViewIvStereoInterleavedColumns);
01673
01674 StdCmdViewIvStereoInterleavedColumns::StdCmdViewIvStereoInterleavedColumns()
01675 : Command("Std_ViewIvStereoInterleavedColumns")
01676 {
01677 sGroup = QT_TR_NOOP("Standard-View");
01678 sMenuText = QT_TR_NOOP("Stereo Interleaved Columns");
01679 sToolTipText = QT_TR_NOOP("Switch stereo viewing to Interleaved Columns");
01680 sWhatsThis = "Std_ViewIvStereo";
01681 sStatusTip = QT_TR_NOOP("Switch stereo viewing to Interleaved Columns");
01682 sPixmap = "Std_Tool7";
01683 eType = Alter3DView;
01684 }
01685
01686 void StdCmdViewIvStereoInterleavedColumns::activated(int iMsg)
01687 {
01688 doCommand(Command::Gui,"Gui.activeDocument().activeView().setStereoType(\"InterleavedColumns\")");
01689 }
01690
01691 bool StdCmdViewIvStereoInterleavedColumns::isActive(void)
01692 {
01693 return getGuiApplication()->sendHasMsgToActiveView("SetStereoInterleavedColumns");
01694 }
01695
01696
01697
01698
01699
01700 DEF_STD_CMD_A(StdCmdViewIvIssueCamPos);
01701
01702 StdCmdViewIvIssueCamPos::StdCmdViewIvIssueCamPos()
01703 : Command("Std_ViewIvIssueCamPos")
01704 {
01705 sGroup = QT_TR_NOOP("Standard-View");
01706 sMenuText = QT_TR_NOOP("Issue camera position");
01707 sToolTipText = QT_TR_NOOP("Issue the camera position to the console and to a macro, to easily recall this position");
01708 sWhatsThis = "Std_ViewIvIssueCamPos";
01709 sStatusTip = QT_TR_NOOP("Issue the camera position to the console and to a macro, to easily recall this position");
01710 sPixmap = "Std_Tool8";
01711 eType = Alter3DView;
01712 }
01713
01714 void StdCmdViewIvIssueCamPos::activated(int iMsg)
01715 {
01716 std::string Temp,Temp2;
01717 std::string::size_type pos;
01718
01719 const char* ppReturn=0;
01720 getGuiApplication()->sendMsgToActiveView("GetCamera",&ppReturn);
01721
01722
01723 Temp2 = ppReturn;
01724 pos = Temp2.find_first_of("\n");
01725 Temp2.erase(0,pos);
01726
01727
01728 while((pos=Temp2.find('\n')) != std::string::npos)
01729 Temp2.replace(pos,1," ");
01730
01731
01732 Temp += "Gui.SendMsgToActiveView(\"SetCamera ";
01733 Temp += Temp2;
01734 Temp += "\")";
01735
01736 Base::Console().Message("%s\n",Temp2.c_str());
01737 getGuiApplication()->macroManager()->addLine(MacroManager::Gui,Temp.c_str());
01738 }
01739
01740 bool StdCmdViewIvIssueCamPos::isActive(void)
01741 {
01742 return getGuiApplication()->sendHasMsgToActiveView("GetCamera");
01743 }
01744
01745
01746
01747
01748
01749 DEF_STD_CMD_A(StdViewZoomIn);
01750
01751 StdViewZoomIn::StdViewZoomIn()
01752 : Command("Std_ViewZoomIn")
01753 {
01754 sGroup = QT_TR_NOOP("Standard-View");
01755 sMenuText = QT_TR_NOOP("Zoom In");
01756 sToolTipText = QT_TR_NOOP("Zoom In");
01757 sWhatsThis = "Std_ViewZoom";
01758 sStatusTip = QT_TR_NOOP("Zoom In");
01759 #if QT_VERSION >= 0x040200
01760 sPixmap = "view-zoom-in";
01761 #endif
01762 sAccel = keySequenceToAccel(QKeySequence::ZoomIn);
01763 eType = Alter3DView;
01764 }
01765
01766 void StdViewZoomIn::activated(int iMsg)
01767 {
01768 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
01769 if ( view ) {
01770 View3DInventorViewer* viewer = view->getViewer();
01771
01772
01773
01774 SoMouseButtonEvent e;
01775 e.setButton(SoMouseButtonEvent::BUTTON5);
01776 e.setState(SoMouseButtonEvent::DOWN);
01777 viewer->sendSoEvent(&e);
01778 }
01779 }
01780
01781 bool StdViewZoomIn::isActive(void)
01782 {
01783 return (qobject_cast<View3DInventor*>(getMainWindow()->activeWindow()));
01784 }
01785
01786
01787
01788
01789 DEF_STD_CMD_A(StdViewZoomOut);
01790
01791 StdViewZoomOut::StdViewZoomOut()
01792 : Command("Std_ViewZoomOut")
01793 {
01794 sGroup = QT_TR_NOOP("Standard-View");
01795 sMenuText = QT_TR_NOOP("Zoom Out");
01796 sToolTipText = QT_TR_NOOP("Zoom Out");
01797 sWhatsThis = "Std_ViewZoom";
01798 sStatusTip = QT_TR_NOOP("Zoom Out");
01799 #if QT_VERSION >= 0x040200
01800 sPixmap = "view-zoom-out";
01801 #endif
01802 sAccel = keySequenceToAccel(QKeySequence::ZoomOut);
01803 eType = Alter3DView;
01804 }
01805
01806 void StdViewZoomOut::activated(int iMsg)
01807 {
01808 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
01809 if (view) {
01810 View3DInventorViewer* viewer = view->getViewer();
01811
01812
01813 SoMouseButtonEvent e;
01814 e.setButton(SoMouseButtonEvent::BUTTON4);
01815 e.setState(SoMouseButtonEvent::DOWN);
01816 viewer->sendSoEvent(&e);
01817 }
01818 }
01819
01820 bool StdViewZoomOut::isActive(void)
01821 {
01822 return (qobject_cast<View3DInventor*>(getMainWindow()->activeWindow()));
01823 }
01824
01825
01826
01827
01828 DEF_3DV_CMD(StdViewBoxZoom);
01829
01830 StdViewBoxZoom::StdViewBoxZoom()
01831 : Command("Std_ViewBoxZoom")
01832 {
01833 sGroup = QT_TR_NOOP("Standard-View");
01834 sMenuText = QT_TR_NOOP("Box zoom");
01835 sToolTipText = QT_TR_NOOP("Box zoom");
01836 sWhatsThis = "Std_ViewBoxZoom";
01837 sStatusTip = QT_TR_NOOP("Box zoom");
01838 #if QT_VERSION >= 0x040200
01839 sPixmap = "view-zoom-border";
01840 #endif
01841 sAccel = "Ctrl+B";
01842 eType = Alter3DView;
01843 }
01844
01845 void StdViewBoxZoom::activated(int iMsg)
01846 {
01847 View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
01848 if ( view ) {
01849 View3DInventorViewer* viewer = view->getViewer();
01850 if (!viewer->isSelecting())
01851 viewer->startSelection(View3DInventorViewer::BoxZoom);
01852 }
01853 }
01854
01855
01856
01857
01858
01859 DEF_STD_CMD(StdCmdTreeSelection);
01860
01861 StdCmdTreeSelection::StdCmdTreeSelection()
01862 : Command("Std_TreeSelection")
01863 {
01864 sGroup = QT_TR_NOOP("View");
01865 sMenuText = QT_TR_NOOP("Go to selection");
01866 sToolTipText = QT_TR_NOOP("Scroll to first selected item");
01867 sWhatsThis = "Std_TreeSelection";
01868 sStatusTip = QT_TR_NOOP("Scroll to first selected item");
01869 eType = Alter3DView;
01870 }
01871
01872 void StdCmdTreeSelection::activated(int iMsg)
01873 {
01874 QList<TreeWidget*> tree = Gui::getMainWindow()->findChildren<TreeWidget*>();
01875 for (QList<TreeWidget*>::iterator it = tree.begin(); it != tree.end(); ++it) {
01876 Gui::Document* doc = Gui::Application::Instance->activeDocument();
01877 (*it)->scrollItemToTop(doc);
01878 }
01879 }
01880
01881
01882
01883
01884
01885 DEF_STD_CMD_A(StdCmdMeasureDistance);
01886
01887 StdCmdMeasureDistance::StdCmdMeasureDistance()
01888 : Command("Std_MeasureDistance")
01889 {
01890 sGroup = QT_TR_NOOP("View");
01891 sMenuText = QT_TR_NOOP("Measure distance");
01892 sToolTipText = QT_TR_NOOP("Measure distance");
01893 sWhatsThis = "Std_MeasureDistance";
01894 sStatusTip = QT_TR_NOOP("Measure distance");
01895 sPixmap = "view-measurement";
01896 eType = Alter3DView;
01897 }
01898
01899 void StdCmdMeasureDistance::activated(int iMsg)
01900 {
01901 Gui::Document* doc = Gui::Application::Instance->activeDocument();
01902 Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
01903 if (view) {
01904 Gui::View3DInventorViewer* viewer = view->getViewer();
01905 viewer->setEditing(true);
01906 PointMarker* marker = new PointMarker(viewer);
01907 viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
01908 ViewProviderMeasureDistance::measureDistanceCallback, marker);
01909 }
01910 }
01911
01912 bool StdCmdMeasureDistance::isActive(void)
01913 {
01914 App::Document* doc = App::GetApplication().getActiveDocument();
01915 if (!doc || doc->countObjectsOfType(App::GeoFeature::getClassTypeId()) == 0)
01916 return false;
01917
01918 Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
01919 if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
01920 Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
01921 return !viewer->isEditing();
01922 }
01923
01924 return false;
01925 }
01926
01927
01928
01929
01930
01931 DEF_3DV_CMD(StdCmdSceneInspector);
01932
01933 StdCmdSceneInspector::StdCmdSceneInspector()
01934 : Command("Std_SceneInspector")
01935 {
01936
01937 sGroup = QT_TR_NOOP("Tools");
01938 sMenuText = QT_TR_NOOP("Scene inspector...");
01939 sToolTipText = QT_TR_NOOP("Scene inspector");
01940 sWhatsThis = "Std_SceneInspector";
01941 sStatusTip = QT_TR_NOOP("Scene inspector");
01942 eType = Alter3DView;
01943 }
01944
01945 void StdCmdSceneInspector::activated(int iMsg)
01946 {
01947 View3DInventor* child = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
01948 if (child) {
01949 View3DInventorViewer* viewer = child->getViewer();
01950 static QPointer<Gui::Dialog::DlgInspector> dlg = 0;
01951 if (!dlg)
01952 dlg = new Gui::Dialog::DlgInspector(getMainWindow());
01953 dlg->setNode(viewer->getSceneGraph());
01954 dlg->setAttribute(Qt::WA_DeleteOnClose);
01955 dlg->show();
01956 }
01957 }
01958
01959
01960
01961
01962
01963 DEF_STD_CMD_A(StdCmdTextureMapping);
01964
01965 StdCmdTextureMapping::StdCmdTextureMapping()
01966 : Command("Std_TextureMapping")
01967 {
01968
01969 sGroup = QT_TR_NOOP("Tools");
01970 sMenuText = QT_TR_NOOP("Texture mapping...");
01971 sToolTipText = QT_TR_NOOP("Texture mapping");
01972 sWhatsThis = "Std_TextureMapping";
01973 sStatusTip = QT_TR_NOOP("Texture mapping");
01974 eType = Alter3DView;
01975 }
01976
01977 void StdCmdTextureMapping::activated(int iMsg)
01978 {
01979 Gui::Control().showDialog(new Gui::Dialog::TaskTextureMapping);
01980 }
01981
01982 bool StdCmdTextureMapping::isActive(void)
01983 {
01984 Gui::MDIView* view = getMainWindow()->activeWindow();
01985 return view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())
01986 && (Gui::Control().activeDialog()==0);
01987 }
01988
01989 DEF_STD_CMD(StdCmdDemoMode);
01990
01991 StdCmdDemoMode::StdCmdDemoMode()
01992 : Command("Std_DemoMode")
01993 {
01994 sGroup = QT_TR_NOOP("Standard-View");
01995 sMenuText = QT_TR_NOOP("View turntable...");
01996 sToolTipText = QT_TR_NOOP("View turntable");
01997 sWhatsThis = QT_TR_NOOP("View turntable");
01998 sStatusTip = QT_TR_NOOP("View turntable");
01999 eType = Alter3DView;
02000 }
02001
02002 void StdCmdDemoMode::activated(int iMsg)
02003 {
02004 static QPointer<QDialog> dlg = 0;
02005 if (!dlg)
02006 dlg = new Gui::Dialog::DemoMode(getMainWindow());
02007 dlg->setAttribute(Qt::WA_DeleteOnClose);
02008 dlg->show();
02009 }
02010
02011
02012
02013
02014
02015
02016
02017 namespace Gui {
02018
02019 void CreateViewStdCommands(void)
02020 {
02021 CommandManager &rcCmdMgr = Application::Instance->commandManager();
02022
02023
02024 rcCmdMgr.addCommand(new StdCmdViewBottom());
02025 rcCmdMgr.addCommand(new StdCmdViewFront());
02026 rcCmdMgr.addCommand(new StdCmdViewLeft());
02027 rcCmdMgr.addCommand(new StdCmdViewRear());
02028 rcCmdMgr.addCommand(new StdCmdViewRight());
02029 rcCmdMgr.addCommand(new StdCmdViewTop());
02030 rcCmdMgr.addCommand(new StdCmdViewAxo());
02031 rcCmdMgr.addCommand(new StdCmdViewFitAll());
02032 rcCmdMgr.addCommand(new StdCmdViewFitSelection());
02033
02034 rcCmdMgr.addCommand(new StdCmdViewExample1());
02035 rcCmdMgr.addCommand(new StdCmdViewExample2());
02036 rcCmdMgr.addCommand(new StdCmdViewExample3());
02037
02038 rcCmdMgr.addCommand(new StdCmdViewIvStereoQuadBuff());
02039 rcCmdMgr.addCommand(new StdCmdViewIvStereoRedGreen());
02040 rcCmdMgr.addCommand(new StdCmdViewIvStereoInterleavedColumns());
02041 rcCmdMgr.addCommand(new StdCmdViewIvStereoInterleavedRows());
02042 rcCmdMgr.addCommand(new StdCmdViewIvStereoOff());
02043
02044 rcCmdMgr.addCommand(new StdCmdViewIvIssueCamPos());
02045
02046 rcCmdMgr.addCommand(new StdCmdViewCreate());
02047 rcCmdMgr.addCommand(new StdViewScreenShot());
02048
02049 rcCmdMgr.addCommand(new StdViewDockUndockFullscreen());
02050 rcCmdMgr.addCommand(new StdCmdSetAppearance());
02051 rcCmdMgr.addCommand(new StdCmdToggleVisibility());
02052 rcCmdMgr.addCommand(new StdCmdToggleSelectability());
02053 rcCmdMgr.addCommand(new StdCmdShowSelection());
02054 rcCmdMgr.addCommand(new StdCmdHideSelection());
02055 rcCmdMgr.addCommand(new StdCmdToggleObjects());
02056 rcCmdMgr.addCommand(new StdCmdShowObjects());
02057 rcCmdMgr.addCommand(new StdCmdHideObjects());
02058 rcCmdMgr.addCommand(new StdOrthographicCamera());
02059 rcCmdMgr.addCommand(new StdPerspectiveCamera());
02060 rcCmdMgr.addCommand(new StdCmdToggleClipPlane());
02061 rcCmdMgr.addCommand(new StdCmdDrawStyle());
02062 rcCmdMgr.addCommand(new StdCmdFreezeViews());
02063 rcCmdMgr.addCommand(new StdViewZoomIn());
02064 rcCmdMgr.addCommand(new StdViewZoomOut());
02065 rcCmdMgr.addCommand(new StdViewBoxZoom());
02066 rcCmdMgr.addCommand(new StdCmdTreeSelection());
02067 rcCmdMgr.addCommand(new StdCmdMeasureDistance());
02068 rcCmdMgr.addCommand(new StdCmdSceneInspector());
02069 rcCmdMgr.addCommand(new StdCmdTextureMapping());
02070 rcCmdMgr.addCommand(new StdCmdDemoMode());
02071 rcCmdMgr.addCommand(new StdCmdToggleNavigation());
02072 rcCmdMgr.addCommand(new StdCmdAxisCross());
02073 }
02074
02075 }
02076