Merge branch 'master' of ssh://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
This commit is contained in:
commit
14a4cbd12b
|
@ -847,6 +847,31 @@ unsigned int Document::getMemSize (void) const
|
|||
return size;
|
||||
}
|
||||
|
||||
void Document::exportGraphviz(std::ostream& out)
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
names.reserve(d->objectMap.size());
|
||||
DependencyList DepList;
|
||||
std::map<DocumentObject*,Vertex> VertexObjectList;
|
||||
|
||||
// Filling up the adjacency List
|
||||
for (std::map<std::string,DocumentObject*>::const_iterator It = d->objectMap.begin(); It != d->objectMap.end();++It) {
|
||||
// add the object as Vertex and remember the index
|
||||
VertexObjectList[It->second] = add_vertex(DepList);
|
||||
names.push_back(It->second->Label.getValue());
|
||||
}
|
||||
// add the edges
|
||||
for (std::map<std::string,DocumentObject*>::const_iterator It = d->objectMap.begin(); It != d->objectMap.end();++It) {
|
||||
std::vector<DocumentObject*> OutList = It->second->getOutList();
|
||||
for (std::vector<DocumentObject*>::const_iterator It2=OutList.begin();It2!=OutList.end();++It2) {
|
||||
if (*It2)
|
||||
add_edge(VertexObjectList[It->second],VertexObjectList[*It2],DepList);
|
||||
}
|
||||
}
|
||||
|
||||
boost::write_graphviz(out, DepList, boost::make_label_writer(&(names[0])));
|
||||
}
|
||||
|
||||
// Save the document under the name it has been opened
|
||||
bool Document::save (void)
|
||||
{
|
||||
|
|
|
@ -114,6 +114,7 @@ public:
|
|||
/// Restore the document from the file in Property Path
|
||||
void restore (void);
|
||||
void exportObjects(const std::vector<App::DocumentObject*>&, std::ostream&);
|
||||
void exportGraphviz(std::ostream&);
|
||||
std::vector<App::DocumentObject*> importObjects(std::istream&);
|
||||
/// Opens the document from its file name
|
||||
//void open (void);
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
<UserDocu>Restore the document from disc</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="exportGraphviz">
|
||||
<Documentation>
|
||||
<UserDocu>Export the dependencies of the objects as graph</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="openTransaction">
|
||||
<Documentation>
|
||||
<UserDocu>Open a new Undo/Redo transaction.</UserDocu>
|
||||
|
|
|
@ -92,6 +92,25 @@ PyObject* DocumentPy::restore(PyObject * args)
|
|||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* DocumentPy::exportGraphviz(PyObject * args)
|
||||
{
|
||||
char* fn=0;
|
||||
if (!PyArg_ParseTuple(args, "|s",&fn)) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
if (fn) {
|
||||
Base::FileInfo fi(fn);
|
||||
Base::ofstream str(fi);
|
||||
getDocumentPtr()->exportGraphviz(str);
|
||||
str.close();
|
||||
Py_Return;
|
||||
}
|
||||
else {
|
||||
std::stringstream str;
|
||||
getDocumentPtr()->exportGraphviz(str);
|
||||
return PyString_FromString(str.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* DocumentPy::addObject(PyObject *args)
|
||||
{
|
||||
char *sType,*sName=0;
|
||||
|
|
|
@ -24,12 +24,16 @@
|
|||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QClipboard>
|
||||
# include <QEventLoop>
|
||||
# include <QStatusBar>
|
||||
# include <QPointer>
|
||||
# include <QProcess>
|
||||
# include <sstream>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/Sequencer.h>
|
||||
#include <App/Document.h>
|
||||
|
@ -311,6 +315,77 @@ bool StdCmdMergeProjects::isActive(void)
|
|||
return this->hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Std_ExportGraphviz
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(StdCmdExportGraphviz);
|
||||
|
||||
StdCmdExportGraphviz::StdCmdExportGraphviz()
|
||||
: Command("Std_ExportGraphviz")
|
||||
{
|
||||
// seting the
|
||||
sGroup = QT_TR_NOOP("Tools");
|
||||
sMenuText = QT_TR_NOOP("Dependency graph...");
|
||||
sToolTipText = QT_TR_NOOP("Show the dependency graph of the objects in the active document");
|
||||
sStatusTip = QT_TR_NOOP("Show the dependency graph of the objects in the active document");
|
||||
sWhatsThis = "Std_ExportGraphviz";
|
||||
eType = 0;
|
||||
}
|
||||
|
||||
void StdCmdExportGraphviz::activated(int iMsg)
|
||||
{
|
||||
App::Document* doc = App::GetApplication().getActiveDocument();
|
||||
Base::FileInfo fi(Base::FileInfo::getTempFileName());
|
||||
Base::ofstream str(fi);
|
||||
doc->exportGraphviz(str);
|
||||
str.close();
|
||||
|
||||
Base::FileInfo out(Base::FileInfo::getTempFileName());
|
||||
QProcess proc;
|
||||
QEventLoop loop;
|
||||
QObject::connect(&proc, SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
&loop, SLOT(quit()));
|
||||
QStringList args;
|
||||
args << QLatin1String("-Tpng") << QString::fromUtf8(fi.filePath().c_str())
|
||||
<< QLatin1String("-o") << QString::fromUtf8(out.filePath().c_str());
|
||||
QString exe = QLatin1String("dot");
|
||||
QStringList env = QProcess::systemEnvironment();
|
||||
proc.setEnvironment(env);
|
||||
proc.start(exe, args);
|
||||
if (proc.state() == QProcess::Running) {
|
||||
loop.exec();
|
||||
fi.deleteFile();
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(getMainWindow(),
|
||||
qApp->translate("Std_ExportGraphviz","Graphviz not found"),
|
||||
qApp->translate("Std_ExportGraphviz","Graphviz couldn't be found on your system"));
|
||||
fi.deleteFile();
|
||||
return;
|
||||
}
|
||||
|
||||
if (out.exists()) {
|
||||
QPixmap px(QString::fromUtf8(out.filePath().c_str()), "PNG");
|
||||
out.deleteFile();
|
||||
QLabel* label = new QLabel(0);
|
||||
label->setAttribute(Qt::WA_DeleteOnClose);
|
||||
label->setPixmap(px);
|
||||
label->resize(px.size());
|
||||
label->show();
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(getMainWindow(),
|
||||
qApp->translate("Std_ExportGraphviz","Graphviz failed"),
|
||||
qApp->translate("Std_ExportGraphviz","Graphviz failed to create an image file"));
|
||||
}
|
||||
}
|
||||
|
||||
bool StdCmdExportGraphviz::isActive(void)
|
||||
{
|
||||
return (getActiveGuiDocument() ? true : false);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Std_New
|
||||
//===========================================================================
|
||||
|
@ -1126,6 +1201,7 @@ void CreateDocCommands(void)
|
|||
rcCmdMgr.addCommand(new StdCmdImport());
|
||||
rcCmdMgr.addCommand(new StdCmdExport());
|
||||
rcCmdMgr.addCommand(new StdCmdMergeProjects());
|
||||
rcCmdMgr.addCommand(new StdCmdExportGraphviz());
|
||||
|
||||
rcCmdMgr.addCommand(new StdCmdSave());
|
||||
rcCmdMgr.addCommand(new StdCmdSaveAs());
|
||||
|
|
|
@ -490,8 +490,9 @@ MenuItem* StdWorkbench::setupMenuBar() const
|
|||
MenuItem* tool = new MenuItem( menuBar );
|
||||
tool->setCommand("&Tools");
|
||||
*tool << "Std_DlgParameter" << "Separator"
|
||||
<< "Std_ViewScreenShot" << "Std_SceneInspector" << "Std_DemoMode"
|
||||
<< "Separator" << "Std_DlgCustomize";
|
||||
<< "Std_ViewScreenShot" << "Std_SceneInspector"
|
||||
<< "Std_ExportGraphviz" << "Std_ProjectUtil"
|
||||
<< "Std_DemoMode" << "Separator" << "Std_DlgCustomize";
|
||||
|
||||
// Macro
|
||||
MenuItem* macro = new MenuItem( menuBar );
|
||||
|
|
|
@ -183,7 +183,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
<< "Std_DlgMacroRecord" << "Std_MacroStopRecord"
|
||||
<< "Std_DlgMacroExecute" << "Std_DlgMacroExecuteDirect"
|
||||
<< "Separator" << "Std_ViewScreenShot" << "Std_SceneInspector"
|
||||
<< "Std_ProjectUtil" << "Std_DemoMode" << "Separator" << "Std_DlgCustomize";
|
||||
<< "Std_ExportGraphviz" << "Std_ProjectUtil"
|
||||
<< "Std_DemoMode" << "Separator" << "Std_DlgCustomize";
|
||||
|
||||
// Mesh ****************************************************************************************************
|
||||
Gui::MenuItem* mesh = new Gui::MenuItem( menuBar );
|
||||
|
|
|
@ -468,6 +468,8 @@ class PlaneTracker(Tracker):
|
|||
p1 = Draft.get3DView().getPoint((100,100))
|
||||
p2 = Draft.get3DView().getPoint((110,100))
|
||||
bl = (p2.sub(p1)).Length * (Draft.getParam("snapRange")/2)
|
||||
pick = coin.SoPickStyle()
|
||||
pick.style.setValue(coin.SoPickStyle.UNPICKABLE)
|
||||
self.trans = coin.SoTransform()
|
||||
self.trans.translation.setValue([0,0,0])
|
||||
m1 = coin.SoMaterial()
|
||||
|
@ -486,6 +488,7 @@ class PlaneTracker(Tracker):
|
|||
l = coin.SoLineSet()
|
||||
l.numVertices.setValues([3,3,3])
|
||||
s = coin.SoSeparator()
|
||||
s.addChild(pick)
|
||||
s.addChild(self.trans)
|
||||
s.addChild(m1)
|
||||
s.addChild(c1)
|
||||
|
@ -542,6 +545,9 @@ class gridTracker(Tracker):
|
|||
self.mainlines = Draft.getParam("gridEvery")
|
||||
self.numlines = 100
|
||||
col = [0.2,0.2,0.3]
|
||||
|
||||
pick = coin.SoPickStyle()
|
||||
pick.style.setValue(coin.SoPickStyle.UNPICKABLE)
|
||||
|
||||
self.trans = coin.SoTransform()
|
||||
self.trans.translation.setValue([0,0,0])
|
||||
|
@ -595,6 +601,7 @@ class gridTracker(Tracker):
|
|||
lines3 = coin.SoLineSet()
|
||||
lines3.numVertices.setValues(aidx)
|
||||
s = coin.SoSeparator()
|
||||
s.addChild(pick)
|
||||
s.addChild(self.trans)
|
||||
s.addChild(mat1)
|
||||
s.addChild(self.coords1)
|
||||
|
|
|
@ -948,7 +948,7 @@ CmdPartLoft::CmdPartLoft()
|
|||
sAppModule = "Part";
|
||||
sGroup = QT_TR_NOOP("Part");
|
||||
sMenuText = QT_TR_NOOP("Loft...");
|
||||
sToolTipText = QT_TR_NOOP("Advanced utility to lofts");
|
||||
sToolTipText = QT_TR_NOOP("Utility to loft");
|
||||
sWhatsThis = sToolTipText;
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Part_Loft";
|
||||
|
@ -974,7 +974,7 @@ CmdPartSweep::CmdPartSweep()
|
|||
sAppModule = "Part";
|
||||
sGroup = QT_TR_NOOP("Part");
|
||||
sMenuText = QT_TR_NOOP("Sweep...");
|
||||
sToolTipText = QT_TR_NOOP("Advanced utility to sweep");
|
||||
sToolTipText = QT_TR_NOOP("Utility to sweep");
|
||||
sWhatsThis = sToolTipText;
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Part_Sweep";
|
||||
|
|
|
@ -67,18 +67,12 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
root->insertItem(item, part);
|
||||
part->setCommand("&Part");
|
||||
*part << "Part_Import" << "Part_Export" << "Separator";
|
||||
*part << prim << "Part_Primitives" << "Separator" << "Part_ShapeFromMesh"
|
||||
<< "Part_MakeSolid" << "Part_ReverseShape" << "Part_SimpleCopy"
|
||||
<< "Part_RefineShape" << "Separator"
|
||||
*part << prim << "Part_Primitives" << "Part_Builder" << "Separator"
|
||||
<< "Part_ShapeFromMesh" << "Part_MakeSolid" << "Part_ReverseShape"
|
||||
<< "Part_SimpleCopy" << "Part_RefineShape" << "Separator"
|
||||
<< "Part_Boolean" << "Part_CrossSections" << "Part_Extrude"
|
||||
<< "Part_Revolve" << "Part_Mirror" << "Part_Fillet" << "Part_Chamfer"
|
||||
<< "Part_RuledSurface" << "Part_Loft" << "Part_Sweep"
|
||||
<< "Part_Builder";
|
||||
|
||||
//Gui::MenuItem* partSimple = new Gui::MenuItem;
|
||||
//root->insertItem(item, partSimple);
|
||||
//partSimple->setCommand("&Simple");
|
||||
//*partSimple << "Part_SimpleCylinder";
|
||||
<< "Part_RuledSurface" << "Part_Loft" << "Part_Sweep";
|
||||
|
||||
return root;
|
||||
}
|
||||
|
@ -89,15 +83,18 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
|
||||
Gui::ToolBarItem* solids = new Gui::ToolBarItem(root);
|
||||
solids->setCommand("Solids");
|
||||
*solids << "Part_Box" << "Part_Cylinder" << "Part_Sphere" << "Part_Cone" << "Part_Torus" << "Part_Primitives";
|
||||
*solids << "Part_Box" << "Part_Cylinder" << "Part_Sphere" << "Part_Cone"
|
||||
<< "Part_Torus" << "Part_Primitives" << "Part_Builder";
|
||||
|
||||
Gui::ToolBarItem* tool = new Gui::ToolBarItem(root);
|
||||
tool->setCommand("Part tools");
|
||||
*tool << "Part_Extrude" << "Part_Revolve" << "Part_Mirror" << "Part_Fillet" << "Part_Chamfer" << "Part_RuledSurface";
|
||||
*tool << "Part_Extrude" << "Part_Revolve" << "Part_Mirror" << "Part_Fillet"
|
||||
<< "Part_Chamfer" << "Part_RuledSurface" << "Part_Loft" << "Part_Sweep";
|
||||
|
||||
Gui::ToolBarItem* boolop = new Gui::ToolBarItem(root);
|
||||
boolop->setCommand("Boolean");
|
||||
*boolop << "Part_Boolean" << "Part_Cut" << "Part_Fuse" << "Part_Common" << "Part_Section";
|
||||
*boolop << "Part_Boolean" << "Part_Cut" << "Part_Fuse" << "Part_Common"
|
||||
<< "Part_Section" << "Part_CrossSections";
|
||||
|
||||
return root;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user