src/jwm_draw_framing/draw_framing.rb
##------------------
## Draw the geometry to show where the cross-section will be placed
Draw the geometry to show where the cross-section will be placed
Draw the geometry to show where the cross - section will be placed
def draw_geometry(pt1, pt2, view)
    puts "draw_geometry called"
    case @state
    when 1 
      view.draw_points @first_pick.position, 12
      view.draw_polyline(@profile_pointsH.contents)
      view.line_width = 3
      view.drawing_color = "orange" 
      view.draw_polyline(@profile_pointsV.contents)
      view.line_width = 2; view.line_stipple = ""
      view.set_color_from_line(pt1, pt1 + @apparent_normal)
      view.draw_line(@first_pick.position, @first_pick.position + @apparent_normal) 
      #
      pt3 = @vec5.to_a.transform @tf2
      view.drawing_color = "orange" 
      view.draw_line(@first_pick.position,pt3)
      view.drawing_color = "magenta" 
    when 2 
      @vec6 = @first_pick.position.vector_to @first_pick.position.offset(@apparent_normal, @frame_length)
      @tf6 = Geom::Transformation.translation(@vec6)
      @profile_points.each_index {|i| @profile_points4[i] = @profile_points[i].transform @tf6}
    end 
end
def draw_geometry ( pt1 , pt2 , view ) puts "draw_geometry called" case @state when 1 view . draw_points @first_pick . position , 12 view . draw_polyline ( @profile_pointsH . contents ) view . line_width = 3 view . drawing_color = "orange" view . draw_polyline ( @profile_pointsV . contents ) view . line_width = 2 ; view . line_stipple = "" view . set_color_from_line ( pt1 , pt1 + @apparent_normal ) view . draw_line ( @first_pick . position , @first_pick . position + @apparent_normal ) pt3 = @vec5 . to_a . transform @tf2 view . drawing_color = "orange" view . draw_line ( @first_pick . position , pt3 ) view . drawing_color = "magenta" when 2 @vec6 = @first_pick . position . vector_to @first_pick . position . offset ( @apparent_normal , @frame_length ) @tf6 = Geom :: Transformation . translation ( @vec6 ) @profile_points . each_index { | i | @profile_points4 [ i ] = @profile_points [ i ] . transform @tf6 } end end
Draw the geometry to show where the cross-section will be placed
Draw the geometry to show where the cross - section will be placed
## Draw timber profile  ## This method has to take account of  ## - the shape of the timber cross-section defined in @profile array ## - whether to flip the cross-section L-R and/or top to bottom  ##     (to be set by the TAB key cycling through L-R = 1, T-B = 2, L-R and T-B = 3, or no flip = 0) ## - the position of the @first_pick (insertion) point relative to ##     world or component origin, which was defined by the transformation @tf ## - the direction of the @reported_normal vector for the length of the inserted timber, which  ##     may be locked to a vector @@axis_lock set by a cursor arrow key  ##     to one of of the X, Y or Z axes, or picked normal to a face; or if no face is picked, ##     and no axis lock is set, to the Z axis by default ## - the current position of the mouse pointer screen coordinates relative to @first_pick  ##     screen position, defined by diff_x and diff_y, to calculate  ##   . which screen @quadrant (upper right, upper left, lower left or lower right) ##       the mouse is in (relative to @first_pick)and hence whether to draw cross-section rotated ##       by 0, 90, 180 or 270 degrees around the @reported_normal vector ##   . whether diff_x or diff_y is larger, and hence whether to draw the profile with its  ##       longer cross-section horizontal or vertical ## If any relevant key is pressed to change the axis lock or flip direction, before  ##   the mouse is released after dragging, or clicked a second time,  ##   the profile needs to be redrawn with the new value(s) ## After first click, waiting for second click or onLButtonUp # puts "Profile_pointsH = " + @profile_pointsH.contents.inspect # @profile_pointsV = @profile_pointsH.clone.flipY ## If orientation (calculated from mouse position relative to first pick) is vertical  ##   where it would otherwise be drawn horizontal, and vice versa, ##   rotate 90 degrees and drop by width coordinates of basic profile ## Rotate about Z_AXIS at origin so as to be parallel in the x-y (rg) plane to the face normal. ## puts @tf3.to_matrix # @profile_points2.each_index {|i| @profile_points3[i] = @profile_points2[i].transform(@tf3)}  ## The profile needs to be revolved about the line  ##  which is normal to the Z_AZIS AND to the face.normal if on a face,  ##  unless the face.normal or @@axis_lock IS the Z_AXIS, in which case no revolution needed. ## And to get the normal, we took the cross-product of  ##  the Z_AZIS and the face.normal in onLButtonDown. # @profile_points2.each_index {|i| @profile_points[i] = @profile_points3[i].transform(@tf4)}  ##See if mouse position requires profile to be reoriented ## Rotate by 90 degrees about @reported_normal @quad times # i = 1 # unless @reverse_rotation  # while i <= (@quadrant - 3 )%4 do # @profile_points.each_index {|i| @profile_points[i].transform! @rotate90_la } # i += 1 # end # else # while i <= (@quadrant - 2 )%4 do # @profile_points.each_index {|i| @profile_points[i].transform! @rotate_minus90_la } # i += 1 # end   # end # Relocate profile to first pick point (transform @tf2)  # @profile_points.each_index {|i| @profile_points[i].transform!(@tf2)}    ##   	puts "@profile_points[] = \n" + @profile_points.to_a.inspect ## Display long axis as visual feedback ##@reported_normal.transform!(@tf2) ## to show direction of long axis of wood   ## end ## Draw normal  to Z_AXIS/face.normal in orange ## puts "@vec5 = " + @vec5.to_a.to_s, (@vec5.to_a.transform @tf2).to_s ## puts @tf2.to_matrix  ##      view.draw_polyline(@profile[2..-1]) ## ------------------------------------------------------------------------------- ## Cross-section drawn, waiting for drag or click to pushpull to length ## @frame_length was defined in onMouseMove @state == 2 ## Define translation to move profile outline along @apparent_normal by @frame_length ## Copy profile along @apparent_normal # view.line_width = 3 # view.drawing_color = "magenta"  # view.draw_polyline(@profile_points) # view.draw_polyline(@profile_points4) # @profile_points.each_index {|i| view.draw_line(@profile_points[i], @profile_points4[i])} ##view.draw_points @first_pick.position.offset(@apparent_normal, @frame_length), 8, 1, "magenta" ## case @state
pt1
<not_specific>
pt2
<not_specific>
view
<not_specific>