« Back to Fachhochschule Nordwestschweiz FHNW

Combining several CLIPs in GraphRep

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Combining several CLIPs in GraphRep
community graphrep documentation
Answer
3/27/14 11:35 AM
I would like to create a resizeable shape, that is a composition of a rectangle and two half-circles.
More precisely, top and bottom parts should be linear as in a rectangle and the right and left sides being regular arcs looking like the two halfs of a circle.
I've tried using CLIP_ROUNDRECT but it doesn't allow me to keep the arcs as half of a circle and the CLIP_ELLIPSE doesn't allow me to keep the upper and downer parts linear. See the image below.
I was wondering if it was possible to create a composition of clippings, as a CLIP_RECTANGLE + a CLIP_ELLIPSE to have as result a shape like the second one of the image.
Attachment

Attachments: mile.PNG (12.3k)

RE: Combining several CLIPs in GraphRep
graphrep table clip_ellipse clip_rect arc
Answer
3/20/14 12:50 PM as a reply to Arianna Pierfranceschi.
Dear Arianna,
This is a very interesting application scenario.
I think the best solution would be to combine one CLIP_RECT and two CLIP_ELLIPSE statements in your GraphRep using the keyword  combine-mode: with the value or.

Below is a solution that I would suggest for this case.
The solution involves defining a table, so the result can be flexibly combined with other graphical elements like for example additional icons, minimum width or height and so on.
In the central part of the table, we combine three CLIP_ statements, as described above, we draw a rectangle (or gradient rectangle, as it results from your image) over this clipped area and then we draw a borded around it.
 1GRAPHREP sizing:asymmetrical
 2SHADOW on
 3
 4#definition of colors
 5SET colBrd: (rgbval("$1646B6"))
 6SET colFFm: (rgbval("white"))
 7SET colFTo: (rgbval("$2655C4"))
 8
 9#definition of the table
10TABLE   x: -1.5cm y: -0.6cm w: 3.0cm h: 1.2cm  cols:3 rows:3
11             w1: 0.25cm w2: 100% w3: 0.25cm
12             h1: 0.10cm h2: 100% h3:0.10cm
13STRETCH off
14
15SET tabw: (tabx2 - tabx1)
16       tabh: (taby2 - taby1)
17
18#set "CLIP_" area
19CLIP_RECT x: (tabx1) y: (taby1) w: (tabw) h: (tabh)
20CLIP_ELLIPSE x: (tabx1) y: (taby1 + tabh*0.5) rx: (tabh*0.5) ry: (tabh*0.5) combine-mode: or
21CLIP_ELLIPSE x: (tabx1 + tabw) y: (taby1 + tabh*0.5) rx: (tabh*0.5) ry: (tabh*0.5) combine-mode: or
22
23#draw a gradient rectangle
24GRADIENT_RECT x: (tabx1 - tabh*0.5) y: (taby1)               
25              w: (tabw + tabh) h: (tabh)
26              style: downdiag
27              color1: (colFFm) color2: (colFTo)
28
29#finish drawing in the "CLIP_" area
30CLIP_OFF
31
32#draw the border around the shape
33PEN w: 0.04cm color: (colBrd)
34
35LINE x1: (tabx1) y1: (taby1) x2: (tabx1 + tabw) y2: (taby1)
36LINE x1: (tabx1) y1: (taby1 + tabh) x2: (tabx1 + tabw) y2: (taby1 + tabh)
37
38ARC x: (tabx1) y: (taby1 + tabh*0.5) rx: (tabh*0.5) ry: (tabh*0.5)
39        x1: (tabx1) y1: (taby1)
40        x2: (tabx1) y2: (taby1 + tabh)
41
42ARC x: (tabx1 + tabw) y: (taby1 + tabh*0.5) rx: (tabh*0.5) ry: (tabh*0.5)
43        x1: (tabx1 + tabw) y1: (taby1 + tabh)
44        x2: (tabx1 + tabw) y2: (taby1)
45
46#continue with other elements that are to be drawn (icons, text, attribute values, etc.)
47...

The attached file coordinates.png contains a sketch with the defined coordinates.
The attached file samples.png shows how this graphrep behaves in the modelling area.
Attachment

Attachment

Attachments: coordinates.png (53.3k), samples.png (84.1k)