def DialogHandler(item, data): if item == kDialogInitEvent: SetupDialog() elif item == kWidth or item == kHeight or item == kElevationInWall or item == kOpeningAngle: CheckData() elif item == kOpenTheWindow or item == kHasCurtains or item == kDrawTheCurts or item == kLeaf: index = vs.GetSelectedChoiceIndex(Constants.dialogId, kLeaf, 0) hasLeaf = not (index == 0) EnableItems(hasLeaf, vs.GetBooleanItem(Constants.dialogId, kOpenTheWindow), vs.GetBooleanItem(Constants.dialogId, kHasCurtains), vs.GetBooleanItem(Constants.dialogId, kDrawTheCurts)) elif item == kOpacitySlider: text = vs.GetPluginString(3054) text += ' (' text += str(data) text += '%): ' vs.SetItemText(Constants.dialogId, kOpacityText, text) elif item == kOK: #The ok button of the dialog has been clicked OnOK()
def DialogHandler(item, data): if item == 12255: # Setup event vs.SetItemText(dialog, ui.dlg.ksize, dialogData.gSize) vs.SetItemText(dialog, ui.dlg.kscale1, dialogData.gScale) pass elif item == ui.dlg.ksize: dialogData.gSize = float( vs.GetItemText(dialog, ui.dlg.ksize, dialogData.gSize)) pass elif item == ui.dlg.kscale1: dialogData.gScale = float( vs.GetItemText(dialog, ui.dlg.kscale1, dialogData.gScale)) pass return item
def SetupDialog(): for i in range(1,6): vs.AddChoice(Constants.dialogId,kLeaf,vs.GetPluginString(4000+i),i-1) vs.AddChoice(Constants.dialogId,kLedgeType,vs.GetPluginString(4006),0) vs.AddChoice(Constants.dialogId,kLedgeType,vs.GetPluginString(4007),1) vs.AddChoice(Constants.dialogId,kLedgeMaterial,vs.GetPluginString(4008),0) vs.AddChoice(Constants.dialogId,kLedgeMaterial,vs.GetPluginString(4009),1) vs.AddChoice(Constants.dialogId,kLedgeMaterial,vs.GetPluginString(4010),2) fraction, display, format, upi, name, squareName = vs.GetUnits() ####################################################### value = vs.GetRField(Constants.h,kPluginName,'IDLabel') vs.SetEditInteger(Constants.dialogId, kIDLabel, vs.Str2Num(value)) ####################################################### value = vs.GetRField(Constants.h,kPluginName,'Width') inches = 0 if(format == 2 or format == 3): index = value.find("'") if index > -1: splitVal = value.split("'") inches += vs.Str2Num(splitVal[0])*12.0 str = splitVal[1] index = str.find(name) if index > -1: str = str.replace(name, "") value = vs.Str2Num(str) inches += value else: index = value.find(name) if index > -1: value = value.replace(name,"") value = vs.Str2Num(value) inches += value else: index = value.find(name) if index > -1: value = value.replace(name, "") inches = vs.Str2Num(value) vs.SetEditReal(Constants.dialogId,kWidth,kEditRealDim,inches) ####################################################### value = vs.GetRField(Constants.h,kPluginName,'Height') inches = 0 if(format == 2 or format == 3): index = value.find("'") if index > -1: splitVal = value.split("'") inches += vs.Str2Num(splitVal[0])*12.0 str = splitVal[1] index = str.find(name) if index > -1: str = str.replace(name, "") value = vs.Str2Num(str) inches += value else: index = value.find(name) if index > -1: value = value.replace(name,"") value = vs.Str2Num(value) inches += value else: index = value.find(name) if index > -1: value = value.replace(name, "") inches = vs.Str2Num(value) vs.SetEditReal(Constants.dialogId,kHeight,kEditRealDim,inches) ####################################################### value = vs.GetRField(Constants.h,kPluginName,'ElvInWall') inches = 0 if(format == 2 or format == 3): index = value.find("'") if index > -1: splitVal = value.split("'") inches += vs.Str2Num(splitVal[0])*12.0 str = splitVal[1] index = str.find(name) if index > -1: str = str.replace(name, "") value = vs.Str2Num(str) inches += value else: index = value.find(name) if index > -1: value = value.replace(name,"") value = vs.Str2Num(value) inches += value else: index = value.find(name) if index > -1: value = value.replace(name, "") inches = vs.Str2Num(value) vs.SetEditReal(Constants.dialogId,kElevationInWall,kEditRealDim,inches) ####################################################### value = vs.GetRField(Constants.h, kPluginName, 'OpenTheWindow') vs.SetBooleanItem(Constants.dialogId, kOpenTheWindow ,value =='True') ####################################################### value = vs.GetRField(Constants.h,kPluginName,'OpeningAngle') newNumber = vs.Str2Num(value) vs.SetEditReal(Constants.dialogId, kOpeningAngle, kEditRealAng,newNumber) ####################################################### leafType = vs.GetRField(Constants.h,kPluginName,'Leaf') if leafType == 'None': vs.SelectChoice(Constants.dialogId, kLeaf, 0, True) elif leafType == '1(no glass)': vs.SelectChoice(Constants.dialogId, kLeaf, 1, True) elif leafType == '1(glass)': vs.SelectChoice(Constants.dialogId, kLeaf, 2, True) elif leafType == '2(no glass)': vs.SelectChoice(Constants.dialogId, kLeaf, 3, True) else: vs.SelectChoice(Constants.dialogId, kLeaf, 4, True) ####################################################### value = vs.GetRField(Constants.h,kPluginName,'HasCurts') vs.SetBooleanItem(Constants.dialogId, kHasCurtains, value =='True') ####################################################### ledgeType = vs.GetRField(Constants.h,kPluginName,'LedgeType') if ledgeType == 'Attach to wall': vs.SelectChoice(Constants.dialogId,kLedgeType,0,True) else: vs.SelectChoice(Constants.dialogId,kLedgeType,1,True) ####################################################### ledgeMaterial = vs.GetRField(Constants.h,kPluginName,'LedgeMaterial') if ledgeMaterial == 'Wood': vs.SelectChoice(Constants.dialogId,kLedgeMaterial,0,True) elif ledgeMaterial == 'Plastic': vs.SelectChoice(Constants.dialogId,kLedgeMaterial,1,True) else: vs.SelectChoice(Constants.dialogId,kLedgeMaterial,2,True) ####################################################### value = vs.GetRField(Constants.h,kPluginName,'DrawTheCurts') vs.SetBooleanItem(Constants.dialogId,kDrawTheCurts,value == 'True') ####################################################### colorIndex = vs.GetRField(Constants.h, kPluginName, '__CustomColor') vs.SetColorChoice(Constants.dialogId,kCurtsColor,vs.Str2Num(colorIndex)) ####################################################### value = vs.GetRField(Constants.h,kPluginName,'Pieces') newNumber = vs.Str2Num(value) vs.SetEditInteger(Constants.dialogId, kPieces, newNumber) ####################################################### opacityText = vs.GetRField(Constants.h,kPluginName,'Opacity') vs.SetControlData(Constants.dialogId,kOpacitySlider,vs.Str2Num(opacityText)) ####################################################### text = vs.GetPluginString(3054) text += ' (' text += opacityText text +='%): ' vs.SetItemText(Constants.dialogId,kOpacityText,text) ####################################################### hasCurtain = vs.GetBooleanItem(Constants.dialogId,kHasCurtains) drawTheCurtain = vs.GetBooleanItem(Constants.dialogId,kDrawTheCurts) index = vs.GetSelectedChoiceIndex(Constants.dialogId, kLeaf, 0) hasLeaf = not(index == 0) EnableItems(hasLeaf, vs.GetBooleanItem(Constants.dialogId,kOpenTheWindow), hasCurtain, drawTheCurtain) vs.SetSliderLiveUpdate(Constants.dialogId, kOpacitySlider, True)
def dialog_handler(self, item: int, data: int) -> int: """ Handles dialog control events """ if item == KDialogInitEvent: vs.SetItemText(self.dialog, self.kWidgetID_pictureName, self.parameters.pictureName) # Image Widgets # =============================================================================================== vs.EnableItem( self.dialog, self.kWidgetID_imageWidthLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imageWidth, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imageHeightLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imageHeight, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imagePositionLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imagePosition, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imageEditButton, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) # Frame Widgets # =============================================================================================== vs.EnableItem( self.dialog, self.kWidgetID_frameWidthLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameWidth, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameHeightLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameHeight, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameThicknessLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameThickness, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameDepthLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameDepth, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameClassLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameClass, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameTextureScaleLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameTextureScale, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameTextureRotationLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_frameTextureRotation, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) # Matboard Widgets # =============================================================================================== vs.EnableItem( self.dialog, self.kWidgetID_matboardPositionLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard)) vs.EnableItem( self.dialog, self.kWidgetID_matboardPosition, vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard)) vs.EnableItem( self.dialog, self.kWidgetID_matboardClassLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard)) vs.EnableItem( self.dialog, self.kWidgetID_matboardClass, vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard)) vs.EnableItem( self.dialog, self.kWidgetID_matboardTextureScaleLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard)) vs.EnableItem( self.dialog, self.kWidgetID_matboardTextureScale, vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard)) vs.EnableItem( self.dialog, self.kWidgetID_matboardTextureRotatLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard)) vs.EnableItem( self.dialog, self.kWidgetID_matboardTextureRotat, vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard)) # Glass Widgets # =============================================================================================== vs.EnableItem( self.dialog, self.kWidgetID_glassPositionLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withGlass)) vs.EnableItem( self.dialog, self.kWidgetID_glassPosition, vs.GetBooleanItem(self.dialog, self.kWidgetID_withGlass)) vs.EnableItem( self.dialog, self.kWidgetID_glassClassLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withGlass)) vs.EnableItem( self.dialog, self.kWidgetID_glassClass, vs.GetBooleanItem(self.dialog, self.kWidgetID_withGlass)) elif item == self.kWidgetID_pictureName: self.parameters.pictureName = vs.GetItemText( self.dialog, self.kWidgetID_pictureName) elif item == self.kWidgetID_withImage: if not data: texture = vs.GetObject(self.parameters.imageTexture) if texture != 0: vs.DelObject(texture) self.parameters.imageTexture = "" elif self.parameters.imageTexture == "": self.select_image_texture() if self.parameters.imageTexture == "": vs.SetBooleanItem(self.dialog, self.kWidgetID_withImage, False) vs.EnableItem( self.dialog, self.kWidgetID_imageWidthLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imageWidth, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imageHeightLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imageHeight, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imagePositionLabel, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imagePosition, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) vs.EnableItem( self.dialog, self.kWidgetID_imageEditButton, vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) elif item == self.kWidgetID_imageEditButton: self.select_image_texture() elif item == self.kWidgetID_withFrame: vs.EnableItem(self.dialog, self.kWidgetID_frameWidthLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_frameWidth, data) vs.EnableItem(self.dialog, self.kWidgetID_frameHeightLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_frameHeight, data) vs.EnableItem(self.dialog, self.kWidgetID_frameThicknessLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_frameThickness, data) vs.EnableItem(self.dialog, self.kWidgetID_frameDepthLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_frameDepth, data) vs.EnableItem(self.dialog, self.kWidgetID_frameClassLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_frameClass, data) vs.EnableItem(self.dialog, self.kWidgetID_frameTextureScaleLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_frameTextureScale, data) vs.EnableItem(self.dialog, self.kWidgetID_frameTextureRotationLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_frameTextureRotation, data) elif item == self.kWidgetID_withMatboard: vs.EnableItem(self.dialog, self.kWidgetID_matboardPositionLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_matboardPosition, data) vs.EnableItem(self.dialog, self.kWidgetID_matboardClassLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_matboardClass, data) vs.EnableItem(self.dialog, self.kWidgetID_matboardTextureScaleLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_matboardTextureScale, data) vs.EnableItem(self.dialog, self.kWidgetID_matboardTextureRotatLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_matboardTextureRotat, data) elif item == self.kWidgetID_withGlass: vs.EnableItem(self.dialog, self.kWidgetID_glassPositionLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_glassPosition, data) vs.EnableItem(self.dialog, self.kWidgetID_glassClassLabel, data) vs.EnableItem(self.dialog, self.kWidgetID_glassClass, data) elif item == kOK: self.parameters.pictureName = vs.GetItemText( self.dialog, self.kWidgetID_pictureName) if self.parameters.pictureName == "": vs.AlertInform( "The picture name cannot be empty. Please add the picture name", "", True) item = -1 elif vs.GetObject(self.parameters.pictureName) != 0: vs.AlertInform( "The picture name is already in use. Please change the picture name to avoid a conflict", "", True) item = -1 elif vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage) is False and \ vs.GetBooleanItem(self.dialog, self.kWidgetID_withFrame) is False and \ vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard) is False and \ vs.GetBooleanItem(self.dialog, self.kWidgetID_withGlass) is False: vs.AlertInform( "This picture contains no elements. \ Please select at least one of the components for the picture object", "", True) item = -1 else: self.parameters.createSymbol = "{}".format( vs.GetBooleanItem(self.dialog, self.kWidgetID_createSymbol)) # Image settings # =============================================================================================== self.parameters.withImage = "{}".format( vs.GetBooleanItem(self.dialog, self.kWidgetID_withImage)) _, img_width = vs.GetEditReal(self.dialog, self.kWidgetID_imageWidth, 3) self.parameters.imageWidth = "{}\"".format(img_width) _, img_height = vs.GetEditReal(self.dialog, self.kWidgetID_imageHeight, 3) self.parameters.imageHeight = "{}\"".format(img_height) _, img_position = vs.GetEditReal(self.dialog, self.kWidgetID_imagePosition, 3) # self.parameters.imagePosition = "{}\"".format(img_position) self.parameters.imagePosition = str(img_position) texture = vs.GetObject(self.parameters.imageTexture) if texture != 0: self.parameters.imageTexture = "{} Prop Texture".format( self.parameters.pictureName) vs.SetName(texture, self.parameters.imageTexture) # Frame settings # =============================================================================================== self.parameters.withFrame = "{}".format( vs.GetBooleanItem(self.dialog, self.kWidgetID_withFrame)) _, frm_width = vs.GetEditReal(self.dialog, self.kWidgetID_frameWidth, 3) self.parameters.frameWidth = "{}".format(frm_width) _, frm_height = vs.GetEditReal(self.dialog, self.kWidgetID_frameHeight, 3) self.parameters.frameHeight = "{}".format(frm_height) _, frm_thickness = vs.GetEditReal( self.dialog, self.kWidgetID_frameThickness, 3) # self.parameters.frameThickness = "{}".format(frm_thickness) self.parameters.frameThickness = str(frm_thickness) _, frm_depth = vs.GetEditReal(self.dialog, self.kWidgetID_frameDepth, 3) # self.parameters.frameDepth = "{}".format(frm_depth) self.parameters.frameDepth = str(frm_depth) _, self.parameters.frameClass = vs.GetSelectedChoiceInfo( self.dialog, self.kWidgetID_frameClass, 0) _, frm_texture_scale = vs.GetEditReal( self.dialog, self.kWidgetID_frameTextureScale, 1) # self.parameters.frameTextureScale = "{}".format(frm_texture_scale) self.parameters.frameTextureScale = str(frm_texture_scale) _, frm_texture_rotation = vs.GetEditReal( self.dialog, self.kWidgetID_frameTextureRotation, 1) # self.parameters.frameTextureRotation = "{}".format(frm_texture_rotation) self.parameters.frameTextureRotation = str( frm_texture_rotation) # Matboard settings # =============================================================================================== self.parameters.withMatboard = "{}".format( vs.GetBooleanItem(self.dialog, self.kWidgetID_withMatboard)) _, matbrd_position = vs.GetEditReal( self.dialog, self.kWidgetID_matboardPosition, 3) # self.parameters.matboardPosition = "{}".format(matbrd_position) self.parameters.matboardPosition = str(matbrd_position) _, self.parameters.matboardClass = vs.GetSelectedChoiceInfo( self.dialog, self.kWidgetID_matboardClass, 0) _, matbrd_texture_scale = vs.GetEditReal( self.dialog, self.kWidgetID_matboardTextureScale, 1) # self.parameters.matboardTextureScale = "{}".format(matbrd_texture_scale) self.parameters.matboardTextureScale = str( matbrd_texture_scale) _, matbrd_texture_rotation = vs.GetEditReal( self.dialog, self.kWidgetID_matboardTextureRotat, 1) # self.parameters.matboardTextureRotat = "{}".format(matbrd_texture_rotation) self.parameters.matboardTextureRotat = str( matbrd_texture_rotation) # Glass settings # =============================================================================================== self.parameters.withGlass = "{}".format( vs.GetBooleanItem(self.dialog, self.kWidgetID_withGlass)) _, self.parameters.glassPosition = vs.GetEditReal( self.dialog, self.kWidgetID_glassPosition, 3) # self.parameters.glassPosition = "{}".format(self.parameters.glassPosition) self.parameters.glassPosition = str( self.parameters.glassPosition) _, self.parameters.glassClass = vs.GetSelectedChoiceInfo( self.dialog, self.kWidgetID_glassClass, 0) elif item == kCancel: texture = vs.GetObject(self.parameters.imageTexture) if texture != 0: vs.DelObject(texture) self.parameters.imageTexture = "" return item