Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code

This commit is contained in:
wmayer 2014-08-07 19:47:11 +02:00
commit 09b8b25144
8 changed files with 18 additions and 90 deletions

View File

@ -98,6 +98,10 @@ Py::Object DocumentObjectPy::getViewObject(void) const
{
try {
Py::Module module(PyImport_ImportModule("FreeCADGui"),true);
if (!module.hasAttr("getDocument")) {
// in v0.14+, the GUI module can be loaded in console mode (but doesn't have all its document methods)
return Py::None();
}
Py::Callable method(module.getAttr("getDocument"));
Py::Tuple arg(1);
arg.setItem(0, Py::String(getDocumentObjectPtr()->getDocument()->getName()));

View File

@ -15,7 +15,6 @@ SET(Draft_SRCS
importSVG.py
importDWG.py
importAirfoilDAT.py
macros.py
Draft_rc.py
TestDraft.py
)

View File

@ -4439,32 +4439,6 @@ class _Array(_DraftObject):
obj.Angle = 360
obj.Axis = Vector(0,0,1)
def onChanged(self,obj,prop):
if prop == "ArrayType":
if obj.ViewObject:
if obj.ArrayType == "ortho":
obj.ViewObject.setEditorMode('Axis',2)
obj.ViewObject.setEditorMode('NumberPolar',2)
obj.ViewObject.setEditorMode('Center',2)
obj.ViewObject.setEditorMode('Angle',2)
obj.ViewObject.setEditorMode('NumberX',0)
obj.ViewObject.setEditorMode('NumberY',0)
obj.ViewObject.setEditorMode('NumberZ',0)
obj.ViewObject.setEditorMode('IntervalX',0)
obj.ViewObject.setEditorMode('IntervalY',0)
obj.ViewObject.setEditorMode('IntervalZ',0)
else:
obj.ViewObject.setEditorMode('Axis',0)
obj.ViewObject.setEditorMode('NumberPolar',0)
obj.ViewObject.setEditorMode('Center',0)
obj.ViewObject.setEditorMode('Angle',0)
obj.ViewObject.setEditorMode('NumberX',2)
obj.ViewObject.setEditorMode('NumberY',2)
obj.ViewObject.setEditorMode('NumberY',2)
obj.ViewObject.setEditorMode('IntervalX',2)
obj.ViewObject.setEditorMode('IntervalY',2)
obj.ViewObject.setEditorMode('IntervalZ',2)
def execute(self,obj):
import DraftGeomUtils
if obj.Base:
@ -4520,8 +4494,7 @@ class _Array(_DraftObject):
nshape.rotate(DraftVecUtils.tup(center), DraftVecUtils.tup(axis), currangle)
if axisvector:
if not DraftVecUtils.isNull(axisvector):
if i > 0:
nshape.translate(FreeCAD.Vector(axisvector).multiply(i))
nshape.translate(FreeCAD.Vector(axisvector).multiply(i+1))
base.append(nshape)
return Part.makeCompound(base)

View File

@ -3868,10 +3868,10 @@ class SelectGroup():
for ob in sel:
for child in ob.OutList:
FreeCADGui.Selection.addSelection(child)
for parent in ob.InList:
FreeCADGui.Selection.addSelection(parent)
for child in parent.OutList:
FreeCADGui.Selection.addSelection(child)
for parent in ob.InList:
FreeCADGui.Selection.addSelection(parent)
for child in parent.OutList:
FreeCADGui.Selection.addSelection(child)
class Shape2DView(Modifier):

View File

@ -95,7 +95,7 @@ class DraftWorkbench (Workbench):
# import Draft tools, icons and macros menu
try:
import os,macros,Draft_rc,DraftTools, DraftGui
import os,Draft_rc,DraftTools, DraftGui
from DraftTools import translate
FreeCADGui.addLanguagePath(":/translations")
FreeCADGui.addIconPath(":/icons")

View File

@ -1,54 +0,0 @@
#***************************************************************************
#* *
#* Copyright (c) 2009 Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import os,FreeCAD,FreeCADGui
macrosList = []
macroPath = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro").GetString("MacroPath")
class MacroCommand():
"A template for macro commands"
def __init__(self,macroname):
self.macroname = macroname
def GetResources(self):
return {'Pixmap' : 'Draft_Macro',
'MenuText': self.macroname,
'ToolTip': 'Executes the '+self.macroname+' macro'}
def Activated(self):
target = macroPath+os.sep+self.macroname+'.FCMacro'
if os.path.exists(target): execfile(target)
if macroPath and os.path.isdir(macroPath):
macros = []
for f in os.listdir(macroPath):
if ".FCMacro" in f:
macros.append(f[:-8])
for m in macros:
cmd = 'Macro_'+m
FreeCADGui.addCommand(cmd,MacroCommand(m))
macrosList.append(cmd)

View File

@ -76,8 +76,12 @@ void FeaturePage::onChanged(const App::Property* prop)
if (!fi.exists())
return;
}
}
if (prop == &Template) {
} else if (prop == &EditableTexts) {
if (!this->isRestoring()) {
this->execute();
return;
}
} else if (prop == &Template) {
if (!this->isRestoring()) {
EditableTexts.setValues(getEditableTextsFromTemplate());
}

View File

@ -104,6 +104,7 @@ void CmdDrawingNewPage::activated(int iMsg)
openCommand("Drawing create page");
doCommand(Doc,"App.activeDocument().addObject('Drawing::FeaturePage','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Template = '%s'",FeatName.c_str(), (const char*)tfi.filePath().toUtf8());
doCommand(Doc,"App.activeDocument().recompute()");
commitCommand();
}
else {
@ -231,6 +232,7 @@ void CmdDrawingNewA3Landscape::activated(int iMsg)
openCommand("Drawing create page");
doCommand(Doc,"App.activeDocument().addObject('Drawing::FeaturePage','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Template = 'A3_Landscape.svg'",FeatName.c_str());
doCommand(Doc,"App.activeDocument().recompute()");
commitCommand();
}