parameters: (self, arg)
docstring: Handle the 3D scene events.
  
          This is installed as an EventCallback in the Inventor view
          by the `Activated` method of the parent class.
  
          Parameters
          ----------
          arg: dict
              Dictionary with strings that indicates the type of event received
              from the 3D view.
docstring_summary: Handle the 3D scene events.
docstring_tokens: Handle the 3D scene events .
function: def action(self, arg):
          """Handle the 3D scene events.
  
          This is installed as an EventCallback in the Inventor view
          by the `Activated` method of the parent class.
  
          Parameters
          ----------
          arg: dict
              Dictionary with strings that indicates the type of event received
              from the 3D view.
          """
          if arg["Type"] == "SoKeyboardEvent":
              if arg["Key"] == "ESCAPE":
                  self.finish()
          elif arg["Type"] == "SoLocation2Event":  # mouse movement detection
              (self.point,
               ctrlPoint, info) = gui_tool_utils.getPoint(self, arg,
                                                          noTracker=True)
              if (len(self.node) - 1) % self.degree == 0 and len(self.node) > 2:
                  prevctrl = 2 * self.node[-1] - self.point
                  # Existing points + this pointer position
                  self.bezcurvetrack.update(self.node[0:-2]
                                            + [prevctrl]
                                            + [self.node[-1]]
                                            + [self.point], degree=self.degree)
              else:
                  # Existing points + this pointer position
                  self.bezcurvetrack.update(self.node
                                            + [self.point], degree=self.degree)
              gui_tool_utils.redraw3DView()
          elif arg["Type"] == "SoMouseButtonEvent":
              # Press and hold the button
              if arg["State"] == "DOWN" and arg["Button"] == "BUTTON1":
                  if arg["Position"] == self.pos:
                      if len(self.node) > 2:
                          self.node = self.node[0:-2]
                      else:
                          self.node = []
                      return
                  else:
                      if (not self.node) and (not self.support):  # first point
                          gui_tool_utils.getSupport(arg)
                          (self.point,
                           ctrlPoint,
                           info) = gui_tool_utils.getPoint(self, arg,
                                                           noTracker=True)
                      if self.point:
                          self.ui.redraw()
                          self.pos = arg["Position"]
                          # add point to "clicked list"
                          self.node.append(self.point)
                          # sb add a control point,
                          # if mod(len(cpoints), 2) == 0
                          # then create 2 handle points?
                          self.drawUpdate(self.point)
                          if not self.isWire and len(self.node) == 2:
                              self.finish(False, cont=True)
                          # does this make sense for a BCurve?
                          if len(self.node) > 2:
                              # add point to "clicked list"
                              self.node.append(self.point)
                              self.drawUpdate(self.point)
                              # DNC: allows to close the curve
                              # by placing ends close to each other
                              # with tol = Draft tolerance
                              # old code has been to insensitive
                              _diff = (self.point - self.node[0]).Length
                              if (_diff < utils.tolerance()
                                      and len(self.node) >= 4):
                                  # self.undolast()
                                  self.node = self.node[0:-2]
                                  # close the curve with a smooth symmetric knot
                                  _sym = 2 * self.node[0] - self.node[1]
                                  self.node.append(_sym)
                                  self.finish(True, cont=True)
                                  _msg(translate("draft",
                                                 "Bézier curve has been closed"))
  
              # Release the held button
              if arg["State"] == "UP" and arg["Button"] == "BUTTON1":
                  if arg["Position"] == self.pos:
                      self.node = self.node[0:-2]
                      return
                  else:
                      if (not self.node) and (not self.support):  # first point
                          return
                      if self.point:
                          self.ui.redraw()
                          self.pos = arg["Position"]
                          # add point to "clicked list"
                          self.node.append(self.point)
                          # sb add a control point,
                          # if mod(len(cpoints),2) == 0
                          # then create 2 handle points?
                          self.drawUpdate(self.point)
                          if not self.isWire and len(self.node) == 2:
                              self.finish(False, cont=True)
                          # Does this make sense for a BCurve?
                          if len(self.node) > 2:
                              self.node[-3] = 2 * self.node[-2] - self.node[-1]
                              self.drawUpdate(self.point)
function_tokens: def action ( self , arg ) : if arg [ "Type" ] == "SoKeyboardEvent" : if arg [ "Key" ] == "ESCAPE" : self . finish ( ) elif arg [ "Type" ] == "SoLocation2Event" : # mouse movement detection ( self . point , ctrlPoint , info ) = gui_tool_utils . getPoint ( self , arg , noTracker = True ) if ( len ( self . node ) - 1 ) % self . degree == 0 and len ( self . node ) > 2 : prevctrl = 2 * self . node [ - 1 ] - self . point # Existing points + this pointer position self . bezcurvetrack . update ( self . node [ 0 : - 2 ] + [ prevctrl ] + [ self . node [ - 1 ] ] + [ self . point ] , degree = self . degree ) else : # Existing points + this pointer position self . bezcurvetrack . update ( self . node + [ self . point ] , degree = self . degree ) gui_tool_utils . redraw3DView ( ) elif arg [ "Type" ] == "SoMouseButtonEvent" : # Press and hold the button if arg [ "State" ] == "DOWN" and arg [ "Button" ] == "BUTTON1" : if arg [ "Position" ] == self . pos : if len ( self . node ) > 2 : self . node = self . node [ 0 : - 2 ] else : self . node = [ ] return else : if ( not self . node ) and ( not self . support ) : # first point gui_tool_utils . getSupport ( arg ) ( self . point , ctrlPoint , info ) = gui_tool_utils . getPoint ( self , arg , noTracker = True ) if self . point : self . ui . redraw ( ) self . pos = arg [ "Position" ] # add point to "clicked list" self . node . append ( self . point ) # sb add a control point, # if mod(len(cpoints), 2) == 0 # then create 2 handle points? self . drawUpdate ( self . point ) if not self . isWire and len ( self . node ) == 2 : self . finish ( False , cont = True ) # does this make sense for a BCurve? if len ( self . node ) > 2 : # add point to "clicked list" self . node . append ( self . point ) self . drawUpdate ( self . point ) # DNC: allows to close the curve # by placing ends close to each other # with tol = Draft tolerance # old code has been to insensitive _diff = ( self . point - self . node [ 0 ] ) . Length if ( _diff < utils . tolerance ( ) and len ( self . node ) >= 4 ) : # self.undolast() self . node = self . node [ 0 : - 2 ] # close the curve with a smooth symmetric knot _sym = 2 * self . node [ 0 ] - self . node [ 1 ] self . node . append ( _sym ) self . finish ( True , cont = True ) _msg ( translate ( "draft" , "Bézier curve has been closed") ) # Release the held button if arg [ "State" ] == "UP" and arg [ "Button" ] == "BUTTON1" : if arg [ "Position" ] == self . pos : self . node = self . node [ 0 : - 2 ] return else : if ( not self . node ) and ( not self . support ) : # first point return if self . point : self . ui . redraw ( ) self . pos = arg [ "Position" ] # add point to "clicked list" self . node . append ( self . point ) # sb add a control point, # if mod(len(cpoints),2) == 0 # then create 2 handle points? self . drawUpdate ( self . point ) if not self . isWire and len ( self . node ) == 2 : self . finish ( False , cont = True ) # Does this make sense for a BCurve? if len ( self . node ) > 2 : self . node [ - 3 ] = 2 * self . node [ - 2 ] - self . node [ - 1 ] self . drawUpdate ( self . point )