Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds initgui and workbench settings - Adds FeaturePython for TextureConfig
- Loading branch information
Showing
10 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
textures/** | ||
testfiles/** | ||
.vscode/** | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Empty for now. Nothing special to initialize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import FreeCAD, FreeCADGui | ||
|
||
class ArchTextureWorkbench (FreeCADGui.Workbench): | ||
"Texture Architectural objects in FreeCAD" | ||
|
||
MenuText = "Arch Texture" | ||
ToolTip = "Texture architectural objects" | ||
|
||
def __init__(self): | ||
from utils.resource_utils import iconPath | ||
# self.__class__.Icon = iconPath("Workbench.svg") | ||
|
||
|
||
def Initialize(self): | ||
# Initialize the module | ||
import toolbars | ||
|
||
for name,commands in toolbars.toolbarManager.Toolbars.items(): | ||
self.appendToolbar(name,[command.commandName for command in commands]) | ||
|
||
# def Activated(self): | ||
|
||
# def Deactivated(self): | ||
|
||
FreeCADGui.addWorkbench(ArchTextureWorkbench()) |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import FreeCAD | ||
import math | ||
from os import path | ||
from pivy import coin | ||
|
||
filePath = path.join(path.dirname(path.realpath(__file__)), 'textures') | ||
bricks = path.join(filePath, 'Bricks_Red.jpg') | ||
|
||
tex = coin.SoTexture2() | ||
tex.filename = bricks | ||
|
||
transform = coin.SoTexture2Transform() | ||
transform.rotation = math.radians(90) | ||
#transform.scaleFactor = [0.8889, 0.8889] | ||
|
||
print(bricks) | ||
|
||
def textureObjects(): | ||
for o in FreeCAD.ActiveDocument.Objects: | ||
if hasattr(o,'Shape'): | ||
if hasattr(o, 'IfcRole'): | ||
print 'got object %s' %(o) | ||
rootnode = o.ViewObject.RootNode | ||
rootnode.insertChild(transform, 1) | ||
rootnode.insertChild(tex, 1) | ||
|
||
|
||
if __name__ == "__main__": | ||
textureObjects() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import FreeCAD, FreeCADGui | ||
from pivy import coin | ||
|
||
class TextureConfig(): | ||
def __init__(self, obj): | ||
obj.Proxy = self | ||
# maybe add some properties later on | ||
# obj.addProperty("App::PropertyString","SomeProp","TextureConfig","Description").SomeProp=value | ||
|
||
def execute(self, fp): | ||
pass | ||
|
||
def __getstate__(self): | ||
'''Store the texture config inside the FreeCAD File''' | ||
return () | ||
|
||
def __setstate__(self, state): | ||
'''Load the texture config from the FreeCAD File''' | ||
pass | ||
|
||
class ViewProviderTextureConfig(): | ||
def __init__(self, vobj): | ||
vobj.Proxy = self | ||
|
||
def attach(self, vobj): | ||
self.ViewObject = vobj | ||
self.Object = vobj.Object | ||
self.TextureConfig = self.Object.Proxy | ||
|
||
self.coinNode = coin.SoGroup() | ||
vobj.addDisplayMode(self.coinNode, "Standard"); | ||
|
||
def getDisplayModes(self,obj): | ||
return ["Standard"] | ||
|
||
def getDefaultDisplayMode(self): | ||
return "Standard" | ||
|
||
def updateData(self, fp, prop): | ||
pass | ||
|
||
def onChanged(self, vp, prop): | ||
pass | ||
|
||
def createTextureConfig(): | ||
textureConfigObject = FreeCAD.ActiveDocument.addObject("App::FeaturePython", "TextureConfig") | ||
textureConfig = TextureConfig(textureConfigObject) | ||
ViewProviderTextureConfig(textureConfigObject.ViewObject) | ||
|
||
if __name__ == "__main__": | ||
createTextureConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from collections import OrderedDict | ||
import FreeCAD, FreeCADGui | ||
|
||
class ToolbarManager: | ||
Toolbars = OrderedDict() | ||
|
||
def registerCommand(self, command): | ||
FreeCADGui.addCommand(command.commandName, command) | ||
self.Toolbars.setdefault(command.toolbarName, []).append(command) | ||
|
||
toolbarManager = ToolbarManager() | ||
|
||
# import commands here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import FreeCAD | ||
from os import path | ||
|
||
resources_path = path.join(path.dirname(path.realpath(__file__)), '../Resources') | ||
icons_path = path.join(resources_path, 'Icons') | ||
ui_path = path.join(resources_path, 'UI') | ||
|
||
def iconPath(name): | ||
f = path.join(icons_path, name) | ||
|
||
return f | ||
|
||
def uiPath(name): | ||
f = path.join(ui_path, name) | ||
|
||
return f |