Show IOSelectObject.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;
using Whiteboard;
using Whiteboard.MaseWS;
namespace New_Study_Project
{
public class IOSelectObject : Object
{
/* Definitions of the Program */
public PointF CentrePoint;
/* calulating stuff */
private enum State{Nothing, Moving, Resizing};
private State state;
private InterfaceGrid interfaceIOSelect;
private ArrayList InterfaceOBJList;
private ArrayList animateObjects;
public RNTObject RNTSELObj;
private PointF TopLeft;
private PointF TopRight;
private PointF BottomRight;
private PointF BottomLeft;
private PointF lastMousePoint;
private PointF slideVector;
private float slideValue;
private float SELObjectMax_X, SELObjectMin_X, SELObjectMax_Y, SELObjectMin_Y;
private int storedAreaPart;
private bool IOSELObjectInsideSplineArea;
private bool rntCalculation;
private bool waitOneStep;
private bool wasSelected;
private Spline IOSELObjInArea;
private InterfaceObject lastHitObject;
//private webServicesService ws;
/* drawing stuff */
private int GLListCircle;
private float SELRed;
private float SELGreen;
private float SELBlue;
private float newScaleValue;
private float fadeScaleValue;
private float currentScaleValue;
private float difScale;
private float zoomValue;
private bool SELchanged;
private int SELColorNumber;
private ArrayList SELColorList;
/* End of Definitions of the Program */
public IOSelectObject(InterfaceGrid IG, int objID, ArrayList animate)
{
this.interfaceIOSelect = IG;
this.InterfaceOBJList = new ArrayList();
this.SELchanged = false;
this.state = State.Nothing;
this.storedAreaPart = 0;
this.IOSELObjectInsideSplineArea = false;
this.IOSELObjInArea = null;
this.rntCalculation = false;
this.waitOneStep = false;
this.currentScaleValue = 1.0f;
this.newScaleValue = 1.0f;
this.fadeScaleValue = 1.0f;
this.difScale = 0.0f;
this.zoomValue = 35.0f;
this.lastHitObject = null;
this.wasSelected = false;
this.slideVector = new PointF(0.0f, 0.0f);
this.slideValue = 0.0f;
this.animateObjects = animate;
//this.ws = SingleWS.getInstance(null);
this.createCircleList();
}
/*******************************************************************/
/* End of the head of this Object - now the user code stuff begins */
/*******************************************************************/
public void addInterfaceObject(InterfaceObject IObj, int inputID)
{
IObj.endSlideBySelection();
this.InterfaceOBJList.Add(IObj);
if(IObj.getIOSelectObject() != null)
{
IObj.getIOSelectObject().endSlideByReselection();
IObj.getIOSelectObject().removeInterfaceObject(IObj, inputID);
}
IObj.setIOSelectObject(this);
}
public void removeInterfaceObject(InterfaceObject IObj, int inputID)
{
this.InterfaceOBJList.Remove(IObj);
if (this.InterfaceOBJList.Count == 0)
{
this.interfaceIOSelect.removeIOSelectObject(this);
this.SELColorList.Remove(this.SELColorNumber);
/*if (this.IOSELObjectInsideSplineArea == true)
{
if (this.storedAreaPart == 66) this.logStartContext = LogFile.Context.InFuzzyBoundary;
else this.logStartContext = LogFile.Context.InStorageTerritory;
}
else this.logStartContext = LogFile.Context.OutsideTerritory;*/
if (this.IOSELObjInArea != null)
{
this.IOSELObjInArea.removeIOSelectObjectFromSpline(this);
this.IOSELObjInArea = null;
this.IOSELObjectInsideSplineArea = true;
}
//this.logfile.SelectionEmpty(this.ObjectID, inputID, this.logStartContext);
}
else if (this.SELchanged == false) this.SELchanged = true;
}
public ArrayList getIOSelectObjectList()
{
return this.InterfaceOBJList;
}
public void initializeIOSelectObject(float red, float green, float blue, int cn, ArrayList cl, Point boxUpLeft, Point boxDownRight, int inputID)
{
if (this.InterfaceOBJList.Count > 0)
{
this.SELRed = red;
this.SELGreen = green;
this.SELBlue = blue;
this.SELColorNumber = cn;
this.SELColorList = cl;
this.SELObjectMax_X = ((InterfaceObject) this.InterfaceOBJList[0]).CentrePoint.X;
this.SELObjectMin_X = ((InterfaceObject) this.InterfaceOBJList[0]).CentrePoint.X;
this.SELObjectMax_Y = ((InterfaceObject) this.InterfaceOBJList[0]).CentrePoint.Y;
this.SELObjectMin_Y = ((InterfaceObject) this.InterfaceOBJList[0]).CentrePoint.Y;
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
this.findBoundingBox(SELObj.getTopLeft());
this.findBoundingBox(SELObj.getTopRight());
this.findBoundingBox(SELObj.getBottomLeft());
this.findBoundingBox(SELObj.getBottomRight());
SELObj.setStatusSelected(this.SELRed, this.SELGreen, this.SELBlue);
this.interfaceIOSelect.removeObject(SELObj);
}
this.TopLeft = new PointF(this.SELObjectMin_X, this.SELObjectMin_Y);
this.TopRight = new PointF(this.SELObjectMax_X, this.SELObjectMin_Y);
this.BottomRight = new PointF(this.SELObjectMax_X, this.SELObjectMax_Y);
this.BottomLeft = new PointF(this.SELObjectMin_X, this.SELObjectMax_Y);
this.RNTSELObj = new RNTObject(this.TopLeft, this.TopRight, this.BottomRight, this.BottomLeft, 35);
this.CentrePoint = this.RNTSELObj.Center;
this.lastMousePoint = this.CentrePoint;
this.isIOSelectObjectAbobeSpline();
this.interfaceIOSelect.addIOSelectObject(this);
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.beforSEL(this.currentScaleValue);
}
this.removeCompletly();
this.interfaceIOSelect.addIOSelectObjectShadow(this);
this.wasSelected = true;
/*if (this.IOSELObjectInsideSplineArea == true)
{
if (this.storedAreaPart == 66) this.logStartContext = LogFile.Context.InFuzzyBoundary;
else this.logStartContext = LogFile.Context.InStorageTerritory;
}
else this.logStartContext = LogFile.Context.OutsideTerritory;
this.logfile.SelectionCreate(this.ObjectID, inputID, this.InterfaceOBJList, this.logStartContext, boxUpLeft, boxDownRight);*/
}
}
public void findBoundingBox(PointF bBox)
{
if (bBox.X < this.SELObjectMin_X) this.SELObjectMin_X = bBox.X;
if (bBox.Y < this.SELObjectMin_Y) this.SELObjectMin_Y = bBox.Y;
if (bBox.X > this.SELObjectMax_X) this.SELObjectMax_X = bBox.X;
if (bBox.Y > this.SELObjectMax_Y) this.SELObjectMax_Y = bBox.Y;
}
public PointF[] BoundingBox()
{
this.lastHitObject = null;
float[] cornerX = {this.TopLeft.X, this.TopRight.X, this.BottomRight.X, this.BottomLeft.X};
float[] cornerY = {this.TopLeft.Y, this.TopRight.Y, this.BottomRight.Y, this.BottomLeft.Y};
cornerX = this.Sort(cornerX);
cornerY = this.Sort(cornerY);
PointF min = new PointF(cornerX[0], cornerY[0]);
PointF max = new PointF(cornerX[cornerX.Length - 1], cornerY[cornerY.Length - 1]);
PointF[] boundingBox = {new PointF(min.X-20, min.Y-20), new PointF(max.X+20, min.Y-20), new PointF(max.X+20, max.Y+20), new PointF(min.X-20, max.Y+20)};
return boundingBox;
}
public bool InsideObject(PointF point)
{
bool side;
int counter;
side = false;
counter = 0;
if (this.lastHitObject != null)
{
if (this.lastHitObject.InsideObject(point) == true) side = true;
else this.lastHitObject = null;
}
while (counter < this.InterfaceOBJList.Count && side == false)
{
if (((InterfaceObject)this.InterfaceOBJList[counter]).InsideObject(point) == true )
{
side = true;
this.lastHitObject = ((InterfaceObject)this.InterfaceOBJList[counter]);
}
counter++;
}
if (side == false)
{
counter = 0;
while (counter < this.InterfaceOBJList.Count && side == false)
{
ObjectButton OBtn = ((InterfaceObject)this.InterfaceOBJList[counter]).getResizeButton();
if (point.X >= (OBtn.Location.X-10) && point.X <= (OBtn.Location.X+10) && point.Y >= (OBtn.Location.Y-10) && point.Y <= (OBtn.Location.Y+10)) side = true;
counter++;
}
}
if (side == false)
{
if (this.squareDistance(this.CentrePoint, point) <= (this.RNTSELObj.TranslateOnlyZoneRadius*this.RNTSELObj.TranslateOnlyZoneRadius)) side = true;
}
return side;
}
private float[] Sort(float[]array)
{
int n = array.Length;
int i, j;
float t;
for( i = 1; i < n; i++)
{
j = i;
t = array[j];
while(j > 0 && array[j - 1] > t)
{
array[j] = array[j - 1];
j--;
}
array[j] = t;
}
return array;
}
private float squareDistance (PointF x, PointF y)
{
return (((x.X - y.X)*(x.X - y.X)) + ((x.Y - y.Y)*(x.Y - y.Y)));
}
public void update(int inputID)
{
if (this.InterfaceOBJList.Count > 0 && (this.SELchanged == true))
{
this.interfaceIOSelect.updateRemoveIOSelectObject(this);
this.SELObjectMax_X = ((InterfaceObject) this.InterfaceOBJList[0]).CentrePoint.X;
this.SELObjectMin_X = ((InterfaceObject) this.InterfaceOBJList[0]).CentrePoint.X;
this.SELObjectMax_Y = ((InterfaceObject) this.InterfaceOBJList[0]).CentrePoint.Y;
this.SELObjectMin_Y = ((InterfaceObject) this.InterfaceOBJList[0]).CentrePoint.Y;
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
this.findBoundingBox(SELObj.getTopLeft());
this.findBoundingBox(SELObj.getTopRight());
this.findBoundingBox(SELObj.getBottomLeft());
this.findBoundingBox(SELObj.getBottomRight());
SELObj.setStatusSelected(this.SELRed, this.SELGreen, this.SELBlue);
this.interfaceIOSelect.removeObject(SELObj);
}
this.TopLeft = new PointF(this.SELObjectMin_X, this.SELObjectMin_Y);
this.TopRight = new PointF(this.SELObjectMax_X, this.SELObjectMin_Y);
this.BottomRight = new PointF(this.SELObjectMax_X, this.SELObjectMax_Y);
this.BottomLeft = new PointF(this.SELObjectMin_X, this.SELObjectMax_Y);
this.RNTSELObj.updateRNTObject(this.TopLeft, this.TopRight, this.BottomRight, this.BottomLeft, this);
this.CentrePoint = this.RNTSELObj.Center;
this.lastMousePoint = this.CentrePoint;
this.interfaceIOSelect.updateAddIOSelectObject(this);
this.SELchanged = false;
/*if (this.IOSELObjectInsideSplineArea == true)
{
if (this.storedAreaPart == 66) this.logStartContext = LogFile.Context.InFuzzyBoundary;
else this.logStartContext = LogFile.Context.InStorageTerritory;
}
else this.logStartContext = LogFile.Context.OutsideTerritory;
this.logfile.SelectionUpdate(this.ObjectID, inputID, this.InterfaceOBJList, this.logStartContext);*/
}
}
public void endSelection()
{
this.endSlideByReselection();
this.interfaceIOSelect.removeIOSelectObject(this);
if (this.IOSELObjInArea != null) this.IOSELObjInArea.removeIOSelectObjectFromSpline(this);
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.removeOnlyButtonsFromGrid();
}
this.RNTSELObj.testInsideDesktop(this.InterfaceOBJList);
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.setIOSelectObject(null);
SELObj.setStatusUnselected();
this.interfaceIOSelect.addObjectShadow(SELObj);
SELObj.afterSELTest();
//this.interfaceIOSelect.addObject(SELObj);
//SELObj.addOnlyButtonsToGrid();
}
this.InterfaceOBJList.Clear();
this.SELColorList.Remove(this.SELColorNumber);
}
public void continueCalculateRNTObject()
{
if (this.state != State.Resizing)
{
if (this.wasSelected == true || this.slideValue > 0.15f || !(this.fadeScaleValue >= (this.currentScaleValue-0.001) && this.fadeScaleValue <= (this.currentScaleValue+0.001)))
{
this.RNTSELObj.RNTSelMoveNScale(this.lastMousePoint, this.fadeScaleValue, this.currentScaleValue, this.InterfaceOBJList);
this.updateBoundingBox();
this.currentScaleValue = this.fadeScaleValue;
}
}
}
public void addCompletly()
{
this.interfaceIOSelect.addIOSelectObject(this);
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.addOnlyButtonsToGrid();
}
}
public void removeCompletly()
{
this.interfaceIOSelect.removeIOSelectObject(this);
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.removeOnlyButtonsFromGrid();
}
}
public void translateIOSelectObject(PointF translatePoint)
{
this.RNTSELObj.RNTTransalteMove(translatePoint);
this.CentrePoint = this.RNTSELObj.Center;
this.TopLeft = this.RNTSELObj.TopLeft;
this.TopRight = this.RNTSELObj.TopRight;
this.BottomRight = this.RNTSELObj.BottomRight;
this.BottomLeft = this.RNTSELObj.BottomLeft;
foreach (InterfaceObject obj in this.InterfaceOBJList)
{
obj.translateInterfaceObject(translatePoint);
}
this.lastMousePoint = new PointF(this.lastMousePoint.X+translatePoint.X, this.lastMousePoint.Y+translatePoint.Y);
}
public void translateEndIOSelectObject()
{
this.RNTSELObj.RNTTransalteEnd();
this.CentrePoint = this.RNTSELObj.Center;
this.TopLeft = this.RNTSELObj.TopLeft;
this.TopRight = this.RNTSELObj.TopRight;
this.BottomRight = this.RNTSELObj.BottomRight;
this.BottomLeft = this.RNTSELObj.BottomLeft;
foreach (InterfaceObject obj in this.InterfaceOBJList)
{
obj.translateEndInterfaceObject();
}
}
public void updateBoundingBox()
{
if (this.InterfaceOBJList.Count > 0)
{
this.CentrePoint = this.RNTSELObj.Center;
this.TopLeft = this.RNTSELObj.TopLeft;
this.TopRight = this.RNTSELObj.TopRight;
this.BottomRight = this.RNTSELObj.BottomRight;
this.BottomLeft = this.RNTSELObj.BottomLeft;
}
}
private void revertIOSelectObjConfiguration()
{
if (this.InterfaceOBJList.Count > 0)
{
RNTSELObj.Center = this.CentrePoint;
RNTSELObj.TopLeft = this.TopLeft;
RNTSELObj.TopRight = this.TopRight;
RNTSELObj.BottomRight = this.BottomRight;
RNTSELObj.BottomLeft = this.BottomLeft;
}
}
private void moveIOSELObject(Point mousePoint)
{
this.RNTSELObj.RNTSelMoveNScale(mousePoint, this.fadeScaleValue, this.currentScaleValue, this.InterfaceOBJList);
if(Utility.checkPtWithBoundry(mousePoint))
{
this.updateBoundingBox();
this.currentScaleValue = this.fadeScaleValue;
}
else
{
revertIOSelectObjConfiguration();
mouseUP(mousePoint);
}
}
private void moveNresizeIOSELObject(Point mousePoint, Spline belowSpline)
{
float[] pixel = new float[3];
int[] viewport = new int[4];
bool newCalc;
if (this.storedAreaPart != 99)
{
Gl.glGetIntegerv(Gl.GL_VIEWPORT,viewport);
Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
belowSpline.drawBackGround(false);
Gl.glReadPixels(mousePoint.X,viewport[3]-mousePoint.Y,1,1,Gl.GL_RGB,Gl.GL_FLOAT,pixel);
if (pixel[0] < belowSpline.getObjectScaleValue()) pixel[0] = belowSpline.getObjectScaleValue();
if (pixel[0] >= (this.newScaleValue-0.001) && pixel[0] <= (this.newScaleValue+0.001)) newCalc = false; else newCalc = true;
this.newScaleValue = pixel[0];
}
else
{
if (belowSpline.getObjectScaleValue() != this.newScaleValue) newCalc = true; else newCalc = false;
this.newScaleValue = belowSpline.getObjectScaleValue();
}
if (this.rntCalculation == false)
{
this.RNTSELObj.RNTSelMoveNScale(mousePoint, this.fadeScaleValue, this.currentScaleValue, this.InterfaceOBJList);
this.updateBoundingBox();
this.currentScaleValue = this.fadeScaleValue;
}
if (newCalc == true)
{
this.difScale = 0.015f+((float) Math.Abs(this.newScaleValue-this.currentScaleValue))/this.zoomValue;
}
if (this.IOSELObjectInsideSplineArea == false)
{
//belowSpline.addIOSelectObjectToSpline(this);
this.IOSELObjInArea = belowSpline;
this.IOSELObjectInsideSplineArea = true;
//this.logfile.SelectionEnterTerritory(this.ObjectID, this.logUserID, this.InterfaceOBJList, this.IOSELObjInArea.getObjectID(), mousePoint, this.RNTSELObj.Angle);
}
else if (this.IOSELObjectInsideSplineArea == true && this.IOSELObjInArea != belowSpline)
{
//belowSpline.addIOSelectObjectToSpline(this);
//this.IOSELObjInArea.removeIOSelectObjectFromSpline(this);
//this.logfile.SelectionSwitchTerritory(this.ObjectID,this.logUserID, this.InterfaceOBJList, mousePoint, this.RNTSELObj.Angle, this.IOSELObjInArea.getObjectID(), belowSpline.getObjectID());
this.IOSELObjInArea = belowSpline;
}
}
private void addSeparatePart()
{
this.interfaceIOSelect.addRealIOSelectObject(this);
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.addOnlyButtonsToGrid();
}
}
private void resizeSELOBJtoOriginalSize(Point mousePoint)
{
this.IOSELObjectInsideSplineArea = false;
this.newScaleValue = 1.0f;
this.difScale = 0.015f+((float) Math.Abs(this.newScaleValue-this.currentScaleValue))/this.zoomValue;
if (this.IOSELObjInArea != null)
{
// this.IOSELObjInArea.removeIOSelectObjectFromSpline(this);
//this.logfile.SelectionLeaveTerritory(this.ObjectID, this.logUserID, this.InterfaceOBJList, this.IOSELObjInArea.getObjectID(), mousePoint, this.RNTSELObj.Angle);
this.IOSELObjInArea = null;
}
}
private void resizeIOSelectObject(PointF mousePoint)
{
this.RNTSELObj.RNTSelScaleMove(mousePoint, this.currentScaleValue, this.InterfaceOBJList);
this.updateBoundingBox();
}
private void isIOSelectObjectAbobeSpline()
{
int hits = 0;
int[] pickmod = new int[200];
int[] viewport = new int[4];
float[] pixel = new float[3];
Gl.glGetIntegerv(Gl.GL_VIEWPORT,viewport);
this.RNTSELObj.setClientBorder((float) viewport[0], (float) viewport[1], (float) viewport[2], (float) viewport[3]);
Gl.glSelectBuffer(200, pickmod);
Gl.glRenderMode(Gl.GL_SELECT);
Gl.glInitNames();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPushMatrix();
Gl.glLoadIdentity();
Glu.gluPickMatrix (this.lastMousePoint.X, viewport[3]-this.lastMousePoint.Y, 1.0, 1.0,viewport);
Glu.gluOrtho2D(0,(double) viewport[2], (double) viewport[3] , 0);
Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPushMatrix();
Gl.glLoadIdentity();
ArrayList MoveSplineList = this.interfaceIOSelect.getAllGridMoveSplines();
for (int names=0; names < MoveSplineList.Count; names++)
{
Gl.glPushName(names);
((Spline) MoveSplineList[names]).drawBackGround(false);
Gl.glPopName();
}
Gl.glPopMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPopMatrix();
Gl.glFlush();
hits = Gl.glRenderMode(Gl.GL_RENDER);
if (hits > 0)
{
Spline belowSpline = ((Spline) MoveSplineList[pickmod[(hits-1)*5+3]]);
Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
belowSpline.drawBackGround(false);
Gl.glReadPixels((int) this.lastMousePoint.X,viewport[3]-((int)(this.lastMousePoint.Y)),1,1,Gl.GL_RGB,Gl.GL_FLOAT,pixel);
if (pixel[0] < belowSpline.getObjectScaleValue()) pixel[0] = belowSpline.getObjectScaleValue();
this.currentScaleValue = pixel[0];
this.newScaleValue = pixel[0];
this.fadeScaleValue = pixel[0];
this.storedAreaPart = pickmod[(hits-1)*5+4];
belowSpline.addIOSelectObjectToSpline(this);
this.IOSELObjInArea = belowSpline;
this.IOSELObjectInsideSplineArea = true;
}
else
{
this.currentScaleValue = 1.0f;
this.newScaleValue = 1.0f;
this.fadeScaleValue = 1.0f;
this.storedAreaPart = 0;
this.IOSELObjInArea = null;
this.IOSELObjectInsideSplineArea = false;
}
}
private bool testObjectButton(ObjectButton ObjBTN, PointF hitP)
{
bool belongTO, hitted;
int objCounter;
InterfaceObject IObjTest;
belongTO = false;
hitted = false;
objCounter=(this.InterfaceOBJList.Count-1);
while (objCounter>=0 && belongTO == false && hitted == false)
{
IObjTest = ((InterfaceObject) this.InterfaceOBJList[objCounter]);
if (IObjTest.pointInObj(hitP) == true && ObjBTN == IObjTest.getResizeButton()) belongTO = true;
else if (IObjTest.pointInObj(hitP) == true) hitted = true;
objCounter--;
}
return belongTO;
}
public void computeAnimations()
{
int hits;
int[] pickmod;
int[] viewport;
//LogFile.Context logThrowEndContext;
/* Zooming of the IOSelectObjectsize */
if (this.newScaleValue < this.currentScaleValue)
{
this.fadeScaleValue = this.fadeScaleValue - this.difScale;
if (this.fadeScaleValue < this.newScaleValue) this.fadeScaleValue = this.newScaleValue;
}
else if (this.newScaleValue > this.currentScaleValue)
{
this.fadeScaleValue = this.fadeScaleValue + this.difScale;
if (this.fadeScaleValue > this.newScaleValue) this.fadeScaleValue = this.newScaleValue;
}
if (this.wasSelected == true)
{
this.wasSelected = this.RNTSELObj.RNTSelScaleAfterSelection(this.CentrePoint, this.currentScaleValue, this.InterfaceOBJList);
this.updateBoundingBox();
if (this.wasSelected == false)
{
this.RNTSELObj.RNTSelUp(this.InterfaceOBJList, this);
this.addSeparatePart();
}
}
if (this.rntCalculation == true)
{
if (this.slideValue > 0.15)
{
hits = 0;
pickmod = new int[200];
viewport = new int[4];
this.lastMousePoint = new PointF(this.lastMousePoint.X+this.slideVector.X, this.lastMousePoint.Y+this.slideVector.Y);
this.slideVector.X = this.slideVector.X*0.95f;
this.slideVector.Y = this.slideVector.Y*0.95f;
this.slideValue = this.slideValue*0.95f;
Gl.glGetIntegerv(Gl.GL_VIEWPORT,viewport);
if (lastMousePoint.X < (((float) viewport[0])))
{
lastMousePoint.X = (((float) viewport[0]));
this.slideValue = 0.001f;
}
if (lastMousePoint.Y < (((float) viewport[1])))
{
lastMousePoint.Y = (((float) viewport[1]));
this.slideValue = 0.001f;
}
if (lastMousePoint.X > (((float) viewport[2])))
{
lastMousePoint.X = (((float) viewport[2]));
this.slideValue = 0.001f;
}
if (lastMousePoint.Y > (((float) viewport[3])))
{
lastMousePoint.Y = (((float) viewport[3]));
this.slideValue = 0.001f;
}
Gl.glSelectBuffer(200, pickmod);
Gl.glRenderMode(Gl.GL_SELECT);
Gl.glInitNames();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPushMatrix();
Gl.glLoadIdentity();
Glu.gluPickMatrix ((int) this.lastMousePoint.X, viewport[3]-((int)this.lastMousePoint.Y), 1.0, 1.0,viewport);
Glu.gluOrtho2D(0,(double) viewport[2], (double) viewport[3] , 0);
Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPushMatrix();
Gl.glLoadIdentity();
ArrayList SplineList = this.interfaceIOSelect.getAllGridMoveSplines();
for (int names=0; names < SplineList.Count; names++)
{
Gl.glPushName(names);
((Spline) SplineList[names]).drawBackGround(false);
Gl.glPopName();
}
Gl.glPopMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPopMatrix();
Gl.glFlush();
hits = Gl.glRenderMode(Gl.GL_RENDER);
if (hits > 0) this.storedAreaPart = pickmod[(hits-1)*5+4]; else this.storedAreaPart = 0;
if (this.IOSELObjectInsideSplineArea == true && hits == 0) this.resizeSELOBJtoOriginalSize(new Point((int) lastMousePoint.X, (int) lastMousePoint.Y));
else if (hits > 0) this.moveNresizeIOSELObject(new Point((int) lastMousePoint.X, (int) lastMousePoint.Y), (Spline) SplineList[pickmod[(hits-1)*5+3]]);
}
this.continueCalculateRNTObject();
if (this.slideValue < 0.15 && !(this.newScaleValue < this.currentScaleValue) && !(this.newScaleValue > this.currentScaleValue))
{
if (this.waitOneStep == true)
{
if (this.state == State.Moving || this.state == State.Resizing) this.RNTSELObj.RNTSelUp(this.InterfaceOBJList, this);
this.state = State.Nothing;
this.rntCalculation = false;
this.waitOneStep = false;
this.addSeparatePart();
if (this.IOSELObjInArea != null) this.IOSELObjInArea.addIOSelectObjectToSpline(this);
this.animateObjects.Remove(this);
this.slideValue = 0.0f;
this.slideVector = new PointF(0.0f, 0.0f);
foreach(InterfaceObject IO in this.InterfaceOBJList)
{
MaseUpdate.registerUpdated(IO);
}
}
else this.waitOneStep = true;
}
}
}
public void endSlideByReselection()
{
//LogFile.Context logThrowEndContext;
if (this.rntCalculation == true)
{
this.RNTSELObj.RNTSelUp(this.InterfaceOBJList, this);
this.slideValue = 0.0f;
this.slideVector = new PointF(0.0f, 0.0f);
this.state = State.Nothing;
this.rntCalculation = false;
this.newScaleValue = this.currentScaleValue;
this.fadeScaleValue = this.currentScaleValue;
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.setCurrentSize(this.currentScaleValue);
SELObj.addOnlyButtonsToGrid();
}
this.animateObjects.Remove(this);
}
}
public void catchIT(Point catchPoint, int inputID)
{
this.RNTSELObj.RNTSelUp(this.InterfaceOBJList, this);
this.interfaceIOSelect.removeIOSelectObjectShadow(this);
this.animateObjects.Remove(this);
this.slideValue = 0.0f;
this.slideVector = new PointF(0.0f, 0.0f);
this.rntCalculation = false;
this.state = State.Moving;
this.lastMousePoint = catchPoint;
this.RNTSELObj.RNTSelDown(catchPoint);
}
/*******************************************************************/
/* This are the drawing Functions which draw MoveSpline stuff */
/*******************************************************************/
private void createCircleList()
{
this.GLListCircle = Gl.glGenLists(1);
Gl.glNewList(this.GLListCircle, Gl.GL_COMPILE);
Gl.glColor4f(0.3f, 0.6f, 0.9f, 0.4f);
Gl.glBegin(Gl.GL_POLYGON);
for(float run=0.0f; run<=2*Math.PI; run+=0.06282f)
{
Gl.glVertex2d(Math.Sin(run), Math.Cos(run));
}
Gl.glEnd();
Gl.glLineWidth(1.0f);
Gl.glColor4f(0.0f, 0.0f, 1.0f, 0.8f);
Gl.glBegin(Gl.GL_LINE_LOOP);
for(float run=0.0f; run<=2*Math.PI; run+=0.06282f)
{
Gl.glVertex2d(Math.Sin(run), Math.Cos(run));
}
Gl.glEnd();
Gl.glEndList();
}
public void drawIOSelectObject(bool MOVEIOSelObj)
{
if (MOVEIOSelObj == true || this.rntCalculation == true || this.wasSelected == true)
{
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.drawInterfaceObject(true);
}
}
else
{
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.drawInterfaceObject(false);
}
}
Gl.glPushMatrix();
Gl.glTranslatef(this.CentrePoint.X, this.CentrePoint.Y, 0.0f);
Gl.glScalef(this.RNTSELObj.TranslateOnlyZoneRadius, this.RNTSELObj.TranslateOnlyZoneRadius, 1.0f);
Gl.glCallList(this.GLListCircle);
Gl.glPopMatrix();
}
public void drawIOSelectObjectShadow()
{
foreach (InterfaceObject SELObj in this.InterfaceOBJList)
{
SELObj.drawInterfaceShadow();
}
Gl.glPushMatrix();
Gl.glTranslatef(this.CentrePoint.X, this.CentrePoint.Y, 0.0f);
Gl.glScalef(this.RNTSELObj.TranslateOnlyZoneRadius, this.RNTSELObj.TranslateOnlyZoneRadius, 1.0f);
Gl.glCallList(this.GLListCircle);
Gl.glPopMatrix();
}
/*******************************************************************/
/* Mouse Events */
/*******************************************************************/
public void mouseDOWN(Point DOWNPoint, int inputID)
{
ObjectButton objButton;
objButton = this.interfaceIOSelect.getAssociatedObjectButton(DOWNPoint);
this.removeCompletly();
if (this.IOSELObjInArea != null) this.IOSELObjInArea.removeIOSelectObjectFromSpline(this);
if (objButton != null && objButton.OwnObject != null && objButton.OwnObject.getIOSelectObject() == this && this.testObjectButton(objButton, DOWNPoint) == true) this.state = State.Resizing; else this.state = State.Moving;
if (this.state == State.Moving)
{
this.RNTSELObj.RNTSelDown(DOWNPoint);
this.lastMousePoint = DOWNPoint;
this.slideVector = new PointF(0.0f, 0.0f);
this.slideValue = 0.0f;
}
else
{
this.RNTSELObj.RNTSelScaleDown(DOWNPoint, objButton.OwnObject);
}
}
public void mouseMOVE(Point MOVEPoint, bool isSplineBelow, Spline belowSpline, int ap)
{
if (this.state == State.Moving)
{
this.slideVector = new PointF(MOVEPoint.X-this.lastMousePoint.X, MOVEPoint.Y-this.lastMousePoint.Y);
this.lastMousePoint = MOVEPoint;
this.storedAreaPart = ap;
if (this.IOSELObjectInsideSplineArea == true && isSplineBelow == false) resizeSELOBJtoOriginalSize(MOVEPoint);
else if (isSplineBelow == false) this.moveIOSELObject(MOVEPoint);
else this.moveNresizeIOSELObject(MOVEPoint, belowSpline);
}
else if (this.state == State.Resizing)
{
this.resizeIOSelectObject(MOVEPoint);
}
}
public void mouseUP(Point UPPoint)
{
if (this.state == State.Moving)
{
this.slideValue = (float) Math.Sqrt((this.slideVector.X*this.slideVector.X) + (this.slideVector.Y*this.slideVector.Y));
if (this.slideValue < 12.5f)
{
this.slideVector = new PointF(0.0f, 0.0f);
this.slideValue = 0.0f;
}
}
this.animateObjects.Add(this);
this.rntCalculation = true;
this.interfaceIOSelect.addIOSelectObjectShadow(this);
}
/*******************************************************************/
/* some function for returning values */
/*******************************************************************/
public int getColorNumber()
{
return this.SELColorNumber;
}
public int getStoredAreaPart()
{
return this.storedAreaPart;
}
public PointF getLastMousePoint()
{
return this.lastMousePoint;
}
public void setLastMousePoint(PointF lp)
{
this.lastMousePoint = lp;
}
/*******************************************************************/
/* ----------------------------------------------------------- */
/*******************************************************************/
}
}
See more files for this project here