Made it possible to drag the origin while in both rotation modes.
Originally committed to SVN as r1355.
This commit is contained in:
parent
4f7bb0f6a8
commit
4d98ea25af
6 changed files with 97 additions and 17 deletions
|
@ -73,9 +73,10 @@ bool VisualDraggableFeature::IsMouseOver(int mx,int my) {
|
|||
|
||||
// Triangle
|
||||
else if (type == DRAG_BIG_TRIANGLE) {
|
||||
if (my < y-8 || my > y+8) return false;
|
||||
int _my = my+2;
|
||||
if (_my < y-8 || _my > y+8) return false;
|
||||
int dx = mx-x;
|
||||
int dy = my-y-8;
|
||||
int dy = _my-y-8;
|
||||
return (16*dx+9*dy < 0 && 16*dx-9*dy > 0);
|
||||
}
|
||||
|
||||
|
@ -113,10 +114,10 @@ void VisualDraggableFeature::Draw(OpenGLWrapper *gl) {
|
|||
|
||||
// Triangle
|
||||
else if (type == DRAG_BIG_TRIANGLE) {
|
||||
gl->DrawTriangle(x-9,y-8,x+9,y-8,x,y+8);
|
||||
gl->DrawLine(x,y-2,x,y-18);
|
||||
gl->DrawLine(x,y-2,x-14,y+6);
|
||||
gl->DrawLine(x,y-2,x+14,y+6);
|
||||
gl->DrawTriangle(x-9,y-6,x+9,y-6,x,y+10);
|
||||
gl->DrawLine(x,y,x,y-16);
|
||||
gl->DrawLine(x,y,x-14,y+8);
|
||||
gl->DrawLine(x,y,x+14,y+8);
|
||||
}
|
||||
|
||||
// Small circle
|
||||
|
|
|
@ -585,6 +585,7 @@ void VisualTool::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2)
|
|||
// Set override
|
||||
void VisualTool::SetOverride(wxString tag,wxString value) {
|
||||
VideoContext::Get()->grid->editBox->SetOverride(tag,value,0,false);
|
||||
parent->SetFocus();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ VisualToolRotateXY::VisualToolRotateXY(VideoDisplay *_parent)
|
|||
: VisualTool(_parent)
|
||||
{
|
||||
_parent->ShowCursor(false);
|
||||
AssDialogue *line = GetActiveDialogueLine();
|
||||
GetLinePosition(line,odx,ody,orgx,orgy);
|
||||
GetLineRotation(line,curAngleX,curAngleY,rz);
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,7 +76,8 @@ void VisualToolRotateXY::Draw() {
|
|||
|
||||
// Pivot coordinates
|
||||
int dx=0,dy=0;
|
||||
GetLinePosition(line,dx,dy,orgx,orgy);
|
||||
if (dragging) GetLinePosition(line,dx,dy);
|
||||
else GetLinePosition(line,dx,dy,orgx,orgy);
|
||||
dx = orgx;
|
||||
dy = orgy;
|
||||
|
||||
|
@ -90,9 +94,7 @@ void VisualToolRotateXY::Draw() {
|
|||
SetFillColour(colour[1],0.3f);
|
||||
|
||||
// Draw pivot
|
||||
DrawCircle(dx,dy,7);
|
||||
DrawLine(dx,dy-16,dx,dy+16);
|
||||
DrawLine(dx-16,dy,dx+16,dy);
|
||||
DrawAllFeatures();
|
||||
|
||||
// Transform grid
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
@ -230,3 +232,35 @@ void VisualToolRotateXY::CommitHold() {
|
|||
SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngleX)));
|
||||
SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngleY)));
|
||||
}
|
||||
|
||||
|
||||
//////////////////
|
||||
// Get \org pivot
|
||||
void VisualToolRotateXY::PopulateFeatureList() {
|
||||
// Get line
|
||||
curDiag = GetActiveDialogueLine();
|
||||
GetLinePosition(curDiag,odx,ody,orgx,orgy);
|
||||
|
||||
// Set features
|
||||
features.resize(1);
|
||||
VisualDraggableFeature &feat = features.back();
|
||||
feat.x = orgx;
|
||||
feat.y = orgy;
|
||||
feat.line = curDiag;
|
||||
feat.type = DRAG_BIG_TRIANGLE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
// Update dragging of \org
|
||||
void VisualToolRotateXY::UpdateDrag(VisualDraggableFeature &feature) {
|
||||
orgx = feature.x;
|
||||
orgy = feature.y;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
// Commit dragging of \org
|
||||
void VisualToolRotateXY::CommitDrag(VisualDraggableFeature &feature) {
|
||||
SetOverride(_T("\\org"),wxString::Format(_T("(%i,%i)"),feature.x,feature.y));
|
||||
}
|
||||
|
|
|
@ -56,6 +56,11 @@ private:
|
|||
void UpdateHold();
|
||||
void CommitHold();
|
||||
|
||||
bool CanDrag() { return true; }
|
||||
void PopulateFeatureList();
|
||||
void UpdateDrag(VisualDraggableFeature &feature);
|
||||
void CommitDrag(VisualDraggableFeature &feature);
|
||||
|
||||
public:
|
||||
VisualToolRotateXY(VideoDisplay *parent);
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ VisualToolRotateZ::VisualToolRotateZ(VideoDisplay *_parent)
|
|||
: VisualTool(_parent)
|
||||
{
|
||||
_parent->ShowCursor(false);
|
||||
AssDialogue *line = GetActiveDialogueLine();
|
||||
GetLinePosition(line,odx,ody,orgx,orgy);
|
||||
GetLineRotation(line,rx,ry,curAngle);
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,9 +74,13 @@ void VisualToolRotateZ::Draw() {
|
|||
AssDialogue *line = GetActiveDialogueLine();
|
||||
if (!line) return;
|
||||
|
||||
// Draw pivot
|
||||
DrawAllFeatures();
|
||||
|
||||
// Radius
|
||||
int dx=0,dy=0;
|
||||
GetLinePosition(line,dx,dy,orgx,orgy);
|
||||
if (dragging) GetLinePosition(line,dx,dy);
|
||||
else GetLinePosition(line,dx,dy,orgx,orgy);
|
||||
int radius = (int) sqrt(double((dx-orgx)*(dx-orgx)+(dy-orgy)*(dy-orgy)));
|
||||
int oRadius = radius;
|
||||
if (radius < 50) radius = 50;
|
||||
|
@ -102,11 +109,6 @@ void VisualToolRotateZ::Draw() {
|
|||
SetLineColour(colour[0]);
|
||||
SetFillColour(colour[1],0.3f);
|
||||
|
||||
// Draw pivot
|
||||
DrawCircle(dx,dy,7);
|
||||
DrawLine(dx,dy-16,dx,dy+16);
|
||||
DrawLine(dx-16,dy,dx+16,dy);
|
||||
|
||||
// Set up the projection
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
@ -155,7 +157,7 @@ void VisualToolRotateZ::Draw() {
|
|||
glPopMatrix();
|
||||
|
||||
// Draw line to mouse
|
||||
if (mouseX != -1) {
|
||||
if (mouseX != -1 && !dragging && GetHighlightedFeature() == -1) {
|
||||
SetLineColour(colour[0]);
|
||||
DrawLine(dx,dy,mx,my);
|
||||
}
|
||||
|
@ -196,3 +198,35 @@ void VisualToolRotateZ::UpdateHold() {
|
|||
void VisualToolRotateZ::CommitHold() {
|
||||
SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)));
|
||||
}
|
||||
|
||||
|
||||
//////////////////
|
||||
// Get \org pivot
|
||||
void VisualToolRotateZ::PopulateFeatureList() {
|
||||
// Get line
|
||||
curDiag = GetActiveDialogueLine();
|
||||
GetLinePosition(curDiag,odx,ody,orgx,orgy);
|
||||
|
||||
// Set features
|
||||
features.resize(1);
|
||||
VisualDraggableFeature &feat = features.back();
|
||||
feat.x = orgx;
|
||||
feat.y = orgy;
|
||||
feat.line = curDiag;
|
||||
feat.type = DRAG_BIG_TRIANGLE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
// Update dragging of \org
|
||||
void VisualToolRotateZ::UpdateDrag(VisualDraggableFeature &feature) {
|
||||
orgx = feature.x;
|
||||
orgy = feature.y;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
// Commit dragging of \org
|
||||
void VisualToolRotateZ::CommitDrag(VisualDraggableFeature &feature) {
|
||||
SetOverride(_T("\\org"),wxString::Format(_T("(%i,%i)"),feature.x,feature.y));
|
||||
}
|
||||
|
|
|
@ -55,6 +55,11 @@ private:
|
|||
void UpdateHold();
|
||||
void CommitHold();
|
||||
|
||||
bool CanDrag() { return true; }
|
||||
void PopulateFeatureList();
|
||||
void UpdateDrag(VisualDraggableFeature &feature);
|
||||
void CommitDrag(VisualDraggableFeature &feature);
|
||||
|
||||
public:
|
||||
VisualToolRotateZ(VideoDisplay *parent);
|
||||
|
||||
|
|
Loading…
Reference in a new issue