def invoke(self, context, event): # if abort is requested just cancel operator if self.abort: self.cancel(context) return {'FINISHED'} # reset messages array and shown state Show3DViewReport.__static_is_shown = True Show3DViewReport.__static_message_l.clear() # add blender tools version in the header Show3DViewReport.__static_message_l.append(_info_utils.get_combined_ver_str()) # split message by new lines for line in self.message.split("\n"): # adapt number of spaces by message type space_count = 22 if line.startswith("WARNING") else 18 # remove tabulator simulated new lines from warnings and errors, written like: "\n\t " line = line.replace("\t ", " " * space_count) # make sure to get rid of any other tabulators and change them for space eg: "INFO\t-" line = line.replace("\t", " ") Show3DViewReport.__static_message_l.append(line) # if report operator is already running don't add new modal handler if Show3DViewReport.__static_running_instances == 1: context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: return {'FINISHED'}
def invoke(self, context, event): # if abort is requested just cancel operator if self.abort: self.cancel(context) return {'FINISHED'} # reset messages array and shown state Show3DViewReport.__static_is_shown = True Show3DViewReport.__static_message_l.clear() # add blender tools version in the header Show3DViewReport.__static_message_l.append( _info_utils.get_combined_ver_str()) # split message by new lines for line in self.message.split("\n"): # adapt number of spaces by message type space_count = 22 if line.startswith("WARNING") else 18 # remove tabulator simulated new lines from warnings and errors, written like: "\n\t " line = line.replace("\t ", " " * space_count) # make sure to get rid of any other tabulators and change them for space eg: "INFO\t-" line = line.replace("\t", " ") Show3DViewReport.__static_message_l.append(line) # if report operator is already running don't add new modal handler if Show3DViewReport.__static_running_instances == 1: context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: return {'FINISHED'}
def invoke(self, context, event): # if abort is requested just cancel operator if self.abort: self.cancel(context) return {'FINISHED'} # reset messages array and shown state Show3DViewReport.__static_is_shown = True Show3DViewReport.__static_message_l.clear() # add blender tools version in the header Show3DViewReport.__static_message_l.append(_info_utils.get_combined_ver_str()) # split message by new lines for line in self.message.split("\n"): # remove tabulator simulated new lines from warnings and errors, written like: "\n\t " line = line.replace("\t ", " " * 4) # remove tabulator simulated empty space before warning or error line of summaries e.g "\t > " line = line.replace("\t ", "") Show3DViewReport.__static_message_l.append(line) # if report operator is already running don't add new modal handler if Show3DViewReport.__static_running_instances == 1: context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: return {'FINISHED'}
def __init__(self, format_version, name): """Constructs header of PIP prefab. :param format_version: version of PIP file format :type format_version: int :param name: name of the prefab :type name: str """ self.__format_version = format_version self.__source = get_combined_ver_str() self.__name = name
def fill_header_section(): """Fills up "Header" section.""" section = _SectionData("Header") section.props.append(("FormatVersion", 1)) section.props.append(("Source", get_combined_ver_str())) section.props.append(("Type", "Configuration")) section.props.append(("Note", "User settings of SCS Blender Tools")) author = bpy.context.user_preferences.system.author if author: section.props.append(("Author", str(author))) section.props.append(("DumpLevel", _property.get_default(bpy.types.GlobalSCSProps.dump_level))) return section
def fill_header_section(): """Fills up "Header" section.""" section = _SectionData("Header") section.props.append(("FormatVersion", 1)) section.props.append(("Source", get_combined_ver_str())) section.props.append(("Type", "Configuration")) section.props.append(("Note", "User settings of SCS Blender Tools")) author = bpy.context.user_preferences.system.author if author: section.props.append(("Author", str(author))) section.props.append(("DumpLevel", _property_utils.get_default(bpy.types.GlobalSCSProps.dump_level))) return section
def fill_header_section(format_version, file_name, sign_export): """Fills up "Header" section.""" section = _SectionData("Header") section.props.append(("FormatVersion", format_version)) section.props.append(("Source", get_combined_ver_str())) section.props.append(("Type", "Trait")) section.props.append(("Name", file_name)) if sign_export: section.props.append(("SourceFilename", str(bpy.data.filepath))) author = bpy.context.user_preferences.system.author if author: section.props.append(("Author", str(author))) return section
def _fill_header_section(file_name, sign_export): """Fills up "Header" section.""" section = _SectionData("Header") section.props.append(("FormatVersion", 1)) section.props.append(("Source", get_combined_ver_str())) section.props.append(("Type", "Trait")) section.props.append(("Name", file_name)) if sign_export: section.props.append(("SourceFilename", str(bpy.data.filepath))) author = bpy.context.user_preferences.system.author if author: section.props.append(("Author", str(author))) return section
def __init__(self, format_type, format_version, name): """Constructs header of PIM model. :param format_type: type of PIM file format (used only for Data Exchange Format) :type format_type: str :param format_version: version of PIM file format :type format_version: int :param name: name of the model :type name: str """ self._format_type = format_type self._format_version = format_version self._source = get_combined_ver_str() self._name = name
def _draw_3dview_report(region): """Draws reports in 3d views. :param region: region of 3D viewport :type region: bpy.types.Region """ pos = region.height - 62 if _Show3DViewReportOperator.has_lines(): glEnable(GL_TEXTURE_2D) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glBindTexture(GL_TEXTURE_2D, _Show3DViewReportOperator.get_scs_logo_img_bindcode()) # draw BT logo glBegin(GL_POLYGON) glColor3f(1, 1, 1) glTexCoord2f(0, 1) glVertex3f(_OP_consts.View3DReport.BT_LOGO_AREA[0], region.height - _OP_consts.View3DReport.BT_LOGO_AREA[2], 0) glTexCoord2f(1, 1) glVertex3f(_OP_consts.View3DReport.BT_LOGO_AREA[1], region.height - _OP_consts.View3DReport.BT_LOGO_AREA[2], 0) glTexCoord2f(1, 0) glVertex3f(_OP_consts.View3DReport.BT_LOGO_AREA[1], region.height - _OP_consts.View3DReport.BT_LOGO_AREA[3], 0) glTexCoord2f(0, 0) glVertex3f(_OP_consts.View3DReport.BT_LOGO_AREA[0], region.height - _OP_consts.View3DReport.BT_LOGO_AREA[3], 0) glEnd() glDisable(GL_TEXTURE_2D) # draw version string blf.size(0, 10, 72) glColor3f(.952, .635, .062) blf.position(0, 20, pos, 0) blf.draw(0, _info_utils.get_combined_ver_str(only_version_numbers=True)) pos -= 20 # draw actual operator title and message if shown if _Show3DViewReportOperator.is_shown(): blf.size(0, 12, 72) glColor3f(1, 1, 1) blf.shadow(0, 5, 0, 0, 0, 1) if _Show3DViewReportOperator.get_title() != "": blf.position(0, 20, pos, 0) blf.draw(0, _Show3DViewReportOperator.get_title()) pos -= 15 blf.enable(0, blf.SHADOW) for line in _Show3DViewReportOperator.get_lines(): # finish printing if running out of space if pos - 60 < 0: blf.position(0, 20, pos, 0) blf.draw(0, "...") break blf.position(0, 20, pos, 0) if "ERROR" in line: blf.shadow(0, 5, 0.5, 0., 0, 1) elif "WARNING" in line: blf.shadow(0, 5, 0.3, 0.15, 0, 1) blf.draw(0, line) pos -= 15 blf.disable(0, blf.SHADOW) # draw control buttons if controls are enabled if _Show3DViewReportOperator.has_controls(): # draw close button glColor3f(.4, .4, .4) glBegin(GL_POLYGON) glVertex3f(_OP_consts.View3DReport.CLOSE_BTN_AREA[0], region.height - _OP_consts.View3DReport.CLOSE_BTN_AREA[2], 0) glVertex3f(_OP_consts.View3DReport.CLOSE_BTN_AREA[1], region.height - _OP_consts.View3DReport.CLOSE_BTN_AREA[2], 0) glVertex3f(_OP_consts.View3DReport.CLOSE_BTN_AREA[1], region.height - _OP_consts.View3DReport.CLOSE_BTN_AREA[3], 0) glVertex3f(_OP_consts.View3DReport.CLOSE_BTN_AREA[0], region.height - _OP_consts.View3DReport.CLOSE_BTN_AREA[3], 0) glEnd() # draw hide button glBegin(GL_POLYGON) glVertex3f(_OP_consts.View3DReport.HIDE_BTN_AREA[0], region.height - _OP_consts.View3DReport.HIDE_BTN_AREA[2], 0) glVertex3f(_OP_consts.View3DReport.HIDE_BTN_AREA[1], region.height - _OP_consts.View3DReport.HIDE_BTN_AREA[2], 0) glVertex3f(_OP_consts.View3DReport.HIDE_BTN_AREA[1], region.height - _OP_consts.View3DReport.HIDE_BTN_AREA[3], 0) glVertex3f(_OP_consts.View3DReport.HIDE_BTN_AREA[0], region.height - _OP_consts.View3DReport.HIDE_BTN_AREA[3], 0) glEnd() # gather texts and positions close_btn_text_pos = _OP_consts.View3DReport.CLOSE_BTN_TEXT_POS[int(not _Show3DViewReportOperator.is_shown())] close_btn_text = _OP_consts.View3DReport.CLOSE_BTN_TEXT[int(not _Show3DViewReportOperator.is_shown())] hide_btn_text_pos = _OP_consts.View3DReport.HIDE_BTN_TEXT_POS[int(not _Show3DViewReportOperator.is_shown())] hide_btn_text = _OP_consts.View3DReport.HIDE_BTN_TEXT[int(not _Show3DViewReportOperator.is_shown())] blf.size(0, 15, 72) # draw close button text glColor3f(1, 1, 1) blf.position(0, close_btn_text_pos[0], region.height - close_btn_text_pos[1], 0) blf.draw(0, close_btn_text) # draw hide button text blf.position(0, hide_btn_text_pos[0], region.height - hide_btn_text_pos[1], 0) blf.draw(0, hide_btn_text)
def _draw_3dview_report(window, area, region): """Draws reports in 3d views. :param window: window of 3D viewport :type window: bpy.types.Window :param area: area of 3D viewport :type area: bpy.types.Area :param region: region of 3D viewport :type region: bpy.types.Region """ from io_scs_tools.operators.wm import SCS_TOOLS_OT_Show3DViewReport as _Show3DViewReport # no reported lines, we don't draw anything if not _Show3DViewReport.has_lines(): return # calculate dynamic left and top margins if bpy.context.preferences.system.use_region_overlap: pos_x = 75 # try to find tools region and properly adopt position X for reg in area.regions: if reg.type == 'TOOLS': pos_x = reg.width + 20 break pos_y = region.height - 105 else: pos_x = 20 pos_y = region.height - 80 # draw BT banner (bindcode, width, height) = _Show3DViewReport.get_scs_banner_img_data(window) bgl.glEnable(bgl.GL_BLEND) bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA) draw_texture_2d(bindcode, (pos_x - 5, pos_y), width, height) bgl.glDisable(bgl.GL_BLEND) # draw control buttons, if controls are enabled if _Show3DViewReport.has_controls(window): blf.size(0, 20, 72) blf.color(0, .8, .8, .8, 1) # set x and y offsets to report operator, so that area calculations for buttons can be calculated properly # considering dynamic left and top margins. _Show3DViewReport.set_btns_xy_offset(pos_x, region.height - pos_y) # draw close button _primitive.draw_rect_2d( ((pos_x + _OP_consts.View3DReport.CLOSE_BTN_AREA[0], pos_y - _OP_consts.View3DReport.CLOSE_BTN_AREA[2]), (pos_x + _OP_consts.View3DReport.CLOSE_BTN_AREA[1], pos_y - _OP_consts.View3DReport.CLOSE_BTN_AREA[2]), (pos_x + _OP_consts.View3DReport.CLOSE_BTN_AREA[1], pos_y - _OP_consts.View3DReport.CLOSE_BTN_AREA[3]), (pos_x + _OP_consts.View3DReport.CLOSE_BTN_AREA[0], pos_y - _OP_consts.View3DReport.CLOSE_BTN_AREA[3])), (.25, .25, .25, 1)) # draw close button text blf.position(0, pos_x + _OP_consts.View3DReport.CLOSE_BTN_TEXT_POS[0], pos_y - _OP_consts.View3DReport.CLOSE_BTN_TEXT_POS[1], 0) blf.draw(0, _OP_consts.View3DReport.CLOSE_BTN_TEXT) # draw hide button _primitive.draw_rect_2d( ((pos_x + _OP_consts.View3DReport.HIDE_BTN_AREA[0], pos_y - _OP_consts.View3DReport.HIDE_BTN_AREA[2]), (pos_x + _OP_consts.View3DReport.HIDE_BTN_AREA[1], pos_y - _OP_consts.View3DReport.HIDE_BTN_AREA[2]), (pos_x + _OP_consts.View3DReport.HIDE_BTN_AREA[1], pos_y - _OP_consts.View3DReport.HIDE_BTN_AREA[3]), (pos_x + _OP_consts.View3DReport.HIDE_BTN_AREA[0], pos_y - _OP_consts.View3DReport.HIDE_BTN_AREA[3])), (.25, .25, .25, 1)) # draw hide button text blf.position(0, pos_x + _OP_consts.View3DReport.HIDE_BTN_TEXT_POS[0], pos_y - _OP_consts.View3DReport.HIDE_BTN_TEXT_POS[1], 0) blf.draw(0, _OP_consts.View3DReport.HIDE_BTN_TEXT) # draw scroll controls if _Show3DViewReport.is_scrolled() and _Show3DViewReport.is_shown(): blf.size(0, 16, 72) # draw scroll up button _primitive.draw_rect_2d( ((pos_x + _OP_consts.View3DReport.SCROLLUP_BTN_AREA[0], pos_y - _OP_consts.View3DReport.SCROLLUP_BTN_AREA[2]), (pos_x + _OP_consts.View3DReport.SCROLLUP_BTN_AREA[1], pos_y - _OP_consts.View3DReport.SCROLLUP_BTN_AREA[2]), (pos_x + _OP_consts.View3DReport.SCROLLUP_BTN_AREA[1], pos_y - _OP_consts.View3DReport.SCROLLUP_BTN_AREA[3]), (pos_x + _OP_consts.View3DReport.SCROLLUP_BTN_AREA[0], pos_y - _OP_consts.View3DReport.SCROLLUP_BTN_AREA[3])), (.25, .25, .25, 1)) # draw scroll up button text blf.position( 0, pos_x + _OP_consts.View3DReport.SCROLLUP_BTN_TEXT_POS[0], pos_y - _OP_consts.View3DReport.SCROLLUP_BTN_TEXT_POS[1], 0) blf.draw(0, _OP_consts.View3DReport.SCROLLUP_BTN_TEXT) # draw scroll down button _primitive.draw_rect_2d( ((pos_x + _OP_consts.View3DReport.SCROLLDOWN_BTN_AREA[0], pos_y - _OP_consts.View3DReport.SCROLLDOWN_BTN_AREA[2]), (pos_x + _OP_consts.View3DReport.SCROLLDOWN_BTN_AREA[1], pos_y - _OP_consts.View3DReport.SCROLLDOWN_BTN_AREA[2]), (pos_x + _OP_consts.View3DReport.SCROLLDOWN_BTN_AREA[1], pos_y - _OP_consts.View3DReport.SCROLLDOWN_BTN_AREA[3]), (pos_x + _OP_consts.View3DReport.SCROLLDOWN_BTN_AREA[0], pos_y - _OP_consts.View3DReport.SCROLLDOWN_BTN_AREA[3])), (.25, .25, .25, 1)) # draw scroll down button text blf.position( 0, pos_x + _OP_consts.View3DReport.SCROLLDOWN_BTN_TEXT_POS[0], pos_y - _OP_consts.View3DReport.SCROLLDOWN_BTN_TEXT_POS[1], 0) blf.draw(0, _OP_consts.View3DReport.SCROLLDOWN_BTN_TEXT) # draw version string pos_y -= 12 blf.size(0, 10, 72) blf.color(0, .952, .635, .062, 1) blf.position(0, pos_x, pos_y, 0) blf.draw(0, _info_utils.get_combined_ver_str(only_version_numbers=True)) pos_y -= 20 # draw actual operator title and message if shown if _Show3DViewReport.is_shown(): blf.size(0, 12, 72) blf.color(0, 1, 1, 1, 1) blf.shadow(0, 5, 0, 0, 0, 1) if _Show3DViewReport.get_title() != "": blf.position(0, pos_x, pos_y, 0) blf.draw(0, _Show3DViewReport.get_title()) pos_y -= 15 blf.enable(0, blf.SHADOW) _Show3DViewReport.set_out_of_bounds(False) for line in _Show3DViewReport.get_lines(): # finish printing if running out of space if pos_y - 60 < 0: blf.position(0, pos_x, pos_y, 0) blf.draw(0, "...") pos_y -= 15 _Show3DViewReport.set_out_of_bounds(True) break blf.position(0, pos_x, pos_y, 0) if "ERROR" in line: blf.shadow(0, 5, 0.5, 0., 0, 1) elif "WARNING" in line: blf.shadow(0, 5, 0.3, 0.15, 0, 1) blf.draw(0, line) pos_y -= 15 blf.disable(0, blf.SHADOW)