Skip to content

Commit

Permalink
Revert "clean the git"
Browse files Browse the repository at this point in the history
This reverts commit 7fabd38.
  • Loading branch information
blenderlounge committed May 7, 2016
1 parent 7fabd38 commit 169478e
Show file tree
Hide file tree
Showing 6 changed files with 1,279 additions and 0 deletions.
72 changes: 72 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'''
Copyright (C) 2015 Pistiwique
Created by Pistiwique
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''

bl_info = {
"name": "Viewport info",
"description": "Display selected info in the viewport",
"author": "Pistiwique",
"version": (0, 0, 8),
"blender": (2, 75, 0),
"location": "View3D",
"warning": "This addon is still in development.",
"wiki_url": "",
"category": "Object" }


# load and reload submodules
##################################

import sys
sys.modules["viewport_info"] = sys.modules[__name__]

from . import developer_utils
modules = developer_utils.setup_addon_modules(__path__, __name__)

# properties
##################################

import bpy

# register
##################################

import traceback

from . properties import viewportInfoCollectionGroup
from . draw import *

def register():
try: bpy.utils.register_module(__name__)
except: traceback.print_exc()
register_pcoll()
bpy.types.WindowManager.show_text = bpy.props.PointerProperty(type = viewportInfoCollectionGroup)
bpy.types.VIEW3D_PT_view3d_shading.append(displayViewportInfoPanel)

print("Registered {} with {} modules".format(bl_info["name"], len(modules)))

def unregister():
unregister_pcoll()
bpy.types.VIEW3D_PT_view3d_shading.remove(displayViewportInfoPanel)

del bpy.types.WindowManager.show_text
try: bpy.utils.unregister_module(__name__)
except: traceback.print_exc()

print("Unregistered {}".format(bl_info["name"]))

41 changes: 41 additions & 0 deletions developer_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import sys
import pkgutil
import importlib

reload_event = False

def setup_addon_modules(path, package_name):
"""
Imports and reloads all modules in this addon.
path -- __path__ from __init__.py
package_name -- __name__ from __init__.py
"""
def get_submodule_names(path = path[0], root = ""):
module_names = []
for importer, module_name, is_package in pkgutil.iter_modules([path]):
if is_package:
sub_path = path + "\\" + module_name
sub_root = root + module_name + "."
module_names.extend(get_submodule_names(sub_path, sub_root))
else:
module_names.append(root + module_name)
return module_names

def import_submodules(names):
modules = []
for name in names:
modules.append(importlib.import_module("." + name, package_name))
return modules

def reload_modules(modules):
for module in modules:
importlib.reload(module)

names = get_submodule_names()
modules = import_submodules(names)
if reload_event:
reload_modules(modules)
return modules

reload_event = True
219 changes: 219 additions & 0 deletions draw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
import bpy
import os
from . properties import *
from . operator import *
import bpy.utils.previews

operator_behaviours = ['triangle', 'ngon']
preview_collections = {}

def displayViewportInfoPanel(self, context):
layout = self.layout
show_text = context.window_manager.show_text
pcoll = preview_collections["nav_main"]

row = layout.row(align=True)
if show_text.vp_info_enabled:
row.operator('view3d.adh_display_text', text="Viewport info", icon='RESTRICT_VIEW_OFF' )
else:
row.operator('view3d.adh_display_text', text="Viewport info", icon='RESTRICT_VIEW_ON')
if show_text.vp_info_display_panel:
icon='TRIA_UP'
else:
icon='SCRIPTWIN'
row.prop(show_text, "vp_info_display_panel", icon=icon)
row = layout.row(align=True)
if show_text.display_color_enabled:
row.operator("object.remove_materials", text="Hidde color", icon='RESTRICT_VIEW_OFF')
else:
row.operator("object.add_materials", text="Display color", icon='COLOR')
row.separator()
icon = pcoll[operator_behaviours[0]]
row.operator("data.triangles_select", text="", icon_value=icon.icon_id)
icon = pcoll[operator_behaviours[1]]
row.operator("data.ngons_select", text="", icon_value=icon.icon_id)

if show_text.vp_info_display_panel:

# Edit mode
split = layout.split(percentage=0.1)
split.separator()
split2 = split.split()
row = split2.row(align=True)
row.prop(show_text, "edt_use", text="Edit", icon='EDITMODE_HLT')
if show_text.edt_options:
icon='TRIA_UP'
else:
icon='SCRIPTWIN'
row.prop(show_text, "edt_options", icon=icon)
if show_text.edt_options:
box = layout.box()
row = box.row(align=True)
row.prop(show_text, "faces_count_edt")
row.prop(show_text, "tris_count_edt")
row = box.row(align=True)
row.prop(show_text, "ngons_count_edt")
row.prop(show_text, "verts_count_edt")
row = box.row()
row.prop(show_text, "edt_corner", expand=True)
row = box.row(align=True)
row.prop(show_text, "edt_pos_x")
row.prop(show_text, "edt_pos_y")


# Object mode
split = layout.split(percentage=0.1)
split.separator()
split2 = split.split()
row = split2.row(align=True)
row.prop(show_text, "obj_use", text="Object", icon='OBJECT_DATAMODE')
if show_text.obj_options:
icon='TRIA_UP'
else:
icon='SCRIPTWIN'
row.prop(show_text, "obj_options", icon=icon)
if show_text.obj_options:
box = layout.box()
row = box.row(align=True)
row.prop(show_text, "faces_count_obj")
row.prop(show_text, "tris_count_obj")
row = box.row(align=True)
row.prop(show_text, "ngons_count_obj")
row.prop(show_text, "verts_count_obj")
if len(bpy.context.selected_objects) >= 2:
row = box.row()
row.prop(show_text, "multi_obj_enabled")
row = box.row()
row.prop(show_text, "obj_corner", expand=True)
row = box.row(align=True)
row.prop(show_text, "obj_pos_x")
row.prop(show_text, "obj_pos_y")


# Sculpt mode
split = layout.split(percentage=0.1)
split.separator()
split2 = split.split()
row = split2.row(align=True)
row.prop(show_text, "sculpt_use", text="Sculpt", icon='SCULPTMODE_HLT')
if show_text.sculpt_options:
icon='TRIA_UP'
else:
icon='SCRIPTWIN'
row.prop(show_text, "sculpt_options", icon=icon)
if show_text.sculpt_options:
box = layout.box()
row = box.row(align=True)
row.prop(show_text, "brush_radius")
row.prop(show_text, "brush_strength")
row = box.row()
row.prop(show_text, "symmetry_use")
row = box.row()
box.label("Dyntopo fonctions:")
row = box.row(align=True)
row.prop(show_text, "refine_method")
row.prop(show_text, "detail_type")
row = box.row()
row.prop(show_text, "sculpt_corner", expand=True)
row = box.row(align=True)
row.prop(show_text, "sculpt_pos_x")
row.prop(show_text, "sculpt_pos_y")


# Render
split = layout.split(percentage=0.1)
split.separator()
split2 = split.split()
row = split2.row(align=True)
row.prop(show_text, "rder_use", text="Render", icon='CAMERA_DATA')
if show_text.rder_options:
icon='TRIA_UP'
else:
icon='SCRIPTWIN'
row.prop(show_text, "rder_options", icon=icon)
if show_text.rder_options:
box = layout.box()
row = box.row(align=True)
row.prop(show_text, "rder_reso")
row.prop(show_text, "rder_f_range")
row = box.row(align=True)
row.prop(show_text, "rder_f_rate")
row.prop(show_text, "rder_sample")
row = box.row()
row.prop(show_text, "rder_corner", expand=True)
row = box.row(align=True)
row.prop(show_text, "rder_pos_x")
row.prop(show_text, "rder_pos_y")


# Scene
split = layout.split(percentage=0.1)
split.separator()
split2 = split.split()
row = split2.row(align=True)
row.prop(show_text, "scn_use", text="Scene", icon='SCENE_DATA')
if show_text.scn_options:
icon='TRIA_UP'
else:
icon='SCRIPTWIN'
row.prop(show_text, "scn_options", icon=icon)
if show_text.scn_options:
box = layout.box()
row = box.row(align=True)
row.prop(show_text, "obj_count")
row.prop(show_text, "cam_dist")
row = box.row(align=True)
row.prop(show_text, "current_frame")
row.prop(show_text, "cam_focal")
row = box.row()
row.prop(show_text, "scn_corner", expand=True)
row = box.row(align=True)
row.prop(show_text, "scn_pos_x")
row.prop(show_text, "scn_pos_y")


# Text options
split = layout.split(percentage=0.1)
split.separator()
split2 = split.split()
if show_text.options_use:
icon='TRIA_UP'
else:
icon='SCRIPTWIN'
split2.prop(show_text, "options_use", text="Options", icon=icon)
if show_text.options_use:
box = layout.box()
row = box.row()
row.prop(show_text, "text_font_size")
row = box.row()
row.prop(show_text, "name_color")
row = box.row()
row.prop(show_text, "label_color")
row = box.row()
row.prop(show_text, "value_color")


def register_pcoll():
import bpy.utils.previews
pcoll = bpy.utils.previews.new()

icons_dir = os.path.join(os.path.dirname(__file__), "icons")

for img in operator_behaviours:
full_img_name = (img + ".png")
img_path = os.path.join(icons_dir, full_img_name)
pcoll.load(img, img_path, 'IMAGE')

preview_collections["nav_main"] = pcoll


def unregisterpcoll():

for pcoll in preview_collections.values():
bpy.utils.previews.remove(pcoll)
preview_collections.clear()





Loading

0 comments on commit 169478e

Please sign in to comment.