[squeak-dev] The Inbox: Morphic-kfr.1620.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Tue Feb 4 17:34:01 UTC 2020


Nice idea :-)


But when I merge this commit, it misses #snapToOtherPolygonPhrase:


[cid:589ef4c5-a822-4f57-8521-d3e85fa5cb51]


Btw, #snapToOtherPolyongs itself is also absent in my image. Are you depending on another inbox commit?


Best,

Christoph


________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Dienstag, 4. Februar 2020 17:56:00
An: squeak-dev at lists.squeakfoundation.org
Betreff: [squeak-dev] The Inbox: Morphic-kfr.1620.mcz

A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-kfr.1620.mcz

==================== Summary ====================

Name: Morphic-kfr.1620
Author: kfr
Time: 4 February 2020, 5:55:31.268512 pm
UUID: 741c35fd-d7ac-e54b-9199-ed1dda9e4df9
Ancestors: Morphic-kfr.1619

Enhancement for PolygonMorph. When a vertex is dropped it will snap if it is close to another PolygonMorphs vertex. It is possible to toggle functionality on/ off in menu

=============== Diff against Morphic-kfr.1619 ===============

Item was changed:
  BorderedMorph subclass: #PolygonMorph
+        instanceVariableNames: 'vertices closed filledForm arrows arrowForms smoothCurve curveState borderDashSpec handles borderForm snapToOtherPolygons'
-        instanceVariableNames: 'vertices closed filledForm arrows arrowForms smoothCurve curveState borderDashSpec handles borderForm'
         classVariableNames: ''
         poolDictionaries: ''
         category: 'Morphic-Basic'!

  !PolygonMorph commentStamp: 'md 2/24/2006 20:34' prior: 0!
  This class implements a morph which can behave as four different objects depending on the the following two facts:
  - is it OPEN or CLOSED?
  - is it SEGMENTED or SMOOTHED.

  1. The OPEN and SEGMENTED variant looks like polyline.

  2. The OPEN and SMOOTHED variant looks like spline (kind of curve)

  3. The CLOSED and SEGMENTED variant looks like polygon. This is actually what you get when you do
         PolygonMorph new openInWorld
  You get a triangle. See below how to manipulate these objects...

  4. The CLOSED and SMOOTHED variant looks like blob (???)

  Prototypes of this morph can also be found in "Object Catalog". Several (different variants) of this object are among "Basic" morphs.

  Explore the assiciated morph-menu. It enables you
  - to toggle showing of "handles". They make it possible to
         - reposition already existing vertices (by moving yellow handles)
         - create new vertices (by moving green handles)
         - delete already existing vertices (by dragging and dropping one yellow handle closely
           nearby the adjacent yellow handle
    Handles can be made visible/hidden by shift+leftclicking the morph. This way it is possible
    to quickly show handles, adjust vertices and then again hide handles.
  - making closed polygon open, i.e. converting it to a curve (and vice versa)
  - toggle smoothed/segmented line/outline
  - set up custom dashing (for line, curves or borders of closed polygons
  - set up custom arrow-heads (for lines resp. curves)

  ------------------------------------------------------------------------------------------
  Implementation notes:

  This class combines the old Polygon and Curve classes.

  The 1-bit fillForm to make display and containment tests reasonably fast.  However, this functionality is in the process of being supplanted by balloon capabilities, which should eventually provide anti-aliasing as well.

  wiz 7/18/2004 21:26
  s have made some changes to this class to

  1) correct some bugs associated with one vertex polygons.

  2) prepare for some enhancements with new curves.

  3) add shaping items to menu.!

Item was changed:
  ----- Method: PolygonMorph>>addCustomMenuItems:hand: (in category 'menu') -----
  addCustomMenuItems: aMenu hand: aHandMorph
         "Add morph-specific items to the given menu which was invoked by the given hand.  This method provides is invoked both from the halo-menu and from the control-menu regimes."

         super addCustomMenuItems: aMenu hand: aHandMorph.
         aMenu addUpdating: #handlesShowingPhrase target: self action: #showOrHideHandles.
         vertices size > 2 ifTrue:
                 [aMenu addUpdating: #openOrClosePhrase target: self action: #makeOpenOrClosed].

         aMenu addUpdating: #smoothPhrase target: self action: #toggleSmoothing.
+        aMenu addUpdating: #snapToOtherPolygonPhrase target: self action: #toggleSnapToOtherPolygons.
         aMenu addLine.
         aMenu add: 'specify dashed line' translated action:  #specifyDashedLine.

         self isOpen ifTrue:
                 [aMenu addLine.
                 aMenu addWithLabel: '---' enablement: [self isOpen and: [arrows ~~ #none]] action:  #makeNoArrows.
                 aMenu addWithLabel: '-->' enablement: [self isOpen and: [arrows ~~ #forward]] action:  #makeForwardArrow.
                 aMenu addWithLabel: '<--' enablement: [self isOpen and: [arrows ~~ #back]] action:  #makeBackArrow.
                 aMenu addWithLabel: '<->' enablement: [self isOpen and: [arrows ~~ #both]] action:  #makeBothArrows.
                 aMenu add: 'customize arrows' translated action: #customizeArrows:.
                 (self hasProperty: #arrowSpec)
                         ifTrue: [aMenu add: 'standard arrows' translated action: #standardArrows]].!

Item was changed:
  ----- Method: PolygonMorph>>dropVertex:event:fromHandle: (in category 'editing') -----
+ dropVertex: ix event: evt fromHandle: handle
+        "Leave vertex in new position. If dropped ontop another vertex delete
+        this one.
- dropVertex: ix event: evt fromHandle: handle
-        "Leave vertex in new position. If dropped ontop another vertex delete this one.
         Check for too few vertices before deleting. The alternative
+        is not pretty -wiz"
+        | p world |
-                                is not pretty -wiz"
-        | p |
         p := vertices at: ix.
+
+        "snap the dropped vertex to a vertex of another PolygonMorph if it is in near proximity"
+        self isSnappingToOtherPolygons
+                ifTrue: [world := Project current world.
+                        world submorphs
+                                do: [:each | ((each respondsTo: #vertices)
+                                                        and: [each ~= self])
+                                                ifTrue: [each vertices
+                                                                do: [:otherMorphsVertex | (otherMorphsVertex dist: p)
+                                                                                        < 3
+                                                                                ifTrue: [vertices at: ix put: otherMorphsVertex]]]]].
         (vertices size >= 2
                         and: ["check for too few vertices before deleting. The alternative
                                 is not pretty -wiz"
                                 ((vertices atWrap: ix - 1)
                                                 dist: p)
                                                 < 3
                                         or: [((vertices atWrap: ix + 1)
                                                         dist: p)
                                                         < 3]])
                 ifTrue: ["Drag a vertex onto its neighbor means delete"
+                        self deleteVertexAt: ix].
-                                self deleteVertexAt: ix .].
         evt shiftPressed
                 ifTrue: [self removeHandles]
                 ifFalse: [self addHandles
                         "remove then add to recreate"]!

Item was changed:
  ----- Method: PolygonMorph>>initialize (in category 'initialization') -----
  initialize
  "initialize the state of the receiver"
         super initialize.
  ""
         vertices := Array
                                 with: 5 @ 0
                                 with: 20 @ 10
                                 with: 0 @ 20.
         closed := true.
         smoothCurve := false.
         arrows := #none.
+        snapToOtherPolygons := false.
         self computeBounds!

Item was added:
+ ----- Method: PolygonMorph>>isSnappingToOtherPolygons (in category 'access') -----
+ isSnappingToOtherPolygons
+   ^snapToOtherPolygons ifNil:[ snapToOtherPolygons := false].
+  !

Item was added:
+ ----- Method: PolygonMorph>>toggleSnapToOtherPolygons (in category 'menu') -----
+ toggleSnapToOtherPolygons
+      ^snapToOtherPolygons := snapToOtherPolygons not!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200204/2414f4dd/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 107564 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200204/2414f4dd/attachment-0001.png>


More information about the Squeak-dev mailing list