Skip to content

Commit

Permalink
new flowsheet object icons
Browse files Browse the repository at this point in the history
  • Loading branch information
DanWBR committed Sep 20, 2022
1 parent c953253 commit ce384d3
Show file tree
Hide file tree
Showing 34 changed files with 2,405 additions and 2,184 deletions.
11 changes: 10 additions & 1 deletion DWSIM.Drawing.SkiaSharp/GraphicObjects/Base/GraphicObject.vb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Namespace GraphicObjects

Friend EmbeddedResourceIconName As String = ""

Friend Image As SKImage

Public Function GetFont() As SKTypeface

Select Case FontStyle
Expand Down Expand Up @@ -490,7 +492,14 @@ Namespace GraphicObjects

If EmbeddedResourceIconName <> "" Then

Return Me.GetType().Assembly.GetManifestResourceStream(String.Format("DWSIM.Drawing.SkiaSharp.{0}", EmbeddedResourceIconName))
Using us = Me.GetType().Assembly.GetManifestResourceStream(String.Format("DWSIM.Drawing.SkiaSharp.{0}", EmbeddedResourceIconName))

Dim ms As New MemoryStream()
us.CopyTo(ms)
ms.Position = 0
Return ms

End Using

Else

Expand Down
104 changes: 63 additions & 41 deletions DWSIM.Drawing.SkiaSharp/GraphicObjects/Base/ShapeGraphic.vb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ Namespace GraphicObjects

End Sub

Friend Sub DrawIcon(canvas As SKCanvas)

If Image Is Nothing Then

Using streamBG = GetIconAsStream()
Using bitmap = SKBitmap.Decode(streamBG)
Image = SKImage.FromBitmap(bitmap)
End Using
End Using

End If

Using p As New SKPaint With {.IsAntialias = False, .FilterQuality = SKFilterQuality.None}
canvas.DrawImage(Image, New SKRect(X, Y, X + Width, Y + Height), p)
End Using

End Sub

Public Sub DrawCalculatingMode(ByVal canvas As SKCanvas)

If CalculatingImage Is Nothing Then
Expand Down Expand Up @@ -597,7 +615,7 @@ Namespace GraphicObjects

Case 2

'Gas/Liquid Flows
DrawIcon(g)

Case 3

Expand All @@ -613,56 +631,60 @@ Namespace GraphicObjects

End Select

Dim rect2 As New SKRect(X + (0.25 - 0.14) * Width, Y + (0.5 - 0.14 / 2) * Height, X + 0.25 * Width, Y + (0.5 - 0.14 / 2) * Height + 0.14 * Height)
Dim rect3 As New SKRect(X + 0.75 * Width, Y + 0.1 * Height, X + 0.75 * Width + 0.14 * Width, Y + 0.1 * Height + 0.14 * Height)
Dim rect4 As New SKRect(X + 0.75 * Width, Y + (0.9 - 0.14) * Height, X + 0.75 * Width + 0.14 * Width, Y + (0.9 - 0.14) * Height + 0.14 * Height)
If DrawMode <> 2 Then

If DrawMode = 0 Then
Dim rect2 As New SKRect(X + (0.25 - 0.14) * Width, Y + (0.5 - 0.14 / 2) * Height, X + 0.25 * Width, Y + (0.5 - 0.14 / 2) * Height + 0.14 * Height)
Dim rect3 As New SKRect(X + 0.75 * Width, Y + 0.1 * Height, X + 0.75 * Width + 0.14 * Width, Y + 0.1 * Height + 0.14 * Height)
Dim rect4 As New SKRect(X + 0.75 * Width, Y + (0.9 - 0.14) * Height, X + 0.75 * Width + 0.14 * Width, Y + (0.9 - 0.14) * Height + 0.14 * Height)

Dim gradPen As New SKPaint()
With gradPen
.Color = LineColor.WithAlpha(50)
.StrokeWidth = LineWidth
.IsStroke = False
.IsAntialias = GlobalSettings.Settings.DrawingAntiAlias
End With
If DrawMode = 0 Then

g.DrawRoundRect(New SKRect(X + 0.25 * Width, Y, X + 0.75 * Width, Y + Height), 5, 5, gradPen)
g.DrawRect(rect2, gradPen)
g.DrawRect(rect3, gradPen)
g.DrawRect(rect4, gradPen)
Dim gradPen As New SKPaint()
With gradPen
.Color = LineColor.WithAlpha(50)
.StrokeWidth = LineWidth
.IsStroke = False
.IsAntialias = GlobalSettings.Settings.DrawingAntiAlias
End With

End If
g.DrawRoundRect(New SKRect(X + 0.25 * Width, Y, X + 0.75 * Width, Y + Height), 5, 5, gradPen)
g.DrawRect(rect2, gradPen)
g.DrawRect(rect3, gradPen)
g.DrawRect(rect4, gradPen)

g.DrawRoundRect(New SKRect(X + 0.25 * Width, Y, X + 0.75 * Width, Y + Height), 5, 5, myPen)
g.DrawRect(rect2, myPen)
g.DrawRect(rect3, myPen)
g.DrawRect(rect4, myPen)
End If

Dim trect As New SKRect(0, 0, 2, 2)
tPen.GetTextPath(TypeName, 0, 0).GetBounds(trect)
Dim size As New SKSize(trect.Right - trect.Left, trect.Top - trect.Bottom)
g.DrawRoundRect(New SKRect(X + 0.25 * Width, Y, X + 0.75 * Width, Y + Height), 5, 5, myPen)
g.DrawRect(rect2, myPen)
g.DrawRect(rect3, myPen)
g.DrawRect(rect4, myPen)

Dim ax, ay As Integer
If Me.FlippedH Then
ax = Me.X + (Me.Width - size.Width) / 2 - 1.0
ay = Me.Y + Me.Height * 0.8 - size.Height
Else
ax = Me.X + (Me.Width - size.Width) / 2 - 1.0
ay = Me.Y + Me.Height * 0.8 - size.Height
End If
Dim trect As New SKRect(0, 0, 2, 2)
tPen.GetTextPath(TypeName, 0, 0).GetBounds(trect)
Dim size As New SKSize(trect.Right - trect.Left, trect.Top - trect.Bottom)

Using New SKAutoCanvasRestore(g)
StraightCanvas(g)
g.DrawText(TypeName, ax, ay, tPen)
End Using
Dim ax, ay As Integer
If Me.FlippedH Then
ax = Me.X + (Me.Width - size.Width) / 2 - 1.0
ay = Me.Y + Me.Height * 0.8 - size.Height
Else
ax = Me.X + (Me.Width - size.Width) / 2 - 1.0
ay = Me.Y + Me.Height * 0.8 - size.Height
End If

Using New SKAutoCanvasRestore(g)
StraightCanvas(g)
g.DrawText(TypeName, ax, ay, tPen)
End Using

'Draw interior packing

'Draw interior packing
g.DrawPoints(SKPointMode.Polygon, New SKPoint() {New SKPoint(X + 0.25 * Width, Y + 0.3 * Height), New SKPoint(X + 0.75 * Width, Me.Y + 0.3 * Height)}, myPen)
g.DrawPoints(SKPointMode.Polygon, New SKPoint() {New SKPoint(X + 0.25 * Width, Y + 0.7 * Height), New SKPoint(X + 0.75 * Width, Me.Y + 0.7 * Height)}, myPen)
g.DrawPoints(SKPointMode.Polygon, New SKPoint() {New SKPoint(X + 0.25 * Width, Y + 0.3 * Height), New SKPoint(X + 0.75 * Width, Me.Y + 0.7 * Height)}, myPen)
g.DrawPoints(SKPointMode.Polygon, New SKPoint() {New SKPoint(X + 0.25 * Width, Y + 0.7 * Height), New SKPoint(X + 0.75 * Width, Me.Y + 0.3 * Height)}, myPen)

g.DrawPoints(SKPointMode.Polygon, New SKPoint() {New SKPoint(X + 0.25 * Width, Y + 0.3 * Height), New SKPoint(X + 0.75 * Width, Me.Y + 0.3 * Height)}, myPen)
g.DrawPoints(SKPointMode.Polygon, New SKPoint() {New SKPoint(X + 0.25 * Width, Y + 0.7 * Height), New SKPoint(X + 0.75 * Width, Me.Y + 0.7 * Height)}, myPen)
g.DrawPoints(SKPointMode.Polygon, New SKPoint() {New SKPoint(X + 0.25 * Width, Y + 0.3 * Height), New SKPoint(X + 0.75 * Width, Me.Y + 0.7 * Height)}, myPen)
g.DrawPoints(SKPointMode.Polygon, New SKPoint() {New SKPoint(X + 0.25 * Width, Y + 0.7 * Height), New SKPoint(X + 0.75 * Width, Me.Y + 0.3 * Height)}, myPen)
End If

End Sub

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,8 @@ Namespace GraphicObjects
ConnectorPath = path

Select Case DrawMode
Case 0

Case 0, 2

'default

Expand Down
15 changes: 9 additions & 6 deletions DWSIM.Drawing.SkiaSharp/GraphicObjects/Shapes/CSTR.vb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ Namespace GraphicObjects.Shapes
With InputConnectors

If .Count <> 0 Then
.Item(0).Position = New Point(X, Y + 0.5 * Height)
If DrawMode = 2 Then
.Item(0).Position = New Point(X + 0.05 * Width, Y + 0.1 * Height)
Else
.Item(0).Position = New Point(X, Y + 0.5 * Height)
End If
.Item(1).Position = New Point(X + 0.125 * Width, Y + 0.7 * Height)
Else
.Add(myIC1)
Expand All @@ -88,13 +92,12 @@ Namespace GraphicObjects.Shapes
With OutputConnectors

If .Count <> 0 Then
If Me.FlippedH Then
.Item(0).Position = New Point(X, Y + 0.5 * Height)
.Item(1).Position = New Point(X + 0.5 * Width, Y)
If DrawMode = 2 Then
.Item(0).Position = New Point(X + Width, Y + 0.7825 * Height)
Else
.Item(0).Position = New Point(X + Width, Y + 0.5 * Height)
.Item(1).Position = New Point(X + 0.5 * Width, Y)
End If
.Item(1).Position = New Point(X + 0.5 * Width, Y)
Else
.Add(myOC1)
.Add(myOC2)
Expand Down Expand Up @@ -213,7 +216,7 @@ Namespace GraphicObjects.Shapes

Case 2

'Gas/Liquid Flows
DrawIcon(canvas)

Case 3

Expand Down
74 changes: 53 additions & 21 deletions DWSIM.Drawing.SkiaSharp/GraphicObjects/Shapes/Compressor.vb
Original file line number Diff line number Diff line change
Expand Up @@ -42,43 +42,74 @@ Namespace GraphicObjects.Shapes

Public Overrides Sub CreateConnectors(InCount As Integer, OutCount As Integer)

Dim myIC1 As New ConnectionPoint
myIC1.Position = New Point(X, Y + 0.5 * Height)
myIC1.Type = ConType.ConIn
Me.EnergyConnector.Active = False

Dim myIC2 As New ConnectionPoint
myIC2.Position = New Point(X + 0.5 * Width, Y + Height)
myIC2.Type = ConType.ConEn
Dim myIC1, myIC2, myOC1 As New ConnectionPoint

Dim myOC1 As New ConnectionPoint
myOC1.Position = New Point(X + Width, Y + 0.5 * Height)
myOC1.Type = ConType.ConOut
If DrawMode = 2 Then

Me.EnergyConnector.Position = New Point(X + 0.5 * Width, Y + Height)
Me.EnergyConnector.Type = ConType.ConEn
Me.EnergyConnector.Direction = ConDir.Up
Me.EnergyConnector.Active = False
myIC1.Position = New Point(X + 0.386 * Width, Y + 0.28 * Height)
myIC1.Type = ConType.ConIn
myIC1.Direction = ConDir.Down

myIC2.Position = New Point(X, Y + 0.5 * Height)
myIC2.Type = ConType.ConEn
myIC2.Direction = ConDir.Right

myOC1.Position = New Point(X + 0.906 * Width, Y + 0.374 * Height)
myOC1.Type = ConType.ConOut
myOC1.Direction = ConDir.Up

Else

myIC1.Position = New Point(X, Y)
myIC1.Type = ConType.ConIn
myIC1.Direction = ConDir.Down

myIC2.Position = New Point(X, Y + 0.5 * Height)
myIC2.Type = ConType.ConEn
myIC2.Direction = ConDir.Right

myOC1.Position = New Point(X + Width, Y + 0.3 * Height)
myOC1.Type = ConType.ConOut
myOC1.Direction = ConDir.Up

End If

With InputConnectors

If .Count = 2 Then
.Item(0).Position = New Point(X, Y + 0.5 * Height)
.Item(1).Position = New Point(X + 0.5 * Width, Y + Height)
If DrawMode = 2 Then
.Item(0).Position = New Point(X + 0.386 * Width, Y + 0.28 * Height)
.Item(1).Position = New Point(X, Y + 0.5 * Height)
.Item(0).Direction = ConDir.Down
.Item(1).Direction = ConDir.Right
Else
.Item(0).Position = New Point(X, Y)
.Item(1).Position = New Point(X, Y + 0.5 * Height)
.Item(0).Direction = ConDir.Down
.Item(1).Direction = ConDir.Right
End If
Else
.Add(myIC1)
.Add(myIC2)
End If

.Item(0).ConnectorName = "Inlet"
.Item(1).ConnectorName = "Energy Stream"
.Item(1).Direction = ConDir.Up

End With

With OutputConnectors

If .Count <> 0 Then
.Item(0).Position = New Point(X + Width, Y + 0.5 * Height)
If DrawMode = 2 Then
.Item(0).Position = New Point(X + 0.906 * Width, Y + 0.374 * Height)
.Item(0).Direction = ConDir.Up
Else
.Item(0).Position = New Point(X + Width, Y + 0.3 * Height)
.Item(0).Direction = ConDir.Up
End If
Else
.Add(myOC1)
End If
Expand All @@ -98,10 +129,8 @@ Namespace GraphicObjects.Shapes

MyBase.Draw(g)


Dim myPen As New SKPaint()


Dim rect As New SKRect(X, Y, X + Width, X + Height)

Dim gp As New SKPath()
Expand Down Expand Up @@ -136,6 +165,8 @@ Namespace GraphicObjects.Shapes
.IsAntialias = GlobalSettings.Settings.DrawingAntiAlias
End With

canvas.DrawPath(gp, myPen)

Case 1

'b/w
Expand All @@ -149,9 +180,11 @@ Namespace GraphicObjects.Shapes

End With

canvas.DrawPath(gp, myPen)

Case 2

'Gas/Liquid Flows
DrawIcon(canvas)

Case 3

Expand All @@ -166,7 +199,6 @@ Namespace GraphicObjects.Shapes
'Temperature/Pressure Gradients

End Select
canvas.DrawPath(gp, myPen)

End Sub

Expand Down
2 changes: 1 addition & 1 deletion DWSIM.Drawing.SkiaSharp/GraphicObjects/Shapes/Cooler.vb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Namespace GraphicObjects.Shapes

Case 2

'Gas/Liquid Flows
DrawIcon(canvas)

Case 3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ Namespace GraphicObjects.Shapes
canvas.DrawPath(gp, myPen2)

Case 2
'Gas/Liquid Flows

DrawIcon(canvas)

Case 3
'Temperature Gradients
Case 4
Expand Down
Loading

0 comments on commit ce384d3

Please sign in to comment.