+ fix overflow problem with string buffer in fuse and common command
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5391 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
776a083dce
commit
325d832010
|
@ -424,6 +424,16 @@ void Command::doCommand(DoCmd_Type eType,const char* sCmd,...)
|
|||
free (format);
|
||||
}
|
||||
|
||||
/// Run a App level Action
|
||||
void Command::runCommand(DoCmd_Type eType,const char* sCmd)
|
||||
{
|
||||
if (eType == Gui)
|
||||
Gui::Application::Instance->macroManager()->addLine(MacroManager::Gui,sCmd);
|
||||
else
|
||||
Gui::Application::Instance->macroManager()->addLine(MacroManager::Base,sCmd);
|
||||
Base::Interpreter().runString(sCmd);
|
||||
}
|
||||
|
||||
void Command::copyVisual(const char* to, const char* attr, const char* from)
|
||||
{
|
||||
doCommand(Gui,"Gui.ActiveDocument.%s.%s=Gui.ActiveDocument.%s.%s", to, attr, from, attr);
|
||||
|
|
|
@ -234,6 +234,7 @@ public:
|
|||
static void blockCommand(bool);
|
||||
/// Run a App level Action
|
||||
static void doCommand(DoCmd_Type eType,const char* sCmd,...);
|
||||
static void runCommand(DoCmd_Type eType,const char* sCmd);
|
||||
static void copyVisual(const char* to, const char* attr, const char* from);
|
||||
static void copyVisual(const char* to, const char* attr_to, const char* from, const char* attr_from);
|
||||
/// import an external module only once
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
# include <QString>
|
||||
# include <QDir>
|
||||
# include <QFileInfo>
|
||||
|
@ -295,17 +296,18 @@ void CmdPartCommon::activated(int iMsg)
|
|||
std::string FeatName = getUniqueObjectName("Common");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::string ObjectBuf;
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Shapes = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
ObjectBuf += std::string("App.activeDocument().") + it->FeatName + ",";
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
}
|
||||
ObjectBuf.erase(--ObjectBuf.end());
|
||||
str << "]";
|
||||
|
||||
openCommand("Common");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"Part::MultiCommon\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Shapes = [%s]",FeatName.c_str(),ObjectBuf.c_str());
|
||||
runCommand(Doc,str.str().c_str());
|
||||
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
|
||||
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", tempSelNames.front().c_str());
|
||||
|
@ -348,17 +350,18 @@ void CmdPartFuse::activated(int iMsg)
|
|||
std::string FeatName = getUniqueObjectName("Fusion");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::string ObjectBuf;
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Shapes = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
ObjectBuf += std::string("App.activeDocument().") + it->FeatName + ",";
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
}
|
||||
ObjectBuf.erase(--ObjectBuf.end());
|
||||
str << "]";
|
||||
|
||||
openCommand("Fusion");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"Part::MultiFuse\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Shapes = [%s]",FeatName.c_str(),ObjectBuf.c_str());
|
||||
runCommand(Doc,str.str().c_str());
|
||||
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
|
||||
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", tempSelNames.front().c_str());
|
||||
|
|
Loading…
Reference in New Issue
Block a user