aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorArthur Valadares2009-08-25 10:32:45 -0300
committerArthur Valadares2009-08-25 10:32:45 -0300
commitefb287f28f89eee06c6b90ad13297a2d33058409 (patch)
tree89c52c4babfd581f06a98f58de5763c193a710b5
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim into arthursv (diff)
downloadopensim-SC-efb287f28f89eee06c6b90ad13297a2d33058409.zip
opensim-SC-efb287f28f89eee06c6b90ad13297a2d33058409.tar.gz
opensim-SC-efb287f28f89eee06c6b90ad13297a2d33058409.tar.bz2
opensim-SC-efb287f28f89eee06c6b90ad13297a2d33058409.tar.xz
Implemented osPenCap, that sets EndCap and StartCap to Pen. This allows using arrow, diamond, round and flat caps.
* Made image request safer, if it can't find an image for any reason, draws a square where the image should be and a message alerting the user.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs77
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs9
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
4 files changed, 85 insertions, 7 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index d7f39b0..e577fbe 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -443,7 +443,16 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
443 endPoint.X = (int) x; 443 endPoint.X = (int) x;
444 endPoint.Y = (int) y; 444 endPoint.Y = (int) y;
445 Image image = ImageHttpRequest(nextLine); 445 Image image = ImageHttpRequest(nextLine);
446 graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y); 446 if (image != null)
447 {
448 graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y);
449 }
450 else
451 {
452 graph.DrawString("URL couldn't be resolved or is", new Font("Arial",6), myBrush, startPoint);
453 graph.DrawString("not an image. Please check URL.", new Font("Arial", 6), myBrush, new Point(startPoint.X, 12 + startPoint.Y));
454 graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
455 }
447 startPoint.X += endPoint.X; 456 startPoint.X += endPoint.X;
448 startPoint.Y += endPoint.Y; 457 startPoint.Y += endPoint.Y;
449 } 458 }
@@ -539,6 +548,57 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
539 float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); 548 float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture);
540 drawPen.Width = size; 549 drawPen.Width = size;
541 } 550 }
551 else if (nextLine.StartsWith("PenCap"))
552 {
553 bool start = true, end = true;
554 nextLine = nextLine.Remove(0, 6);
555 nextLine = nextLine.Trim();
556 string[] cap = nextLine.Split(partsDelimiter);
557 if (cap[0].ToLower() == "start")
558 end = false;
559 else if (cap[0].ToLower() == "end")
560 start = false;
561 else if (cap[0].ToLower() != "both")
562 return;
563 string type = cap[1].ToLower();
564
565 if (end)
566 {
567 switch (type)
568 {
569 case "arrow":
570 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
571 break;
572 case "round":
573 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
574 break;
575 case "diamond":
576 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
577 break;
578 case "flat":
579 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.Flat;
580 break;
581 }
582 }
583 if (start)
584 {
585 switch (type)
586 {
587 case "arrow":
588 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
589 break;
590 case "round":
591 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
592 break;
593 case "diamond":
594 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
595 break;
596 case "flat":
597 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.Flat;
598 break;
599 }
600 }
601 }
542 else if (nextLine.StartsWith("PenColour")) 602 else if (nextLine.StartsWith("PenColour"))
543 { 603 {
544 nextLine = nextLine.Remove(0, 9); 604 nextLine = nextLine.Remove(0, 9);
@@ -610,16 +670,19 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
610 670
611 private Bitmap ImageHttpRequest(string url) 671 private Bitmap ImageHttpRequest(string url)
612 { 672 {
673 try
674 {
613 WebRequest request = HttpWebRequest.Create(url); 675 WebRequest request = HttpWebRequest.Create(url);
614//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. 676//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
615//Ckrinke Stream str = null; 677//Ckrinke Stream str = null;
616 HttpWebResponse response = (HttpWebResponse) (request).GetResponse(); 678 HttpWebResponse response = (HttpWebResponse)(request).GetResponse();
617 if (response.StatusCode == HttpStatusCode.OK) 679 if (response.StatusCode == HttpStatusCode.OK)
618 { 680 {
619 Bitmap image = new Bitmap(response.GetResponseStream()); 681 Bitmap image = new Bitmap(response.GetResponseStream());
620 return image; 682 return image;
683 }
621 } 684 }
622 685 catch { }
623 return null; 686 return null;
624 } 687 }
625 } 688 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index b40e441..b1c357c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -879,6 +879,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
879 return drawList; 879 return drawList;
880 } 880 }
881 881
882 public string osSetPenCap(string drawList, string direction, string type)
883 {
884 CheckThreatLevel(ThreatLevel.None, "osSetPenColour");
885
886 m_host.AddScriptLPS(1);
887 drawList += "PenCap " + direction + "," + type + "; ";
888 return drawList;
889 }
890
882 public string osDrawImage(string drawList, int width, int height, string imageUrl) 891 public string osDrawImage(string drawList, int width, int height, string imageUrl)
883 { 892 {
884 CheckThreatLevel(ThreatLevel.None, "osDrawImage"); 893 CheckThreatLevel(ThreatLevel.None, "osDrawImage");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 202bf41..2365bee 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -101,6 +101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
101 string osSetFontSize(string drawList, int fontSize); 101 string osSetFontSize(string drawList, int fontSize);
102 string osSetPenSize(string drawList, int penSize); 102 string osSetPenSize(string drawList, int penSize);
103 string osSetPenColour(string drawList, string colour); 103 string osSetPenColour(string drawList, string colour);
104 string osSetPenCap(string drawList, string direction, string type);
104 string osDrawImage(string drawList, int width, int height, string imageUrl); 105 string osDrawImage(string drawList, int width, int height, string imageUrl);
105 vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize); 106 vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize);
106 void osSetStateEvents(int events); 107 void osSetStateEvents(int events);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index b6bfb43..f877acb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -282,6 +282,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
282 return m_OSSL_Functions.osSetPenSize(drawList, penSize); 282 return m_OSSL_Functions.osSetPenSize(drawList, penSize);
283 } 283 }
284 284
285 public string osSetPenCap(string drawList, string direction, string type)
286 {
287 return m_OSSL_Functions.osSetPenCap(drawList, direction, type);
288 }
289
285 public string osSetPenColour(string drawList, string colour) 290 public string osSetPenColour(string drawList, string colour)
286 { 291 {
287 return m_OSSL_Functions.osSetPenColour(drawList, colour); 292 return m_OSSL_Functions.osSetPenColour(drawList, colour);