Example #1
0
    def __init__(self, vectors: List[App.Vector] = [],
                 label: str = [[]], lineWidth=1,
                 _color=FR_COLOR.FR_BLACK,
                 _lblColor=FR_COLOR.FR_WHITE,
                 _rotation=[0.0, 0.0, 1.0, 0.0],
                  _scale: List[float] = [3, 3, 3],
                 _arrowType=0,
                 _opacity: float = 0.0):
        # Must be initialized first as per the following discussion.
        # https://stackoverflow.com/questions/67877603/how-to-override-a-function-in-an-inheritance-hierarchy#67877671
        super().__init__(vectors, label)

        self.w_lineWidth = lineWidth  # Default line width
        self.w_widgetType = constant.FR_WidgetType.FR_ARROW

        self.w_callback_ = callback  # External function
        self.w_lbl_calback_ = callback  # External function
        self.w_KB_callback_ = callback  # External function
        self.w_move_callback_ = callback  # External function
        self.w_wdgsoSwitch = coin.SoSwitch()
        self.w_color = _color  # Default color is green
        self.w_rotation = _rotation  # (x,y,z), Angle
        self.w_userData = userDataObject()   # Keep info about the widget
        self.w_userData.ArrowObj = self
        self.releaseDrag = -1  # -1 mouse no clicked not dragging, 0 is clicked, 1 is dragging
        self.arrowType = _arrowType  # 0 3D Default , 1= 2D, 2=2D
        self.w_lbluserData = fr_widget.propertyValues()
        self.w_lblColor = _lblColor
        self.w_opacity = _opacity
        self.w_scale = _scale
 def __init__(self, vectors: List[App.Vector] = [], labels: str = "", lineWidth=1):
     # It must be initialized first refer to fr_line_widget for more info
     super().__init__(vectors, labels)
     self.w_vector = vectors
     # default line width        # Here we have a list (4 labels)
     self.w_lineWidth = lineWidth
     self.w_label = labels
     self.w_widgetType = constant.FR_WidgetType.FR_SQUARE_FRAME
     self.w_callback_ = callback_default
     self.w_lbl_calback_ = callback_defaultlbl
     self.w_lbluserData = fr_widget.propertyValues()
Example #3
0
 def __init__(self,
              vectors: List[App.Vector] = [],
              label: str = "",
              lineWidth=1):
     super().__init__(vectors, label)
     # Must be initialized first as per the following discussion.
     # https://stackoverflow.com/questions/67877603/how-to-override-a-function-in-an-inheritance-hierarchy#67877671
     self.w_lineWidth = lineWidth  # Default line width
     self.w_widgetType = constant.FR_WidgetType.FR_EDGE
     self.w_callback_ = callback  # External function
     self.w_lbl_calback_ = lblcallback  # External function
     self.w_KB_callback_ = KBcallback  # External function
     self.w_move_callback_ = movecallback  # External function
     self.w_wdgsoSwitch = coin.SoSwitch()
     self.w_wdgsoSwitch.whichChild = coin.SO_SWITCH_ALL  # Show all
     self.w_lbluserData = fr_widget.propertyValues()
Example #4
0
    def __init__(self,
                 _boundary: None,
                 label: str = [[]],
                 _color=[FR_COLOR.FR_RED, FR_COLOR.FR_GREEN, FR_COLOR.FR_BLUE],
                 _lblColor=FR_COLOR.FR_WHITE,
                 _AlignType=0,
                 _opacity: float = 0.0):
        # Vectors are not used, but I need to return something to Fr_Widget
        super().__init__([App.Vector(0, 0, 0), App.Vector(0, 0, 0)], label)

        self.w_lineWidth = 1  # Default line width
        self.w_widgetType = constant.FR_WidgetType.FR_ALIGN

        self.w_callback_ = callback  # External function
        self.w_lbl_calback_ = callback  # External function
        self.w_KB_callback_ = callback  # External function
        self.w_wdgsoSwitch = coin.SoSwitch()
        self.w_color = _color  # Default color is red, green & blue
        self.w_userData = userDataObject()  # Keep info about the widget
        self.w_userData.Align = self
        self.w_lbluserData = fr_widget.propertyValues()
        self.w_lblColor = _lblColor
        self.w_opacity = _opacity
        self.w_btnObjs = []  # 9 sphere objects
        self.w_baseObjs = None  #
        # This must be provided or we can not draw anything
        self.w_boundary = _boundary
        self.w_btnCallbacks_ = [
            callback_btn0, callback_btn1, callback_btn2, callback_btn3,
            callback_btn4, callback_btn5, callback_btn6, callback_btn7,
            callback_btn8
        ]
        self.w_selColor = [[i * 1.5 for i in self.w_color[0]],
                           [j * 1.5 for j in self.w_color[1]],
                           [k * 1.5 for k in self.w_color[2]]]
        self.w_inactiveColor = [[i * 0.9 for i in self.w_color[0]],
                                [j * 0.9 for j in self.w_color[1]],
                                [k * 0.9 for k in self.w_color[2]]]
    def __init__(
            self,
            vectors: List[App.Vector] = [],
            label: str = [[]],
            _axisType: str = 'X',  # Default is X axis and RED color
            _lblColor=FR_COLOR.FR_WHITE,
            _axisColor=FR_COLOR.FR_RED,
            # User controlled rotation.
            # Face position-direction controlled rotation at creation.
            # Whole widget rotation
            _rotation: List[float] = [0.0, 0.0, 0.0, 0.0],
            _scale: List[float] = [3, 3, 3],
            _type: int = 1,
            _opacity: float = 0.0,
            _distanceBetweenThem: float = 5.0):
        super().__init__(vectors, label)

        self.w_lbluserData = fr_widget.propertyValues()
        self.w_widgetType = constant.FR_WidgetType.FR_ONE_DISC
        # General widget callback (mouse-button) function - External function
        self.w_callback_ = callback
        self.w_lbl_calback_ = callback  # Label callback
        self.w_KB_callback_ = callback  # Keyboard
        # Dummy callback Axis
        self.w_ArrowAxis_cb_ = callback1

        # Dummy callback          disc
        self.w_rotary_cb_ = callback2

        self.Opacity = _opacity
        self.DrawingType = _type
        # Use this to separate the arrows/lbl from the origin of the widget
        self.distanceBetweenThem = _distanceBetweenThem
        self.axisType = _axisType  # X, Y or Z

        self.w_wdgsoSwitch = coin.SoSwitch()
        self.w_ArrowsSeparator = None
        self.w_discSeparator = None

        self.w_color = _axisColor
        self.w_rotaryDisc_color = _axisColor
        self.w_selColor = [i * 1.2 for i in self.w_color]
        self.w_Scale = _scale
        self.w_inactiveColor = [i * 0.7 for i in self.w_selColor]

        self.w_userData = userDataObject()  # Keep info about the widget
        self.w_userData.discObj = self
        self.w_discAngle = 0.0  # Only disc rotation.
        self.oldAngle = 0.0
        self.rotationDirection = 1  # +1 CCW , -1 ACCW

        # This affect only the Widget label - nothing else
        self.w_lbluserData.linewidth = self.w_lineWidth
        self.w_lbluserData.vectors = self.w_vector

        # We must make it higher or it will intersect the object and won't be visible
        # TODO:Check if this works always?
        self.w_lbluserData.vectors[0].x = self.w_lbluserData.vectors[0].x + \
            self.distanceBetweenThem
        self.w_lbluserData.vectors[0].y = self.w_lbluserData.vectors[0].y + \
            self.distanceBetweenThem
        self.w_lbluserData.vectors[0].z = self.w_lbluserData.vectors[0].z + \
            self.distanceBetweenThem
        self.w_lbluserData.labelcolor = _lblColor

        # Use this to save rotation degree of the disk which is the whole widget angle.
        self.w_WidgetDiskRotation = 0.0

        self.w_rotation = _rotation  # Whole onearrow object Rotation

        self.w_discEnabled = False
        self.releaseDragAxis = -1  # Used to avoid running drag code while it is in drag mode
        # -1 no click, 0 mouse clicked, 1 mouse dragging
        self.releaseDragDisc = -1  # Used to avoid running drag code while it is in drag mode
        # -1 no click, 0 mouse clicked, 1 mouse dragging
        self.run_Once = False
        self.startVector = 0.0
        self.endVector = 0.0