Mod/Import/Gui/Command.cpp
Go to the documentation of this file.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 #ifndef _PreComp_
00026 #endif
00027
00028 #include <Base/Exception.h>
00029 #include <App/Document.h>
00030 #include <Gui/Application.h>
00031 #include <Gui/MainWindow.h>
00032 #include <Gui/Command.h>
00033 #include <Gui/FileDialog.h>
00034
00035
00036
00037 using Gui::FileDialog;
00038
00039
00040
00041
00042 DEF_STD_CMD_A(FCCmdImportReadBREP);
00043
00044 FCCmdImportReadBREP::FCCmdImportReadBREP()
00045 : Command("Import_ReadBREP")
00046 {
00047 sAppModule = "Import";
00048 sGroup = "Import";
00049 sMenuText = "Read BREP";
00050 sToolTipText = "Read a BREP file";
00051 sWhatsThis = sToolTipText;
00052 sStatusTip = sToolTipText;
00053 sPixmap = "Std_Tool1";
00054 }
00055
00056 void FCCmdImportReadBREP::activated(int iMsg)
00057 {
00058 openCommand("Read BREP");
00059 QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), QLatin1String("BREP (*.brep *.rle)"));
00060 if (fn.isEmpty()) {
00061 abortCommand();
00062 return;
00063 }
00064
00065 doCommand(Doc,"TopoShape = Import.ReadBREP(\"%s\")",(const char*)fn.toUtf8());
00066 commitCommand();
00067 }
00068
00069 bool FCCmdImportReadBREP::isActive(void)
00070 {
00071 return getGuiApplication()->activeDocument() != 0;
00072 }
00073
00074
00075
00076
00077 DEF_STD_CMD_A(ImportStep);
00078
00079 ImportStep::ImportStep()
00080 : Command("Part_ImportStep")
00081 {
00082 sAppModule = "Part";
00083 sGroup = "Part";
00084 sMenuText = "Import STEP";
00085 sToolTipText = "Create or change a Import STEP feature";
00086 sWhatsThis = sToolTipText;
00087 sStatusTip = sToolTipText;
00088 sPixmap = "Save";
00089 }
00090
00091
00092 void ImportStep::activated(int iMsg)
00093 {
00094 QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), QLatin1String("STEP (*.stp *.step)"));
00095 if (!fn.isEmpty()) {
00096 openCommand("Part ImportSTEP Create");
00097 doCommand(Doc,"f = App.document().addObject(\"ImportStep\",\"ImportStep\")");
00098 doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toUtf8());
00099 commitCommand();
00100 updateActive();
00101 }
00102 }
00103
00104 bool ImportStep::isActive(void)
00105 {
00106 if (getActiveGuiDocument())
00107 return true;
00108 else
00109 return false;
00110 }
00111
00112
00113
00114
00115
00116 DEF_STD_CMD_A(ImportIges);
00117
00118 ImportIges::ImportIges()
00119 : Command("Import_Iges")
00120 {
00121 sAppModule = "Import";
00122 sGroup = "Part";
00123 sMenuText = "Import IGES";
00124 sToolTipText = "Create or change a Import IGES feature";
00125 sWhatsThis = sToolTipText;
00126 sStatusTip = sToolTipText;
00127 sPixmap = "Save";
00128 }
00129
00130 void ImportIges::activated(int iMsg)
00131 {
00132 QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), QLatin1String("IGES (*.igs *.iges)"));
00133 if (!fn.isEmpty()) {
00134 openCommand("ImportIGES Create");
00135 doCommand(Doc,"f = App.document().addObject(\"ImportIges\",\"ImportIges\")");
00136 doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toUtf8());
00137 commitCommand();
00138 updateActive();
00139 }
00140 }
00141
00142 bool ImportIges::isActive(void)
00143 {
00144 if (getActiveGuiDocument())
00145 return true;
00146 else
00147 return false;
00148 }
00149
00150
00151 void CreateImportCommands(void)
00152 {
00153 Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
00154 rcCmdMgr.addCommand(new FCCmdImportReadBREP());
00155 }
00156
00157
00158