Show Old_MoveAbleSpline.cs syntax highlighted
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Tao.Platform.Windows;
using Tao.OpenGl;
namespace New_Study_Project
{
public class MoveAbleSpline : Spline
{
/* Definitions of the Program */
private PointF Center;
/* Create Variables for Spline Creation and Interaction */
private ControlPoint c1, c2, c3, c4, c5, c6, c7, c8;
/* Create Buttons and the belonging stuff */
private PointF MovePoint, ResizePoint, ReshapePoint;
private ObjectButton MoveButton, ResizeButton, ReshapeButton;
private bool moving;
private bool resizing;
private bool reshaping;
private int logUserID;
private int logStartWidth;
private Point logStartPoint;
/* Create Drawing Stuff */
private int GlList_FG;
private int GlList_BG;
private int GLListArms;
private float[] vertexArray_BorderOutside;
private float[] vertexArray_BorderInside;
private float[] vertexArray_TriangleStrip;
private float[,] colorArray;
/* this is for the menu effect */
private float sinAlpha, cosAlpha;
/* End of Definitions of the Program */
public MoveAbleSpline(PointF center, PointF[] cornerpoints, InterfaceGrid IG, int objID, LogFile log, int[] IT)
{
int colorCounter;
this.typ = Typ.MoveAbleSpline;
this.Center = center;
this.nodeList = new List();
this.nodeList_old = new List();
this.interfaceSP = IG;
this.IconTextures = IT;
this.MOVINGControlPoint = null;
this.logfile = log;
this.ObjectID = objID;
this.fuzzyWidth = 30;
this.objScaleValue = 0.35f;
this.InterfaceObjectList = new ArrayList();
this.IOSelectObjectList = new ArrayList();
this.drawInterfaceObject = false;
/* Create the Spline */
this.c1 = new ControlPoint(cornerpoints[0], this, ControlPoint.State.OnlyCircle);
this.c2 = new ControlPoint(cornerpoints[1], this, ControlPoint.State.OnlyCircle);
this.c3 = new ControlPoint(cornerpoints[2], this, ControlPoint.State.OnlyCircle);
this.c4 = new ControlPoint(cornerpoints[3], this, ControlPoint.State.OnlyCircle);
this.c5 = new ControlPoint(cornerpoints[4], this, ControlPoint.State.OnlyCircle);
this.c6 = new ControlPoint(cornerpoints[5], this, ControlPoint.State.OnlyCircle);
this.c7 = new ControlPoint(cornerpoints[6], this, ControlPoint.State.OnlyCircle);
this.c8 = new ControlPoint(cornerpoints[7], this, ControlPoint.State.OnlyCircle);
this.nodeList.InsertAtBack(c1);
this.nodeList.InsertAtBack(c2);
this.nodeList.InsertAtBack(c3);
this.nodeList.InsertAtBack(c4);
this.nodeList.InsertAtBack(c5);
this.nodeList.InsertAtBack(c6);
this.nodeList.InsertAtBack(c7);
this.nodeList.InsertAtBack(c8);
this.nodeList_old.InsertAtBack(c1);
this.nodeList_old.InsertAtBack(c2);
this.nodeList_old.InsertAtBack(c3);
this.nodeList_old.InsertAtBack(c4);
this.nodeList_old.InsertAtBack(c5);
this.nodeList_old.InsertAtBack(c6);
this.nodeList_old.InsertAtBack(c7);
this.nodeList_old.InsertAtBack(c8);
this.Subdivision(5, nodeList, nodeList_old);
this.AddControlPoints();
this.vertexArray_BorderOutside = new float[nodeList.Length*2];
this.vertexArray_BorderInside = new float[nodeList.Length*2+4];
this.vertexArray_TriangleStrip = new float[nodeList.Length*4+4];
this.colorArray = new float[nodeList.Length*2+2,3];
this.fillVertexArrays();
/* filling the colorArray */
colorCounter = 0;
for(int nodes = 0; nodes<nodeList.Length; nodes++)
{
this.colorArray[colorCounter,0] = 1.0f;
this.colorArray[colorCounter,1] = 1.0f;
this.colorArray[colorCounter,2] = 1.0f;
colorCounter++;
this.colorArray[colorCounter,0] = 0.25f;
this.colorArray[colorCounter,1] = 0.25f;
this.colorArray[colorCounter,2] = 0.25f;
colorCounter++;
}
this.colorArray[colorCounter,0] = 1.0f;
this.colorArray[colorCounter,1] = 1.0f;
this.colorArray[colorCounter,2] = 1.0f;
colorCounter++;
this.colorArray[colorCounter,0] = 0.25f;
this.colorArray[colorCounter,1] = 0.25f;
this.colorArray[colorCounter,2] = 0.25f;
/* end of filling the colorArray */
this.createFGList();
this.createBGList();
this.create_List_Star();
/* create GLList for arms */
this.GLListArms = Gl.glGenLists(1);
Gl.glNewList(this.GLListArms, Gl.GL_COMPILE);
Gl.glPushMatrix();
Gl.glBegin(Gl.GL_LINE_STRIP);
Gl.glVertex2f(0.0f, 0.0f);
Gl.glVertex2f(0.0f, -32.0f);
Gl.glEnd();
Gl.glRotatef(-120.0f, 0.0f, 0.0f, 1.0f);
Gl.glBegin(Gl.GL_LINE_STRIP);
Gl.glVertex2f(0.0f, 0.0f);
Gl.glVertex2f(0.0f, -30.0f);
Gl.glEnd();
Gl.glRotatef(-120.0f, 0.0f, 0.0f, 1.0f);
Gl.glBegin(Gl.GL_LINE_STRIP);
Gl.glVertex2f(0.0f, 0.0f);
Gl.glVertex2f(0.0f, -30.0f);
Gl.glEnd();
Gl.glPopMatrix();
Gl.glEndList();
/* setting values */
this.menuArmScale = 15.0f;
this.fadeMenu = 0.0f;
this.menuScale = 0.0f;
this.waitCloseTime = 0;
this.SAVEControlPoint = null;
this.drawMenus = false;
this.drawOpenMenu = false;
/* Create Buttons for the menu */
this.MovePoint = new PointF(0.0f, 0.0f);
this.ResizePoint = new PointF(0.0f, 0.0f);
this.ReshapePoint = new PointF(0.0f, 0.0f);
this.MoveButton = new ObjectButton(this, new PointF(0.0f, 0.0f), ObjectButton.State.StoreMove);
this.ResizeButton = new ObjectButton(this, new PointF(0.0f, 0.0f), ObjectButton.State.StoreResize);
this.ReshapeButton = new ObjectButton(this, new PointF(0.0f, 0.0f), ObjectButton.State.StoreReshape);
this.logfile.StorageTerritoryMobileCreate(this.ObjectID, new Point((int) this.Center.X, (int) this.Center.Y), (int) this.distance(this.Center , new PointF(this.c1.getX, this.c1.getY)));
}
private void AddControlPoints()
{
ListNode currentNode = this.nodeList_old.FirstNode;
ListNode lastNode = this.nodeList_old.LastNode;
while(currentNode != lastNode)
{
this.interfaceSP.addControlPoint(currentNode.getControlPoint);
currentNode = currentNode.Next;
}
this.interfaceSP.addControlPoint(lastNode.getControlPoint);
}
private void RemoveControlPoints()
{
ListNode currentNode = this.nodeList_old.FirstNode;
ListNode lastNode = this.nodeList_old.LastNode;
while(currentNode != lastNode)
{
this.interfaceSP.removeControlPoint(currentNode.getControlPoint);
currentNode = currentNode.Next;
}
this.interfaceSP.removeControlPoint(lastNode.getControlPoint);
}
private void addStoreButtontoGrid()
{
this.interfaceSP.removeObjectButtons(this.MoveButton);
this.interfaceSP.removeObjectButtons(this.ResizeButton);
this.interfaceSP.removeObjectButtons(this.ReshapeButton);
this.MoveButton.Location = new PointF(this.MovePoint.X, this.MovePoint.Y);
this.MoveButton.LastLocation = this.MoveButton.Location;
this.ResizeButton.Location = new PointF(this.ResizePoint.X, this.ResizePoint.Y);
this.ResizeButton.LastLocation = this.ResizeButton.Location;
this.ReshapeButton.Location = new PointF(this.ReshapePoint.X, this.ReshapePoint.Y);
this.ReshapeButton.LastLocation = this.ReshapeButton.Location;
this.interfaceSP.addObjectButton(this.MoveButton);
this.interfaceSP.addObjectButton(this.ResizeButton);
this.interfaceSP.addObjectButton(this.ReshapeButton);
}
private void removeStoreButtonfromGrid()
{
this.interfaceSP.removeObjectButtons(this.MoveButton);
this.interfaceSP.removeObjectButtons(this.ResizeButton);
this.interfaceSP.removeObjectButtons(this.ReshapeButton);
}
private void Subdivision(int iteration, List list, List list_old)
{
int counter = iteration;
int step = 1;
float length = list_old.Length;
while(step != counter)
{
ListNode currentNode = list_old.LastNode;
ListNode firstNode = list_old.FirstNode;
while(currentNode != firstNode)
{
float X = -currentNode.Previous.getControlPoint.getX/16 + (9 * currentNode.getControlPoint.getX/16) + (9 * currentNode.Next.getControlPoint.getX/16) + ((-1) * currentNode.Next.Next.getControlPoint.getX/16);
float Y = -currentNode.Previous.getControlPoint.getY/16 + (9 * currentNode.getControlPoint.getY/16) + (9 * currentNode.Next.getControlPoint.getY/16) + ((-1) * currentNode.Next.Next.getControlPoint.getY/16);
PointF newPoint = new PointF(X, Y);
list.InsertBehind(currentNode.getControlPoint, new ControlPoint(newPoint, this, ControlPoint.State.OnlyCircle));
currentNode = currentNode.Previous;
}
if(currentNode == firstNode)
{
float X = -currentNode.Previous.getControlPoint.getX/16 + (9 * currentNode.getControlPoint.getX/16) + (9 * currentNode.Next.getControlPoint.getX/16) + ((-1) * currentNode.Next.Next.getControlPoint.getX/16);
float Y = -currentNode.Previous.getControlPoint.getY/16 + (9 * currentNode.getControlPoint.getY/16) + (9 * currentNode.Next.getControlPoint.getY/16) + ((-1) * currentNode.Next.Next.getControlPoint.getY/16);
PointF newPoint = new PointF(X, Y);
list.InsertBehind(currentNode.getControlPoint, new ControlPoint(newPoint, this, ControlPoint.State.OnlyCircle));
}
//alte NodeList loeschen
list_old.RemoveAll();
ListNode currentNode_new = list.FirstNode;
ListNode lastNode_new = list.LastNode;
while(currentNode_new != lastNode_new)
{
list_old.InsertAtBack(currentNode_new.getControlPoint);
currentNode_new = currentNode_new.Next;
}
list_old.InsertAtBack(lastNode_new.getControlPoint);
step = step + 1;
}
list_old.RemoveAll();
list_old.InsertAtBack(c1);
list_old.InsertAtBack(c2);
list_old.InsertAtBack(c3);
list_old.InsertAtBack(c4);
list_old.InsertAtBack(c5);
list_old.InsertAtBack(c6);
list_old.InsertAtBack(c7);
list_old.InsertAtBack(c8);
}
private void recaculateMoveAbleSpline()
{
this.nodeList.RemoveAll();
this.nodeList_old.RemoveAll();
this.nodeList.InsertAtBack(c1);
this.nodeList.InsertAtBack(c2);
this.nodeList.InsertAtBack(c3);
this.nodeList.InsertAtBack(c4);
this.nodeList.InsertAtBack(c5);
this.nodeList.InsertAtBack(c6);
this.nodeList.InsertAtBack(c7);
this.nodeList.InsertAtBack(c8);
this.nodeList_old.InsertAtBack(c1);
this.nodeList_old.InsertAtBack(c2);
this.nodeList_old.InsertAtBack(c3);
this.nodeList_old.InsertAtBack(c4);
this.nodeList_old.InsertAtBack(c5);
this.nodeList_old.InsertAtBack(c6);
this.nodeList_old.InsertAtBack(c7);
this.nodeList_old.InsertAtBack(c8);
this.Subdivision(5, nodeList, nodeList_old);
this.fillVertexArrays();
}
private void moveStorageArea(PointF MoveSAPoint)
{
int counter, counterStrip;
ListNode currentNodeIN, currentNodeOUT;
this.Center = new PointF(this.Center.X+MoveSAPoint.X, this.Center.Y+MoveSAPoint.Y);
counter = 0;
currentNodeIN = this.insideList.FirstNode;
currentNodeOUT = this.nodeList.FirstNode;
this.vertexArray_BorderInside[0] = this.Center.X;
this.vertexArray_BorderInside[1] = this.Center.Y;
for(int nodes = 0; nodes<nodeList.Length; nodes++)
{
currentNodeOUT.getControlPoint.setControlPoint(new PointF(currentNodeOUT.getControlPoint.getX + MoveSAPoint.X, currentNodeOUT.getControlPoint.getY + MoveSAPoint.Y));
currentNodeIN.getControlPoint.setControlPoint(new PointF(currentNodeIN.getControlPoint.getX + MoveSAPoint.X, currentNodeIN.getControlPoint.getY + MoveSAPoint.Y));
this.vertexArray_BorderOutside[counter] = currentNodeOUT.getControlPoint.getX;
this.vertexArray_BorderInside[counter+2] = currentNodeIN.getControlPoint.getX;
counter++;
this.vertexArray_BorderOutside[counter] = currentNodeOUT.getControlPoint.getY;
this.vertexArray_BorderInside[counter+2] = currentNodeIN.getControlPoint.getY;
counter++;
currentNodeIN = currentNodeIN.Next;
currentNodeOUT = currentNodeOUT.Next;
}
this.vertexArray_BorderInside[counter+2] = this.insideList.FirstNode.getControlPoint.getX;
counter++;
this.vertexArray_BorderInside[counter+2] = this.insideList.FirstNode.getControlPoint.getY;
counter = 0;
counterStrip = 0;
currentNodeIN = this.nodeList.FirstNode;
for(int nodes = 0; nodes<this.insideList.Length; nodes++)
{
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderOutside[counter];
counterStrip++;
counter++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderOutside[counter];
counterStrip++;
counter++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderInside[counter];
counterStrip++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderInside[counter+1];
counterStrip++;
currentNodeIN = currentNodeIN.Next;
}
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderOutside[0];
counterStrip++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderOutside[1];
counterStrip++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderInside[2];
counterStrip++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderInside[3];
}
private void resizeStorageArea(PointF oldPos, PointF newPos)
{
float VectorLengthOPP, new_dist, old_dist, proportion;
float getAngle, rotSin, rotCos;
double vectorAngle;
PointF vectorOLD, vectorNEW;
ListNode currentNodeOUT;
ListNode lastNodeOUT;
old_dist = this.distance(this.Center, this.MOVINGControlPoint.getControlPoint());
vectorOLD = new PointF((this.MOVINGControlPoint.getX-this.Center.X), (this.MOVINGControlPoint.getY-this.Center.Y));
VectorLengthOPP = 1.0f /((float) (Math.Sqrt((vectorOLD.X*vectorOLD.X)+(vectorOLD.Y*vectorOLD.Y))));
vectorOLD.X *= VectorLengthOPP;
vectorOLD.Y *= VectorLengthOPP;
newPos = new PointF(this.MOVINGControlPoint.getX+(newPos.X-oldPos.X), this.MOVINGControlPoint.getY+(newPos.Y-oldPos.Y));
new_dist = this.distance(this.Center, newPos);
vectorNEW = new PointF((newPos.X-this.Center.X), (newPos.Y-this.Center.Y));
VectorLengthOPP = 1.0f /((float) (Math.Sqrt((vectorNEW.X*vectorNEW.X)+(vectorNEW.Y*vectorNEW.Y))));
vectorNEW.X *= VectorLengthOPP;
vectorNEW.Y *= VectorLengthOPP;
proportion = new_dist/old_dist;
getAngle = ((vectorOLD.X*vectorNEW.X) + (vectorOLD.Y*vectorNEW.Y));
if (getAngle >= 1.0f) getAngle = 1.0f; // because of the rounding mistakes
if (getAngle <= -1.0f) getAngle = -1.0f;
vectorAngle = Math.Acos(getAngle);
vectorOLD = new PointF(-vectorOLD.Y, vectorOLD.X);
if ((vectorOLD.X*vectorNEW.X + vectorOLD.Y*vectorNEW.Y) < 0) vectorAngle = -vectorAngle;
rotSin = (float) Math.Sin(vectorAngle);
rotCos = (float) Math.Cos(vectorAngle);
currentNodeOUT = nodeList_old.FirstNode;
lastNodeOUT = nodeList_old.LastNode;
while(currentNodeOUT != lastNodeOUT)
{
currentNodeOUT.getControlPoint.setControlPoint (new PointF((currentNodeOUT.getControlPoint.getX-this.Center.X)*proportion, (currentNodeOUT.getControlPoint.getY-this.Center.Y)*proportion));
currentNodeOUT.getControlPoint.setControlPoint (new PointF((currentNodeOUT.getControlPoint.getX*rotCos - currentNodeOUT.getControlPoint.getY*rotSin), (currentNodeOUT.getControlPoint.getX*rotSin + currentNodeOUT.getControlPoint.getY*rotCos)));
currentNodeOUT.getControlPoint.setControlPoint (new PointF((currentNodeOUT.getControlPoint.getX+this.Center.X), (currentNodeOUT.getControlPoint.getY+this.Center.Y)));
currentNodeOUT = currentNodeOUT.Next;
}
currentNodeOUT.getControlPoint.setControlPoint (new PointF((currentNodeOUT.getControlPoint.getX-this.Center.X)*proportion, (currentNodeOUT.getControlPoint.getY-this.Center.Y)*proportion));
currentNodeOUT.getControlPoint.setControlPoint (new PointF((currentNodeOUT.getControlPoint.getX*rotCos - currentNodeOUT.getControlPoint.getY*rotSin), (currentNodeOUT.getControlPoint.getX*rotSin + currentNodeOUT.getControlPoint.getY*rotCos)));
currentNodeOUT.getControlPoint.setControlPoint (new PointF((currentNodeOUT.getControlPoint.getX+this.Center.X), (currentNodeOUT.getControlPoint.getY+this.Center.Y)));
this.nodeList.RemoveAll();
this.nodeList_old.RemoveAll();
this.nodeList.InsertAtBack(c1);
this.nodeList.InsertAtBack(c2);
this.nodeList.InsertAtBack(c3);
this.nodeList.InsertAtBack(c4);
this.nodeList.InsertAtBack(c5);
this.nodeList.InsertAtBack(c6);
this.nodeList.InsertAtBack(c7);
this.nodeList.InsertAtBack(c8);
this.nodeList_old.InsertAtBack(c1);
this.nodeList_old.InsertAtBack(c2);
this.nodeList_old.InsertAtBack(c3);
this.nodeList_old.InsertAtBack(c4);
this.nodeList_old.InsertAtBack(c5);
this.nodeList_old.InsertAtBack(c6);
this.nodeList_old.InsertAtBack(c7);
this.nodeList_old.InsertAtBack(c8);
this.Subdivision(5, nodeList, nodeList_old);
this.fillVertexArrays();
}
private float distance (PointF x, PointF y)
{
return (float)Math.Sqrt(((x.X - y.X)*(x.X - y.X)) + ((x.Y - y.Y)*(x.Y - y.Y)));
}
/*******************************************************************/
/* End of the head of this Object - now the user code stuff begins */
/*******************************************************************/
protected override void repositonIOSelectObjectToInside(IOSelectObject IOSEL, PointF lastP)
{
ListNode current = this.insideList.FirstNode;
ListNode last = this.insideList.LastNode;
float sqr_dist = (float) (Math.Pow((lastP.X - current.getControlPoint.getX),2) + Math.Pow((lastP.Y - current.getControlPoint.getY),2));
float sqr_dist2 = sqr_dist;
ListNode closest = current;
while(current != last)
{
current = current.Next;
sqr_dist2 = (float) (Math.Pow((lastP.X - current.getControlPoint.getX),2) + Math.Pow((lastP.Y - current.getControlPoint.getY),2));
if (sqr_dist2 < sqr_dist)
{
sqr_dist = sqr_dist2;
closest = current;
}
}
IOSEL.translateIOSelectObject(new PointF((closest.getControlPoint.getX-lastP.X), (closest.getControlPoint.getY-lastP.Y)));
}
protected override void repositonIOSelectObjectToOutside(IOSelectObject IOSEL, PointF lastP)
{
ListNode current = this.nodeList.FirstNode;
ListNode last = this.nodeList.LastNode;
float sqr_dist = (float) (Math.Pow((lastP.X - current.getControlPoint.getX),2) + Math.Pow((lastP.Y - current.getControlPoint.getY),2));
float sqr_dist2 = sqr_dist;
ListNode closest = current;
while(current != last)
{
current = current.Next;
sqr_dist2 = (float) (Math.Pow((lastP.X - current.getControlPoint.getX),2) + Math.Pow((lastP.Y - current.getControlPoint.getY),2));
if (sqr_dist2 < sqr_dist)
{
sqr_dist = sqr_dist2;
closest = current;
}
}
IOSEL.translateIOSelectObject(new PointF((closest.getControlPoint.getX-lastP.X), (closest.getControlPoint.getY-lastP.Y)));
}
protected override void repositonInterfaceObjectToInside(InterfaceObject obj, PointF lastP)
{
ListNode current = this.insideList.FirstNode;
ListNode last = this.insideList.LastNode;
float sqr_dist = (float) (Math.Pow((lastP.X - current.getControlPoint.getX),2) + Math.Pow((lastP.Y - current.getControlPoint.getY),2));
float sqr_dist2 = sqr_dist;
ListNode closest = current;
while(current != last)
{
current = current.Next;
sqr_dist2 = (float) (Math.Pow((lastP.X - current.getControlPoint.getX),2) + Math.Pow((lastP.Y - current.getControlPoint.getY),2));
if (sqr_dist2 < sqr_dist)
{
sqr_dist = sqr_dist2;
closest = current;
}
}
obj.translateInterfaceObject(new PointF((closest.getControlPoint.getX-lastP.X), (closest.getControlPoint.getY-lastP.Y)));
}
protected override void repositonInterfaceObjectToOutside(InterfaceObject obj, PointF lastP)
{
ListNode current = this.nodeList.FirstNode;
ListNode last = this.nodeList.LastNode;
float sqr_dist = (float) (Math.Pow((lastP.X - current.getControlPoint.getX),2) + Math.Pow((lastP.Y - current.getControlPoint.getY),2));
float sqr_dist2 = sqr_dist;
ListNode closest = current;
while(current != last)
{
current = current.Next;
sqr_dist2 = (float) (Math.Pow((lastP.X - current.getControlPoint.getX),2) + Math.Pow((lastP.Y - current.getControlPoint.getY),2));
if (sqr_dist2 < sqr_dist)
{
sqr_dist = sqr_dist2;
closest = current;
}
}
obj.translateInterfaceObject(new PointF((closest.getControlPoint.getX-lastP.X), (closest.getControlPoint.getY-lastP.Y)));
}
/*******************************************************************/
/* This are the drawing Functions which draw MoveSpline stuff */
/*******************************************************************/
private void fillVertexArrays()
{
int counter, counterStrip;
ListNode currentNode;
ListNode lastNode;
ControlPoint InsideC;
PointF SPVector1, SPVector2, SPVectorSum;
PointF newPoint;
float SPVectorLengthOPP;
/* filling vertexArray_BorderOutside */
counter = 0;
this.insideList = new List();
this.insideList_old = new List();
currentNode = nodeList.FirstNode;
for(int nodes = 0; nodes<nodeList.Length; nodes++)
{
this.vertexArray_BorderOutside[counter] = currentNode.getControlPoint.getX;
counter++;
this.vertexArray_BorderOutside[counter] = currentNode.getControlPoint.getY;
counter++;
currentNode = currentNode.Next;
}
/* computing and filling vertexArray_BorderInside */
currentNode = nodeList_old.FirstNode;
lastNode = nodeList_old.LastNode;
while(currentNode != lastNode)
{
SPVector1 = new PointF((currentNode.Previous.getControlPoint.getX-currentNode.getControlPoint.getX), (currentNode.Previous.getControlPoint.getY-currentNode.getControlPoint.getY));
SPVector1 = new PointF(SPVector1.Y, -SPVector1.X); // CrossProduct with Vector V(0,0,1)
/* normalize this vector */
SPVectorLengthOPP = 1.0f /((float) (Math.Sqrt((SPVector1.X*SPVector1.X)+(SPVector1.Y*SPVector1.Y))));
SPVector1.X *= SPVectorLengthOPP;
SPVector1.Y *= SPVectorLengthOPP;
SPVector2 = new PointF((currentNode.getControlPoint.getX-currentNode.Next.getControlPoint.getX), (currentNode.getControlPoint.getY-currentNode.Next.getControlPoint.getY));
SPVector2 = new PointF(SPVector2.Y, -SPVector2.X); // CrossProduct with Vector V(0,0,1)
/* normalize this vector */
SPVectorLengthOPP = 1.0f /((float) (Math.Sqrt((SPVector2.X*SPVector2.X)+(SPVector2.Y*SPVector2.Y))));
SPVector2.X *= SPVectorLengthOPP;
SPVector2.Y *= SPVectorLengthOPP;
SPVectorSum = new PointF(((SPVector1.X+SPVector2.X)), ((SPVector1.Y+SPVector2.Y)));
SPVectorLengthOPP = 1.0f /((float) (Math.Sqrt((SPVectorSum.X*SPVectorSum.X)+(SPVectorSum.Y*SPVectorSum.Y))));
SPVectorSum.X *= SPVectorLengthOPP;
SPVectorSum.Y *= SPVectorLengthOPP;
newPoint = new PointF((currentNode.getControlPoint.getX+SPVectorSum.X*fuzzyWidth), (currentNode.getControlPoint.getY+SPVectorSum.Y*fuzzyWidth));
InsideC = new ControlPoint(newPoint, this, ControlPoint.State.OnlyCircle);
this.insideList.InsertAtBack(InsideC);
this.insideList_old.InsertAtBack(InsideC);
currentNode = currentNode.Next;
}
SPVector1 = new PointF((currentNode.Previous.getControlPoint.getX-currentNode.getControlPoint.getX), (currentNode.Previous.getControlPoint.getY-currentNode.getControlPoint.getY));
SPVector1 = new PointF(SPVector1.Y, -SPVector1.X); // CrossProduct with Vector V(0,0,1)
/* normalize this vector */
SPVectorLengthOPP = 1.0f /((float) (Math.Sqrt((SPVector1.X*SPVector1.X)+(SPVector1.Y*SPVector1.Y))));
SPVector1.X *= SPVectorLengthOPP;
SPVector1.Y *= SPVectorLengthOPP;
SPVector2 = new PointF((currentNode.getControlPoint.getX-currentNode.Next.getControlPoint.getX), (currentNode.getControlPoint.getY-currentNode.Next.getControlPoint.getY));
SPVector2 = new PointF(SPVector2.Y, -SPVector2.X); // CrossProduct with Vector V(0,0,1)
/* normalize this vector */
SPVectorLengthOPP = 1.0f /((float) (Math.Sqrt((SPVector2.X*SPVector2.X)+(SPVector2.Y*SPVector2.Y))));
SPVector2.X *= SPVectorLengthOPP;
SPVector2.Y *= SPVectorLengthOPP;
SPVectorSum = new PointF(((SPVector1.X+SPVector2.X)), ((SPVector1.Y+SPVector2.Y)));
SPVectorLengthOPP = 1.0f /((float) (Math.Sqrt((SPVectorSum.X*SPVectorSum.X)+(SPVectorSum.Y*SPVectorSum.Y))));
SPVectorSum.X *= SPVectorLengthOPP;
SPVectorSum.Y *= SPVectorLengthOPP;
newPoint = new PointF((currentNode.getControlPoint.getX+SPVectorSum.X*fuzzyWidth), (currentNode.getControlPoint.getY+SPVectorSum.Y*fuzzyWidth));
InsideC = new ControlPoint(newPoint, this, ControlPoint.State.OnlyCircle);
this.insideList.InsertAtBack(InsideC);
this.insideList_old.InsertAtBack(InsideC);
this.Subdivision(5, insideList, insideList_old);
counter = 0;
currentNode = insideList.FirstNode;
this.vertexArray_BorderInside[counter] = this.Center.X;
counter++;
this.vertexArray_BorderInside[counter] = this.Center.Y;
counter++;
for(int nodes = 0; nodes<this.insideList.Length; nodes++)
{
this.vertexArray_BorderInside[counter] = currentNode.getControlPoint.getX;
counter++;
this.vertexArray_BorderInside[counter] = currentNode.getControlPoint.getY;
counter++;
currentNode = currentNode.Next;
}
this.vertexArray_BorderInside[counter] = insideList.FirstNode.getControlPoint.getX;
counter++;
this.vertexArray_BorderInside[counter] = insideList.FirstNode.getControlPoint.getY;
counter++;
/* filling vertexArray_TriangleStrip and the colorArray */
counter = 0;
counterStrip = 0;
for(int nodes = 0; nodes<this.insideList.Length; nodes++)
{
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderOutside[counter];
counterStrip++;
counter++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderOutside[counter];
counterStrip++;
counter++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderInside[counter];
counterStrip++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderInside[counter+1];
counterStrip++;
currentNode = currentNode.Next;
}
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderOutside[0];
counterStrip++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderOutside[1];
counterStrip++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderInside[2];
counterStrip++;
this.vertexArray_TriangleStrip[counterStrip] = this.vertexArray_BorderInside[3];
}
private void createFGList()
{
this.GlList_FG = Gl.glGenLists(1);
Gl.glNewList(this.GlList_FG, Gl.GL_COMPILE);
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glPushMatrix();
Gl.glColor4f(0.2f, 0.4f, 0.8f, 0.3f);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_BorderInside);
Gl.glDrawArrays(Gl.GL_TRIANGLE_FAN, 0, nodeList.Length+2);
Gl.glColor4f(0.3f, 0.6f, 0.9f, 0.15f);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_TriangleStrip);
Gl.glDrawArrays(Gl.GL_TRIANGLE_STRIP, 0, nodeList.Length*2+2);
Gl.glLineWidth(1.5f);
Gl.glColor4f(0.2f, 0.5f, 0.9f, 1.0f);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_BorderInside);
Gl.glDrawArrays(Gl.GL_LINE_LOOP, 1, nodeList.Length);
Gl.glLineWidth(2.0f);
Gl.glColor4f(0.2f, 0.5f, 0.9f, 1.0f);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_BorderOutside);
Gl.glDrawArrays(Gl.GL_LINE_LOOP, 0, nodeList.Length);
Gl.glPopMatrix();
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glEndList();
}
private void createBGList()
{
this.GlList_BG = Gl.glGenLists(1);
Gl.glNewList(this.GlList_BG, Gl.GL_COMPILE);
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glPushName(99);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_BorderInside);
Gl.glDrawArrays(Gl.GL_TRIANGLE_FAN, 0, nodeList.Length+2);
Gl.glPopName();
Gl.glPushName(66);
Gl.glEnableClientState(Gl.GL_COLOR_ARRAY);
Gl.glColorPointer(3, Gl.GL_FLOAT, 0, colorArray);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_TriangleStrip);
Gl.glDrawArrays(Gl.GL_TRIANGLE_STRIP, 0, nodeList.Length*2+2);
Gl.glDisableClientState(Gl.GL_COLOR_ARRAY);
Gl.glPopName();
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glEndList();
}
public override void drawSpline(bool moveSP)
{
if (moveSP == true)
{
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glPushMatrix();
Gl.glColor4f(0.2f, 0.4f, 0.8f, 0.3f);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_BorderInside);
Gl.glDrawArrays(Gl.GL_TRIANGLE_FAN, 0, nodeList.Length+2);
Gl.glColor4f(0.3f, 0.6f, 0.9f, 0.15f);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_TriangleStrip);
Gl.glDrawArrays(Gl.GL_TRIANGLE_STRIP, 0, nodeList.Length*2+2);
Gl.glLineWidth(1.5f);
Gl.glColor4f(0.2f, 0.5f, 0.9f, 1.0f);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_BorderInside);
Gl.glDrawArrays(Gl.GL_LINE_LOOP, 1, nodeList.Length);
Gl.glLineWidth(2.0f);
Gl.glColor4f(0.2f, 0.5f, 0.9f, 1.0f);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_BorderOutside);
Gl.glDrawArrays(Gl.GL_LINE_LOOP, 0, nodeList.Length);
Gl.glPopMatrix();
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
}
else
{
Gl.glPushMatrix();
Gl.glCallList(this.GlList_FG);
Gl.glPopMatrix();
}
/* drawing Controlpoints */
ListNode currentNode = nodeList_old.FirstNode;
ListNode lastNode = nodeList_old.LastNode;
while(currentNode != lastNode)
{
Gl.glPushMatrix();
Gl.glTranslatef(currentNode.getControlPoint.getX, currentNode.getControlPoint.getY, 0.0f);
this.drawControlPoints();
Gl.glPopMatrix();
currentNode = currentNode.Next;
}
Gl.glPushMatrix();
Gl.glTranslatef(currentNode.getControlPoint.getX, currentNode.getControlPoint.getY, 0.0f);
this.drawControlPoints();
Gl.glPopMatrix();
/* draw the centerpoint */
if (this.drawMenus == true)
{
Gl.glPushMatrix();
Gl.glTranslatef(this.Center.X, this.Center.Y, 0.0f);
Gl.glScalef(this.menuArmScale*1.4f, this.menuArmScale*1.4f, 1.0f);
this.drawControlPoints();
Gl.glPopMatrix();
}
/* draw InterfaceObjects if there are any inside */
if(this.drawInterfaceObject == true)
{
foreach (IOSelectObject IOSEL in this.IOSelectObjectList)
{
IOSEL.drawIOSelectObject(true);
}
foreach (InterfaceObject obj in this.InterfaceObjectList)
{
obj.drawInterfaceObject(true);
}
}
/* draw the menus */
if (this.drawMenus == true)
{
Gl.glPushMatrix();
Gl.glTranslatef(menuPos.X, menuPos.Y, 0.0f);
Gl.glRotatef(this.menuAngle, 0.0f, 0.0f, 1.0f);
Gl.glPushMatrix();
Gl.glLineWidth(1.5f);
Gl.glColor4f(0.2f, 0.5f, 1.0f, this.fadeMenu);
Gl.glScalef(this.menuArmScale, this.menuArmScale, 1.0f);
Gl.glCallList(this.GLListArms);
Gl.glPopMatrix();
this.drawMoveIcon(new PointF(-1.0f, -29.0f));
this.drawResizeIcon(new PointF(28.0f, 15.0f));
this.drawReshapeIcon(new PointF(-28.0f, 15.0f));
Gl.glPopMatrix();
/* calculations for the effect of the menu */
if (this.drawOpenMenu == true)
{
if (this.fadeMenu >= 1.0f)
{
if (this.fadeMenu > 1.0f) this.fadeMenu = 1.0f;
this.menuScale = this.menuScale + 0.2f;
if (this.menuScale >= 1.0f)
{
this.menuScale = 1.0f;
if (this.moving == false && this.resizing == false && this.reshaping == false) this.addStoreButtontoGrid();
this.drawOpenMenu = false;
}
}
else
{
this.fadeMenu = this.fadeMenu + 0.2f;
this.menuArmScale = this.menuArmScale + 0.2f;
}
}
if (this.drawCloseMenu == true && this.drawOpenMenu == false)
{
if (this.waitCloseTime < 100) this.waitCloseTime++;
else
{
this.menuScale = this.menuScale - 0.2f;
if (this.menuScale <= 0.0f)
{
if (this.menuScale < 0.0f) this.menuScale = 0.0f;
this.fadeMenu = this.fadeMenu - 0.2f;
this.menuArmScale = this.menuArmScale - 0.2f;
if (this.fadeMenu <= 0.0f)
{
this.fadeMenu = 0.0f;
this.removeStoreButtonfromGrid();
this.drawMenus = false;
this.drawCloseMenu = false;
}
}
}
}
}
/* End of calculations for the effect of the menu */
}
public override void drawBackGround(bool moveSP)
{
if (moveSP == true)
{
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glPushMatrix();
Gl.glPushName(99);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_BorderInside);
Gl.glDrawArrays(Gl.GL_TRIANGLE_FAN, 0, this.nodeList.Length+2);
Gl.glPopName();
Gl.glPushName(66);
Gl.glEnableClientState(Gl.GL_COLOR_ARRAY);
Gl.glColorPointer(3, Gl.GL_FLOAT, 0, this.colorArray);
Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, this.vertexArray_TriangleStrip);
Gl.glDrawArrays(Gl.GL_TRIANGLE_STRIP, 0, this.nodeList.Length*2+2);
Gl.glDisableClientState(Gl.GL_COLOR_ARRAY);
Gl.glPopName();
Gl.glPopMatrix();
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
}
else
{
Gl.glPushMatrix();
Gl.glCallList(this.GlList_BG);
Gl.glPopMatrix();
}
}
private void drawMoveIcon(PointF pos)
{
Gl.glPushMatrix();
Gl.glTranslatef(pos.X, pos.Y, 0.0f);
Gl.glScalef(this.menuScale, this.menuScale, 1.0f);
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBlendFunc(Gl.GL_DST_COLOR,Gl.GL_ZERO);// Blend Screen Color With Zero (Black)
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[2]);
Gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex2f(-16.0f, -16.0f); // bottom Left
Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex2f(-16.0f, +16.0f); // top Left
Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex2f(+16.0f, +16.0f); // top Right
Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex2f(+16.0f, -16.0f); // bottom Right
Gl.glEnd();
Gl.glBlendFunc(Gl.GL_ONE, Gl.GL_ONE);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[3]);
Gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex2f(-16.0f, -16.0f); // bottom Left
Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex2f(-16.0f, +16.0f); // top Left
Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex2f(+16.0f, +16.0f); // top Right
Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex2f(+16.0f, -16.0f); // bottom Right
Gl.glEnd();
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
Gl.glDisable(Gl.GL_TEXTURE_2D);
Gl.glPopMatrix();
}
private void drawResizeIcon(PointF pos)
{
Gl.glPushMatrix();
Gl.glTranslatef(pos.X, pos.Y, 0.0f);
Gl.glRotatef(75.0f, 0.0f, 0.0f, 1.0f);
Gl.glScalef(this.menuScale, this.menuScale, 1.0f);
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBlendFunc(Gl.GL_DST_COLOR,Gl.GL_ZERO);// Blend Screen Color With Zero (Black)
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[4]);
Gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex2f(-16.0f, -16.0f); // bottom Left
Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex2f(-16.0f, +16.0f); // top Left
Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex2f(+16.0f, +16.0f); // top Right
Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex2f(+16.0f, -16.0f); // bottom Right
Gl.glEnd();
Gl.glBlendFunc(Gl.GL_ONE, Gl.GL_ONE);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[5]);
Gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex2f(-16.0f, -16.0f); // bottom Left
Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex2f(-16.0f, +16.0f); // top Left
Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex2f(+16.0f, +16.0f); // top Right
Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex2f(+16.0f, -16.0f); // bottom Right
Gl.glEnd();
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
Gl.glDisable(Gl.GL_TEXTURE_2D);
Gl.glPopMatrix();
}
private void drawReshapeIcon(PointF pos)
{
Gl.glPushMatrix();
Gl.glTranslatef(pos.X, pos.Y, 0.0f);
Gl.glRotatef(15.0f, 0.0f, 0.0f, 1.0f);
Gl.glScalef(this.menuScale, this.menuScale, 1.0f);
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBlendFunc(Gl.GL_DST_COLOR,Gl.GL_ZERO);// Blend Screen Color With Zero (Black)
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[6]);
Gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex2f(-16.0f, -16.0f); // bottom Left
Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex2f(-16.0f, +16.0f); // top Left
Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex2f(+16.0f, +16.0f); // top Right
Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex2f(+16.0f, -16.0f); // bottom Right
Gl.glEnd();
Gl.glBlendFunc(Gl.GL_ONE, Gl.GL_ONE);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[7]);
Gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex2f(-16.0f, -16.0f); // bottom Left
Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex2f(-16.0f, +16.0f); // top Left
Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex2f(+16.0f, +16.0f); // top Right
Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex2f(+16.0f, -16.0f);// bottom Right
Gl.glEnd();
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
Gl.glDisable(Gl.GL_TEXTURE_2D);
Gl.glPopMatrix();
}
/*******************************************************************/
/* drawing menus */
/*******************************************************************/
private void open_menu(PointF pos)
{
PointF vectorCC;
float lengthVCC, bogenAngle;
if (this.drawMenus == false || this.MOVINGControlPoint != this.SAVEControlPoint)
{
this.menuPos = pos;
vectorCC = new PointF((this.Center.X-pos.X), (this.Center.Y-pos.Y));
/* normalize vector */
lengthVCC = 1.0f /((float) (Math.Sqrt((vectorCC.X*vectorCC.X)+(vectorCC.Y*vectorCC.Y))));
vectorCC.X *= lengthVCC;
vectorCC.Y *= -lengthVCC; // changing the sign because the Y-axis is going up
/* computing the dot product to find out the angle and the direction of the angle */
if (vectorCC.Y >= 1) vectorCC.Y = 1.0f; // because of the rounding mistakes
if (vectorCC.Y <= -1) vectorCC.Y = -1.0f;
if (vectorCC.X>0)
{
bogenAngle = (float) Math.Acos(vectorCC.Y);
this.menuAngle = (float) (180.0*bogenAngle/ Math.PI);
}
else
{
bogenAngle = (float) -Math.Acos(vectorCC.Y);
this.menuAngle = (float) (180.0*bogenAngle/ Math.PI);
}
this.sinAlpha = (float) Math.Sin(bogenAngle);
this.cosAlpha = (float) Math.Cos(bogenAngle);
this.MovePoint.X = 29*this.sinAlpha+this.menuPos.X;
this.MovePoint.Y = -29*this.cosAlpha+this.menuPos.Y;
this.ResizePoint.X = 28*this.cosAlpha-15*this.sinAlpha+this.menuPos.X;
this.ResizePoint.Y = 28*this.sinAlpha+15*this.cosAlpha+this.menuPos.Y;
this.ReshapePoint.X = -28*this.cosAlpha-15*this.sinAlpha+this.menuPos.X;
this.ReshapePoint.Y = -28*this.sinAlpha+15*this.cosAlpha+this.menuPos.Y;
this.removeStoreButtonfromGrid();
this.fadeMenu = 0.0f;
this.menuScale = 0.0f;
this.menuArmScale = 0.0f;
}
this.drawOpenMenu = true;
this.drawMenus = true;
this.drawCloseMenu = false;
}
private void close_menu()
{
this.waitCloseTime = 0;
this.drawCloseMenu = true;
}
private void refreshButtonPositions()
{
this.MovePoint.X = 29*this.sinAlpha+this.menuPos.X;
this.MovePoint.Y = -29*this.cosAlpha+this.menuPos.Y;
this.ResizePoint.X = 28*this.cosAlpha-15*this.sinAlpha+this.menuPos.X;
this.ResizePoint.Y = 28*this.sinAlpha+15*this.cosAlpha+this.menuPos.Y;
this.ReshapePoint.X = -28*this.cosAlpha-15*this.sinAlpha+this.menuPos.X;
this.ReshapePoint.Y = -28*this.sinAlpha+15*this.cosAlpha+this.menuPos.Y;
}
/*******************************************************************/
/* Mouse Events */
/*******************************************************************/
public override void mouseDOWN(ControlPoint MOVINGCP, int inputID)
{
this.interfaceSP.removeWholeMoveSpline(this);
this.removeInterfaceObjectsFromGrid();
this.RemoveControlPoints();
this.drawInterfaceObject = true;
this.MOVINGControlPoint = MOVINGCP;
this.open_menu(new PointF(MOVINGCP.getX, MOVINGCP.getY));
this.SAVEControlPoint = MOVINGCP;
this.logUserID = inputID;
this.moving = false;
this.resizing = false;
this.reshaping = false;
}
public override void mouseMOVE(Point MOVEPoint)
{
if (this.moving == false && this.resizing == false && this.reshaping == false)
{
ObjectButton getStoreButton = this.interfaceSP.getAssociatedObjectButton(new Point((int)(MOVEPoint.X), (int) (MOVEPoint.Y)));
if (getStoreButton != null && (getStoreButton == this.MoveButton || getStoreButton == this.ResizeButton || getStoreButton == this.ReshapeButton))
{
if (getStoreButton.getState.Equals(ObjectButton.State.StoreMove))
{
this.MOVINGSplinePoint = MOVEPoint;
this.logStartPoint = new Point((int) (this.MOVINGControlPoint.getX), (int) (this.MOVINGControlPoint.getY));
this.moving = true;
}
else if (getStoreButton.getState.Equals(ObjectButton.State.StoreResize))
{
this.MOVINGSplinePoint = MOVEPoint;
this.logStartPoint = new Point((int) (this.MOVINGControlPoint.getX), (int) (this.MOVINGControlPoint.getY));
this.logStartWidth = (int) this.distance(new PointF(this.MOVINGControlPoint.getX, this.MOVINGControlPoint.getY), this.Center);
this.resizing = true;
}
else if (getStoreButton.getState.Equals(ObjectButton.State.StoreReshape))
{
this.MOVINGSplinePoint = MOVEPoint;
this.logStartPoint = new Point((int) (this.MOVINGControlPoint.getX), (int) (this.MOVINGControlPoint.getY));
this.logStartWidth = (int) this.distance(new PointF(this.MOVINGControlPoint.getX, this.MOVINGControlPoint.getY), this.Center);
this.reshaping = true;
}
this.removeStoreButtonfromGrid();
}
}
else
{
if (this.moving == true)
{
PointF MOVPoint = new PointF((MOVEPoint.X-this.MOVINGSplinePoint.X), (MOVEPoint.Y-this.MOVINGSplinePoint.Y));
this.moveStorageArea(MOVPoint);
this.translateInterfaceObjects(MOVPoint);
this.menuPos.X = MOVINGControlPoint.getX;
this.menuPos.Y = MOVINGControlPoint.getY;
this.MOVINGSplinePoint = MOVEPoint;
}
else if (this.resizing == true)
{
this.resizeStorageArea(this.MOVINGSplinePoint, MOVEPoint);
this.menuPos.X = MOVINGControlPoint.getX;
this.menuPos.Y = MOVINGControlPoint.getY;
this.MOVINGSplinePoint = MOVEPoint;
this.testInterfaceObjectsInStorageArea();
this.testIOSelectObjectsInStorageArea();
}
else if (this.reshaping == true)
{
PointF RSHPoint = new PointF((MOVEPoint.X-this.MOVINGSplinePoint.X), (MOVEPoint.Y-this.MOVINGSplinePoint.Y));
this.MOVINGControlPoint.moveControlPoint(RSHPoint);
this.menuPos.X = MOVINGControlPoint.getX;
this.menuPos.Y = MOVINGControlPoint.getY;
this.recaculateMoveAbleSpline();
this.MOVINGSplinePoint = MOVEPoint;
this.testInterfaceObjectsInStorageArea();
this.testIOSelectObjectsInStorageArea();
}
}
}
public override void mouseUP(Point UPPoint)
{
int logEndWidth;
this.createFGList();
this.createBGList();
/* end of for logfile stuff */
if (this.moving == true)
{
this.logfile.StorageTerritoryMobileMove(this.logUserID, this.ObjectID, this.logStartPoint, new Point((int) (this.MOVINGControlPoint.getX), (int) (this.MOVINGControlPoint.getY)));
}
else if (this.resizing == true)
{
logEndWidth = (int) this.distance(new PointF(this.MOVINGControlPoint.getX, this.MOVINGControlPoint.getY), this.Center);
this.logfile.StorageTerritoryMobileResize(this.logUserID, this.ObjectID, this.logStartPoint, new Point((int) (this.MOVINGControlPoint.getX), (int) (this.MOVINGControlPoint.getY)), this.logStartWidth, logEndWidth);
}
else if (this.reshaping == true)
{
logEndWidth = (int) this.distance(new PointF(this.MOVINGControlPoint.getX, this.MOVINGControlPoint.getY), this.Center);
this.logfile.StorageTerritoryMobileReshape(this.logUserID, this.ObjectID, this.logStartPoint, new Point((int) (this.MOVINGControlPoint.getX), (int) (this.MOVINGControlPoint.getY)), this.logStartWidth, logEndWidth);
}
/* for logfile stuff */
this.moving = false;
this.resizing = false;
this.reshaping = false;
this.drawInterfaceObject = false;
this.interfaceSP.addWholeMoveSpline(this);
this.addInterfaceObjectsToGrid();
this.AddControlPoints();
this.refreshButtonPositions();
this.addStoreButtontoGrid();
this.close_menu();
}
public override void clickedStorageButton(Point CLICKEDPoint, ObjectButton getStoreButton, int inputID)
{
this.open_menu(new PointF(this.MOVINGControlPoint.getX, this.MOVINGControlPoint.getY));
if (getStoreButton.getState.Equals(ObjectButton.State.StoreMove))
{
this.MOVINGSplinePoint = CLICKEDPoint;
this.logUserID = inputID;
this.logStartPoint = new Point((int) (this.MOVINGControlPoint.getX), (int) (this.MOVINGControlPoint.getY));
this.moving = true;
}
else if (getStoreButton.getState.Equals(ObjectButton.State.StoreResize))
{
this.MOVINGSplinePoint = CLICKEDPoint;
this.logUserID = inputID;
this.logStartPoint = new Point((int) (this.MOVINGControlPoint.getX), (int) (this.MOVINGControlPoint.getY));
this.logStartWidth = (int) this.distance(new PointF(this.MOVINGControlPoint.getX, this.MOVINGControlPoint.getY), this.Center);
this.resizing = true;
}
else if (getStoreButton.getState.Equals(ObjectButton.State.StoreReshape))
{
this.MOVINGSplinePoint = CLICKEDPoint;
this.logUserID = inputID;
this.logStartPoint = new Point((int) (this.MOVINGControlPoint.getX), (int) (this.MOVINGControlPoint.getY));
this.logStartWidth = (int) this.distance(new PointF(this.MOVINGControlPoint.getX, this.MOVINGControlPoint.getY), this.Center);
this.reshaping = true;
}
this.interfaceSP.removeWholeMoveSpline(this);
this.removeInterfaceObjectsFromGrid();
this.RemoveControlPoints();
this.removeStoreButtonfromGrid();
this.drawInterfaceObject = true;
}
public override void changeBorderSize(int valueSize)
{
this.fuzzyWidth = valueSize;
this.nodeList.RemoveAll();
this.nodeList_old.RemoveAll();
this.nodeList.InsertAtBack(c1);
this.nodeList.InsertAtBack(c2);
this.nodeList.InsertAtBack(c3);
this.nodeList.InsertAtBack(c4);
this.nodeList.InsertAtBack(c5);
this.nodeList.InsertAtBack(c6);
this.nodeList.InsertAtBack(c7);
this.nodeList.InsertAtBack(c8);
this.nodeList_old.InsertAtBack(c1);
this.nodeList_old.InsertAtBack(c2);
this.nodeList_old.InsertAtBack(c3);
this.nodeList_old.InsertAtBack(c4);
this.nodeList_old.InsertAtBack(c5);
this.nodeList_old.InsertAtBack(c6);
this.nodeList_old.InsertAtBack(c7);
this.nodeList_old.InsertAtBack(c8);
this.Subdivision(5, nodeList, nodeList_old);
this.fillVertexArrays();
this.createFGList();
this.createBGList();
}
public override void changeObjectSize(float objSize)
{
int colorCounter;
this.objScaleValue = objSize;
colorCounter = 0;
for(int nodes = 0; nodes<nodeList.Length; nodes++)
{
this.colorArray[colorCounter,0] = 1.0f;
this.colorArray[colorCounter,1] = 1.0f;
this.colorArray[colorCounter,2] = 1.0f;
colorCounter++;
this.colorArray[colorCounter,0] = this.objScaleValue;
this.colorArray[colorCounter,1] = this.objScaleValue;
this.colorArray[colorCounter,2] = this.objScaleValue;
colorCounter++;
}
this.colorArray[colorCounter,0] = 1.0f;
this.colorArray[colorCounter,1] = 1.0f;
this.colorArray[colorCounter,2] = 1.0f;
colorCounter++;
this.colorArray[colorCounter,0] = this.objScaleValue;
this.colorArray[colorCounter,1] = this.objScaleValue;
this.colorArray[colorCounter,2] = this.objScaleValue;
this.createFGList();
this.createBGList();
}
/*******************************************************************/
/* ----------------------------------------------------------- */
/*******************************************************************/
}
}
See more files for this project here