Skip to content

Commit

Permalink
Just PEP8 formatting applied to code
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmrqs committed Sep 21, 2021
1 parent 7fd6ff7 commit 3860c06
Show file tree
Hide file tree
Showing 17 changed files with 1,845 additions and 1,760 deletions.
66 changes: 37 additions & 29 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,35 @@
'''
Reference Cameras add-on
'''
#--- ### Header
bl_info = {
"name": "Reference Cameras Control Panel",
"description": "Handles cameras associated with reference photos",
"author": "Marcelo M. Marques (fork of Witold Jaworski's & Jayanam's projects)",
"version": (1, 0, 1),
"blender": (2, 80, 75),
"location": "View3D > side panel ([N]), [Cameras] tab",
"support": "COMMUNITY",
"category": "3D View",
"warning": "Version numbering diverges from Witold's original project",
"doc_url": "http://airplanes3d.net/scripts-257_e.xml",
"tracker_url": "https://github.com/mmmrqs/Blender-Reference-Camera-Panel-addon/issues"
}

#--- ### Change log

#v1.0.1 (09.12.2021) - by Marcelo M. Marques
#Chang: updated version with fixes
#v1.0.0 (09.01.2021) - by Marcelo M. Marques
#Added: initial creation

#--- ### Imports
# --- ### Header
bl_info = {"name": "Reference Cameras Control Panel",
"description": "Handles cameras associated with reference photos",
"author": "Marcelo M. Marques (fork of Witold Jaworski's & Jayanam's projects)",
"version": (1, 0, 2),
"blender": (2, 80, 75),
"location": "View3D > side panel ([N]), [Cameras] tab",
"support": "COMMUNITY",
"category": "3D View",
"warning": "Version numbering diverges from Witold's original project",
"doc_url": "http://airplanes3d.net/scripts-257_e.xml",
"tracker_url": "https://github.com/mmmrqs/Blender-Reference-Camera-Panel-addon/issues"
}

# --- ### Change log

# Note: Because the way Blender's Preferences window displays the Addon version number,
# I am forced to keep this file in sync with the greatest version number of all modules.

# v1.0.2 (09.20.2021) - by Marcelo M. Marques
# Chang: just some pep8 code formatting

# v1.0.1 (09.12.2021) - by Marcelo M. Marques
# Chang: updated version with fixes

# v1.0.0 (09.01.2021) - by Marcelo M. Marques
# Added: initial creation

# --- ### Imports
import bpy
import sys
import importlib
Expand All @@ -50,8 +56,7 @@

modulesFullNames = {}

modulesNames = [
'prefs',
modulesNames = ['prefs',
'bl_ui_widgets.bl_ui_draw_op',
'bl_ui_widgets.bl_ui_widget',
'bl_ui_widgets.bl_ui_label',
Expand All @@ -64,7 +69,7 @@
'bl_ui_widgets.bl_ui_drag_panel',
'addon.drag_panel_op',
'addon.reference_cameras',
]
]

for currentModuleName in modulesNames:
if 'DEBUG_MODE' in sys.argv:
Expand All @@ -83,25 +88,28 @@
print(timestr, __name__ + ": registered")
print()
sys.argv.remove('DEBUG_MODE')

for currentModuleFullName in modulesFullNames.values():
if currentModuleFullName in sys.modules:
importlib.reload(sys.modules[currentModuleFullName])
else:
globals()[currentModuleFullName] = importlib.import_module(currentModuleFullName)
setattr(globals()[currentModuleFullName], 'modulesNames', modulesFullNames)



def register():
for currentModuleName in modulesFullNames.values():
if currentModuleName in sys.modules:
if hasattr(sys.modules[currentModuleName], 'register'):
sys.modules[currentModuleName].register()


def unregister():
for currentModuleName in modulesFullNames.values():
if currentModuleName in sys.modules:
if hasattr(sys.modules[currentModuleName], 'unregister'):
sys.modules[currentModuleName].unregister()



if __name__ == "__main__":
register()
Binary file modified __init__backups/bl_ui_widgets_demo.zip
Binary file not shown.
Binary file modified __init__backups/reference_cameras.zip
Binary file not shown.
115 changes: 62 additions & 53 deletions addon/bl_ui_widget_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,34 @@
#
# ##### END GPL LICENSE BLOCK #####

#--- ### Header
bl_info = {
"name": "BL UI Widgets",
"description": "UI Widgets to draw in the 3D view",
"author": "Marcelo M. Marques",
"version": (1, 0, 0),
"blender": (2, 80, 75),
"location": "View3D > side panel ([N]), [BL_UI_Widget] tab",
"support": "COMMUNITY",
"category": "3D View",
"warning": "",
"doc_url": "https://github.com/mmmrqs/bl_ui_widgets",
"tracker_url": "https://github.com/mmmrqs/bl_ui_widgets/issues"
}

#--- ### Change log

#v1.0.0 (09.01.2021) - by Marcelo M. Marques
#Added: initial creation

#--- ### Imports
# --- ### Header
bl_info = {"name": "BL UI Widgets",
"description": "UI Widgets to draw in the 3D view",
"author": "Marcelo M. Marques",
"version": (1, 0, 1),
"blender": (2, 80, 75),
"location": "View3D > side panel ([N]), [BL_UI_Widget] tab",
"support": "COMMUNITY",
"category": "3D View",
"warning": "",
"doc_url": "https://github.com/mmmrqs/bl_ui_widgets",
"tracker_url": "https://github.com/mmmrqs/bl_ui_widgets/issues"
}

# --- ### Change log

# v1.0.1 (09.20.2021) - by Marcelo M. Marques
# Chang: just some pep8 code formatting

# v1.0.0 (09.01.2021) - by Marcelo M. Marques
# Added: initial creation

# --- ### Imports
import bpy
from bpy.props import StringProperty, BoolProperty

#--- ### Properties

# --- ### Properties
class Variables(bpy.types.PropertyGroup):
OpState1: bpy.props.BoolProperty(default=False)
OpState2: bpy.props.BoolProperty(default=False)
Expand All @@ -51,61 +54,65 @@ class Variables(bpy.types.PropertyGroup):
RemoVisible: bpy.props.BoolProperty(default=False)
btnRemoText: bpy.props.StringProperty(default="Open Demo Panel")

def is_desired_mode(context = None):

def is_desired_mode(context=None):
""" Returns True, when Blender is in one of the desired Modes
Arguments:
@context (Context): current context (optional - as received by the operator)
Possible desired mode options (as of Blender 2.8):
'EDIT_MESH', 'EDIT_CURVE', 'EDIT_SURFACE', 'EDIT_TEXT', 'EDIT_ARMATURE', 'EDIT_METABALL',
'EDIT_LATTICE', 'POSE', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE', 'PARTICLE',
'OBJECT', 'PAINT_GPENCIL', 'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL',
Additional desired mode option (as of Blender 2.9):
'VERTEX_GPENCIL'
Possible desired mode options (as of Blender 2.8):
'EDIT_MESH', 'EDIT_CURVE', 'EDIT_SURFACE', 'EDIT_TEXT', 'EDIT_ARMATURE', 'EDIT_METABALL',
'EDIT_LATTICE', 'POSE', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE', 'PARTICLE',
'OBJECT', 'PAINT_GPENCIL', 'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL',
Additional desired mode option (as of Blender 2.9):
'VERTEX_GPENCIL'
"""
desired_modes = ['OBJECT','EDIT_MESH','POSE',]
desired_modes = ['OBJECT', 'EDIT_MESH', 'POSE', ]
if context:
return (context.mode in desired_modes)
else:
return (bpy.context.mode in desired_modes)


class Set_Demo_Panel(bpy.types.Operator):
''' Opens/Closes the remote control demo panel '''
bl_idname = "object.set_demo_panel"
bl_idname = "object.set_demo_panel"
bl_label = "Open Demo Panel"
bl_description = "Turns the remote control demo panel on/off"
#--- Blender interface methods

# --- Blender interface methods
@classmethod
def poll(cls,context):
def poll(cls, context):
return is_desired_mode(context)

def invoke(self, context, event):
#input validation:
# input validation:
return self.execute(context)
def execute(self,context):
if context.scene.var.RemoVisible == True:

def execute(self, context):
if context.scene.var.RemoVisible:
context.scene.var.btnRemoText = "Open Demo Panel"
else:
else:
context.scene.var.btnRemoText = "Close Demo Panel"
context.scene.var.objRemote = bpy.ops.object.dp_ot_draw_operator('INVOKE_DEFAULT')

context.scene.var.RemoVisible = not context.scene.var.RemoVisible
context.scene.var.RemoVisible = not context.scene.var.RemoVisible
return {'FINISHED'}



class OBJECT_PT_Demo(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "BL_UI_Widget"
bl_label = "BL_UI_Widget"

@classmethod
def poll(cls, context):
return is_desired_mode()

def draw(self, context):
if context.space_data.type == 'VIEW_3D' and is_desired_mode():
#-- remote control switch button
if context.space_data.type == 'VIEW_3D' and is_desired_mode():
# -- remote control switch button
op = self.layout.operator(Set_Demo_Panel.bl_idname, text=context.scene.var.btnRemoText)
return None

Expand All @@ -114,21 +121,23 @@ def draw(self, context):
from bpy.utils import unregister_class, register_class

# List of classes in this add-on to be registered in Blender's API:
classes = [
Variables,
Set_Demo_Panel,
OBJECT_PT_Demo,
]
classes = [Variables,
Set_Demo_Panel,
OBJECT_PT_Demo,
]


def register():
for cls in classes:
register_class(cls)
bpy.types.Scene.var = bpy.props.PointerProperty(type=Variables)


def unregister():
del bpy.types.Scene.var
for cls in reversed(classes):
unregister_class(cls)
unregister_class(cls)


if __name__ == '__main__':
register()
Loading

0 comments on commit 3860c06

Please sign in to comment.