Mod/Import/Gui/Command.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2002 Jürgen Riegel (juergen.riegel@web.de)              *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
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 // Import_Box
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 // PartImportStep
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 // ImportIges
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 

Generated on Wed Nov 23 19:00:01 2011 for FreeCAD by  doxygen 1.6.1