* Implementation of drawing command
*/
-DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, wxClassInfo *info, float xx, float yy,
+DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, wxClassInfo *info, double xx, double yy,
bool sel, wxShape *theShape, wxShape *fs, wxShape *ts):
wxCommand(TRUE, name)
{
* MyEvtHandler: an event handler class for all shapes
*/
-void MyEvtHandler::OnLeftClick(float x, float y, int keys, int attachment)
+void MyEvtHandler::OnLeftClick(double x, double y, int keys, int attachment)
{
wxClientDC dc(GetShape()->GetCanvas());
GetShape()->GetCanvas()->PrepareDC(dc);
* Implement connection of two shapes by right-dragging between them.
*/
-void MyEvtHandler::OnBeginDragRight(float x, float y, int keys, int attachment)
+void MyEvtHandler::OnBeginDragRight(double x, double y, int keys, int attachment)
{
// Force attachment to be zero for now. Eventually we can deal with
// the actual attachment point, e.g. a rectangle side if attachment mode is on.
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
dc.SetLogicalFunction(wxXOR);
dc.SetPen(dottedPen);
- float xp, yp;
+ double xp, yp;
GetShape()->GetAttachmentPosition(attachment, &xp, &yp);
dc.DrawLine(xp, yp, x, y);
GetShape()->GetCanvas()->CaptureMouse();
}
-void MyEvtHandler::OnDragRight(bool draw, float x, float y, int keys, int attachment)
+void MyEvtHandler::OnDragRight(bool draw, double x, double y, int keys, int attachment)
{
// Force attachment to be zero for now
attachment = 0;
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
dc.SetLogicalFunction(wxXOR);
dc.SetPen(dottedPen);
- float xp, yp;
+ double xp, yp;
GetShape()->GetAttachmentPosition(attachment, &xp, &yp);
dc.DrawLine(xp, yp, x, y);
}
-void MyEvtHandler::OnEndDragRight(float x, float y, int keys, int attachment)
+void MyEvtHandler::OnEndDragRight(double x, double y, int keys, int attachment)
{
GetShape()->GetCanvas()->ReleaseMouse();
MyCanvas *canvas = (MyCanvas *)GetShape()->GetCanvas();
}
}
-void MyEvtHandler::OnEndSize(float x, float y)
+void MyEvtHandler::OnEndSize(double x, double y)
{
wxClientDC dc(GetShape()->GetCanvas());
GetShape()->GetCanvas()->PrepareDC(dc);
IMPLEMENT_DYNAMIC_CLASS(wxRoundedRectangleShape, wxRectangleShape)
-wxRoundedRectangleShape::wxRoundedRectangleShape(float w, float h):
+wxRoundedRectangleShape::wxRoundedRectangleShape(double w, double h):
wxRectangleShape(w, h)
{
// 0.3 of the smaller rectangle dimension
- SetCornerRadius((float) -0.3);
+ SetCornerRadius((double) -0.3);
}
IMPLEMENT_DYNAMIC_CLASS(wxDiamondShape, wxPolygonShape)
-wxDiamondShape::wxDiamondShape(float w, float h):
+wxDiamondShape::wxDiamondShape(double w, double h):
wxPolygonShape()
{
// wxPolygonShape::SetSize relies on the shape having non-zero
DECLARE_DYNAMIC_CLASS(wxRoundedRectangleShape)
private:
public:
- wxRoundedRectangleShape(float w = 0.0, float h = 0.0);
+ wxRoundedRectangleShape(double w = 0.0, double h = 0.0);
};
class wxDiamondShape: public wxPolygonShape
DECLARE_DYNAMIC_CLASS(wxDiamondShape)
private:
public:
- wxDiamondShape(float w = 0.0, float h = 0.0);
+ wxDiamondShape(double w = 0.0, double h = 0.0);
};
/*
~MyEvtHandler(void)
{
}
- void OnLeftClick(float x, float y, int keys = 0, int attachment = 0);
- void OnBeginDragRight(float x, float y, int keys = 0, int attachment = 0);
- void OnDragRight(bool draw, float x, float y, int keys = 0, int attachment = 0);
- void OnEndDragRight(float x, float y, int keys = 0, int attachment = 0);
- void OnEndSize(float x, float y);
+ void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
+ void OnBeginDragRight(double x, double y, int keys = 0, int attachment = 0);
+ void OnDragRight(bool draw, double x, double y, int keys = 0, int attachment = 0);
+ void OnEndDragRight(double x, double y, int keys = 0, int attachment = 0);
+ void OnEndSize(double x, double y);
};
/*
wxShape *fromShape;
wxShape *toShape;
wxClassInfo *shapeInfo;
- float x;
- float y;
+ double x;
+ double y;
bool selected;
bool deleteShape;
public:
// Multi-purpose constructor for creating, deleting shapes
DiagramCommand(char *name, int cmd, DiagramDocument *ddoc, wxClassInfo *shapeInfo = NULL,
- float x = 0.0, float y = 0.0, bool sel = FALSE, wxShape *theShape = NULL, wxShape *fs = NULL, wxShape *ts = NULL);
+ double x = 0.0, double y = 0.0, bool sel = FALSE, wxShape *theShape = NULL, wxShape *fs = NULL, wxShape *ts = NULL);
// Property-changing command constructors
DiagramCommand(char *name, int cmd, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape);
{
}
-void MyCanvas::OnLeftClick(float x, float y, int keys)
+void MyCanvas::OnLeftClick(double x, double y, int keys)
{
EditorToolPalette *palette = wxGetApp().frame->palette;
wxClassInfo *info = NULL;
}
}
-void MyCanvas::OnRightClick(float x, float y, int keys)
+void MyCanvas::OnRightClick(double x, double y, int keys)
{
}
-void MyCanvas::OnDragLeft(bool draw, float x, float y, int keys)
+void MyCanvas::OnDragLeft(bool draw, double x, double y, int keys)
{
}
-void MyCanvas::OnBeginDragLeft(float x, float y, int keys)
+void MyCanvas::OnBeginDragLeft(double x, double y, int keys)
{
}
-void MyCanvas::OnEndDragLeft(float x, float y, int keys)
+void MyCanvas::OnEndDragLeft(double x, double y, int keys)
{
}
-void MyCanvas::OnDragRight(bool draw, float x, float y, int keys)
+void MyCanvas::OnDragRight(bool draw, double x, double y, int keys)
{
}
-void MyCanvas::OnBeginDragRight(float x, float y, int keys)
+void MyCanvas::OnBeginDragRight(double x, double y, int keys)
{
}
-void MyCanvas::OnEndDragRight(float x, float y, int keys)
+void MyCanvas::OnEndDragRight(double x, double y, int keys)
{
}
void OnMouseEvent(wxMouseEvent& event);
void OnPaint(wxPaintEvent& event);
- virtual void OnLeftClick(float x, float y, int keys = 0);
- virtual void OnRightClick(float x, float y, int keys = 0);
+ virtual void OnLeftClick(double x, double y, int keys = 0);
+ virtual void OnRightClick(double x, double y, int keys = 0);
- virtual void OnDragLeft(bool draw, float x, float y, int keys=0); // Erase if draw false
- virtual void OnBeginDragLeft(float x, float y, int keys=0);
- virtual void OnEndDragLeft(float x, float y, int keys=0);
+ virtual void OnDragLeft(bool draw, double x, double y, int keys=0); // Erase if draw false
+ virtual void OnBeginDragLeft(double x, double y, int keys=0);
+ virtual void OnEndDragLeft(double x, double y, int keys=0);
- virtual void OnDragRight(bool draw, float x, float y, int keys=0); // Erase if draw false
- virtual void OnBeginDragRight(float x, float y, int keys=0);
- virtual void OnEndDragRight(float x, float y, int keys=0);
+ virtual void OnDragRight(bool draw, double x, double y, int keys=0); // Erase if draw false
+ virtual void OnBeginDragRight(double x, double y, int keys=0);
+ virtual void OnEndDragRight(double x, double y, int keys=0);
DECLARE_EVENT_TABLE()
};
IMPLEMENT_DYNAMIC_CLASS(wxShapeTextLine, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxAttachmentPoint, wxObject)
-wxShapeTextLine::wxShapeTextLine(float the_x, float the_y, const wxString& the_line)
+wxShapeTextLine::wxShapeTextLine(double the_x, double the_y, const wxString& the_line)
{
m_x = the_x; m_y = the_y; m_line = the_line;
}
m_previousHandler->OnDrawContents(dc);
}
-void wxShapeEvtHandler::OnSize(float x, float y)
+void wxShapeEvtHandler::OnSize(double x, double y)
{
if (m_previousHandler)
m_previousHandler->OnSize(x, y);
}
-bool wxShapeEvtHandler::OnMovePre(wxDC& dc, float x, float y, float old_x, float old_y, bool display)
+bool wxShapeEvtHandler::OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display)
{
if (m_previousHandler)
return m_previousHandler->OnMovePre(dc, x, y, old_x, old_y, display);
return TRUE;
}
-void wxShapeEvtHandler::OnMovePost(wxDC& dc, float x, float y, float old_x, float old_y, bool display)
+void wxShapeEvtHandler::OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display)
{
if (m_previousHandler)
m_previousHandler->OnMovePost(dc, x, y, old_x, old_y, display);
m_previousHandler->OnHighlight(dc);
}
-void wxShapeEvtHandler::OnLeftClick(float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnLeftClick(double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnLeftClick(x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnRightClick(float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnRightClick(double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnRightClick(x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnDragLeft(draw, x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnBeginDragLeft(x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnEndDragLeft(double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnEndDragLeft(x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnDragRight(bool draw, float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnDragRight(bool draw, double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnDragRight(draw, x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnBeginDragRight(float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnBeginDragRight(double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnBeginDragRight(x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnEndDragRight(float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnEndDragRight(double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnEndDragRight(x, y, keys, attachment);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
-void wxShapeEvtHandler::OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnSizingDragLeft(pt, draw, x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnSizingBeginDragLeft(pt, x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
+void wxShapeEvtHandler::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
{
if (m_previousHandler)
m_previousHandler->OnSizingEndDragLeft(pt, x, y, keys, attachment);
}
-void wxShapeEvtHandler::OnDrawOutline(wxDC& dc, float x, float y, float w, float h)
+void wxShapeEvtHandler::OnDrawOutline(wxDC& dc, double x, double y, double w, double h)
{
if (m_previousHandler)
m_previousHandler->OnDrawOutline(dc, x, y, w, h);
m_previousHandler->OnEraseControlPoints(dc);
}
+// Can override this to prevent or intercept line reordering.
+void wxShapeEvtHandler::OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering)
+{
+ if (m_previousHandler)
+ m_previousHandler->OnChangeAttachment(attachment, line, ordering);
+}
+
IMPLEMENT_ABSTRACT_CLASS(wxShape, wxShapeEvtHandler)
wxShape::wxShape(wxShapeCanvas *can)
m_formatted = FALSE;
m_canvas = can;
m_xpos = 0.0; m_ypos = 0.0;
- m_pen = black_pen;
+ m_pen = g_oglBlackPen;
m_brush = wxWHITE_BRUSH;
m_font = g_oglNormalFont;
m_textColour = wxBLACK;
wxNode *node = m_regions.First();
if (!node) return;
wxShapeRegion *region = (wxShapeRegion *)node->Data();
- float w, h;
+ double w, h;
GetBoundingBoxMin(&w, &h);
region->SetSize(w, h);
}
-bool wxShape::HitTest(float x, float y, int *attachment, float *distance)
+bool wxShape::HitTest(double x, double y, int *attachment, double *distance)
{
// if (!sensitive)
// return FALSE;
- float width = 0.0, height = 0.0;
+ double width = 0.0, height = 0.0;
GetBoundingBoxMin(&width, &height);
if (fabs(width) < 4.0) width = 4.0;
if (fabs(height) < 4.0) height = 4.0;
- width += (float)4.0; height += (float)4.0; // Allowance for inaccurate mousing
+ width += (double)4.0; height += (double)4.0; // Allowance for inaccurate mousing
- float left = (float)(m_xpos - (width/2.0));
- float top = (float)(m_ypos - (height/2.0));
- float right = (float)(m_xpos + (width/2.0));
- float bottom = (float)(m_ypos + (height/2.0));
+ double left = (double)(m_xpos - (width/2.0));
+ double top = (double)(m_ypos - (height/2.0));
+ double right = (double)(m_xpos + (width/2.0));
+ double bottom = (double)(m_ypos + (height/2.0));
int nearest_attachment = 0;
if (x >= left && x <= right && y >= top && y <= bottom)
{
int n = GetNumberOfAttachments();
- float nearest = 999999.0;
+ double nearest = 999999.0;
for (int i = 0; i < n; i++)
{
- float xp, yp;
+ double xp, yp;
if (GetAttachmentPosition(i, &xp, &yp))
{
- float l = (float)sqrt(((xp - x) * (xp - x)) +
+ double l = (double)sqrt(((xp - x) * (xp - x)) +
((yp - y) * (yp - y)));
if (l < nearest)
static bool GraphicsInSizeToContents = FALSE; // Infinite recursion elimination
void wxShape::FormatText(wxDC& dc, const wxString& s, int i)
{
- float w, h;
+ double w, h;
ClearText(i);
if (m_regions.Number() < 1)
region->GetSize(&w, &h);
- wxList *string_list = ::FormatText(dc, s, (w-5), (h-5), region->GetFormatMode());
- node = string_list->First();
+ wxStringList *stringList = oglFormatText(dc, s, (w-5), (h-5), region->GetFormatMode());
+ node = stringList->First();
while (node)
{
char *s = (char *)node->Data();
wxShapeTextLine *line = new wxShapeTextLine(0.0, 0.0, s);
region->GetFormattedText().Append((wxObject *)line);
- delete node;
- node = string_list->First();
+ node = node->Next();
}
- delete string_list;
- float actualW = w;
- float actualH = h;
+ delete stringList;
+ double actualW = w;
+ double actualH = h;
// Don't try to resize an object with more than one image (this case should be dealt
// with by overriden handlers)
if ((region->GetFormatMode() & FORMAT_SIZE_TO_CONTENTS) &&
(region->GetFormattedText().Number() > 0) &&
(m_regions.Number() == 1) && !GraphicsInSizeToContents)
{
- GetCentredTextExtent(dc, &(region->GetFormattedText()), m_xpos, m_ypos, w, h, &actualW, &actualH);
+ oglGetCentredTextExtent(dc, &(region->GetFormattedText()), m_xpos, m_ypos, w, h, &actualW, &actualH);
if ((actualW+m_textMarginX != w ) || (actualH+m_textMarginY != h))
{
// If we are a descendant of a composite, must make sure the composite gets
EraseContents(dc);
}
}
- CentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, actualW, actualH, region->GetFormatMode());
+ oglCentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, actualW, actualH, region->GetFormatMode());
m_formatted = TRUE;
}
void wxShape::Recentre(wxDC& dc)
{
- float w, h;
+ double w, h;
GetBoundingBoxMin(&w, &h);
int noRegions = m_regions.Number();
if (node)
{
wxShapeRegion *region = (wxShapeRegion *)node->Data();
- CentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, w, h, region->GetFormatMode());
+ oglCentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, w, h, region->GetFormatMode());
}
}
}
-bool wxShape::GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3)
+bool wxShape::GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3)
{
return FALSE;
}
void wxShape::OnDrawContents(wxDC& dc)
{
- float bound_x, bound_y;
+ double bound_x, bound_y;
GetBoundingBoxMin(&bound_x, &bound_y);
if (m_regions.Number() < 1) return;
dc.SetBackgroundMode(wxTRANSPARENT);
if (!m_formatted)
{
- CentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, bound_x, bound_y, region->GetFormatMode());
+ oglCentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, bound_x, bound_y, region->GetFormatMode());
m_formatted = TRUE;
}
if (!GetDisableLabel())
{
- DrawFormattedText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, bound_x, bound_y, region->GetFormatMode());
+ oglDrawFormattedText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, bound_x, bound_y, region->GetFormatMode());
}
}
GetEventHandler()->OnDrawContents(dc);
}
-void wxShape::OnSize(float x, float y)
+void wxShape::OnSize(double x, double y)
{
}
-bool wxShape::OnMovePre(wxDC& dc, float x, float y, float old_x, float old_y, bool display)
+bool wxShape::OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display)
{
return TRUE;
}
-void wxShape::OnMovePost(wxDC& dc, float x, float y, float old_x, float old_y, bool display)
+void wxShape::OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display)
{
}
if (!m_visible)
return;
- float maxX, maxY, minX, minY;
- float xp = GetX();
- float yp = GetY();
+ double maxX, maxY, minX, minY;
+ double xp = GetX();
+ double yp = GetY();
GetBoundingBoxMin(&minX, &minY);
GetBoundingBoxMax(&maxX, &maxY);
- float topLeftX = (float)(xp - (maxX / 2.0) - 2.0);
- float topLeftY = (float)(yp - (maxY / 2.0) - 2.0);
+ double topLeftX = (double)(xp - (maxX / 2.0) - 2.0);
+ double topLeftY = (double)(yp - (maxY / 2.0) - 2.0);
int penWidth = 0;
if (m_pen)
penWidth = m_pen->GetWidth();
- dc.SetPen(white_background_pen);
- dc.SetBrush(white_background_brush);
- dc.DrawRectangle((float)(topLeftX - penWidth), (float)(topLeftY - penWidth),
- (float)(maxX + penWidth*2.0 + 4.0), (float)(maxY + penWidth*2.0 + 4.0));
+ dc.SetPen(g_oglWhiteBackgroundPen);
+ dc.SetBrush(g_oglWhiteBackgroundBrush);
+ dc.DrawRectangle(WXROUND(topLeftX - penWidth), WXROUND(topLeftY - penWidth),
+ WXROUND(maxX + penWidth*2.0 + 4.0), WXROUND(maxY + penWidth*2.0 + 4.0));
}
void wxShape::EraseLinks(wxDC& dc, int attachment, bool recurse)
}
}
+// Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
+// edge of the shape.
+// attachmentPoint is the attachment point (= side) in question.
+
+// This is the default, rectangular implementation.
+bool wxShape::AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2)
+{
+ switch (attachmentPoint)
+ {
+ case 0:
+ case 2:
+ {
+ return (pt1.x <= pt2.x) ;
+ break;
+ }
+ case 1:
+ case 3:
+ {
+ return (pt1.y <= pt2.y) ;
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
void wxShape::MoveLineToNewAttachment(wxDC& dc, wxLineShape *to_move,
- float x, float y)
+ double x, double y)
{
- int new_point;
- float distance;
+ if (!GetAttachmentMode())
+ return;
+
+ int newAttachment, oldAttachment;
+ double distance;
// Is (x, y) on this object? If so, find the new attachment point
// the user has moved the point to
- bool hit = HitTest(x, y, &new_point, &distance);
+ bool hit = HitTest(x, y, &newAttachment, &distance);
if (!hit)
return;
EraseLinks(dc);
- int old_attachment;
if (to_move->GetTo() == this)
- old_attachment = to_move->GetAttachmentTo();
+ oldAttachment = to_move->GetAttachmentTo();
else
- old_attachment = to_move->GetAttachmentFrom();
+ oldAttachment = to_move->GetAttachmentFrom();
+
+ // The links in a new ordering.
+ wxList newOrdering;
+
+ // First, add all links to the new list.
+ wxNode *node = m_lines.First();
+ while (node)
+ {
+ newOrdering.Append(node->Data());
+ node = node->Next();
+ }
// Delete the line object from the list of links; we're going to move
// it to another position in the list
- m_lines.DeleteObject(to_move);
+ newOrdering.DeleteObject(to_move);
- float old_x = (float) -9999.9;
- float old_y = (float) -9999.9;
+ double old_x = (double) -99999.9;
+ double old_y = (double) -99999.9;
- wxNode *node = m_lines.First();
+ node = newOrdering.First();
bool found = FALSE;
- while (node && !found)
+ while (!found && node)
{
wxLineShape *line = (wxLineShape *)node->Data();
- if ((line->GetTo() == this && old_attachment == line->GetAttachmentTo()) ||
- (line->GetFrom() == this && old_attachment == line->GetAttachmentFrom()))
+ if ((line->GetTo() == this && oldAttachment == line->GetAttachmentTo()) ||
+ (line->GetFrom() == this && oldAttachment == line->GetAttachmentFrom()))
{
- float startX, startY, endX, endY;
- float xp, yp;
+ double startX, startY, endX, endY;
+ double xp, yp;
line->GetEnds(&startX, &startY, &endX, &endY);
if (line->GetTo() == this)
{
-// xp = line->m_xpos2 + line->m_xpos;
-// yp = line->m_ypos2 + line->m_ypos;
- xp = startX;
- yp = startY;
- } else
- {
-// xp = line->m_xpos1 + line->m_xpos;
-// yp = line->m_ypos1 + line->m_ypos;
xp = endX;
yp = endY;
+ } else
+ {
+ xp = startX;
+ yp = startY;
}
- switch (old_attachment)
+ wxRealPoint thisPoint(xp, yp);
+ wxRealPoint lastPoint(old_x, old_y);
+ wxRealPoint newPoint(x, y);
+
+ if (AttachmentSortTest(newAttachment, newPoint, thisPoint) && AttachmentSortTest(newAttachment, lastPoint, newPoint))
{
- case 0:
- case 2:
- {
- if (x > old_x && x <= xp)
- {
- found = TRUE;
- m_lines.Insert(node, to_move);
- }
- break;
- }
- case 1:
- case 3:
- {
- if (y > old_y && y <= yp)
- {
- found = TRUE;
- m_lines.Insert(node, to_move);
- }
- break;
- }
+ found = TRUE;
+ newOrdering.Insert(node, to_move);
}
+
old_x = xp;
old_y = yp;
}
node = node->Next();
}
+
if (!found)
- m_lines.Append(to_move);
+ newOrdering.Append(to_move);
+
+ GetEventHandler()->OnChangeAttachment(newAttachment, to_move, newOrdering);
+}
+
+void wxShape::OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering)
+{
+ if (line->GetTo() == this)
+ line->SetAttachmentTo(attachment);
+ else
+ line->SetAttachmentFrom(attachment);
+
+ ApplyAttachmentOrdering(ordering);
+
+ wxClientDC dc(GetCanvas());
+ GetCanvas()->PrepareDC(dc);
+
+ MoveLinks(dc);
+
+ if (!GetCanvas()->GetQuickEditMode()) GetCanvas()->Redraw(dc);
+}
+
+// Reorders the lines according to the given list.
+void wxShape::ApplyAttachmentOrdering(wxList& linesToSort)
+{
+ // This is a temporary store of all the lines.
+ wxList linesStore;
+
+ wxNode *node = m_lines.First();
+ while (node)
+ {
+ wxLineShape *line = (wxLineShape *)node->Data();
+ linesStore.Append(line);
+ node = node->Next();;
+ }
+
+ m_lines.Clear();
+
+ node = linesToSort.First();
+ while (node)
+ {
+ wxLineShape *line = (wxLineShape *)node->Data();
+ if (linesStore.Member(line))
+ {
+ // Done this one
+ linesStore.DeleteObject(line);
+ m_lines.Append(line);
+ }
+ node = node->Next();
+ }
+
+ // Now add any lines that haven't been listed in linesToSort.
+ node = linesStore.First();
+ while (node)
+ {
+ wxLineShape *line = (wxLineShape *)node->Data();
+ m_lines.Append(line);
+ node = node->Next();
+ }
}
// Reorders the lines coming into the node image at this attachment
{
}
-void wxShape::OnLeftClick(float x, float y, int keys, int attachment)
+void wxShape::OnLeftClick(double x, double y, int keys, int attachment)
{
if ((m_sensitivity & OP_CLICK_LEFT) != OP_CLICK_LEFT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
}
}
-void wxShape::OnRightClick(float x, float y, int keys, int attachment)
+void wxShape::OnRightClick(double x, double y, int keys, int attachment)
{
if ((m_sensitivity & OP_CLICK_RIGHT) != OP_CLICK_RIGHT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
}
}
-float DragOffsetX = 0.0;
-float DragOffsetY = 0.0;
+double DragOffsetX = 0.0;
+double DragOffsetY = 0.0;
-void wxShape::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
dc.SetPen(dottedPen);
dc.SetBrush(* wxTRANSPARENT_BRUSH);
- float xx, yy;
+ double xx, yy;
xx = x + DragOffsetX;
yy = y + DragOffsetY;
m_canvas->Snap(&xx, &yy);
// m_xpos = xx; m_ypos = yy;
- float w, h;
+ double w, h;
GetBoundingBoxMax(&w, &h);
GetEventHandler()->OnDrawOutline(dc, xx, yy, w, h);
}
-void wxShape::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxShape::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
- Erase(dc);
- float xx, yy;
+ // New policy: don't erase shape until end of drag.
+// Erase(dc);
+
+ double xx, yy;
xx = x + DragOffsetX;
yy = y + DragOffsetY;
m_canvas->Snap(&xx, &yy);
dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH));
- float w, h;
+ double w, h;
GetBoundingBoxMax(&w, &h);
GetEventHandler()->OnDrawOutline(dc, xx, yy, w, h);
m_canvas->CaptureMouse();
}
-void wxShape::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxShape::OnEndDragLeft(double x, double y, int keys, int attachment)
{
m_canvas->ReleaseMouse();
if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
dc.SetLogicalFunction(wxCOPY);
- float xx = x + DragOffsetX;
- float yy = y + DragOffsetY;
+ double xx = x + DragOffsetX;
+ double yy = y + DragOffsetY;
m_canvas->Snap(&xx, &yy);
// canvas->Snap(&m_xpos, &m_ypos);
+
+ // New policy: erase shape at end of drag.
+ Erase(dc);
+
Move(dc, xx, yy);
if (m_canvas && !m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc);
}
-void wxShape::OnDragRight(bool draw, float x, float y, int keys, int attachment)
+void wxShape::OnDragRight(bool draw, double x, double y, int keys, int attachment)
{
if ((m_sensitivity & OP_DRAG_RIGHT) != OP_DRAG_RIGHT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
}
}
-void wxShape::OnBeginDragRight(float x, float y, int keys, int attachment)
+void wxShape::OnBeginDragRight(double x, double y, int keys, int attachment)
{
if ((m_sensitivity & OP_DRAG_RIGHT) != OP_DRAG_RIGHT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
}
}
-void wxShape::OnEndDragRight(float x, float y, int keys, int attachment)
+void wxShape::OnEndDragRight(double x, double y, int keys, int attachment)
{
if ((m_sensitivity & OP_DRAG_RIGHT) != OP_DRAG_RIGHT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
}
}
-void wxShape::OnDrawOutline(wxDC& dc, float x, float y, float w, float h)
+void wxShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double h)
{
- float top_left_x = (float)(x - w/2.0);
- float top_left_y = (float)(y - h/2.0);
- float top_right_x = (float)(top_left_x + w);
- float top_right_y = (float)top_left_y;
- float bottom_left_x = (float)top_left_x;
- float bottom_left_y = (float)(top_left_y + h);
- float bottom_right_x = (float)top_right_x;
- float bottom_right_y = (float)bottom_left_y;
+ double top_left_x = (double)(x - w/2.0);
+ double top_left_y = (double)(y - h/2.0);
+ double top_right_x = (double)(top_left_x + w);
+ double top_right_y = (double)top_left_y;
+ double bottom_left_x = (double)top_left_x;
+ double bottom_left_y = (double)(top_left_y + h);
+ double bottom_right_x = (double)top_right_x;
+ double bottom_right_y = (double)bottom_left_y;
wxPoint points[5];
- points[0].x = top_left_x; points[0].y = top_left_y;
- points[1].x = top_right_x; points[1].y = top_right_y;
- points[2].x = bottom_right_x; points[2].y = bottom_right_y;
- points[3].x = bottom_left_x; points[3].y = bottom_left_y;
- points[4].x = top_left_x; points[4].y = top_left_y;
+ points[0].x = WXROUND(top_left_x); points[0].y = WXROUND(top_left_y);
+ points[1].x = WXROUND(top_right_x); points[1].y = WXROUND(top_right_y);
+ points[2].x = WXROUND(bottom_right_x); points[2].y = WXROUND(bottom_right_y);
+ points[3].x = WXROUND(bottom_left_x); points[3].y = WXROUND(bottom_left_y);
+ points[4].x = WXROUND(top_left_x); points[4].y = WXROUND(top_left_y);
dc.DrawLines(5, points);
}
m_canvas = NULL;
}
-void wxShape::Move(wxDC& dc, float x, float y, bool display)
+void wxShape::Move(wxDC& dc, double x, double y, bool display)
{
- float old_x = m_xpos;
- float old_y = m_ypos;
+ double old_x = m_xpos;
+ double old_y = m_ypos;
m_xpos = x; m_ypos = y;
m_formatted = FALSE;
}
-void wxShape::SetSize(float x, float y, bool recursive)
+void wxShape::SetSize(double x, double y, bool recursive)
{
SetAttachmentSize(x, y);
SetDefaultRegionSize();
}
-void wxShape::SetAttachmentSize(float w, float h)
+void wxShape::SetAttachmentSize(double w, double h)
{
- float scaleX;
- float scaleY;
- float width, height;
+ double scaleX;
+ double scaleY;
+ double width, height;
GetBoundingBoxMin(&width, &height);
if (width == 0.0)
scaleX = 1.0;
while (node)
{
wxAttachmentPoint *point = (wxAttachmentPoint *)node->Data();
- point->m_x = (float)(point->m_x * scaleX);
- point->m_y = (float)(point->m_y * scaleY);
+ point->m_x = (double)(point->m_x * scaleX);
+ point->m_y = (double)(point->m_y * scaleY);
node = node->Next();
}
}
// Add line FROM this object
void wxShape::AddLine(wxLineShape *line, wxShape *other,
- int attachFrom, int attachTo)
+ int attachFrom, int attachTo,
+ // The line ordering
+ int positionFrom, int positionTo)
{
- if (!m_lines.Member(line))
- m_lines.Append(line);
+ m_lines.DeleteObject(line);
+ other->m_lines.DeleteObject(line);
+
+ if (positionFrom == -1)
+ m_lines.Append(line);
+ else
+ {
+ if (positionFrom < m_lines.Number())
+ {
+ wxNode* node = m_lines.Nth(positionFrom);
+ m_lines.Insert(node, line);
+ }
+ else
+ m_lines.Append(line);
+ }
- if (!other->m_lines.Member(line))
- other->m_lines.Append(line);
+ if (positionTo == -1)
+ other->m_lines.Append(line);
+ else
+ {
+ if (positionTo < other->m_lines.Number())
+ {
+ wxNode* node = other->m_lines.Nth(positionTo);
+ other->m_lines.Insert(node, line);
+ }
+ else
+ other->m_lines.Append(line);
+ }
- line->SetFrom(this);
- line->SetTo(other);
- line->SetAttachments(attachFrom, attachTo);
+ line->SetFrom(this);
+ line->SetTo(other);
+ line->SetAttachments(attachFrom, attachTo);
}
void wxShape::RemoveLine(wxLineShape *line)
while (node)
{
wxExpr *string_expr = node;
- float the_x = 0.0;
- float the_y = 0.0;
+ double the_x = 0.0;
+ double the_y = 0.0;
wxString the_string("");
// string_expr can either be a string, or a list of
{
if (first->Type() == PrologReal)
the_x = first->RealValue();
- else the_x = (float)first->IntegerValue();
+ else the_x = (double)first->IntegerValue();
if (second->Type() == PrologReal)
the_y = second->RealValue();
- else the_y = (float)second->IntegerValue();
+ else the_y = (double)second->IntegerValue();
the_string = third->StringValue();
}
int point_size = 10;
clause->GetAttributeValue("point_size", point_size);
- SetFont(MatchFont(point_size));
+ SetFont(oglMatchFont(point_size));
// Read user-defined attachment points, if any
wxExpr *attachmentList = clause->AttributeValue("user_attachments");
wxString regionName("");
wxString regionText("");
- float x = 0.0;
- float y = 0.0;
- float width = 0.0;
- float height = 0.0;
- float minWidth = 5.0;
- float minHeight = 5.0;
- float m_regionProportionX = -1.0;
- float m_regionProportionY = -1.0;
+ double x = 0.0;
+ double y = 0.0;
+ double width = 0.0;
+ double height = 0.0;
+ double minWidth = 5.0;
+ double minHeight = 5.0;
+ double m_regionProportionX = -1.0;
+ double m_regionProportionY = -1.0;
int formatMode = FORMAT_NONE;
int fontSize = 10;
int fontFamily = wxSWISS;
while (node)
{
wxExpr *string_expr = node;
- float the_x = 0.0;
- float the_y = 0.0;
+ double the_x = 0.0;
+ double the_y = 0.0;
wxString the_string("");
// string_expr can either be a string, or a list of
{
if (first->Type() == PrologReal)
the_x = first->RealValue();
- else the_x = (float)first->IntegerValue();
+ else the_x = (double)first->IntegerValue();
if (second->Type() == PrologReal)
the_y = second->RealValue();
- else the_y = (float)second->IntegerValue();
+ else the_y = (double)second->IntegerValue();
the_string = third->StringValue();
}
copy.m_attachmentPoints.Append((wxObject *)newPoint);
node = node->Next();
}
+
+ // Copy lines
+ copy.m_lines.Clear();
+ node = m_lines.First();
+ while (node)
+ {
+ wxLineShape* line = (wxLineShape*) node->Data();
+ copy.m_lines.Append(line);
+ node = node->Next();
+ }
}
// Create and return a new, fully copied object.
wxShape *wxShape::CreateNewCopy(bool resetMapping, bool recompute)
{
if (resetMapping)
- wxObjectCopyMapping.Clear();
+ oglObjectCopyMapping.Clear();
wxShape* newObject = (wxShape*) GetClassInfo()->CreateObject();
// Default - make 6 control points
void wxShape::MakeControlPoints()
{
- float maxX, maxY, minX, minY;
+ double maxX, maxY, minX, minY;
GetBoundingBoxMax(&maxX, &maxY);
GetBoundingBoxMin(&minX, &minY);
- float widthMin = (float)(minX + CONTROL_POINT_SIZE + 2);
- float heightMin = (float)(minY + CONTROL_POINT_SIZE + 2);
+ double widthMin = (double)(minX + CONTROL_POINT_SIZE + 2);
+ double heightMin = (double)(minY + CONTROL_POINT_SIZE + 2);
// Offsets from main object
- float top = (float)(- (heightMin / 2.0));
- float bottom = (float)(heightMin / 2.0 + (maxY - minY));
- float left = (float)(- (widthMin / 2.0));
- float right = (float)(widthMin / 2.0 + (maxX - minX));
+ double top = (double)(- (heightMin / 2.0));
+ double bottom = (double)(heightMin / 2.0 + (maxY - minY));
+ double left = (double)(- (widthMin / 2.0));
+ double right = (double)(widthMin / 2.0 + (maxX - minX));
wxControlPoint *control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, left, top,
CONTROL_POINT_DIAGONAL);
if (m_controlPoints.Number() < 1)
return;
- float maxX, maxY, minX, minY;
+ double maxX, maxY, minX, minY;
GetBoundingBoxMax(&maxX, &maxY);
GetBoundingBoxMin(&minX, &minY);
- float widthMin = (float)(minX + CONTROL_POINT_SIZE + 2);
- float heightMin = (float)(minY + CONTROL_POINT_SIZE + 2);
+ double widthMin = (double)(minX + CONTROL_POINT_SIZE + 2);
+ double heightMin = (double)(minY + CONTROL_POINT_SIZE + 2);
// Offsets from main object
- float top = (float)(- (heightMin / 2.0));
- float bottom = (float)(heightMin / 2.0 + (maxY - minY));
- float left = (float)(- (widthMin / 2.0));
- float right = (float)(widthMin / 2.0 + (maxX - minX));
+ double top = (double)(- (heightMin / 2.0));
+ double bottom = (double)(heightMin / 2.0 + (maxY - minY));
+ double left = (double)(- (widthMin / 2.0));
+ double right = (double)(widthMin / 2.0 + (maxX - minX));
wxNode *node = m_controlPoints.First();
wxControlPoint *control = (wxControlPoint *)node->Data();
return FALSE;
}
-bool wxShape::GetAttachmentPosition(int attachment, float *x, float *y,
+bool wxShape::GetAttachmentPosition(int attachment, double *x, double *y,
int nth, int no_arcs, wxLineShape *line)
{
if (!m_attachmentMode)
wxAttachmentPoint *point = (wxAttachmentPoint *)node->Data();
if (point->m_id == attachment)
{
- *x = (float)(m_xpos + point->m_x);
- *y = (float)(m_ypos + point->m_y);
+ *x = (double)(m_xpos + point->m_x);
+ *y = (double)(m_ypos + point->m_y);
return TRUE;
}
node = node->Next();
}
}
-void wxShape::GetBoundingBoxMax(float *w, float *h)
+void wxShape::GetBoundingBoxMax(double *w, double *h)
{
- float ww, hh;
+ double ww, hh;
GetBoundingBoxMin(&ww, &hh);
if (m_shadowMode != SHADOW_NONE)
{
list.Clear();
}
+// Assuming the attachment lies along a vertical or horizontal line,
+// calculate the position on that point.
+wxRealPoint wxShape::CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2,
+ int nth, int noArcs, wxLineShape* line)
+{
+ bool isEnd = (line && line->IsEnd(this));
+
+ // Are we horizontal or vertical?
+ bool isHorizontal = (oglRoughlyEqual(pt1.y, pt2.y) == TRUE);
+
+ double x, y;
+
+ if (isHorizontal)
+ {
+ wxRealPoint firstPoint, secondPoint;
+ if (pt1.x > pt2.x)
+ {
+ firstPoint = pt2;
+ secondPoint = pt1;
+ }
+ else
+ {
+ firstPoint = pt1;
+ secondPoint = pt2;
+ }
+
+ if (m_spaceAttachments)
+ {
+ if (line && (line->GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE))
+ {
+ // Align line according to the next handle along
+ wxRealPoint *point = line->GetNextControlPoint(this);
+ if (point->x < firstPoint.x)
+ x = firstPoint.x;
+ else if (point->x > secondPoint.x)
+ x = secondPoint.x;
+ else
+ x = point->x;
+ }
+ else
+ x = firstPoint.x + (nth + 1)*(secondPoint.x - firstPoint.x)/(noArcs + 1);
+ }
+ else x = (secondPoint.x - firstPoint.x)/2.0; // Midpoint
+
+ y = pt1.y;
+ }
+ else
+ {
+ wxASSERT( oglRoughlyEqual(pt1.x, pt2.x) == TRUE );
+
+ wxRealPoint firstPoint, secondPoint;
+ if (pt1.y > pt2.y)
+ {
+ firstPoint = pt2;
+ secondPoint = pt1;
+ }
+ else
+ {
+ firstPoint = pt1;
+ secondPoint = pt2;
+ }
+
+ if (m_spaceAttachments)
+ {
+ if (line && (line->GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE))
+ {
+ // Align line according to the next handle along
+ wxRealPoint *point = line->GetNextControlPoint(this);
+ if (point->y < firstPoint.y)
+ y = firstPoint.y;
+ else if (point->y > secondPoint.y)
+ y = secondPoint.y;
+ else
+ y = point->y;
+ }
+ else
+ y = firstPoint.y + (nth + 1)*(secondPoint.y - firstPoint.y)/(noArcs + 1);
+ }
+ else y = (secondPoint.y - firstPoint.y)/2.0; // Midpoint
+
+ x = pt1.x;
+ }
+
+ return wxRealPoint(x, y);
+}
+
+// Return the zero-based position in m_lines of line.
+int wxShape::GetLinePosition(wxLineShape* line)
+{
+ int i = 0;
+ for (i = 0; i < m_lines.Number(); i++)
+ if ((wxLineShape*) (m_lines.Nth(i)->Data()) == line)
+ return i;
+
+ return 0;
+}
+
class WXDLLEXPORT wxExprDatabase;
#endif
+// Round up
+#define WXROUND(x) ( (long) (x + 0.5) )
+
class wxShapeEvtHandler: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler)
virtual void OnErase(wxDC& dc);
virtual void OnEraseContents(wxDC& dc);
virtual void OnHighlight(wxDC& dc);
- virtual void OnLeftClick(float x, float y, int keys = 0, int attachment = 0);
- virtual void OnRightClick(float x, float y, int keys = 0, int attachment = 0);
- virtual void OnSize(float x, float y);
- virtual bool OnMovePre(wxDC& dc, float x, float y, float old_x, float old_y, bool display = TRUE);
- virtual void OnMovePost(wxDC& dc, float x, float y, float old_x, float old_y, bool display = TRUE);
-
- virtual void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0); // Erase if draw false
- virtual void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
- virtual void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
- virtual void OnDragRight(bool draw, float x, float y, int keys=0, int attachment = 0); // Erase if draw false
- virtual void OnBeginDragRight(float x, float y, int keys=0, int attachment = 0);
- virtual void OnEndDragRight(float x, float y, int keys=0, int attachment = 0);
- virtual void OnDrawOutline(wxDC& dc, float x, float y, float w, float h);
+ virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
+ virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
+ virtual void OnSize(double x, double y);
+ virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
+ virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
+
+ virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
+ virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
+ virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
+ virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
+ virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
+ virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
+ virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
virtual void OnDrawControlPoints(wxDC& dc);
virtual void OnEraseControlPoints(wxDC& dc);
virtual void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
- virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys=0, int attachment = 0); // Erase if draw false
- virtual void OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
- virtual void OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
+ virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
+ virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
+ virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
+
+ virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
+ virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
- virtual void OnBeginSize(float WXUNUSED(w), float WXUNUSED(h)) { }
- virtual void OnEndSize(float WXUNUSED(w), float WXUNUSED(h)) { }
+ // Can override this to prevent or intercept line reordering.
+ virtual void OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering);
// Creates a copy of this event handler.
wxShapeEvtHandler *CreateNewCopy();
wxShape(wxShapeCanvas *can = NULL);
virtual ~wxShape();
- virtual void GetBoundingBoxMax(float *width, float *height);
- virtual void GetBoundingBoxMin(float *width, float *height) = 0;
- virtual bool GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3);
+ virtual void GetBoundingBoxMax(double *width, double *height);
+ virtual void GetBoundingBoxMin(double *width, double *height) = 0;
+ virtual bool GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3);
inline wxShapeCanvas *GetCanvas() { return m_canvas; }
void SetCanvas(wxShapeCanvas *the_canvas);
virtual void AddToCanvas(wxShapeCanvas *the_canvas, wxShape *addAfter = NULL);
virtual void InsertInCanvas(wxShapeCanvas *the_canvas);
virtual void RemoveFromCanvas(wxShapeCanvas *the_canvas);
- inline float GetX() const { return m_xpos; }
- inline float GetY() const { return m_ypos; }
- inline void SetX(float x) { m_xpos = x; }
- inline void SetY(float y) { m_ypos = y; }
+ inline double GetX() const { return m_xpos; }
+ inline double GetY() const { return m_ypos; }
+ inline void SetX(double x) { m_xpos = x; }
+ inline void SetY(double y) { m_ypos = y; }
inline wxShape *GetParent() const { return m_parent; }
inline void SetParent(wxShape *p) { m_parent = p; }
virtual void OnErase(wxDC& dc);
virtual void OnEraseContents(wxDC& dc);
virtual void OnHighlight(wxDC& dc);
- virtual void OnLeftClick(float x, float y, int keys = 0, int attachment = 0);
- virtual void OnRightClick(float x, float y, int keys = 0, int attachment = 0);
- virtual void OnSize(float x, float y);
- virtual bool OnMovePre(wxDC& dc, float x, float y, float old_x, float old_y, bool display = TRUE);
- virtual void OnMovePost(wxDC& dc, float x, float y, float old_x, float old_y, bool display = TRUE);
-
- virtual void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0); // Erase if draw false
- virtual void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
- virtual void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
- virtual void OnDragRight(bool draw, float x, float y, int keys=0, int attachment = 0); // Erase if draw false
- virtual void OnBeginDragRight(float x, float y, int keys=0, int attachment = 0);
- virtual void OnEndDragRight(float x, float y, int keys=0, int attachment = 0);
- virtual void OnDrawOutline(wxDC& dc, float x, float y, float w, float h);
+ virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
+ virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
+ virtual void OnSize(double x, double y);
+ virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
+ virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
+
+ virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
+ virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
+ virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
+ virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
+ virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
+ virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
+ virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
virtual void OnDrawControlPoints(wxDC& dc);
virtual void OnEraseControlPoints(wxDC& dc);
- virtual void OnBeginSize(float WXUNUSED(w), float WXUNUSED(h)) { }
- virtual void OnEndSize(float WXUNUSED(w), float WXUNUSED(h)) { }
+ virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
+ virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
- virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys=0, int attachment = 0); // Erase if draw false
- virtual void OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
- virtual void OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
+ virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
+ virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
+ virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
virtual void MakeControlPoints();
virtual void DeleteControlPoints(wxDC *dc = NULL);
inline bool GetSpaceAttachments() const { return m_spaceAttachments; };
void SetShadowMode(int mode, bool redraw = FALSE);
inline int GetShadowMode() const { return m_shadowMode; }
- virtual bool HitTest(float x, float y, int *attachment, float *distance);
+ virtual bool HitTest(double x, double y, int *attachment, double *distance);
inline void SetCentreResize(bool cr) { m_centreResize = cr; }
inline bool GetCentreResize() const { return m_centreResize; }
inline wxList& GetLines() { return m_lines; }
virtual void Show(bool show);
virtual bool IsShown() const { return m_visible; }
- virtual void Move(wxDC& dc, float x1, float y1, bool display = TRUE);
+ virtual void Move(wxDC& dc, double x1, double y1, bool display = TRUE);
virtual void Erase(wxDC& dc);
virtual void EraseContents(wxDC& dc);
virtual void Draw(wxDC& dc);
virtual void Flash();
virtual void MoveLinks(wxDC& dc);
virtual void DrawContents(wxDC& dc); // E.g. for drawing text label
- virtual void SetSize(float x, float y, bool recursive = TRUE);
- virtual void SetAttachmentSize(float x, float y);
+ virtual void SetSize(double x, double y, bool recursive = TRUE);
+ virtual void SetAttachmentSize(double x, double y);
void Attach(wxShapeCanvas *can);
void Detach();
inline virtual bool Constrain() { return FALSE; } ;
void AddLine(wxLineShape *line, wxShape *other,
- int attachFrom = 0, int attachTo = 0);
+ int attachFrom = 0, int attachTo = 0,
+ // The line ordering
+ int positionFrom = -1, int positionTo = -1);
+
+ // Return the zero-based position in m_lines of line.
+ int GetLinePosition(wxLineShape* line);
+
void AddText(const wxString& string);
inline wxPen *GetPen() const { return m_pen; }
#endif
// Attachment code
- virtual bool GetAttachmentPosition(int attachment, float *x, float *y,
+ virtual bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
virtual int GetNumberOfAttachments();
virtual bool AttachmentIsValid(int attachment);
+ // Assuming the attachment lies along a vertical or horizontal line,
+ // calculate the position on that point.
+ wxRealPoint CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2,
+ int nth, int noArcs, wxLineShape* line);
+
+ // Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
+ // edge of the shape.
+ // attachmentPoint is the attachment point (= side) in question.
+ bool AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2);
+
virtual void EraseLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
virtual void DrawLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
virtual void MoveLineToNewAttachment(wxDC& dc, wxLineShape *to_move,
- float x, float y);
+ double x, double y);
// Reorders the lines coming into the node image at this attachment
// position, in the order in which they appear in linesToSort.
virtual void SortLines(int attachment, wxList& linesToSort);
+ // Apply an attachment ordering change
+ void ApplyAttachmentOrdering(wxList& ordering);
+
+ // Can override this to prevent or intercept line reordering.
+ virtual void OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering);
+
// This is really to distinguish between lines and other images.
// For lines, want to pass drag to canvas, since lines tend to prevent
// dragging on a canvas (they get in the way.)
// (does nothing for most objects)
// But even non-rotating objects should record their notional
// rotation in case it's important (e.g. in dog-leg code).
- virtual inline void Rotate(float WXUNUSED(x), float WXUNUSED(y), float theta) { m_rotation = theta; }
- virtual inline float GetRotation() const { return m_rotation; }
+ virtual inline void Rotate(double WXUNUSED(x), double WXUNUSED(y), double theta) { m_rotation = theta; }
+ virtual inline double GetRotation() const { return m_rotation; }
void ClearAttachments();
protected:
wxShapeEvtHandler* m_eventHandler;
bool m_formatted;
- float m_xpos, m_ypos;
+ double m_xpos, m_ypos;
wxPen* m_pen;
wxBrush* m_brush;
wxFont* m_font;
bool m_selected;
bool m_highlighted; // Different from selected: user-defined highlighting,
// e.g. thick border.
- float m_rotation;
+ double m_rotation;
int m_sensitivity;
bool m_draggable;
bool m_attachmentMode; // TRUE if using attachments, FALSE otherwise
virtual void Create(wxList *points);
virtual void ClearPoints();
- void GetBoundingBoxMin(float *w, float *h);
+ void GetBoundingBoxMin(double *w, double *h);
void CalculateBoundingBox();
- bool GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3);
- bool HitTest(float x, float y, int *attachment, float *distance);
- void SetSize(float x, float y, bool recursive = TRUE);
+ bool GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3);
+ bool HitTest(double x, double y, int *attachment, double *distance);
+ void SetSize(double x, double y, bool recursive = TRUE);
void OnDraw(wxDC& dc);
- void OnDrawOutline(wxDC& dc, float x, float y, float w, float h);
+ void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
- virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys=0, int attachment = 0);
- virtual void OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
- virtual void OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
+ virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
+ virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
+ virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
// A polygon should have a control point at each vertex,
// with the option of moving the control points individually
#endif
int GetNumberOfAttachments();
- bool GetAttachmentPosition(int attachment, float *x, float *y,
+ bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
bool AttachmentIsValid(int attachment);
// Does the copying for this object
private:
wxList* m_points;
wxList* m_originalPoints;
- float m_boundWidth;
- float m_boundHeight;
- float m_originalWidth;
- float m_originalHeight;
+ double m_boundWidth;
+ double m_boundHeight;
+ double m_originalWidth;
+ double m_originalHeight;
};
class wxRectangleShape: public wxShape
{
DECLARE_DYNAMIC_CLASS(wxRectangleShape)
public:
- wxRectangleShape(float w = 0.0, float h = 0.0);
- void GetBoundingBoxMin(float *w, float *h);
- bool GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3);
+ wxRectangleShape(double w = 0.0, double h = 0.0);
+ void GetBoundingBoxMin(double *w, double *h);
+ bool GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3);
void OnDraw(wxDC& dc);
- void SetSize(float x, float y, bool recursive = TRUE);
- void SetCornerRadius(float rad); // If > 0, rounded corners
+ void SetSize(double x, double y, bool recursive = TRUE);
+ void SetCornerRadius(double rad); // If > 0, rounded corners
#ifdef PROLOGIO
// Prolog database stuff
#endif
int GetNumberOfAttachments();
- bool GetAttachmentPosition(int attachment, float *x, float *y,
+ bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
// Does the copying for this object
void Copy(wxShape& copy);
- inline float GetWidth() const { return m_width; }
- inline float GetHeight() const { return m_height; }
- inline void SetWidth(float w) { m_width = w; }
- inline void SetHeight(float h) { m_height = h; }
+ inline double GetWidth() const { return m_width; }
+ inline double GetHeight() const { return m_height; }
+ inline void SetWidth(double w) { m_width = w; }
+ inline void SetHeight(double h) { m_height = h; }
protected:
- float m_width;
- float m_height;
- float m_cornerRadius;
+ double m_width;
+ double m_height;
+ double m_cornerRadius;
};
class wxTextShape: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxTextShape)
public:
- wxTextShape(float width = 0.0, float height = 0.0);
+ wxTextShape(double width = 0.0, double height = 0.0);
void OnDraw(wxDC& dc);
{
DECLARE_DYNAMIC_CLASS(wxEllipseShape)
public:
- wxEllipseShape(float w = 0.0, float h = 0.0);
+ wxEllipseShape(double w = 0.0, double h = 0.0);
- void GetBoundingBoxMin(float *w, float *h);
- bool GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3);
+ void GetBoundingBoxMin(double *w, double *h);
+ bool GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3);
void OnDraw(wxDC& dc);
- void SetSize(float x, float y, bool recursive = TRUE);
+ void SetSize(double x, double y, bool recursive = TRUE);
#ifdef PROLOGIO
// Prolog database stuff
#endif
int GetNumberOfAttachments();
- bool GetAttachmentPosition(int attachment, float *x, float *y,
+ bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
// Does the copying for this object
void Copy(wxShape& copy);
- inline float GetWidth() const { return m_width; }
- inline float GetHeight() const { return m_height; }
+ inline double GetWidth() const { return m_width; }
+ inline double GetHeight() const { return m_height; }
protected:
- float m_width;
- float m_height;
+ double m_width;
+ double m_height;
};
class wxCircleShape: public wxEllipseShape
{
DECLARE_DYNAMIC_CLASS(wxCircleShape)
public:
- wxCircleShape(float w = 0.0);
+ wxCircleShape(double w = 0.0);
- bool GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3);
+ bool GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3);
// Does the copying for this object
void Copy(wxShape& copy);
};
// Width and height. Centre of object is centre of box.
-void wxPolygonShape::GetBoundingBoxMin(float *width, float *height)
+void wxPolygonShape::GetBoundingBoxMin(double *width, double *height)
{
*width = m_boundWidth;
*height = m_boundHeight;
void wxPolygonShape::CalculateBoundingBox()
{
// Calculate bounding box at construction (and presumably resize) time
- float left = 10000;
- float right = -10000;
- float top = 10000;
- float bottom = -10000;
+ double left = 10000;
+ double right = -10000;
+ double top = 10000;
+ double bottom = -10000;
wxNode *node = m_points->First();
while (node)
// box.
void wxPolygonShape::CalculatePolygonCentre()
{
- float left = 10000;
- float right = -10000;
- float top = 10000;
- float bottom = -10000;
+ double left = 10000;
+ double right = -10000;
+ double top = 10000;
+ double bottom = -10000;
wxNode *node = m_points->First();
while (node)
node = node->Next();
}
- float bwidth = right - left;
- float bheight = bottom - top;
-
- float newCentreX = (float)(left + (bwidth/2.0));
- float newCentreY = (float)(top + (bheight/2.0));
+ double bwidth = right - left;
+ double bheight = bottom - top;
+
+ double newCentreX = (double)(left + (bwidth/2.0));
+ double newCentreY = (double)(top + (bheight/2.0));
node = m_points->First();
while (node)
m_ypos += newCentreY;
}
-bool PolylineHitTest(float n, float xvec[], float yvec[],
- float x1, float y1, float x2, float y2)
+bool PolylineHitTest(double n, double xvec[], double yvec[],
+ double x1, double y1, double x2, double y2)
{
bool isAHit = FALSE;
int i;
- float lastx = xvec[0];
- float lasty = yvec[0];
+ double lastx = xvec[0];
+ double lasty = yvec[0];
- float min_ratio = 1.0;
- float line_ratio;
- float other_ratio;
+ double min_ratio = 1.0;
+ double line_ratio;
+ double other_ratio;
// char buf[300];
for (i = 1; i < n; i++)
{
- check_line_intersection(x1, y1, x2, y2, lastx, lasty, xvec[i], yvec[i],
+ oglCheckLineIntersection(x1, y1, x2, y2, lastx, lasty, xvec[i], yvec[i],
&line_ratio, &other_ratio);
if (line_ratio != 1.0)
isAHit = TRUE;
min_ratio = line_ratio;
}
- // Do last (implicit) line if last and first floats are not identical
+ // Do last (implicit) line if last and first doubles are not identical
if (!(xvec[0] == lastx && yvec[0] == lasty))
{
- check_line_intersection(x1, y1, x2, y2, lastx, lasty, xvec[0], yvec[0],
+ oglCheckLineIntersection(x1, y1, x2, y2, lastx, lasty, xvec[0], yvec[0],
&line_ratio, &other_ratio);
if (line_ratio != 1.0)
isAHit = TRUE;
return isAHit;
}
-bool wxPolygonShape::HitTest(float x, float y, int *attachment, float *distance)
+bool wxPolygonShape::HitTest(double x, double y, int *attachment, double *distance)
{
// Imagine four lines radiating from this point. If all of these lines hit the polygon,
// we're inside it, otherwise we're not. Obviously we'd need more radiating lines
// to be sure of correct results for very strange (concave) shapes.
- float endPointsX[4];
- float endPointsY[4];
+ double endPointsX[4];
+ double endPointsY[4];
// North
endPointsX[0] = x;
- endPointsY[0] = (float)(y - 1000.0);
+ endPointsY[0] = (double)(y - 1000.0);
// East
- endPointsX[1] = (float)(x + 1000.0);
+ endPointsX[1] = (double)(x + 1000.0);
endPointsY[1] = y;
// South
endPointsX[2] = x;
- endPointsY[2] = (float)(y + 1000.0);
+ endPointsY[2] = (double)(y + 1000.0);
// West
- endPointsX[3] = (float)(x - 1000.0);
+ endPointsX[3] = (double)(x - 1000.0);
endPointsY[3] = y;
// Store polygon points in an array
int np = m_points->Number();
- float *xpoints = new float[np];
- float *ypoints = new float[np];
+ double *xpoints = new double[np];
+ double *ypoints = new double[np];
wxNode *node = m_points->First();
int i = 0;
while (node)
// If a hit, check the attachment points within the object.
int n = GetNumberOfAttachments();
- float nearest = 999999.0;
+ double nearest = 999999.0;
for (i = 0; i < n; i++)
{
- float xp, yp;
+ double xp, yp;
if (GetAttachmentPosition(i, &xp, &yp))
{
- float l = (float)sqrt(((xp - x) * (xp - x)) +
+ double l = (double)sqrt(((xp - x) * (xp - x)) +
((yp - y) * (yp - y)));
if (l < nearest)
{
// Really need to be able to reset the shape! Otherwise, if the
// points ever go to zero, we've lost it, and can't resize.
-void wxPolygonShape::SetSize(float new_width, float new_height, bool recursive)
+void wxPolygonShape::SetSize(double new_width, double new_height, bool recursive)
{
SetAttachmentSize(new_width, new_height);
// Multiply all points by proportion of new size to old size
- float x_proportion = (float)(fabs(new_width/m_originalWidth));
- float y_proportion = (float)(fabs(new_height/m_originalHeight));
+ double x_proportion = (double)(fabs(new_width/m_originalWidth));
+ double y_proportion = (double)(fabs(new_height/m_originalHeight));
wxNode *node = m_points->First();
wxNode *original_node = m_originalPoints->First();
}
// CalculateBoundingBox();
- m_boundWidth = (float)fabs(new_width);
- m_boundHeight = (float)fabs(new_height);
+ m_boundWidth = (double)fabs(new_width);
+ m_boundHeight = (double)fabs(new_height);
SetDefaultRegionSize();
}
if (!node2) node2 = m_points->First();
wxRealPoint *secondPoint = (wxRealPoint *)node2->Data();
- float x = (float)((secondPoint->x - firstPoint->x)/2.0 + firstPoint->x);
- float y = (float)((secondPoint->y - firstPoint->y)/2.0 + firstPoint->y);
+ double x = (double)((secondPoint->x - firstPoint->x)/2.0 + firstPoint->x);
+ double y = (double)((secondPoint->y - firstPoint->y)/2.0 + firstPoint->y);
wxRealPoint *point = new wxRealPoint(x, y);
if (pos >= (m_points->Number() - 1))
}
// Assume (x1, y1) is centre of box (most generally, line end at box)
-bool wxPolygonShape::GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3)
+bool wxPolygonShape::GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3)
{
int n = m_points->Number();
// First check for situation where the line is vertical,
// and we would want to connect to a point on that vertical --
- // find_end_for_polyline can't cope with this (the arrow
+ // oglFindEndForPolyline can't cope with this (the arrow
// gets drawn to the wrong place).
if ((!m_attachmentMode) && (x1 == x2))
{
}
}
- float *xpoints = new float[n];
- float *ypoints = new float[n];
+ double *xpoints = new double[n];
+ double *ypoints = new double[n];
wxNode *node = m_points->First();
int i = 0;
node = node->Next();
i ++;
}
-/*
- wxRealPoint *point = (wxRealPoint *)m_points->First()->Data();
- xpoints[i] = point->x + m_xpos;
- ypoints[i] = point->y + m_ypos;
-*/
- find_end_for_polyline(n, xpoints, ypoints,
+ oglFindEndForPolyline(n, xpoints, ypoints,
x1, y1, x2, y2, x3, y3);
- delete xpoints;
- delete ypoints;
+ delete[] xpoints;
+ delete[] ypoints;
return TRUE;
}
for (i = 0; i < n; i++)
{
wxRealPoint* point = (wxRealPoint*) m_points->Nth(i)->Data();
- intPoints[i].x = (int) point->x;
- intPoints[i].y = (int) point->y;
+ intPoints[i].x = WXROUND(point->x);
+ intPoints[i].y = WXROUND(point->y);
}
if (m_shadowMode != SHADOW_NONE)
{
if (m_shadowBrush)
dc.SetBrush(m_shadowBrush);
- dc.SetPen(transparent_pen);
+ dc.SetPen(g_oglTransparentPen);
- dc.DrawPolygon(n, intPoints, m_xpos + m_shadowOffsetX, m_ypos + m_shadowOffsetY);
+ dc.DrawPolygon(n, intPoints, WXROUND(m_xpos + m_shadowOffsetX), WXROUND(m_ypos + m_shadowOffsetY));
}
if (m_pen)
{
if (m_pen->GetWidth() == 0)
- dc.SetPen(transparent_pen);
+ dc.SetPen(g_oglTransparentPen);
else
dc.SetPen(m_pen);
}
if (m_brush)
dc.SetBrush(m_brush);
- dc.DrawPolygon(n, intPoints, m_xpos, m_ypos);
+ dc.DrawPolygon(n, intPoints, WXROUND(m_xpos), WXROUND(m_ypos));
delete[] intPoints;
}
-void wxPolygonShape::OnDrawOutline(wxDC& dc, float x, float y, float w, float h)
+void wxPolygonShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double h)
{
dc.SetBrush(wxTRANSPARENT_BRUSH);
// Multiply all points by proportion of new size to old size
- float x_proportion = (float)(fabs(w/m_originalWidth));
- float y_proportion = (float)(fabs(h/m_originalHeight));
+ double x_proportion = (double)(fabs(w/m_originalWidth));
+ double y_proportion = (double)(fabs(h/m_originalHeight));
int n = m_originalPoints->Number();
wxPoint *intPoints = new wxPoint[n];
for (i = 0; i < n; i++)
{
wxRealPoint* point = (wxRealPoint*) m_originalPoints->Nth(i)->Data();
- intPoints[i].x = (int) (x_proportion * point->x);
- intPoints[i].y = (int) (y_proportion * point->y);
+ intPoints[i].x = WXROUND(x_proportion * point->x);
+ intPoints[i].y = WXROUND(y_proportion * point->y);
}
- dc.DrawPolygon(n, intPoints, x, y);
+ dc.DrawPolygon(n, intPoints, WXROUND(x), WXROUND(y));
delete[] intPoints;
}
}
/*
- float maxX, maxY, minX, minY;
+ double maxX, maxY, minX, minY;
GetBoundingBoxMax(&maxX, &maxY);
GetBoundingBoxMin(&minX, &minY);
- float widthMin = (float)(minX + CONTROL_POINT_SIZE + 2);
- float heightMin = (float)(minY + CONTROL_POINT_SIZE + 2);
+ double widthMin = (double)(minX + CONTROL_POINT_SIZE + 2);
+ double heightMin = (double)(minY + CONTROL_POINT_SIZE + 2);
// Offsets from main object
- float top = (float)(- (heightMin / 2.0));
- float bottom = (float)(heightMin / 2.0 + (maxY - minY));
- float left = (float)(- (widthMin / 2.0));
- float right = (float)(widthMin / 2.0 + (maxX - minX));
+ double top = (double)(- (heightMin / 2.0));
+ double bottom = (double)(heightMin / 2.0 + (maxY - minY));
+ double left = (double)(- (widthMin / 2.0));
+ double right = (double)(widthMin / 2.0 + (maxX - minX));
wxControlPoint *control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, left, top,
CONTROL_POINT_DIAGONAL);
if (m_controlPoints.Number() < 1)
return;
- float maxX, maxY, minX, minY;
+ double maxX, maxY, minX, minY;
GetBoundingBoxMax(&maxX, &maxY);
GetBoundingBoxMin(&minX, &minY);
- float widthMin = (float)(minX + CONTROL_POINT_SIZE + 2);
- float heightMin = (float)(minY + CONTROL_POINT_SIZE + 2);
+ double widthMin = (double)(minX + CONTROL_POINT_SIZE + 2);
+ double heightMin = (double)(minY + CONTROL_POINT_SIZE + 2);
// Offsets from main object
- float top = (float)(- (heightMin / 2.0));
- float bottom = (float)(heightMin / 2.0 + (maxY - minY));
- float left = (float)(- (widthMin / 2.0));
- float right = (float)(widthMin / 2.0 + (maxX - minX));
+ double top = (double)(- (heightMin / 2.0));
+ double bottom = (double)(heightMin / 2.0 + (maxY - minY));
+ double left = (double)(- (widthMin / 2.0));
+ double right = (double)(widthMin / 2.0 + (maxX - minX));
wxNode *node = m_controlPoints.First();
wxControlPoint *control = (wxControlPoint *)node->Data();
{
wxRealPoint *point = (wxRealPoint *)node->Data();
wxExpr *point_list = new wxExpr(PrologList);
- wxExpr *x_expr = new wxExpr((float)point->x);
- wxExpr *y_expr = new wxExpr((float)point->y);
+ wxExpr *x_expr = new wxExpr((double)point->x);
+ wxExpr *y_expr = new wxExpr((double)point->y);
point_list->Append(x_expr);
point_list->Append(y_expr);
{
wxRealPoint *point = (wxRealPoint *)node->Data();
wxExpr *point_list = new wxExpr(PrologList);
- wxExpr *x_expr = new wxExpr((float) point->x);
- wxExpr *y_expr = new wxExpr((float) point->y);
+ wxExpr *x_expr = new wxExpr((double) point->x);
+ wxExpr *y_expr = new wxExpr((double) point->y);
point_list->Append(x_expr);
point_list->Append(y_expr);
list->Append(point_list);
clause->AssignAttributeValue("points", &points_list);
// If no points_list, don't crash!! Assume a diamond instead.
- float the_height = 100.0;
- float the_width = 100.0;
+ double the_height = 100.0;
+ double the_width = 100.0;
if (!points_list)
{
wxRealPoint *point = new wxRealPoint(0.0, (-the_height/2));
wxExpr *yexpr = xexpr->next;
long y = yexpr->IntegerValue();
- wxRealPoint *point = new wxRealPoint((float)x, (float)y);
+ wxRealPoint *point = new wxRealPoint((double)x, (double)y);
m_points->Append((wxObject*) point);
node = node->next;
else
{
wxExpr *node = points_list->value.first;
- float min_x = 1000;
- float min_y = 1000;
- float max_x = -1000;
- float max_y = -1000;
+ double min_x = 1000;
+ double min_y = 1000;
+ double max_x = -1000;
+ double max_y = -1000;
while (node)
{
wxExpr *xexpr = node->value.first;
wxExpr *yexpr = xexpr->next;
long y = yexpr->IntegerValue();
- wxRealPoint *point = new wxRealPoint((float)x, (float)y);
+ wxRealPoint *point = new wxRealPoint((double)x, (double)y);
m_originalPoints->Append((wxObject*) point);
if (x < min_x)
- min_x = (float)x;
+ min_x = (double)x;
if (y < min_y)
- min_y = (float)y;
+ min_y = (double)y;
if (x > max_x)
- max_x = (float)x;
+ max_x = (double)x;
if (y > max_y)
- max_y = (float)y;
+ max_y = (double)y;
node = node->next;
}
return maxN+1;;
}
-bool wxPolygonShape::GetAttachmentPosition(int attachment, float *x, float *y,
+bool wxPolygonShape::GetAttachmentPosition(int attachment, double *x, double *y,
int nth, int no_arcs, wxLineShape *line)
{
if (m_attachmentMode && m_points && attachment < m_points->Number())
IMPLEMENT_DYNAMIC_CLASS(wxRectangleShape, wxShape)
-wxRectangleShape::wxRectangleShape(float w, float h)
+wxRectangleShape::wxRectangleShape(double w, double h)
{
m_width = w; m_height = h; m_cornerRadius = 0.0;
SetDefaultRegionSize();
void wxRectangleShape::OnDraw(wxDC& dc)
{
- float x1 = (float)(m_xpos - m_width/2.0);
- float y1 = (float)(m_ypos - m_height/2.0);
+ double x1 = (double)(m_xpos - m_width/2.0);
+ double y1 = (double)(m_ypos - m_height/2.0);
if (m_shadowMode != SHADOW_NONE)
{
if (m_shadowBrush)
dc.SetBrush(m_shadowBrush);
- dc.SetPen(transparent_pen);
+ dc.SetPen(g_oglTransparentPen);
if (m_cornerRadius != 0.0)
- dc.DrawRoundedRectangle(x1 + m_shadowOffsetX, y1 + m_shadowOffsetY,
- m_width, m_height, m_cornerRadius);
+ dc.DrawRoundedRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY),
+ WXROUND(m_width), WXROUND(m_height), m_cornerRadius);
else
- dc.DrawRectangle(x1 + m_shadowOffsetX, y1 + m_shadowOffsetY, m_width, m_height);
+ dc.DrawRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY), WXROUND(m_width), WXROUND(m_height));
}
if (m_pen)
{
if (m_pen->GetWidth() == 0)
- dc.SetPen(transparent_pen);
+ dc.SetPen(g_oglTransparentPen);
else
dc.SetPen(m_pen);
}
dc.SetBrush(m_brush);
if (m_cornerRadius != 0.0)
- dc.DrawRoundedRectangle(x1, y1, m_width, m_height, m_cornerRadius);
+ dc.DrawRoundedRectangle(WXROUND(x1), WXROUND(y1), WXROUND(m_width), WXROUND(m_height), m_cornerRadius);
else
- dc.DrawRectangle(x1, y1, m_width, m_height);
+ dc.DrawRectangle(WXROUND(x1), WXROUND(y1), WXROUND(m_width), WXROUND(m_height));
}
-void wxRectangleShape::GetBoundingBoxMin(float *the_width, float *the_height)
+void wxRectangleShape::GetBoundingBoxMin(double *the_width, double *the_height)
{
*the_width = m_width;
*the_height = m_height;
}
-void wxRectangleShape::SetSize(float x, float y, bool recursive)
+void wxRectangleShape::SetSize(double x, double y, bool recursive)
{
SetAttachmentSize(x, y);
- m_width = (float)wxMax(x, 1.0);
- m_height = (float)wxMax(y, 1.0);
+ m_width = (double)wxMax(x, 1.0);
+ m_height = (double)wxMax(y, 1.0);
SetDefaultRegionSize();
}
-void wxRectangleShape::SetCornerRadius(float rad)
+void wxRectangleShape::SetCornerRadius(double rad)
{
m_cornerRadius = rad;
}
// Assume (x1, y1) is centre of box (most generally, line end at box)
-bool wxRectangleShape::GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3)
+bool wxRectangleShape::GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3)
{
- float bound_x, bound_y;
+ double bound_x, bound_y;
GetBoundingBoxMax(&bound_x, &bound_y);
- find_end_for_box(bound_x, bound_y, m_xpos, m_ypos, x2, y2, x3, y3);
+ oglFindEndForBox(bound_x, bound_y, m_xpos, m_ypos, x2, y2, x3, y3);
return TRUE;
}
return wxShape::GetNumberOfAttachments();
}
+
// There are 4 attachment points on a rectangle - 0 = top, 1 = right, 2 = bottom,
// 3 = left.
-bool wxRectangleShape::GetAttachmentPosition(int attachment, float *x, float *y,
+bool wxRectangleShape::GetAttachmentPosition(int attachment, double *x, double *y,
int nth, int no_arcs, wxLineShape *line)
{
if (m_attachmentMode)
{
- float top = (float)(m_ypos + m_height/2.0);
- float bottom = (float)(m_ypos - m_height/2.0);
- float left = (float)(m_xpos - m_width/2.0);
- float right = (float)(m_xpos + m_width/2.0);
+ double top = (double)(m_ypos + m_height/2.0);
+ double bottom = (double)(m_ypos - m_height/2.0);
+ double left = (double)(m_xpos - m_width/2.0);
+ double right = (double)(m_xpos + m_width/2.0);
bool isEnd = (line && line->IsEnd(this));
+ // Simplified code
+ switch (attachment)
+ {
+ case 0:
+ {
+ wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(left, bottom), wxRealPoint(right, bottom),
+ nth, no_arcs, line);
+
+ *x = pt.x; *y = pt.y;
+ break;
+ }
+ case 1:
+ {
+ wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(right, bottom), wxRealPoint(right, top),
+ nth, no_arcs, line);
+
+ *x = pt.x; *y = pt.y;
+ break;
+ }
+ case 2:
+ {
+ wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(left, top), wxRealPoint(right, top),
+ nth, no_arcs, line);
+
+ *x = pt.x; *y = pt.y;
+ break;
+ }
+ case 3:
+ {
+ wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(left, bottom), wxRealPoint(left, top),
+ nth, no_arcs, line);
+
+ *x = pt.x; *y = pt.y;
+ break;
+ }
+ default:
+ {
+ return wxShape::GetAttachmentPosition(attachment, x, y, nth, no_arcs, line);
+ break;
+ }
+ }
+
+ // Old code
+#if 0
switch (attachment)
{
case 0:
break;
}
}
+#endif
return TRUE;
}
else
IMPLEMENT_DYNAMIC_CLASS(wxTextShape, wxRectangleShape)
-wxTextShape::wxTextShape(float width, float height):
+wxTextShape::wxTextShape(double width, double height):
wxRectangleShape(width, height)
{
}
IMPLEMENT_DYNAMIC_CLASS(wxEllipseShape, wxShape)
-wxEllipseShape::wxEllipseShape(float w, float h)
+wxEllipseShape::wxEllipseShape(double w, double h)
{
m_width = w; m_height = h;
SetDefaultRegionSize();
}
-void wxEllipseShape::GetBoundingBoxMin(float *w, float *h)
+void wxEllipseShape::GetBoundingBoxMin(double *w, double *h)
{
*w = m_width; *h = m_height;
}
-bool wxEllipseShape::GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3)
+bool wxEllipseShape::GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3)
{
- float bound_x, bound_y;
+ double bound_x, bound_y;
GetBoundingBoxMax(&bound_x, &bound_y);
-// find_end_for_box(bound_x, bound_y, m_xpos, m_ypos, x2, y2, x3, y3);
- draw_arc_to_ellipse(m_xpos, m_ypos, bound_x, bound_y, x2, y2, x1, y1, x3, y3);
+// oglFindEndForBox(bound_x, bound_y, m_xpos, m_ypos, x2, y2, x3, y3);
+ oglDrawArcToEllipse(m_xpos, m_ypos, bound_x, bound_y, x2, y2, x1, y1, x3, y3);
return TRUE;
}
{
if (m_shadowBrush)
dc.SetBrush(m_shadowBrush);
- dc.SetPen(transparent_pen);
+ dc.SetPen(g_oglTransparentPen);
dc.DrawEllipse((m_xpos - GetWidth()/2) + m_shadowOffsetX,
(m_ypos - GetHeight()/2) + m_shadowOffsetY,
GetWidth(), GetHeight());
if (m_pen)
{
if (m_pen->GetWidth() == 0)
- dc.SetPen(transparent_pen);
+ dc.SetPen(g_oglTransparentPen);
else
dc.SetPen(m_pen);
}
dc.DrawEllipse((m_xpos - GetWidth()/2), (m_ypos - GetHeight()/2), GetWidth(), GetHeight());
}
-void wxEllipseShape::SetSize(float x, float y, bool recursive)
+void wxEllipseShape::SetSize(double x, double y, bool recursive)
{
SetAttachmentSize(x, y);
m_width = x;
// There are 4 attachment points on an ellipse - 0 = top, 1 = right, 2 = bottom,
// 3 = left.
-bool wxEllipseShape::GetAttachmentPosition(int attachment, float *x, float *y,
+bool wxEllipseShape::GetAttachmentPosition(int attachment, double *x, double *y,
int nth, int no_arcs, wxLineShape *line)
{
if (m_attachmentMode)
{
- float top = (float)(m_ypos + m_height/2.0);
- float bottom = (float)(m_ypos - m_height/2.0);
- float left = (float)(m_xpos - m_width/2.0);
- float right = (float)(m_xpos + m_width/2.0);
+ double top = (double)(m_ypos + m_height/2.0);
+ double bottom = (double)(m_ypos - m_height/2.0);
+ double left = (double)(m_xpos - m_width/2.0);
+ double right = (double)(m_xpos + m_width/2.0);
switch (attachment)
{
case 0:
// We now have the point on the bounding box: but get the point on the ellipse
// by imagining a vertical line from (*x, m_ypos - m_height- 500) to (*x, m_ypos) intersecting
// the ellipse.
- draw_arc_to_ellipse(m_xpos, m_ypos, m_width, m_height, *x, (float)(m_ypos-m_height-500), *x, m_ypos, x, y);
+ oglDrawArcToEllipse(m_xpos, m_ypos, m_width, m_height, *x, (double)(m_ypos-m_height-500), *x, m_ypos, x, y);
break;
}
case 1:
if (m_spaceAttachments)
*y = bottom + (nth + 1)*m_height/(no_arcs + 1);
else *y = m_ypos;
- draw_arc_to_ellipse(m_xpos, m_ypos, m_width, m_height, (float)(m_xpos+m_width+500), *y, m_xpos, *y, x, y);
+ oglDrawArcToEllipse(m_xpos, m_ypos, m_width, m_height, (double)(m_xpos+m_width+500), *y, m_xpos, *y, x, y);
break;
}
case 2:
*x = left + (nth + 1)*m_width/(no_arcs + 1);
else *x = m_xpos;
*y = bottom;
- draw_arc_to_ellipse(m_xpos, m_ypos, m_width, m_height, *x, (float)(m_ypos+m_height+500), *x, m_ypos, x, y);
+ oglDrawArcToEllipse(m_xpos, m_ypos, m_width, m_height, *x, (double)(m_ypos+m_height+500), *x, m_ypos, x, y);
break;
}
case 3:
if (m_spaceAttachments)
*y = bottom + (nth + 1)*m_height/(no_arcs + 1);
else *y = m_ypos;
- draw_arc_to_ellipse(m_xpos, m_ypos, m_width, m_height, (float)(m_xpos-m_width-500), *y, m_xpos, *y, x, y);
+ oglDrawArcToEllipse(m_xpos, m_ypos, m_width, m_height, (double)(m_xpos-m_width-500), *y, m_xpos, *y, x, y);
break;
}
default:
// Circle object
IMPLEMENT_DYNAMIC_CLASS(wxCircleShape, wxEllipseShape)
-wxCircleShape::wxCircleShape(float diameter):wxEllipseShape(diameter, diameter)
+wxCircleShape::wxCircleShape(double diameter):wxEllipseShape(diameter, diameter)
{
}
wxEllipseShape::Copy(copy);
}
-bool wxCircleShape::GetPerimeterPoint(float x1, float y1,
- float x2, float y2,
- float *x3, float *y3)
+bool wxCircleShape::GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3)
{
- find_end_for_circle(m_width/2,
+ oglFindEndForCircle(m_width/2,
m_xpos, m_ypos, // Centre of circle
x2, y2, // Other end of line
x3, y3);
// Control points
-float wxControlPoint::controlPointDragStartX = 0.0;
-float wxControlPoint::controlPointDragStartY = 0.0;
-float wxControlPoint::controlPointDragStartWidth = 0.0;
-float wxControlPoint::controlPointDragStartHeight = 0.0;
-float wxControlPoint::controlPointDragEndWidth = 0.0;
-float wxControlPoint::controlPointDragEndHeight = 0.0;
-float wxControlPoint::controlPointDragPosX = 0.0;
-float wxControlPoint::controlPointDragPosY = 0.0;
+double wxControlPoint::controlPointDragStartX = 0.0;
+double wxControlPoint::controlPointDragStartY = 0.0;
+double wxControlPoint::controlPointDragStartWidth = 0.0;
+double wxControlPoint::controlPointDragStartHeight = 0.0;
+double wxControlPoint::controlPointDragEndWidth = 0.0;
+double wxControlPoint::controlPointDragEndHeight = 0.0;
+double wxControlPoint::controlPointDragPosX = 0.0;
+double wxControlPoint::controlPointDragPosY = 0.0;
IMPLEMENT_DYNAMIC_CLASS(wxControlPoint, wxRectangleShape)
-wxControlPoint::wxControlPoint(wxShapeCanvas *theCanvas, wxShape *object, float size, float the_xoffset, float the_yoffset, int the_type):wxRectangleShape(size, size)
+wxControlPoint::wxControlPoint(wxShapeCanvas *theCanvas, wxShape *object, double size, double the_xoffset, double the_yoffset, int the_type):wxRectangleShape(size, size)
{
m_canvas = theCanvas;
m_shape = object;
m_xoffset = the_xoffset;
m_yoffset = the_yoffset;
m_type = the_type;
- SetPen(black_foreground_pen);
+ SetPen(g_oglBlackForegroundPen);
SetBrush(wxBLACK_BRUSH);
m_oldCursor = NULL;
m_visible = TRUE;
}
// Implement resizing of canvas object
-void wxControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxControlPoint::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingDragLeft(this, draw, x, y, keys, attachment);
}
-void wxControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxControlPoint::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingBeginDragLeft(this, x, y, keys, attachment);
}
-void wxControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxControlPoint::OnEndDragLeft(double x, double y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingEndDragLeft(this, x, y, keys, attachment);
}
return 1;
}
-bool wxControlPoint::GetAttachmentPosition(int attachment, float *x, float *y,
+bool wxControlPoint::GetAttachmentPosition(int attachment, double *x, double *y,
int nth, int no_arcs, wxLineShape *line)
{
*x = m_xpos; *y = m_ypos;
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
-void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys, int attachment)
+void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys, int attachment)
{
- float bound_x;
- float bound_y;
+ double bound_x;
+ double bound_y;
this->GetBoundingBoxMin(&bound_x, &bound_y);
wxClientDC dc(GetCanvas());
if (this->GetCentreResize())
{
// Maintain the same centre point.
- float new_width = (float)(2.0*fabs(x - this->GetX()));
- float new_height = (float)(2.0*fabs(y - this->GetY()));
+ double new_width = (double)(2.0*fabs(x - this->GetX()));
+ double new_height = (double)(2.0*fabs(y - this->GetY()));
// Constrain sizing according to what control point you're dragging
if (pt->m_type == CONTROL_POINT_HORIZONTAL)
else
{
// Don't maintain the same centre point!
- float newX1 = wxMin(pt->controlPointDragStartX, x);
- float newY1 = wxMin(pt->controlPointDragStartY, y);
- float newX2 = wxMax(pt->controlPointDragStartX, x);
- float newY2 = wxMax(pt->controlPointDragStartY, y);
+ double newX1 = wxMin(pt->controlPointDragStartX, x);
+ double newY1 = wxMin(pt->controlPointDragStartY, y);
+ double newX2 = wxMax(pt->controlPointDragStartX, x);
+ double newY2 = wxMax(pt->controlPointDragStartY, y);
if (pt->m_type == CONTROL_POINT_HORIZONTAL)
{
newY1 = pt->controlPointDragStartY;
}
else if (pt->m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT))
{
- float newH = (float)((newX2 - newX1)*(pt->controlPointDragStartHeight/pt->controlPointDragStartWidth));
+ double newH = (double)((newX2 - newX1)*(pt->controlPointDragStartHeight/pt->controlPointDragStartWidth));
if (GetY() > pt->controlPointDragStartY)
- newY2 = (float)(newY1 + newH);
+ newY2 = (double)(newY1 + newH);
else
- newY1 = (float)(newY2 - newH);
+ newY1 = (double)(newY2 - newH);
}
- float newWidth = (float)(newX2 - newX1);
- float newHeight = (float)(newY2 - newY1);
+ double newWidth = (double)(newX2 - newX1);
+ double newHeight = (double)(newY2 - newY1);
- pt->controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
- pt->controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
+ pt->controlPointDragPosX = (double)(newX1 + (newWidth/2.0));
+ pt->controlPointDragPosY = (double)(newY1 + (newHeight/2.0));
if (this->GetFixedWidth())
newWidth = bound_x;
}
}
-void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
+void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
{
m_canvas->CaptureMouse();
dc.SetLogicalFunction(wxXOR);
- float bound_x;
- float bound_y;
+ double bound_x;
+ double bound_y;
this->GetBoundingBoxMin(&bound_x, &bound_y);
// Choose the 'opposite corner' of the object as the stationary
// point in case this is non-centring resizing.
if (pt->GetX() < this->GetX())
- pt->controlPointDragStartX = (float)(this->GetX() + (bound_x/2.0));
+ pt->controlPointDragStartX = (double)(this->GetX() + (bound_x/2.0));
else
- pt->controlPointDragStartX = (float)(this->GetX() - (bound_x/2.0));
+ pt->controlPointDragStartX = (double)(this->GetX() - (bound_x/2.0));
if (pt->GetY() < this->GetY())
- pt->controlPointDragStartY = (float)(this->GetY() + (bound_y/2.0));
+ pt->controlPointDragStartY = (double)(this->GetY() + (bound_y/2.0));
else
- pt->controlPointDragStartY = (float)(this->GetY() - (bound_y/2.0));
+ pt->controlPointDragStartY = (double)(this->GetY() - (bound_y/2.0));
if (pt->m_type == CONTROL_POINT_HORIZONTAL)
- pt->controlPointDragStartY = (float)(this->GetY() - (bound_y/2.0));
+ pt->controlPointDragStartY = (double)(this->GetY() - (bound_y/2.0));
else if (pt->m_type == CONTROL_POINT_VERTICAL)
- pt->controlPointDragStartX = (float)(this->GetX() - (bound_x/2.0));
+ pt->controlPointDragStartX = (double)(this->GetX() - (bound_x/2.0));
// We may require the old width and height.
pt->controlPointDragStartWidth = bound_x;
if (this->GetCentreResize())
{
- float new_width = (float)(2.0*fabs(x - this->GetX()));
- float new_height = (float)(2.0*fabs(y - this->GetY()));
+ double new_width = (double)(2.0*fabs(x - this->GetX()));
+ double new_height = (double)(2.0*fabs(y - this->GetY()));
// Constrain sizing according to what control point you're dragging
if (pt->m_type == CONTROL_POINT_HORIZONTAL)
else
{
// Don't maintain the same centre point!
- float newX1 = wxMin(pt->controlPointDragStartX, x);
- float newY1 = wxMin(pt->controlPointDragStartY, y);
- float newX2 = wxMax(pt->controlPointDragStartX, x);
- float newY2 = wxMax(pt->controlPointDragStartY, y);
+ double newX1 = wxMin(pt->controlPointDragStartX, x);
+ double newY1 = wxMin(pt->controlPointDragStartY, y);
+ double newX2 = wxMax(pt->controlPointDragStartX, x);
+ double newY2 = wxMax(pt->controlPointDragStartY, y);
if (pt->m_type == CONTROL_POINT_HORIZONTAL)
{
newY1 = pt->controlPointDragStartY;
}
else if (pt->m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT))
{
- float newH = (float)((newX2 - newX1)*(pt->controlPointDragStartHeight/pt->controlPointDragStartWidth));
+ double newH = (double)((newX2 - newX1)*(pt->controlPointDragStartHeight/pt->controlPointDragStartWidth));
if (pt->GetY() > pt->controlPointDragStartY)
- newY2 = (float)(newY1 + newH);
+ newY2 = (double)(newY1 + newH);
else
- newY1 = (float)(newY2 - newH);
+ newY1 = (double)(newY2 - newH);
}
- float newWidth = (float)(newX2 - newX1);
- float newHeight = (float)(newY2 - newY1);
+ double newWidth = (double)(newX2 - newX1);
+ double newHeight = (double)(newY2 - newY1);
- pt->controlPointDragPosX = (float)(newX1 + (newWidth/2.0));
- pt->controlPointDragPosY = (float)(newY1 + (newHeight/2.0));
+ pt->controlPointDragPosX = (double)(newX1 + (newWidth/2.0));
+ pt->controlPointDragPosY = (double)(newY1 + (newHeight/2.0));
if (this->GetFixedWidth())
newWidth = bound_x;
}
}
-void wxShape::OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
+void wxShape::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
{
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
if (theObject->GetChildren().Number() > 0)
theObject->DrawLinks(dc, -1, TRUE);
- float width, height;
+ double width, height;
theObject->GetBoundingBoxMax(&width, &height);
theObject->GetEventHandler()->OnEndSize(width, height);
IMPLEMENT_DYNAMIC_CLASS(wxPolygonControlPoint, wxControlPoint)
-wxPolygonControlPoint::wxPolygonControlPoint(wxShapeCanvas *theCanvas, wxShape *object, float size,
- wxRealPoint *vertex, float the_xoffset, float the_yoffset):
+wxPolygonControlPoint::wxPolygonControlPoint(wxShapeCanvas *theCanvas, wxShape *object, double size,
+ wxRealPoint *vertex, double the_xoffset, double the_yoffset):
wxControlPoint(theCanvas, object, size, the_xoffset, the_yoffset, 0)
{
m_polygonVertex = vertex;
}
// Calculate what new size would be, at end of resize
-void wxPolygonControlPoint::CalculateNewSize(float x, float y)
+void wxPolygonControlPoint::CalculateNewSize(double x, double y)
{
- float bound_x;
- float bound_y;
+ double bound_x;
+ double bound_y;
GetShape()->GetBoundingBoxMin(&bound_x, &bound_y);
- float dist = (float)sqrt((x - m_shape->GetX())*(x - m_shape->GetX()) +
+ double dist = (double)sqrt((x - m_shape->GetX())*(x - m_shape->GetX()) +
(y - m_shape->GetY())*(y - m_shape->GetY()));
- m_newSize.x = (float)(dist/this->m_originalDistance)*this->m_originalSize.x;
- m_newSize.y = (float)(dist/this->m_originalDistance)*this->m_originalSize.y;
+ m_newSize.x = (double)(dist/this->m_originalDistance)*this->m_originalSize.x;
+ m_newSize.y = (double)(dist/this->m_originalDistance)*this->m_originalSize.y;
}
// Implement resizing polygon or moving the vertex.
-void wxPolygonControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxPolygonControlPoint::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingDragLeft(this, draw, x, y, keys, attachment);
}
-void wxPolygonControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxPolygonControlPoint::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingBeginDragLeft(this, x, y, keys, attachment);
}
-void wxPolygonControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxPolygonControlPoint::OnEndDragLeft(double x, double y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingEndDragLeft(this, x, y, keys, attachment);
}
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
-void wxPolygonShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys, int attachment)
+void wxPolygonShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys, int attachment)
{
wxPolygonControlPoint* ppt = (wxPolygonControlPoint*) pt;
ppt->GetNewSize().x, ppt->GetNewSize().y);
}
-void wxPolygonShape::OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
+void wxPolygonShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
{
wxPolygonControlPoint* ppt = (wxPolygonControlPoint*) pt;
dc.SetLogicalFunction(wxXOR);
- float bound_x;
- float bound_y;
+ double bound_x;
+ double bound_y;
this->GetBoundingBoxMin(&bound_x, &bound_y);
- float dist = (float)sqrt((x - this->GetX())*(x - this->GetX()) +
+ double dist = (double)sqrt((x - this->GetX())*(x - this->GetX()) +
(y - this->GetY())*(y - this->GetY()));
ppt->m_originalDistance = dist;
ppt->m_originalSize.x = bound_x;
ppt->m_originalSize.y = bound_y;
- if (ppt->m_originalDistance == 0.0) ppt->m_originalDistance = (float) 0.0001;
+ if (ppt->m_originalDistance == 0.0) ppt->m_originalDistance = (double) 0.0001;
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
dc.SetPen(dottedPen);
m_canvas->CaptureMouse();
}
-void wxPolygonShape::OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
+void wxPolygonShape::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
{
wxPolygonControlPoint* ppt = (wxPolygonControlPoint*) pt;
m_font = f;
}
-void wxShapeRegion::SetMinSize(float w, float h)
+void wxShapeRegion::SetMinSize(double w, double h)
{
m_minWidth = w;
m_minHeight = h;
}
-void wxShapeRegion::SetSize(float w, float h)
+void wxShapeRegion::SetSize(double w, double h)
{
m_width = w;
m_height = h;
}
-void wxShapeRegion::SetPosition(float xp, float yp)
+void wxShapeRegion::SetPosition(double xp, double yp)
{
m_x = xp;
m_y = yp;
}
-void wxShapeRegion::SetProportions(float xp, float yp)
+void wxShapeRegion::SetProportions(double xp, double yp)
{
m_regionProportionX = xp;
m_regionProportionY = yp;
{
DECLARE_DYNAMIC_CLASS(wxShapeTextLine)
public:
- wxShapeTextLine(float the_x = 0.0, float the_y = 0.0, const wxString& the_line = "");
+ wxShapeTextLine(double the_x = 0.0, double the_y = 0.0, const wxString& the_line = "");
~wxShapeTextLine();
- inline float GetX() const { return m_x; }
- inline float GetY() const { return m_y; }
+ inline double GetX() const { return m_x; }
+ inline double GetY() const { return m_y; }
- inline void SetX(float x) { m_x = x; }
- inline void SetY(float y) { m_y = y; }
+ inline void SetX(double x) { m_x = x; }
+ inline void SetY(double y) { m_y = y; }
inline void SetText(const wxString& text) { m_line = text; }
inline wxString GetText() const { return m_line; }
protected:
wxString m_line;
- float m_x;
- float m_y;
+ double m_x;
+ double m_y;
};
class wxShape;
friend class wxShape;
public:
- wxControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0, float the_xoffset = 0.0,
- float the_yoffset = 0.0, int the_type = 0);
+ wxControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0, double the_xoffset = 0.0,
+ double the_yoffset = 0.0, int the_type = 0);
~wxControlPoint();
void OnDraw(wxDC& dc);
void OnErase(wxDC& dc);
void OnDrawContents(wxDC& dc);
- void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0);
- void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
- void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
+ void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
+ void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
+ void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
- bool GetAttachmentPosition(int attachment, float *x, float *y,
+ bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
int GetNumberOfAttachments();
public:
int m_type;
- float m_xoffset;
- float m_yoffset;
+ double m_xoffset;
+ double m_yoffset;
wxShape* m_shape;
wxCursor* m_oldCursor;
bool m_eraseObject; // If TRUE, erases object before dragging handle.
* Store original top-left, bottom-right coordinates
* in case we're doing non-vertical resizing.
*/
- static float controlPointDragStartX;
- static float controlPointDragStartY;
- static float controlPointDragStartWidth;
- static float controlPointDragStartHeight;
- static float controlPointDragEndWidth;
- static float controlPointDragEndHeight;
- static float controlPointDragPosX;
- static float controlPointDragPosY;
+ static double controlPointDragStartX;
+ static double controlPointDragStartY;
+ static double controlPointDragStartWidth;
+ static double controlPointDragStartHeight;
+ static double controlPointDragEndWidth;
+ static double controlPointDragEndHeight;
+ static double controlPointDragPosX;
+ static double controlPointDragPosY;
};
class wxPolygonShape;
DECLARE_DYNAMIC_CLASS(wxPolygonControlPoint)
friend class wxPolygonShape;
public:
- wxPolygonControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0, wxRealPoint *vertex = NULL,
- float the_xoffset = 0.0, float the_yoffset = 0.0);
+ wxPolygonControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0, wxRealPoint *vertex = NULL,
+ double the_xoffset = 0.0, double the_yoffset = 0.0);
~wxPolygonControlPoint();
- void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0);
- void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
- void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
+ void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
+ void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
+ void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
// Calculate what new size would be, at end of resize
- virtual void CalculateNewSize(float x, float y);
+ virtual void CalculateNewSize(double x, double y);
// Get new size
inline wxRealPoint GetNewSize() const { return m_newSize; };
public:
wxRealPoint* m_polygonVertex;
wxRealPoint m_originalSize;
- float m_originalDistance;
+ double m_originalDistance;
wxRealPoint m_newSize;
};
// Accessors
inline void SetText(const wxString& s) { m_regionText = s; }
void SetFont(wxFont *f);
- void SetMinSize(float w, float h);
- void SetSize(float w, float h);
- void SetPosition(float x, float y);
- void SetProportions(float x, float y);
+ void SetMinSize(double w, double h);
+ void SetSize(double w, double h);
+ void SetPosition(double x, double y);
+ void SetProportions(double x, double y);
void SetFormatMode(int mode);
inline void SetName(const wxString& s) { m_regionName = s; };
void SetColour(const wxString& col); // Text colour
inline wxString GetText() const { return m_regionText; }
inline wxFont *GetFont() const { return m_font; }
- inline void GetMinSize(float *x, float *y) const { *x = m_minWidth; *y = m_minHeight; }
- inline void GetProportion(float *x, float *y) const { *x = m_regionProportionX; *y = m_regionProportionY; }
- inline void GetSize(float *x, float *y) const { *x = m_width; *y = m_height; }
- inline void GetPosition(float *xp, float *yp) const { *xp = m_x; *yp = m_y; }
+ inline void GetMinSize(double *x, double *y) const { *x = m_minWidth; *y = m_minHeight; }
+ inline void GetProportion(double *x, double *y) const { *x = m_regionProportionX; *y = m_regionProportionY; }
+ inline void GetSize(double *x, double *y) const { *x = m_width; *y = m_height; }
+ inline void GetPosition(double *xp, double *yp) const { *xp = m_x; *yp = m_y; }
inline int GetFormatMode() const { return m_formatMode; }
inline wxString GetName() const { return m_regionName; }
inline wxString GetColour() const { return m_textColour; }
inline void SetPenStyle(int style) { m_penStyle = style; m_actualPenObject = NULL; }
void SetPenColour(const wxString& col);
wxPen *GetActualPen();
- inline float GetWidth() const { return m_width; }
- inline float GetHeight() const { return m_height; }
+ inline double GetWidth() const { return m_width; }
+ inline double GetHeight() const { return m_height; }
void ClearText();
wxString m_regionText;
wxList m_formattedText; // List of wxShapeTextLines
wxFont* m_font;
- float m_minHeight; // If zero, hide region.
- float m_minWidth; // If zero, hide region.
- float m_width;
- float m_height;
- float m_x;
- float m_y;
-
- float m_regionProportionX; // Proportion of total object size;
+ double m_minHeight; // If zero, hide region.
+ double m_minWidth; // If zero, hide region.
+ double m_width;
+ double m_height;
+ double m_x;
+ double m_y;
+
+ double m_regionProportionX; // Proportion of total object size;
// -1.0 indicates equal proportion
- float m_regionProportionY; // Proportion of total object size;
+ double m_regionProportionY; // Proportion of total object size;
// -1.0 indicates equal proportion
int m_formatMode; // FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT | FORMAT_NONE
{
m_id = 0; m_x = 0.0; m_y = 0.0;
}
+ inline wxAttachmentPoint(int id, double x, double y)
+ {
+ m_id = id; m_x = x; m_y = y;
+ }
public:
- int m_id; // Identifier
- float m_x; // x offset from centre of object
- float m_y; // y offset from centre of object
+ int m_id; // Identifier
+ double m_x; // x offset from centre of object
+ double m_y; // y offset from centre of object
};
#endif
wxMemoryDC tempDC;
tempDC.SelectObject(m_bitmap);
- float x, y;
- x = (long)(m_xpos - m_bitmap.GetWidth() / 2.0);
- y = (long)(m_ypos - m_bitmap.GetHeight() / 2.0);
+ double x, y;
+ x = WXROUND(m_xpos - m_bitmap.GetWidth() / 2.0);
+ y = WXROUND(m_ypos - m_bitmap.GetHeight() / 2.0);
dc.Blit(x, y, m_bitmap.GetWidth(), m_bitmap.GetHeight(), &tempDC, 0, 0);
}
-void wxBitmapShape::SetSize(float w, float h, bool recursive)
+void wxBitmapShape::SetSize(double w, double h, bool recursive)
{
if (m_bitmap.Ok())
{
// Does the copying for this object
void Copy(wxShape& copy);
- void SetSize(float w, float h, bool recursive = TRUE);
+ void SetSize(double w, double h, bool recursive = TRUE);
inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
void SetBitmap(const wxBitmap& bm);
inline void SetFilename(const wxString& f) { m_filename = f; };
#define CONTROL_POINT_ENDPOINT_FROM 5
#define CONTROL_POINT_LINE 6
-extern wxCursor *GraphicsBullseyeCursor;
+extern wxCursor *g_oglBullseyeCursor;
IMPLEMENT_DYNAMIC_CLASS(wxShapeCanvas, wxScrolledWindow)
wxPoint logPos(event.GetLogicalPosition(dc));
- float x, y;
- x = (float) logPos.x;
- y = (float) logPos.y;
+ double x, y;
+ x = (double) logPos.x;
+ y = (double) logPos.y;
int keys = 0;
if (event.ShiftDown())
// If the object isn't m_draggable, transfer message to canvas
if (m_draggedShape->Draggable())
- m_draggedShape->GetEventHandler()->OnBeginDragLeft((float)x, (float)y, keys, m_draggedAttachment);
+ m_draggedShape->GetEventHandler()->OnBeginDragLeft((double)x, (double)y, keys, m_draggedAttachment);
else
{
m_draggedShape = NULL;
- OnBeginDragLeft((float)x, (float)y, keys);
+ OnBeginDragLeft((double)x, (double)y, keys);
}
m_oldDragX = x; m_oldDragY = y;
{
// Continue dragging
m_draggedShape->GetEventHandler()->OnDragLeft(FALSE, m_oldDragX, m_oldDragY, keys, m_draggedAttachment);
- m_draggedShape->GetEventHandler()->OnDragLeft(TRUE, (float)x, (float)y, keys, m_draggedAttachment);
+ m_draggedShape->GetEventHandler()->OnDragLeft(TRUE, (double)x, (double)y, keys, m_draggedAttachment);
m_oldDragX = x; m_oldDragY = y;
}
else if (event.LeftUp() && m_draggedShape && m_dragState == ContinueDraggingLeft)
m_draggedShape->GetEventHandler()->OnDragLeft(FALSE, m_oldDragX, m_oldDragY, keys, m_draggedAttachment);
- m_draggedShape->GetEventHandler()->OnEndDragLeft((float)x, (float)y, keys, m_draggedAttachment);
+ m_draggedShape->GetEventHandler()->OnEndDragLeft((double)x, (double)y, keys, m_draggedAttachment);
m_draggedShape = NULL;
}
else if (dragging && m_draggedShape && m_dragState == StartDraggingRight)
m_dragState = ContinueDraggingRight;
if (m_draggedShape->Draggable())
- m_draggedShape->GetEventHandler()->OnBeginDragRight((float)x, (float)y, keys, m_draggedAttachment);
+ m_draggedShape->GetEventHandler()->OnBeginDragRight((double)x, (double)y, keys, m_draggedAttachment);
else
{
m_draggedShape = NULL;
- OnBeginDragRight((float)x, (float)y, keys);
+ OnBeginDragRight((double)x, (double)y, keys);
}
m_oldDragX = x; m_oldDragY = y;
}
{
// Continue dragging
m_draggedShape->GetEventHandler()->OnDragRight(FALSE, m_oldDragX, m_oldDragY, keys, m_draggedAttachment);
- m_draggedShape->GetEventHandler()->OnDragRight(TRUE, (float)x, (float)y, keys, m_draggedAttachment);
+ m_draggedShape->GetEventHandler()->OnDragRight(TRUE, (double)x, (double)y, keys, m_draggedAttachment);
m_oldDragX = x; m_oldDragY = y;
}
else if (event.RightUp() && m_draggedShape && m_dragState == ContinueDraggingRight)
m_draggedShape->GetEventHandler()->OnDragRight(FALSE, m_oldDragX, m_oldDragY, keys, m_draggedAttachment);
- m_draggedShape->GetEventHandler()->OnEndDragRight((float)x, (float)y, keys, m_draggedAttachment);
+ m_draggedShape->GetEventHandler()->OnEndDragRight((double)x, (double)y, keys, m_draggedAttachment);
m_draggedShape = NULL;
}
else if (dragging && !m_draggedShape && m_dragState == StartDraggingLeft)
{
m_dragState = ContinueDraggingLeft;
- OnBeginDragLeft((float)x, (float)y, keys);
+ OnBeginDragLeft((double)x, (double)y, keys);
m_oldDragX = x; m_oldDragY = y;
}
else if (dragging && !m_draggedShape && m_dragState == ContinueDraggingLeft)
{
// Continue dragging
OnDragLeft(FALSE, m_oldDragX, m_oldDragY, keys);
- OnDragLeft(TRUE, (float)x, (float)y, keys);
+ OnDragLeft(TRUE, (double)x, (double)y, keys);
m_oldDragX = x; m_oldDragY = y;
}
else if (event.LeftUp() && !m_draggedShape && m_dragState == ContinueDraggingLeft)
m_checkTolerance = TRUE;
OnDragLeft(FALSE, m_oldDragX, m_oldDragY, keys);
- OnEndDragLeft((float)x, (float)y, keys);
+ OnEndDragLeft((double)x, (double)y, keys);
m_draggedShape = NULL;
}
else if (dragging && !m_draggedShape && m_dragState == StartDraggingRight)
{
m_dragState = ContinueDraggingRight;
- OnBeginDragRight((float)x, (float)y, keys);
+ OnBeginDragRight((double)x, (double)y, keys);
m_oldDragX = x; m_oldDragY = y;
}
else if (dragging && !m_draggedShape && m_dragState == ContinueDraggingRight)
{
// Continue dragging
OnDragRight(FALSE, m_oldDragX, m_oldDragY, keys);
- OnDragRight(TRUE, (float)x, (float)y, keys);
+ OnDragRight(TRUE, (double)x, (double)y, keys);
m_oldDragX = x; m_oldDragY = y;
}
else if (event.RightUp() && !m_draggedShape && m_dragState == ContinueDraggingRight)
m_checkTolerance = TRUE;
OnDragRight(FALSE, m_oldDragX, m_oldDragY, keys);
- OnEndDragRight((float)x, (float)y, keys);
+ OnEndDragRight((double)x, (double)y, keys);
m_draggedShape = NULL;
}
// N.B. Only register a click if the same object was
// identified for down *and* up.
if (nearest_object == m_draggedShape)
- nearest_object->GetEventHandler()->OnLeftClick((float)x, (float)y, keys, attachment);
+ nearest_object->GetEventHandler()->OnLeftClick((double)x, (double)y, keys, attachment);
m_draggedShape = NULL;
m_dragState = NoDragging;
else if (event.RightUp())
{
if (nearest_object == m_draggedShape)
- nearest_object->GetEventHandler()->OnRightClick((float)x, (float)y, keys, attachment);
+ nearest_object->GetEventHandler()->OnRightClick((double)x, (double)y, keys, attachment);
m_draggedShape = NULL;
m_dragState = NoDragging;
}
else if (event.LeftUp())
{
- OnLeftClick((float)x, (float)y, keys);
+ OnLeftClick((double)x, (double)y, keys);
m_draggedShape = NULL;
m_dragState = NoDragging;
}
else if (event.RightUp())
{
- OnRightClick((float)x, (float)y, keys);
+ OnRightClick((double)x, (double)y, keys);
m_draggedShape = NULL;
m_dragState = NoDragging;
* Try to find a sensitive object, working up the hierarchy of composites.
*
*/
-wxShape *wxShapeCanvas::FindFirstSensitiveShape(float x, float y, int *new_attachment, int op)
+wxShape *wxShapeCanvas::FindFirstSensitiveShape(double x, double y, int *new_attachment, int op)
{
wxShape *image = FindShape(x, y, new_attachment);
if (!image) return NULL;
wxShape *actualImage = FindFirstSensitiveShape1(image, op);
if (actualImage)
{
- float dist;
+ double dist;
// Find actual attachment
actualImage->HitTest(x, y, new_attachment, &dist);
}
// Helper function: TRUE if 'contains' wholly contains 'contained'.
static bool WhollyContains(wxShape *contains, wxShape *contained)
{
- float xp1, yp1, xp2, yp2;
- float w1, h1, w2, h2;
- float left1, top1, right1, bottom1, left2, top2, right2, bottom2;
+ double xp1, yp1, xp2, yp2;
+ double w1, h1, w2, h2;
+ double left1, top1, right1, bottom1, left2, top2, right2, bottom2;
xp1 = contains->GetX(); yp1 = contains->GetY(); xp2 = contained->GetX(); yp2 = contained->GetY();
contains->GetBoundingBoxMax(&w1, &h1);
contained->GetBoundingBoxMax(&w2, &h2);
- left1 = (float)(xp1 - (w1 / 2.0));
- top1 = (float)(yp1 - (h1 / 2.0));
- right1 = (float)(xp1 + (w1 / 2.0));
- bottom1 = (float)(yp1 + (h1 / 2.0));
+ left1 = (double)(xp1 - (w1 / 2.0));
+ top1 = (double)(yp1 - (h1 / 2.0));
+ right1 = (double)(xp1 + (w1 / 2.0));
+ bottom1 = (double)(yp1 + (h1 / 2.0));
- left2 = (float)(xp2 - (w2 / 2.0));
- top2 = (float)(yp2 - (h2 / 2.0));
- right2 = (float)(xp2 + (w2 / 2.0));
- bottom2 = (float)(yp2 + (h2 / 2.0));
+ left2 = (double)(xp2 - (w2 / 2.0));
+ top2 = (double)(yp2 - (h2 / 2.0));
+ right2 = (double)(xp2 + (w2 / 2.0));
+ bottom2 = (double)(yp2 + (h2 / 2.0));
return ((left1 <= left2) && (top1 <= top2) && (right1 >= right2) && (bottom1 >= bottom2));
}
-wxShape *wxShapeCanvas::FindShape(float x, float y, int *attachment, wxClassInfo *info, wxShape *notObject)
+wxShape *wxShapeCanvas::FindShape(double x, double y, int *attachment, wxClassInfo *info, wxShape *notObject)
{
- float nearest = 100000.0;
+ double nearest = 100000.0;
int nearest_attachment = 0;
wxShape *nearest_object = NULL;
{
wxShape *object = (wxShape *)current->Data();
- float dist;
+ double dist;
int temp_attachment;
// First pass for lines, which might be inside a container, so we
while (current)
{
wxShape *object = (wxShape *)current->Data();
- float dist;
+ double dist;
int temp_attachment;
// On second pass, only ever consider non-composites or divisions. If children want to pass
*
*/
-void wxShapeCanvas::OnLeftClick(float x, float y, int keys)
+void wxShapeCanvas::OnLeftClick(double x, double y, int keys)
{
}
-void wxShapeCanvas::OnRightClick(float x, float y, int keys)
+void wxShapeCanvas::OnRightClick(double x, double y, int keys)
{
}
-void wxShapeCanvas::OnDragLeft(bool draw, float x, float y, int keys)
+void wxShapeCanvas::OnDragLeft(bool draw, double x, double y, int keys)
{
}
-void wxShapeCanvas::OnBeginDragLeft(float x, float y, int keys)
+void wxShapeCanvas::OnBeginDragLeft(double x, double y, int keys)
{
}
-void wxShapeCanvas::OnEndDragLeft(float x, float y, int keys)
+void wxShapeCanvas::OnEndDragLeft(double x, double y, int keys)
{
}
-void wxShapeCanvas::OnDragRight(bool draw, float x, float y, int keys)
+void wxShapeCanvas::OnDragRight(bool draw, double x, double y, int keys)
{
}
-void wxShapeCanvas::OnBeginDragRight(float x, float y, int keys)
+void wxShapeCanvas::OnBeginDragRight(double x, double y, int keys)
{
}
-void wxShapeCanvas::OnEndDragRight(float x, float y, int keys)
+void wxShapeCanvas::OnEndDragRight(double x, double y, int keys)
{
}
{ return GetDiagram()->GetQuickEditMode(); }
void wxShapeCanvas::Redraw(wxDC& dc)
{ GetDiagram()->Redraw(dc); }
-void wxShapeCanvas::Snap(float *x, float *y)
+void wxShapeCanvas::Snap(double *x, double *y)
{ GetDiagram()->Snap(x, y); }
inline void SetDiagram(wxDiagram *diag) { m_shapeDiagram = diag; }
inline wxDiagram *GetDiagram() const { return m_shapeDiagram; }
- virtual void OnLeftClick(float x, float y, int keys = 0);
- virtual void OnRightClick(float x, float y, int keys = 0);
+ virtual void OnLeftClick(double x, double y, int keys = 0);
+ virtual void OnRightClick(double x, double y, int keys = 0);
- virtual void OnDragLeft(bool draw, float x, float y, int keys=0); // Erase if draw false
- virtual void OnBeginDragLeft(float x, float y, int keys=0);
- virtual void OnEndDragLeft(float x, float y, int keys=0);
+ virtual void OnDragLeft(bool draw, double x, double y, int keys=0); // Erase if draw false
+ virtual void OnBeginDragLeft(double x, double y, int keys=0);
+ virtual void OnEndDragLeft(double x, double y, int keys=0);
- virtual void OnDragRight(bool draw, float x, float y, int keys=0); // Erase if draw false
- virtual void OnBeginDragRight(float x, float y, int keys=0);
- virtual void OnEndDragRight(float x, float y, int keys=0);
+ virtual void OnDragRight(bool draw, double x, double y, int keys=0); // Erase if draw false
+ virtual void OnBeginDragRight(double x, double y, int keys=0);
+ virtual void OnEndDragRight(double x, double y, int keys=0);
// Find object for mouse click, of given wxClassInfo (NULL for any type).
// If notImage is non-NULL, don't find an object that is equal to or a descendant of notImage
- virtual wxShape *FindShape(float x, float y, int *attachment, wxClassInfo *info = NULL, wxShape *notImage = NULL);
- wxShape *FindFirstSensitiveShape(float x, float y, int *new_attachment, int op);
+ virtual wxShape *FindShape(double x, double y, int *attachment, wxClassInfo *info = NULL, wxShape *notImage = NULL);
+ wxShape *FindFirstSensitiveShape(double x, double y, int *new_attachment, int op);
wxShape *FindFirstSensitiveShape1(wxShape *image, int op);
// Redirect to wxDiagram object
virtual void RemoveShape(wxShape *object);
virtual bool GetQuickEditMode();
virtual void Redraw(wxDC& dc);
- void Snap(float *x, float *y);
+ void Snap(double *x, double *y);
// Events
void OnPaint(wxPaintEvent& event);
protected:
wxDiagram* m_shapeDiagram;
int m_dragState;
- float m_oldDragX, m_oldDragY; // Previous drag coordinates
- float m_firstDragX, m_firstDragY; // INITIAL drag coordinates
+ double m_oldDragX, m_oldDragY; // Previous drag coordinates
+ double m_firstDragX, m_firstDragY; // INITIAL drag coordinates
bool m_checkTolerance; // Whether to check drag tolerance
wxShape* m_draggedShape;
int m_draggedAttachment;
DECLARE_DYNAMIC_CLASS(wxDivisionControlPoint)
public:
wxDivisionControlPoint() {}
- wxDivisionControlPoint(wxShapeCanvas *the_canvas, wxShape *object, float size, float the_xoffset, float the_yoffset, int the_type);
+ wxDivisionControlPoint(wxShapeCanvas *the_canvas, wxShape *object, double size, double the_xoffset, double the_yoffset, int the_type);
~wxDivisionControlPoint();
- void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0);
- void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
- void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
+ void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
+ void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
+ void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
};
IMPLEMENT_DYNAMIC_CLASS(wxDivisionControlPoint, wxControlPoint)
void wxCompositeShape::OnDraw(wxDC& dc)
{
- float x1 = (float)(m_xpos - m_width/2.0);
- float y1 = (float)(m_ypos - m_height/2.0);
+ double x1 = (double)(m_xpos - m_width/2.0);
+ double y1 = (double)(m_ypos - m_height/2.0);
if (m_shadowMode != SHADOW_NONE)
{
if (m_shadowBrush)
dc.SetBrush(m_shadowBrush);
- dc.SetPen(transparent_pen);
+ dc.SetPen(g_oglTransparentPen);
if (m_cornerRadius != 0.0)
- dc.DrawRoundedRectangle(x1 + m_shadowOffsetX, y1 + m_shadowOffsetY,
- m_width, m_height, m_cornerRadius);
+ dc.DrawRoundedRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY),
+ WXROUND(m_width), WXROUND(m_height), m_cornerRadius);
else
- dc.DrawRectangle(x1 + m_shadowOffsetX, y1 + m_shadowOffsetY, m_width, m_height);
+ dc.DrawRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY), WXROUND(m_width), WXROUND(m_height));
}
}
wxShape::OnDrawContents(dc);
}
-bool wxCompositeShape::OnMovePre(wxDC& dc, float x, float y, float oldx, float oldy, bool display)
+bool wxCompositeShape::OnMovePre(wxDC& dc, double x, double y, double oldx, double oldy, bool display)
{
- float diffX = x - oldx;
- float diffY = y - oldy;
+ double diffX = x - oldx;
+ double diffY = y - oldy;
wxNode *node = m_children.First();
while (node)
{
}
}
-static float objectStartX = 0.0;
-static float objectStartY = 0.0;
+static double objectStartX = 0.0;
+static double objectStartY = 0.0;
-void wxCompositeShape::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxCompositeShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
- float xx = x;
- float yy = y;
+ double xx = x;
+ double yy = y;
m_canvas->Snap(&xx, &yy);
- float offsetX = xx - objectStartX;
- float offsetY = yy - objectStartY;
+ double offsetX = xx - objectStartX;
+ double offsetY = yy - objectStartY;
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
// wxShape::OnDragLeft(draw, x, y, keys, attachment);
}
-void wxCompositeShape::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxCompositeShape::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
objectStartX = x;
objectStartY = y;
dc.SetBrush((* wxTRANSPARENT_BRUSH));
m_canvas->CaptureMouse();
- float xx = x;
- float yy = y;
+ double xx = x;
+ double yy = y;
m_canvas->Snap(&xx, &yy);
- float offsetX = xx - objectStartX;
- float offsetY = yy - objectStartY;
+ double offsetX = xx - objectStartX;
+ double offsetY = yy - objectStartY;
GetEventHandler()->OnDrawOutline(dc, GetX() + offsetX, GetY() + offsetY, GetWidth(), GetHeight());
// wxShape::OnBeginDragLeft(x, y, keys, attachment);
}
-void wxCompositeShape::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxCompositeShape::OnEndDragLeft(double x, double y, int keys, int attachment)
{
// wxShape::OnEndDragLeft(x, y, keys, attachment);
}
dc.SetLogicalFunction(wxCOPY);
- float xx = x;
- float yy = y;
+ double xx = x;
+ double yy = y;
m_canvas->Snap(&xx, &yy);
- float offsetX = xx - objectStartX;
- float offsetY = yy - objectStartY;
+ double offsetX = xx - objectStartX;
+ double offsetY = yy - objectStartY;
Move(dc, GetX() + offsetX, GetY() + offsetY);
if (m_canvas && !m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc);
}
-void wxCompositeShape::OnRightClick(float x, float y, int keys, int attachment)
+void wxCompositeShape::OnRightClick(double x, double y, int keys, int attachment)
{
// If we get a ctrl-right click, this means send the message to
// the division, so we can invoke a user interface for dealing with regions.
wxDivisionShape *division = (wxDivisionShape *)node->Data();
wxNode *next = node->Next();
int attach = 0;
- float dist = 0.0;
+ double dist = 0.0;
if (division->HitTest(x, y, &attach, &dist))
{
division->GetEventHandler()->OnRightClick(x, y, keys, attach);
}
}
-void wxCompositeShape::SetSize(float w, float h, bool recursive)
+void wxCompositeShape::SetSize(double w, double h, bool recursive)
{
SetAttachmentSize(w, h);
- float xScale = (float)(w/(wxMax(1.0, GetWidth())));
- float yScale = (float)(h/(wxMax(1.0, GetHeight())));
+ double xScale = (double)(w/(wxMax(1.0, GetWidth())));
+ double yScale = (double)(h/(wxMax(1.0, GetHeight())));
m_width = w;
m_height = h;
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
- float xBound, yBound;
+ double xBound, yBound;
while (node)
{
wxShape *object = (wxShape *)node->Data();
// Scale the position first
- float newX = (float)(((object->GetX() - GetX())*xScale) + GetX());
- float newY = (float)(((object->GetY() - GetY())*yScale) + GetY());
+ double newX = (double)(((object->GetX() - GetX())*xScale) + GetX());
+ double newY = (double)(((object->GetY() - GetY())*yScale) + GetY());
object->Show(FALSE);
object->Move(dc, newX, newY);
object->Show(TRUE);
wxCompositeShape& compositeCopy = (wxCompositeShape&) copy;
// Associate old and new copies for compositeCopying constraints and division geometry
- wxObjectCopyMapping.Append((long)this, &compositeCopy);
+ oglObjectCopyMapping.Append((long)this, &compositeCopy);
// Copy the children
wxNode *node = m_children.First();
if (m_divisions.Member(object))
compositeCopy.m_divisions.Append(newObject);
- wxObjectCopyMapping.Append((long)object, newObject);
+ oglObjectCopyMapping.Append((long)object, newObject);
node = node->Next();
}
{
OGLConstraint *constraint = (OGLConstraint *)node->Data();
- wxShape *newConstraining = (wxShape *)(wxObjectCopyMapping.Find((long)constraint->m_constrainingObject)->Data());
+ wxShape *newConstraining = (wxShape *)(oglObjectCopyMapping.Find((long)constraint->m_constrainingObject)->Data());
wxList newConstrainedList;
wxNode *node2 = constraint->m_constrainedObjects.First();
while (node2)
{
wxShape *constrainedObject = (wxShape *)node2->Data();
- wxShape *newConstrained = (wxShape *)(wxObjectCopyMapping.Find((long)constrainedObject)->Data());
+ wxShape *newConstrained = (wxShape *)(oglObjectCopyMapping.Find((long)constrainedObject)->Data());
newConstrainedList.Append(newConstrained);
node2 = node2->Next();
}
while (node)
{
wxDivisionShape *division = (wxDivisionShape *)node->Data();
- wxNode *node1 = wxObjectCopyMapping.Find((long)division);
+ wxNode *node1 = oglObjectCopyMapping.Find((long)division);
wxNode *leftNode = NULL;
wxNode *topNode = NULL;
wxNode *rightNode = NULL;
wxNode *bottomNode = NULL;
if (division->GetLeftSide())
- leftNode = wxObjectCopyMapping.Find((long)division->GetLeftSide());
+ leftNode = oglObjectCopyMapping.Find((long)division->GetLeftSide());
if (division->GetTopSide())
- topNode = wxObjectCopyMapping.Find((long)division->GetTopSide());
+ topNode = oglObjectCopyMapping.Find((long)division->GetTopSide());
if (division->GetRightSide())
- rightNode = wxObjectCopyMapping.Find((long)division->GetRightSide());
+ rightNode = oglObjectCopyMapping.Find((long)division->GetRightSide());
if (division->GetBottomSide())
- bottomNode = wxObjectCopyMapping.Find((long)division->GetBottomSide());
+ bottomNode = oglObjectCopyMapping.Find((long)division->GetBottomSide());
if (node1)
{
wxDivisionShape *newDivision = (wxDivisionShape *)node1->Data();
void wxCompositeShape::CalculateSize()
{
- float maxX = (float) -999999.9;
- float maxY = (float) -999999.9;
- float minX = (float) 999999.9;
- float minY = (float) 999999.9;
+ double maxX = (double) -999999.9;
+ double maxY = (double) -999999.9;
+ double minX = (double) 999999.9;
+ double minY = (double) 999999.9;
- float w, h;
+ double w, h;
wxNode *node = m_children.First();
while (node)
{
object->GetBoundingBoxMax(&w, &h);
if ((object->GetX() + (w/2.0)) > maxX)
- maxX = (float)(object->GetX() + (w/2.0));
+ maxX = (double)(object->GetX() + (w/2.0));
if ((object->GetX() - (w/2.0)) < minX)
- minX = (float)(object->GetX() - (w/2.0));
+ minX = (double)(object->GetX() - (w/2.0));
if ((object->GetY() + (h/2.0)) > maxY)
- maxY = (float)(object->GetY() + (h/2.0));
+ maxY = (double)(object->GetY() + (h/2.0));
if ((object->GetY() - (h/2.0)) < minY)
- minY = (float)(object->GetY() - (h/2.0));
+ minY = (double)(object->GetY() - (h/2.0));
node = node->Next();
}
m_width = maxX - minX;
m_height = maxY - minY;
- m_xpos = (float)(m_width/2.0 + minX);
- m_ypos = (float)(m_height/2.0 + minY);
+ m_xpos = (double)(m_width/2.0 + minX);
+ m_ypos = (double)(m_height/2.0 + minY);
}
bool wxCompositeShape::Recompute()
break;
}
int cType = 0;
- float cXSpacing = 0.0;
- float cYSpacing = 0.0;
+ double cXSpacing = 0.0;
+ double cYSpacing = 0.0;
wxString cName("");
long cId = 0;
wxShape *m_constrainingObject = NULL;
dc.SetBrush(wxTRANSPARENT_BRUSH);
dc.SetBackgroundMode(wxTRANSPARENT);
- float x1 = (float)(GetX() - (GetWidth()/2.0));
- float y1 = (float)(GetY() - (GetHeight()/2.0));
- float x2 = (float)(GetX() + (GetWidth()/2.0));
- float y2 = (float)(GetY() + (GetHeight()/2.0));
+ double x1 = (double)(GetX() - (GetWidth()/2.0));
+ double y1 = (double)(GetY() - (GetHeight()/2.0));
+ double x2 = (double)(GetX() + (GetWidth()/2.0));
+ double y2 = (double)(GetY() + (GetHeight()/2.0));
// Should subtract 1 pixel if drawing under Windows
#ifdef __WXMSW__
- y2 -= (float)1.0;
+ y2 -= (double)1.0;
#endif
if (m_leftSide)
{
dc.SetPen(m_leftSidePen);
- dc.DrawLine(x1, y2, x1, y1);
+ dc.DrawLine(WXROUND(x1), WXROUND(y2), WXROUND(x1), WXROUND(y1));
}
if (m_topSide)
{
dc.SetPen(m_topSidePen);
- dc.DrawLine(x1, y1, x2, y1);
+ dc.DrawLine(WXROUND(x1), WXROUND(y1), WXROUND(x2), WXROUND(y1));
}
// For testing purposes, draw a rectangle so we know
wxCompositeShape::OnDrawContents(dc);
}
-bool wxDivisionShape::OnMovePre(wxDC& dc, float x, float y, float oldx, float oldy, bool display)
+bool wxDivisionShape::OnMovePre(wxDC& dc, double x, double y, double oldx, double oldy, bool display)
{
- float diffX = x - oldx;
- float diffY = y - oldy;
+ double diffX = x - oldx;
+ double diffY = y - oldy;
wxNode *node = m_children.First();
while (node)
{
return TRUE;
}
-void wxDivisionShape::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxDivisionShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
wxShape::OnDragLeft(draw, x, y, keys, attachment);
}
-void wxDivisionShape::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxDivisionShape::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
wxShape::OnBeginDragLeft(x, y, keys, attachment);
}
-void wxDivisionShape::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxDivisionShape::OnEndDragLeft(double x, double y, int keys, int attachment)
{
m_canvas->ReleaseMouse();
if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT)
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
if (m_canvas && !m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc);
}
-void wxDivisionShape::SetSize(float w, float h, bool recursive)
+void wxDivisionShape::SetSize(double w, double h, bool recursive)
{
m_width = w;
m_height = h;
#endif
// Experimental
-void wxDivisionShape::OnRightClick(float x, float y, int keys, int attachment)
+void wxDivisionShape::OnRightClick(double x, double y, int keys, int attachment)
{
if (keys & KEY_CTRL)
{
else
{
attachment = 0;
- float dist;
+ double dist;
if (m_parent)
{
m_parent->HitTest(x, y, &attachment, &dist);
bool wxDivisionShape::Divide(int direction)
{
// Calculate existing top-left, bottom-right
- float x1 = (float)(GetX() - (GetWidth()/2.0));
- float y1 = (float)(GetY() - (GetHeight()/2.0));
+ double x1 = (double)(GetX() - (GetWidth()/2.0));
+ double y1 = (double)(GetY() - (GetHeight()/2.0));
wxCompositeShape *compositeParent = (wxCompositeShape *)GetParent();
- float oldWidth = GetWidth();
- float oldHeight = GetHeight();
+ double oldWidth = GetWidth();
+ double oldHeight = GetHeight();
if (Selected())
Select(FALSE);
{
// Dividing vertically means notionally putting a horizontal line through it.
// Break existing piece into two.
- float newXPos1 = GetX();
- float newYPos1 = (float)(y1 + (GetHeight()/4.0));
- float newXPos2 = GetX();
- float newYPos2 = (float)(y1 + (3.0*GetHeight()/4.0));
+ double newXPos1 = GetX();
+ double newYPos1 = (double)(y1 + (GetHeight()/4.0));
+ double newXPos2 = GetX();
+ double newYPos2 = (double)(y1 + (3.0*GetHeight()/4.0));
wxDivisionShape *newDivision = compositeParent->OnCreateDivision();
newDivision->Show(TRUE);
m_handleSide = DIVISION_SIDE_BOTTOM;
newDivision->SetHandleSide(DIVISION_SIDE_TOP);
- SetSize(oldWidth, (float)(oldHeight/2.0));
+ SetSize(oldWidth, (double)(oldHeight/2.0));
Move(dc, newXPos1, newYPos1);
- newDivision->SetSize(oldWidth, (float)(oldHeight/2.0));
+ newDivision->SetSize(oldWidth, (double)(oldHeight/2.0));
newDivision->Move(dc, newXPos2, newYPos2);
}
else
{
// Dividing horizontally means notionally putting a vertical line through it.
// Break existing piece into two.
- float newXPos1 = (float)(x1 + (GetWidth()/4.0));
- float newYPos1 = GetY();
- float newXPos2 = (float)(x1 + (3.0*GetWidth()/4.0));
- float newYPos2 = GetY();
+ double newXPos1 = (double)(x1 + (GetWidth()/4.0));
+ double newYPos1 = GetY();
+ double newXPos2 = (double)(x1 + (3.0*GetWidth()/4.0));
+ double newYPos2 = GetY();
wxDivisionShape *newDivision = compositeParent->OnCreateDivision();
newDivision->Show(TRUE);
m_handleSide = DIVISION_SIDE_RIGHT;
newDivision->SetHandleSide(DIVISION_SIDE_LEFT);
- SetSize((float)(oldWidth/2.0), oldHeight);
+ SetSize((double)(oldWidth/2.0), oldHeight);
Move(dc, newXPos1, newYPos1);
- newDivision->SetSize((float)(oldWidth/2.0), oldHeight);
+ newDivision->SetSize((double)(oldWidth/2.0), oldHeight);
newDivision->Move(dc, newXPos2, newYPos2);
}
if (compositeParent->Selected())
void wxDivisionShape::MakeMandatoryControlPoints()
{
- float maxX, maxY;
+ double maxX, maxY;
GetBoundingBoxMax(&maxX, &maxY);
- float x, y;
+ double x, y;
int direction;
/*
if (m_leftSide)
{
- x = (float)(-maxX/2.0);
+ x = (double)(-maxX/2.0);
y = 0.0;
wxDivisionControlPoint *control = new wxDivisionControlPoint(m_canvas, this, CONTROL_POINT_SIZE, x, y,
CONTROL_POINT_HORIZONTAL);
if (m_topSide)
{
x = 0.0;
- y = (float)(-maxY/2.0);
+ y = (double)(-maxY/2.0);
wxDivisionControlPoint *control = new wxDivisionControlPoint(m_canvas, this, CONTROL_POINT_SIZE, x, y,
CONTROL_POINT_VERTICAL);
m_canvas->AddShape(control);
{
case DIVISION_SIDE_LEFT:
{
- x = (float)(-maxX/2.0);
+ x = (double)(-maxX/2.0);
y = 0.0;
direction = CONTROL_POINT_HORIZONTAL;
break;
case DIVISION_SIDE_TOP:
{
x = 0.0;
- y = (float)(-maxY/2.0);
+ y = (double)(-maxY/2.0);
direction = CONTROL_POINT_VERTICAL;
break;
}
case DIVISION_SIDE_RIGHT:
{
- x = (float)(maxX/2.0);
+ x = (double)(maxX/2.0);
y = 0.0;
direction = CONTROL_POINT_HORIZONTAL;
break;
case DIVISION_SIDE_BOTTOM:
{
x = 0.0;
- y = (float)(maxY/2.0);
+ y = (double)(maxY/2.0);
direction = CONTROL_POINT_VERTICAL;
break;
}
if (m_controlPoints.Number() < 1)
return;
- float maxX, maxY;
+ double maxX, maxY;
GetBoundingBoxMax(&maxX, &maxY);
/*
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data();
if (control->type == CONTROL_POINT_HORIZONTAL)
{
- control->xoffset = (float)(-maxX/2.0); control->m_yoffset = 0.0;
+ control->xoffset = (double)(-maxX/2.0); control->m_yoffset = 0.0;
}
else if (control->type == CONTROL_POINT_VERTICAL)
{
- control->xoffset = 0.0; control->m_yoffset = (float)(-maxY/2.0);
+ control->xoffset = 0.0; control->m_yoffset = (double)(-maxY/2.0);
}
node = node->Next();
}
if ((m_handleSide == DIVISION_SIDE_LEFT) && node)
{
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data();
- control->m_xoffset = (float)(-maxX/2.0); control->m_yoffset = 0.0;
+ control->m_xoffset = (double)(-maxX/2.0); control->m_yoffset = 0.0;
}
if ((m_handleSide == DIVISION_SIDE_TOP) && node)
{
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data();
- control->m_xoffset = 0.0; control->m_yoffset = (float)(-maxY/2.0);
+ control->m_xoffset = 0.0; control->m_yoffset = (double)(-maxY/2.0);
}
if ((m_handleSide == DIVISION_SIDE_RIGHT) && node)
{
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data();
- control->m_xoffset = (float)(maxX/2.0); control->m_yoffset = 0.0;
+ control->m_xoffset = (double)(maxX/2.0); control->m_yoffset = 0.0;
}
if ((m_handleSide == DIVISION_SIDE_BOTTOM) && node)
{
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data();
- control->m_xoffset = 0.0; control->m_yoffset = (float)(maxY/2.0);
+ control->m_xoffset = 0.0; control->m_yoffset = (double)(maxY/2.0);
}
}
// Adjust a side, returning FALSE if it's not physically possible.
-bool wxDivisionShape::AdjustLeft(float left, bool test)
+bool wxDivisionShape::AdjustLeft(double left, bool test)
{
- float x2 = (float)(GetX() + (GetWidth()/2.0));
+ double x2 = (double)(GetX() + (GetWidth()/2.0));
if (left >= x2)
return FALSE;
if (test)
return TRUE;
- float newW = x2 - left;
- float newX = (float)(left + newW/2.0);
+ double newW = x2 - left;
+ double newX = (double)(left + newW/2.0);
SetSize(newW, GetHeight());
wxClientDC dc(GetCanvas());
return TRUE;
}
-bool wxDivisionShape::AdjustTop(float top, bool test)
+bool wxDivisionShape::AdjustTop(double top, bool test)
{
- float y2 = (float)(GetY() + (GetHeight()/2.0));
+ double y2 = (double)(GetY() + (GetHeight()/2.0));
if (top >= y2)
return FALSE;
if (test)
return TRUE;
- float newH = y2 - top;
- float newY = (float)(top + newH/2.0);
+ double newH = y2 - top;
+ double newY = (double)(top + newH/2.0);
SetSize(GetWidth(), newH);
wxClientDC dc(GetCanvas());
return TRUE;
}
-bool wxDivisionShape::AdjustRight(float right, bool test)
+bool wxDivisionShape::AdjustRight(double right, bool test)
{
- float x1 = (float)(GetX() - (GetWidth()/2.0));
+ double x1 = (double)(GetX() - (GetWidth()/2.0));
if (right <= x1)
return FALSE;
if (test)
return TRUE;
- float newW = right - x1;
- float newX = (float)(x1 + newW/2.0);
+ double newW = right - x1;
+ double newX = (double)(x1 + newW/2.0);
SetSize(newW, GetHeight());
wxClientDC dc(GetCanvas());
return TRUE;
}
-bool wxDivisionShape::AdjustBottom(float bottom, bool test)
+bool wxDivisionShape::AdjustBottom(double bottom, bool test)
{
- float y1 = (float)(GetY() - (GetHeight()/2.0));
+ double y1 = (double)(GetY() - (GetHeight()/2.0));
if (bottom <= y1)
return FALSE;
if (test)
return TRUE;
- float newH = bottom - y1;
- float newY = (float)(y1 + newH/2.0);
+ double newH = bottom - y1;
+ double newY = (double)(y1 + newH/2.0);
SetSize(GetWidth(), newH);
wxClientDC dc(GetCanvas());
return TRUE;
}
-wxDivisionControlPoint::wxDivisionControlPoint(wxShapeCanvas *the_canvas, wxShape *object, float size, float the_xoffset, float the_yoffset, int the_type):
+wxDivisionControlPoint::wxDivisionControlPoint(wxShapeCanvas *the_canvas, wxShape *object, double size, double the_xoffset, double the_yoffset, int the_type):
wxControlPoint(the_canvas, object, size, the_xoffset, the_yoffset, the_type)
{
SetEraseObject(FALSE);
{
}
-static float originalX = 0.0;
-static float originalY = 0.0;
-static float originalW = 0.0;
-static float originalH = 0.0;
+static double originalX = 0.0;
+static double originalY = 0.0;
+static double originalW = 0.0;
+static double originalH = 0.0;
// Implement resizing of canvas object
-void wxDivisionControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxDivisionControlPoint::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
wxControlPoint::OnDragLeft(draw, x, y, keys, attachment);
}
-void wxDivisionControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxDivisionControlPoint::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
wxDivisionShape *division = (wxDivisionShape *)m_shape;
originalX = division->GetX();
wxControlPoint::OnBeginDragLeft(x, y, keys, attachment);
}
-void wxDivisionControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxDivisionControlPoint::OnEndDragLeft(double x, double y, int keys, int attachment)
{
wxControlPoint::OnEndDragLeft(x, y, keys, attachment);
wxCompositeShape *divisionParent = (wxCompositeShape *)division->GetParent();
// Need to check it's within the bounds of the parent composite.
- float x1 = (float)(divisionParent->GetX() - (divisionParent->GetWidth()/2.0));
- float y1 = (float)(divisionParent->GetY() - (divisionParent->GetHeight()/2.0));
- float x2 = (float)(divisionParent->GetX() + (divisionParent->GetWidth()/2.0));
- float y2 = (float)(divisionParent->GetY() + (divisionParent->GetHeight()/2.0));
+ double x1 = (double)(divisionParent->GetX() - (divisionParent->GetWidth()/2.0));
+ double y1 = (double)(divisionParent->GetY() - (divisionParent->GetHeight()/2.0));
+ double x2 = (double)(divisionParent->GetX() + (divisionParent->GetWidth()/2.0));
+ double y2 = (double)(divisionParent->GetY() + (divisionParent->GetHeight()/2.0));
// Need to check it has not made the division zero or negative width/height
- float dx1 = (float)(division->GetX() - (division->GetWidth()/2.0));
- float dy1 = (float)(division->GetY() - (division->GetHeight()/2.0));
- float dx2 = (float)(division->GetX() + (division->GetWidth()/2.0));
- float dy2 = (float)(division->GetY() + (division->GetHeight()/2.0));
+ double dx1 = (double)(division->GetX() - (division->GetWidth()/2.0));
+ double dy1 = (double)(division->GetY() - (division->GetHeight()/2.0));
+ double dx2 = (double)(division->GetX() + (division->GetWidth()/2.0));
+ double dy2 = (double)(division->GetY() + (division->GetHeight()/2.0));
bool success = TRUE;
switch (division->GetHandleSide())
If size goes to zero or end position is other side of start position,
resize to original size and return.
*/
-bool wxDivisionShape::ResizeAdjoining(int side, float newPos, bool test)
+bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test)
{
wxCompositeShape *divisionParent = (wxCompositeShape *)GetParent();
wxNode *node = divisionParent->GetDivisions().First();
}
// Popup menu
-void wxDivisionShape::PopupMenu(float x, float y)
+void wxDivisionShape::PopupMenu(double x, double y)
{
oglPopupDivisionMenu->SetClientData((char *)this);
if (m_leftSide)
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
void OnErase(wxDC& dc);
- bool OnMovePre(wxDC& dc, float x, float y, float oldX, float oldY, bool display = TRUE);
- void OnDragLeft(bool draw, float x, float y, int keys, int attachment = 0);
- void OnBeginDragLeft(float x, float y, int keys, int attachment = 0);
- void OnEndDragLeft(float x, float y, int keys, int attachment = 0);
+ bool OnMovePre(wxDC& dc, double x, double y, double oldX, double oldY, bool display = TRUE);
+ void OnDragLeft(bool draw, double x, double y, int keys, int attachment = 0);
+ void OnBeginDragLeft(double x, double y, int keys, int attachment = 0);
+ void OnEndDragLeft(double x, double y, int keys, int attachment = 0);
- void OnRightClick(float x, float y, int keys, int attachment = 0);
+ void OnRightClick(double x, double y, int keys, int attachment = 0);
- void SetSize(float w, float h, bool recursive = TRUE);
+ void SetSize(double w, double h, bool recursive = TRUE);
// Returns TRUE if it settled down
bool Recompute();
inline wxList& GetConstraints() const { return (wxList&) m_constraints; }
protected:
- float m_oldX;
- float m_oldY;
+ double m_oldX;
+ double m_oldY;
wxList m_constraints;
wxList m_divisions; // In case it's a container
};
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
- bool OnMovePre(wxDC& dc, float x, float y, float oldX, float oldY, bool display = TRUE);
- void OnDragLeft(bool draw, float x, float y, int keys, int attachment = 0);
- void OnBeginDragLeft(float x, float y, int keys, int attachment = 0);
- void OnEndDragLeft(float x, float y, int keys, int attachment = 0);
+ bool OnMovePre(wxDC& dc, double x, double y, double oldX, double oldY, bool display = TRUE);
+ void OnDragLeft(bool draw, double x, double y, int keys, int attachment = 0);
+ void OnBeginDragLeft(double x, double y, int keys, int attachment = 0);
+ void OnEndDragLeft(double x, double y, int keys, int attachment = 0);
- void OnRightClick(float x, float y, int keys = 0, int attachment = 0);
+ void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
// Don't want this kind of composite to resize its subdiagrams, so
// override composite's SetSize.
- void SetSize(float w, float h, bool recursive = TRUE);
+ void SetSize(double w, double h, bool recursive = TRUE);
// Similarly for calculating size: it's fixed at whatever SetSize
// set it to, not in terms of children.
// Resize adjoining divisions at the given side. If test is TRUE,
// just see whether it's possible for each adjoining region,
// returning FALSE if it's not.
- bool ResizeAdjoining(int side, float newPos, bool test);
+ bool ResizeAdjoining(int side, double newPos, bool test);
// Adjust a side, returning FALSE if it's not physically possible.
- bool AdjustLeft(float left, bool test);
- bool AdjustTop(float top, bool test);
- bool AdjustRight(float right, bool test);
- bool AdjustBottom(float bottom, bool test);
+ bool AdjustLeft(double left, bool test);
+ bool AdjustTop(double top, bool test);
+ bool AdjustRight(double right, bool test);
+ bool AdjustBottom(double bottom, bool test);
// Edit style of left or top side
void EditEdge(int side);
// Popup menu
- void PopupMenu(float x, float y);
-
+ void PopupMenu(double x, double y);
+
inline void SetLeftSide(wxDivisionShape *shape) { m_leftSide = shape; }
inline void SetTopSide(wxDivisionShape *shape) { m_topSide = shape; }
inline void SetRightSide(wxDivisionShape *shape) { m_rightSide = shape; }
{
}
-bool OGLConstraint::Equals(float a, float b)
+bool OGLConstraint::Equals(double a, double b)
{
- float marg = 0.5;
+ double marg = 0.5;
bool eq = ((b <= a + marg) && (b >= a - marg));
return eq;
// Return TRUE if anything changed
bool OGLConstraint::Evaluate()
{
- float maxWidth, maxHeight, minWidth, minHeight, x, y;
+ double maxWidth, maxHeight, minWidth, minHeight, x, y;
m_constrainingObject->GetBoundingBoxMax(&maxWidth, &maxHeight);
m_constrainingObject->GetBoundingBoxMin(&minWidth, &minHeight);
x = m_constrainingObject->GetX();
case gyCONSTRAINT_CENTRED_VERTICALLY:
{
int n = m_constrainedObjects.Number();
- float totalObjectHeight = 0.0;
+ double totalObjectHeight = 0.0;
wxNode *node = m_constrainedObjects.First();
while (node)
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
totalObjectHeight += height2;
node = node->Next();
}
- float startY;
- float spacingY;
+ double startY;
+ double spacingY;
// Check if within the constraining object...
if ((totalObjectHeight + (n + 1)*m_ySpacing) <= minHeight)
{
- spacingY = (float)((minHeight - totalObjectHeight)/(n + 1));
- startY = (float)(y - (minHeight/2.0));
+ spacingY = (double)((minHeight - totalObjectHeight)/(n + 1));
+ startY = (double)(y - (minHeight/2.0));
}
// Otherwise, use default spacing
else
{
spacingY = m_ySpacing;
- startY = (float)(y - ((totalObjectHeight + (n+1)*spacingY)/2.0));
+ startY = (double)(y - ((totalObjectHeight + (n+1)*spacingY)/2.0));
}
// Now position the objects
while (node)
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- startY += (float)(spacingY + (height2/2.0));
+ startY += (double)(spacingY + (height2/2.0));
if (!Equals(startY, constrainedObject->GetY()))
{
constrainedObject->Move(dc, constrainedObject->GetX(), startY, FALSE);
changed = TRUE;
}
- startY += (float)(height2/2.0);
+ startY += (double)(height2/2.0);
node = node->Next();
}
return changed;
case gyCONSTRAINT_CENTRED_HORIZONTALLY:
{
int n = m_constrainedObjects.Number();
- float totalObjectWidth = 0.0;
+ double totalObjectWidth = 0.0;
wxNode *node = m_constrainedObjects.First();
while (node)
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
totalObjectWidth += width2;
node = node->Next();
}
- float startX;
- float spacingX;
+ double startX;
+ double spacingX;
// Check if within the constraining object...
if ((totalObjectWidth + (n + 1)*m_xSpacing) <= minWidth)
{
- spacingX = (float)((minWidth - totalObjectWidth)/(n + 1));
- startX = (float)(x - (minWidth/2.0));
+ spacingX = (double)((minWidth - totalObjectWidth)/(n + 1));
+ startX = (double)(x - (minWidth/2.0));
}
// Otherwise, use default spacing
else
{
spacingX = m_xSpacing;
- startX = (float)(x - ((totalObjectWidth + (n+1)*spacingX)/2.0));
+ startX = (double)(x - ((totalObjectWidth + (n+1)*spacingX)/2.0));
}
// Now position the objects
while (node)
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- startX += (float)(spacingX + (width2/2.0));
+ startX += (double)(spacingX + (width2/2.0));
if (!Equals(startX, constrainedObject->GetX()))
{
constrainedObject->Move(dc, startX, constrainedObject->GetY(), FALSE);
changed = TRUE;
}
- startX += (float)(width2/2.0);
+ startX += (double)(width2/2.0);
node = node->Next();
}
return changed;
case gyCONSTRAINT_CENTRED_BOTH:
{
int n = m_constrainedObjects.Number();
- float totalObjectWidth = 0.0;
- float totalObjectHeight = 0.0;
+ double totalObjectWidth = 0.0;
+ double totalObjectHeight = 0.0;
wxNode *node = m_constrainedObjects.First();
while (node)
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
totalObjectWidth += width2;
totalObjectHeight += height2;
node = node->Next();
}
- float startX;
- float spacingX;
- float startY;
- float spacingY;
+ double startX;
+ double spacingX;
+ double startY;
+ double spacingY;
// Check if within the constraining object...
if ((totalObjectWidth + (n + 1)*m_xSpacing) <= minWidth)
{
- spacingX = (float)((minWidth - totalObjectWidth)/(n + 1));
- startX = (float)(x - (minWidth/2.0));
+ spacingX = (double)((minWidth - totalObjectWidth)/(n + 1));
+ startX = (double)(x - (minWidth/2.0));
}
// Otherwise, use default spacing
else
{
spacingX = m_xSpacing;
- startX = (float)(x - ((totalObjectWidth + (n+1)*spacingX)/2.0));
+ startX = (double)(x - ((totalObjectWidth + (n+1)*spacingX)/2.0));
}
// Check if within the constraining object...
if ((totalObjectHeight + (n + 1)*m_ySpacing) <= minHeight)
{
- spacingY = (float)((minHeight - totalObjectHeight)/(n + 1));
- startY = (float)(y - (minHeight/2.0));
+ spacingY = (double)((minHeight - totalObjectHeight)/(n + 1));
+ startY = (double)(y - (minHeight/2.0));
}
// Otherwise, use default spacing
else
{
spacingY = m_ySpacing;
- startY = (float)(y - ((totalObjectHeight + (n+1)*spacingY)/2.0));
+ startY = (double)(y - ((totalObjectHeight + (n+1)*spacingY)/2.0));
}
// Now position the objects
while (node)
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- startX += (float)(spacingX + (width2/2.0));
- startY += (float)(spacingY + (height2/2.0));
+ startX += (double)(spacingX + (width2/2.0));
+ startY += (double)(spacingY + (height2/2.0));
if ((!Equals(startX, constrainedObject->GetX())) || (!Equals(startY, constrainedObject->GetY())))
{
changed = TRUE;
}
- startX += (float)(width2/2.0);
- startY += (float)(height2/2.0);
+ startX += (double)(width2/2.0);
+ startY += (double)(height2/2.0);
node = node->Next();
}
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- float x3 = (float)(x - (minWidth/2.0) - (width2/2.0) - m_xSpacing);
+ double x3 = (double)(x - (minWidth/2.0) - (width2/2.0) - m_xSpacing);
if (!Equals(x3, constrainedObject->GetX()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- float x3 = (float)(x + (minWidth/2.0) + (width2/2.0) + m_xSpacing);
+ double x3 = (double)(x + (minWidth/2.0) + (width2/2.0) + m_xSpacing);
if (!Equals(x3, constrainedObject->GetX()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- float y3 = (float)(y - (minHeight/2.0) - (height2/2.0) - m_ySpacing);
+ double y3 = (double)(y - (minHeight/2.0) - (height2/2.0) - m_ySpacing);
if (!Equals(y3, constrainedObject->GetY()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- float y3 = (float)(y + (minHeight/2.0) + (height2/2.0) + m_ySpacing);
+ double y3 = (double)(y + (minHeight/2.0) + (height2/2.0) + m_ySpacing);
if (!Equals(y3, constrainedObject->GetY()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- float x3 = (float)(x - (minWidth/2.0) + (width2/2.0) + m_xSpacing);
+ double x3 = (double)(x - (minWidth/2.0) + (width2/2.0) + m_xSpacing);
if (!Equals(x3, constrainedObject->GetX()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- float x3 = (float)(x + (minWidth/2.0) - (width2/2.0) - m_xSpacing);
+ double x3 = (double)(x + (minWidth/2.0) - (width2/2.0) - m_xSpacing);
if (!Equals(x3, constrainedObject->GetX()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- float y3 = (float)(y - (minHeight/2.0) + (height2/2.0) + m_ySpacing);
+ double y3 = (double)(y - (minHeight/2.0) + (height2/2.0) + m_ySpacing);
if (!Equals(y3, constrainedObject->GetY()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float width2, height2;
+ double width2, height2;
constrainedObject->GetBoundingBoxMax(&width2, &height2);
- float y3 = (float)(y + (minHeight/2.0) - (height2/2.0) - m_ySpacing);
+ double y3 = (double)(y + (minHeight/2.0) - (height2/2.0) - m_ySpacing);
if (!Equals(y3, constrainedObject->GetY()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float x3 = (float)(x - (minWidth/2.0));
+ double x3 = (double)(x - (minWidth/2.0));
if (!Equals(x3, constrainedObject->GetX()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float x3 = (float)(x + (minWidth/2.0));
+ double x3 = (double)(x + (minWidth/2.0));
if (!Equals(x3, constrainedObject->GetX()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float y3 = (float)(y - (minHeight/2.0));
+ double y3 = (double)(y - (minHeight/2.0));
if (!Equals(y3, constrainedObject->GetY()))
{
changed = TRUE;
{
wxShape *constrainedObject = (wxShape *)node->Data();
- float y3 = (float)(y + (minHeight/2.0));
+ double y3 = (double)(y + (minHeight/2.0));
if (!Equals(y3, constrainedObject->GetY()))
{
changed = TRUE;
// Returns TRUE if anything changed
bool Evaluate();
- inline void SetSpacing(float x, float y) { m_xSpacing = x; m_ySpacing = y; };
- bool Equals(float a, float b);
+ inline void SetSpacing(double x, double y) { m_xSpacing = x; m_ySpacing = y; };
+ bool Equals(double a, double b);
- float m_xSpacing;
- float m_ySpacing;
+ double m_xSpacing;
+ double m_ySpacing;
int m_constraintType;
wxString m_constraintName;
long m_constraintId;
public:
wxDividedShapeControlPoint() { regionId = 0; }
wxDividedShapeControlPoint(wxShapeCanvas *the_canvas, wxShape *object, int region,
- float size, float the_xoffset, float the_yoffset, int the_type);
+ double size, double the_xoffset, double the_yoffset, int the_type);
~wxDividedShapeControlPoint();
- void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0);
- void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
- void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
+ void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
+ void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
+ void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
};
IMPLEMENT_DYNAMIC_CLASS(wxDividedShapeControlPoint, wxControlPoint)
IMPLEMENT_DYNAMIC_CLASS(wxDividedShape, wxRectangleShape)
-wxDividedShape::wxDividedShape(float w, float h): wxRectangleShape(w, h)
+wxDividedShape::wxDividedShape(double w, double h): wxRectangleShape(w, h)
{
ClearRegions();
}
void wxDividedShape::OnDrawContents(wxDC& dc)
{
- float defaultProportion = (float)(GetRegions().Number() > 0 ? (1.0/((float)(GetRegions().Number()))) : 0.0);
- float currentY = (float)(m_ypos - (m_height / 2.0));
- float maxY = (float)(m_ypos + (m_height / 2.0));
+ double defaultProportion = (double)(GetRegions().Number() > 0 ? (1.0/((double)(GetRegions().Number()))) : 0.0);
+ double currentY = (double)(m_ypos - (m_height / 2.0));
+ double maxY = (double)(m_ypos + (m_height / 2.0));
- float leftX = (float)(m_xpos - (m_width / 2.0));
- float rightX = (float)(m_xpos + (m_width / 2.0));
+ double leftX = (double)(m_xpos - (m_width / 2.0));
+ double rightX = (double)(m_xpos + (m_width / 2.0));
if (m_pen) dc.SetPen(m_pen);
*/
if (GetDisableLabel()) return;
- float xMargin = 2;
- float yMargin = 2;
+ double xMargin = 2;
+ double yMargin = 2;
dc.SetBackgroundMode(wxTRANSPARENT);
wxNode *node = GetRegions().First();
dc.SetFont(region->GetFont());
dc.SetTextForeground(* region->GetActualColourObject());
- float proportion =
+ double proportion =
region->m_regionProportionY < 0.0 ? defaultProportion : region->m_regionProportionY;
- float y = currentY + m_height*proportion;
- float actualY = maxY < y ? maxY : y;
+ double y = currentY + m_height*proportion;
+ double actualY = maxY < y ? maxY : y;
- float centreX = m_xpos;
- float centreY = (float)(currentY + (actualY - currentY)/2.0);
+ double centreX = m_xpos;
+ double centreY = (double)(currentY + (actualY - currentY)/2.0);
- DrawFormattedText(dc, ®ion->m_formattedText,
- (float)(centreX), (float)(centreY), (float)(m_width-2*xMargin), (float)(actualY - currentY - 2*yMargin),
+ oglDrawFormattedText(dc, ®ion->m_formattedText,
+ (double)(centreX), (double)(centreY), (double)(m_width-2*xMargin), (double)(actualY - currentY - 2*yMargin),
region->m_formatMode);
if ((y <= maxY) && (node->Next()))
{
if (regionPen)
{
dc.SetPen(regionPen);
- dc.DrawLine(leftX, y, rightX, y);
+ dc.DrawLine(WXROUND(leftX), WXROUND(y), WXROUND(rightX), WXROUND(y));
}
}
}
}
-void wxDividedShape::SetSize(float w, float h, bool recursive)
+void wxDividedShape::SetSize(double w, double h, bool recursive)
{
SetAttachmentSize(w, h);
m_width = w;
if (GetRegions().Number() == 0)
return;
- float defaultProportion = (float)(GetRegions().Number() > 0 ? (1.0/((float)(GetRegions().Number()))) : 0.0);
- float currentY = (float)(m_ypos - (m_height / 2.0));
- float maxY = (float)(m_ypos + (m_height / 2.0));
+ double defaultProportion = (double)(GetRegions().Number() > 0 ? (1.0/((double)(GetRegions().Number()))) : 0.0);
+ double currentY = (double)(m_ypos - (m_height / 2.0));
+ double maxY = (double)(m_ypos + (m_height / 2.0));
-// float leftX = (float)(m_xpos - (m_width / 2.0));
-// float rightX = (float)(m_xpos + (m_width / 2.0));
+// double leftX = (double)(m_xpos - (m_width / 2.0));
+// double rightX = (double)(m_xpos + (m_width / 2.0));
wxNode *node = GetRegions().First();
while (node)
{
wxShapeRegion *region = (wxShapeRegion *)node->Data();
- float proportion =
+ double proportion =
region->m_regionProportionY <= 0.0 ? defaultProportion : region->m_regionProportionY;
- float sizeY = (float)proportion*m_height;
- float y = currentY + sizeY;
- float actualY = maxY < y ? maxY : y;
+ double sizeY = (double)proportion*m_height;
+ double y = currentY + sizeY;
+ double actualY = maxY < y ? maxY : y;
- float centreY = (float)(currentY + (actualY - currentY)/2.0);
+ double centreY = (double)(currentY + (actualY - currentY)/2.0);
region->SetSize(m_width, sizeY);
- region->SetPosition(0.0, (float)(centreY - m_ypos));
+ region->SetPosition(0.0, (double)(centreY - m_ypos));
currentY = actualY;
node = node->Next();
}
}
// Attachment points correspond to regions in the divided box
-bool wxDividedShape::GetAttachmentPosition(int attachment, float *x, float *y, int nth, int no_arcs,
+bool wxDividedShape::GetAttachmentPosition(int attachment, double *x, double *y, int nth, int no_arcs,
wxLineShape *line)
{
int totalNumberAttachments = (GetRegions().Number() * 2) + 2;
int n = GetRegions().Number();
bool isEnd = (line && line->IsEnd(this));
- float left = (float)(m_xpos - m_width/2.0);
- float right = (float)(m_xpos + m_width/2.0);
- float top = (float)(m_ypos - m_height/2.0);
- float bottom = (float)(m_ypos + m_height/2.0);
+ double left = (double)(m_xpos - m_width/2.0);
+ double right = (double)(m_xpos + m_width/2.0);
+ double top = (double)(m_ypos - m_height/2.0);
+ double bottom = (double)(m_ypos + m_height/2.0);
// Zero is top, n+1 is bottom.
if (attachment == 0)
*x = right;
// Calculate top and bottom of region
- top = (float)((m_ypos + region->m_y) - (region->m_height/2.0));
- bottom = (float)((m_ypos + region->m_y) + (region->m_height/2.0));
+ top = (double)((m_ypos + region->m_y) - (region->m_height/2.0));
+ bottom = (double)((m_ypos + region->m_y) + (region->m_height/2.0));
// Assuming we can trust the absolute size and
// position of these regions...
*y = point->y;
}
else
-// *y = (float)(((m_ypos + region->m_y) - (region->m_height/2.0)) + (nth + 1)*region->m_height/(no_arcs+1));
- *y = (float)(top + (nth + 1)*region->m_height/(no_arcs+1));
+// *y = (double)(((m_ypos + region->m_y) - (region->m_height/2.0)) + (nth + 1)*region->m_height/(no_arcs+1));
+ *y = (double)(top + (nth + 1)*region->m_height/(no_arcs+1));
}
else
- *y = (float)(m_ypos + region->m_y);
+ *y = (double)(m_ypos + region->m_y);
}
else
{
void wxDividedShape::MakeMandatoryControlPoints()
{
- float currentY = (float)(GetY() - (m_height / 2.0));
- float maxY = (float)(GetY() + (m_height / 2.0));
+ double currentY = (double)(GetY() - (m_height / 2.0));
+ double maxY = (double)(GetY() + (m_height / 2.0));
wxNode *node = GetRegions().First();
int i = 0;
{
wxShapeRegion *region = (wxShapeRegion *)node->Data();
- float proportion = region->m_regionProportionY;
+ double proportion = region->m_regionProportionY;
- float y = currentY + m_height*proportion;
- float actualY = (float)(maxY < y ? maxY : y);
+ double y = currentY + m_height*proportion;
+ double actualY = (double)(maxY < y ? maxY : y);
if (node->Next())
{
wxDividedShapeControlPoint *controlPoint =
- new wxDividedShapeControlPoint(m_canvas, this, i, CONTROL_POINT_SIZE, 0.0, (float)(actualY - GetY()), 0);
+ new wxDividedShapeControlPoint(m_canvas, this, i, CONTROL_POINT_SIZE, 0.0, (double)(actualY - GetY()), 0);
m_canvas->AddShape(controlPoint);
m_controlPoints.Append(controlPoint);
}
void wxDividedShape::ResetMandatoryControlPoints()
{
- float currentY = (float)(GetY() - (m_height / 2.0));
- float maxY = (float)(GetY() + (m_height / 2.0));
+ double currentY = (double)(GetY() - (m_height / 2.0));
+ double maxY = (double)(GetY() + (m_height / 2.0));
wxNode *node = m_controlPoints.First();
int i = 0;
wxNode *node1 = GetRegions().Nth(i);
wxShapeRegion *region = (wxShapeRegion *)node1->Data();
- float proportion = region->m_regionProportionY;
+ double proportion = region->m_regionProportionY;
- float y = currentY + m_height*proportion;
- float actualY = (float)(maxY < y ? maxY : y);
+ double y = currentY + m_height*proportion;
+ double actualY = (double)(maxY < y ? maxY : y);
controlPoint->m_xoffset = 0.0;
- controlPoint->m_yoffset = (float)(actualY - GetY());
+ controlPoint->m_yoffset = (double)(actualY - GetY());
currentY = actualY;
i ++;
}
#endif
}
-void wxDividedShape::OnRightClick(float x, float y, int keys, int attachment)
+void wxDividedShape::OnRightClick(double x, double y, int keys, int attachment)
{
if (keys & KEY_CTRL)
{
}
wxDividedShapeControlPoint::wxDividedShapeControlPoint(wxShapeCanvas *the_canvas, wxShape *object,
- int region, float size, float the_m_xoffset, float the_m_yoffset, int the_type):
+ int region, double size, double the_m_xoffset, double the_m_yoffset, int the_type):
wxControlPoint(the_canvas, object, size, the_m_xoffset, the_m_yoffset, the_type)
{
regionId = region;
}
// Implement resizing of divided object division
-void wxDividedShapeControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxDividedShapeControlPoint::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
dc.SetBrush((* wxTRANSPARENT_BRUSH));
wxDividedShape *dividedObject = (wxDividedShape *)m_shape;
- float x1 = (float)(dividedObject->GetX() - (dividedObject->GetWidth()/2.0));
- float y1 = y;
- float x2 = (float)(dividedObject->GetX() + (dividedObject->GetWidth()/2.0));
- float y2 = y;
- dc.DrawLine(x1, y1, x2, y2);
+ double x1 = (double)(dividedObject->GetX() - (dividedObject->GetWidth()/2.0));
+ double y1 = y;
+ double x2 = (double)(dividedObject->GetX() + (dividedObject->GetWidth()/2.0));
+ double y2 = y;
+ dc.DrawLine(WXROUND(x1), WXROUND(y1), WXROUND(x2), WXROUND(y2));
}
-void wxDividedShapeControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxDividedShapeControlPoint::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
dc.SetPen(dottedPen);
dc.SetBrush((* wxTRANSPARENT_BRUSH));
- float x1 = (float)(dividedObject->GetX() - (dividedObject->GetWidth()/2.0));
- float y1 = y;
- float x2 = (float)(dividedObject->GetX() + (dividedObject->GetWidth()/2.0));
- float y2 = y;
- dc.DrawLine(x1, y1, x2, y2);
+ double x1 = (double)(dividedObject->GetX() - (dividedObject->GetWidth()/2.0));
+ double y1 = y;
+ double x2 = (double)(dividedObject->GetX() + (dividedObject->GetWidth()/2.0));
+ double y2 = y;
+ dc.DrawLine(WXROUND(x1), WXROUND(y1), WXROUND(x2), WXROUND(y2));
m_canvas->CaptureMouse();
}
-void wxDividedShapeControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxDividedShapeControlPoint::OnEndDragLeft(double x, double y, int keys, int attachment)
{
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
// and calculate the new proportion for this region
// if legal.
- float currentY = (float)(dividedObject->GetY() - (dividedObject->GetHeight() / 2.0));
- float maxY = (float)(dividedObject->GetY() + (dividedObject->GetHeight() / 2.0));
+ double currentY = (double)(dividedObject->GetY() - (dividedObject->GetHeight() / 2.0));
+ double maxY = (double)(dividedObject->GetY() + (dividedObject->GetHeight() / 2.0));
// Save values
- float thisRegionTop = 0.0;
- float thisRegionBottom = 0.0;
- float nextRegionBottom = 0.0;
+ double thisRegionTop = 0.0;
+ double thisRegionBottom = 0.0;
+ double nextRegionBottom = 0.0;
node = dividedObject->GetRegions().First();
while (node)
{
wxShapeRegion *region = (wxShapeRegion *)node->Data();
- float proportion = region->m_regionProportionY;
- float yy = currentY + (dividedObject->GetHeight()*proportion);
- float actualY = (float)(maxY < yy ? maxY : yy);
+ double proportion = region->m_regionProportionY;
+ double yy = currentY + (dividedObject->GetHeight()*proportion);
+ double actualY = (double)(maxY < yy ? maxY : yy);
if (region == thisRegion)
{
dividedObject->EraseLinks(dc);
// Now calculate the new proportions of this region and the next region.
- float thisProportion = (float)((y - thisRegionTop)/dividedObject->GetHeight());
- float nextProportion = (float)((nextRegionBottom - y)/dividedObject->GetHeight());
+ double thisProportion = (double)((y - thisRegionTop)/dividedObject->GetHeight());
+ double nextProportion = (double)((nextRegionBottom - y)/dividedObject->GetHeight());
thisRegion->SetProportions(0.0, thisProportion);
nextRegion->SetProportions(0.0, nextProportion);
- m_yoffset = (float)(y - dividedObject->GetY());
+ m_yoffset = (double)(y - dividedObject->GetY());
// Now reformat text
int i = 0;
DECLARE_DYNAMIC_CLASS(wxDividedShape)
public:
- wxDividedShape(float w = 0.0, float h = 0.0);
+ wxDividedShape(double w = 0.0, double h = 0.0);
~wxDividedShape();
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
- void SetSize(float w, float h, bool recursive = TRUE);
+ void SetSize(double w, double h, bool recursive = TRUE);
void MakeControlPoints();
void ResetControlPoints();
void EditRegions();
// Attachment points correspond to regions in the divided box
- bool GetAttachmentPosition(int attachment, float *x, float *y,
+ bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
bool AttachmentIsValid(int attachment);
int GetNumberOfAttachments();
// Invoke editor on CTRL-right click
- void OnRightClick(float x, float y, int keys = 0, int attachment = 0);
+ void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
};
#endif
static void IntToHex(unsigned int dec, char *buf);
static unsigned long HexToInt(char *buf);
-extern char *GraphicsBuffer;
+extern char *oglBuffer;
#define gyTYPE_PEN 40
#define gyTYPE_BRUSH 41
wxDrawnShape::wxDrawnShape():wxRectangleShape(100.0, 50.0)
{
m_saveToFile = TRUE;
+ m_currentAngle = oglDRAWN_ANGLE_0;
}
wxDrawnShape::~wxDrawnShape()
if (m_shadowMode != SHADOW_NONE)
{
if (m_shadowBrush)
- m_metafile.m_fillBrush = m_shadowBrush;
- m_metafile.m_outlinePen = transparent_pen;
- m_metafile.Draw(dc, m_xpos + m_shadowOffsetX, m_ypos + m_shadowOffsetY);
+ m_metafiles[m_currentAngle].m_fillBrush = m_shadowBrush;
+ m_metafiles[m_currentAngle].m_outlinePen = g_oglTransparentPen;
+ m_metafiles[m_currentAngle].Draw(dc, m_xpos + m_shadowOffsetX, m_ypos + m_shadowOffsetY);
}
- m_metafile.m_outlinePen = m_pen;
- m_metafile.m_fillBrush = m_brush;
- m_metafile.Draw(dc, m_xpos, m_ypos);
+ m_metafiles[m_currentAngle].m_outlinePen = m_pen;
+ m_metafiles[m_currentAngle].m_fillBrush = m_brush;
+ m_metafiles[m_currentAngle].Draw(dc, m_xpos, m_ypos);
}
-void wxDrawnShape::SetSize(float w, float h, bool recursive)
+void wxDrawnShape::SetSize(double w, double h, bool recursive)
{
SetAttachmentSize(w, h);
- float scaleX;
- float scaleY;
+ double scaleX;
+ double scaleY;
if (GetWidth() == 0.0)
scaleX = 1.0;
else scaleX = w/GetWidth();
scaleY = 1.0;
else scaleY = h/GetHeight();
- m_metafile.Scale(scaleX, scaleY);
+ int i = 0;
+ for (i = 0; i < 4; i++)
+ {
+ if (m_metafiles[i].IsValid())
+ m_metafiles[i].Scale(scaleX, scaleY);
+ }
m_width = w;
m_height = h;
SetDefaultRegionSize();
}
-void wxDrawnShape::Scale(float sx, float sy)
+void wxDrawnShape::Scale(double sx, double sy)
{
- m_metafile.Scale(sx, sy);
- m_metafile.CalculateSize(this);
+ int i;
+ for (i = 0; i < 4; i++)
+ {
+ if (m_metafiles[i].IsValid())
+ {
+ m_metafiles[i].Scale(sx, sy);
+ m_metafiles[i].CalculateSize(this);
+ }
+ }
}
-void wxDrawnShape::Translate(float x, float y)
+void wxDrawnShape::Translate(double x, double y)
{
- m_metafile.Translate(x, y);
- m_metafile.CalculateSize(this);
+ int i;
+ for (i = 0; i < 4; i++)
+ {
+ if (m_metafiles[i].IsValid())
+ {
+ m_metafiles[i].Translate(x, y);
+ m_metafiles[i].CalculateSize(this);
+ }
+ }
}
-void wxDrawnShape::Rotate(float x, float y, float theta)
+// theta is absolute rotation from the zero position
+void wxDrawnShape::Rotate(double x, double y, double theta)
{
- if (!m_metafile.GetRotateable())
- return;
+ m_currentAngle = DetermineMetaFile(theta);
+
+ if (m_currentAngle == 0)
+ {
+ // Rotate metafile
+ if (!m_metafiles[0].GetRotateable())
+ return;
- float actualTheta = theta-m_metafile.m_currentRotation;
+ m_metafiles[0].Rotate(x, y, theta);
+ }
- // Rotate metafile
- m_metafile.Rotate(x, y, theta);
+ double actualTheta = theta-m_rotation;
// Rotate attachment points
- float sinTheta = (float)sin(actualTheta);
- float cosTheta = (float)cos(actualTheta);
+ double sinTheta = (double)sin(actualTheta);
+ double cosTheta = (double)cos(actualTheta);
wxNode *node = m_attachmentPoints.First();
while (node)
{
wxAttachmentPoint *point = (wxAttachmentPoint *)node->Data();
- float x1 = point->m_x;
- float y1 = point->m_y;
- point->m_x = x1*cosTheta - y1*sinTheta + x*(1 - cosTheta) + y*sinTheta;
- point->m_y = x1*sinTheta + y1*cosTheta + y*(1 - cosTheta) + x*sinTheta;
+ double x1 = point->m_x;
+ double y1 = point->m_y;
+ point->m_x = x1*cosTheta - y1*sinTheta + x*(1.0 - cosTheta) + y*sinTheta;
+ point->m_y = x1*sinTheta + y1*cosTheta + y*(1.0 - cosTheta) + x*sinTheta;
node = node->Next();
}
m_rotation = theta;
- m_metafile.CalculateSize(this);
+ m_metafiles[m_currentAngle].CalculateSize(this);
+}
+
+// Which metafile do we use now? Based on current rotation and validity
+// of metafiles.
+
+int wxDrawnShape::DetermineMetaFile(double rotation)
+{
+ double tolerance = 0.0001;
+ const double pi = 3.1415926535897932384626433832795 ;
+ double angle1 = 0.0;
+ double angle2 = pi/2.0;
+ double angle3 = pi;
+ double angle4 = 3.0*pi/2.0;
+
+ int whichMetafile = 0;
+
+ if (oglRoughlyEqual(rotation, angle1, tolerance))
+ {
+ whichMetafile = 0;
+ }
+ else if (oglRoughlyEqual(rotation, angle2, tolerance))
+ {
+ whichMetafile = 1;
+ }
+ else if (oglRoughlyEqual(rotation, angle3, tolerance))
+ {
+ whichMetafile = 2;
+ }
+ else if (oglRoughlyEqual(rotation, angle4, tolerance))
+ {
+ whichMetafile = 3;
+ }
+
+ if ((whichMetafile > 0) && !m_metafiles[whichMetafile].IsValid())
+ whichMetafile = 0;
+
+ return whichMetafile;
+}
+
+void wxDrawnShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double h)
+{
+ if (m_metafiles[m_currentAngle].GetOutlineOp() != -1)
+ {
+ wxNode* node = m_metafiles[m_currentAngle].GetOps().Nth(m_metafiles[m_currentAngle].GetOutlineOp());
+ wxASSERT (node != NULL);
+ wxDrawOp* op = (wxDrawOp*) node->Data();
+
+ if (op->OnDrawOutline(dc, x, y, w, h, m_width, m_height))
+ return;
+ }
+
+ // Default... just use a rectangle
+ wxRectangleShape::OnDrawOutline(dc, x, y, w, h);
+}
+
+// Get the perimeter point using the special outline op, if there is one,
+// otherwise use default wxRectangleShape scheme
+bool wxDrawnShape::GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3)
+{
+ if (m_metafiles[m_currentAngle].GetOutlineOp() != -1)
+ {
+ wxNode* node = m_metafiles[m_currentAngle].GetOps().Nth(m_metafiles[m_currentAngle].GetOutlineOp());
+ wxASSERT (node != NULL);
+ wxDrawOp* op = (wxDrawOp*) node->Data();
+
+ if (op->GetPerimeterPoint(x1, y1, x2, y2, x3, y3, GetX(), GetY(), GetAttachmentMode()))
+ return TRUE;
+ }
+
+ // Default... just use a rectangle
+ return wxRectangleShape::GetPerimeterPoint(x1, y1, x2, y2, x3, y3);
}
#ifdef PROLOGIO
clause->AddAttributeValue("save_metafile", (long)m_saveToFile);
if (m_saveToFile)
- m_metafile.WritePrologAttributes(clause);
+ {
+ int i = 0;
+ for (i = 0; i < 4; i++)
+ {
+ if (m_metafiles[i].IsValid())
+ m_metafiles[i].WritePrologAttributes(clause, i);
+ }
+ }
}
void wxDrawnShape::ReadPrologAttributes(wxExpr *clause)
m_saveToFile = (iVal != 0);
if (m_saveToFile)
- m_metafile.ReadPrologAttributes(clause);
+ {
+ int i = 0;
+ for (i = 0; i < 4; i++)
+ {
+ m_metafiles[i].ReadPrologAttributes(clause, i);
+ }
+ }
}
#endif
wxDrawnShape& drawnCopy = (wxDrawnShape&) copy;
- m_metafile.Copy(drawnCopy.m_metafile);
+ int i = 0;
+ for (i = 0; i < 4; i++)
+ {
+ m_metafiles[i].Copy(drawnCopy.m_metafiles[i]);
+ }
drawnCopy.m_saveToFile = m_saveToFile;
+ drawnCopy.m_currentAngle = m_currentAngle;
}
bool wxDrawnShape::LoadFromMetaFile(char *filename)
{
- return m_metafile.LoadFromMetaFile(filename, &m_width, &m_height);
+ return m_metafiles[0].LoadFromMetaFile(filename, &m_width, &m_height);
}
// Set of functions for drawing into a pseudo metafile.
void wxDrawnShape::DrawLine(const wxPoint& pt1, const wxPoint& pt2)
{
- m_metafile.DrawLine(pt1, pt2);
+ m_metafiles[m_currentAngle].DrawLine(pt1, pt2);
}
void wxDrawnShape::DrawRectangle(const wxRect& rect)
{
- m_metafile.DrawRectangle(rect);
+ m_metafiles[m_currentAngle].DrawRectangle(rect);
}
void wxDrawnShape::DrawRoundedRectangle(const wxRect& rect, double radius)
{
- m_metafile.DrawRoundedRectangle(rect, radius);
+ m_metafiles[m_currentAngle].DrawRoundedRectangle(rect, radius);
}
void wxDrawnShape::DrawEllipse(const wxRect& rect)
{
- m_metafile.DrawEllipse(rect);
+ m_metafiles[m_currentAngle].DrawEllipse(rect);
+}
+
+void wxDrawnShape::DrawArc(const wxPoint& centrePt, const wxPoint& startPt, const wxPoint& endPt)
+{
+ m_metafiles[m_currentAngle].DrawArc(centrePt, startPt, endPt);
+}
+
+void wxDrawnShape::DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle)
+{
+ m_metafiles[m_currentAngle].DrawEllipticArc(rect, startAngle, endAngle);
}
void wxDrawnShape::DrawPoint(const wxPoint& pt)
{
- m_metafile.DrawPoint(pt);
+ m_metafiles[m_currentAngle].DrawPoint(pt);
}
void wxDrawnShape::DrawText(const wxString& text, const wxPoint& pt)
{
- m_metafile.DrawText(text, pt);
+ m_metafiles[m_currentAngle].DrawText(text, pt);
}
void wxDrawnShape::DrawLines(int n, wxPoint pts[])
{
- m_metafile.DrawLines(n, pts);
+ m_metafiles[m_currentAngle].DrawLines(n, pts);
}
-void wxDrawnShape::DrawPolygon(int n, wxPoint pts[])
+void wxDrawnShape::DrawPolygon(int n, wxPoint pts[], int flags)
{
- m_metafile.DrawPolygon(n, pts);
+ if (flags & oglMETAFLAGS_ATTACHMENTS)
+ {
+ ClearAttachments();
+ int i;
+ for (i = 0; i < n; i++)
+ m_attachmentPoints.Append(new wxAttachmentPoint(i, pts[i].x, pts[i].y));
+ }
+ m_metafiles[m_currentAngle].DrawPolygon(n, pts, flags);
}
void wxDrawnShape::DrawSpline(int n, wxPoint pts[])
{
- m_metafile.DrawSpline(n, pts);
+ m_metafiles[m_currentAngle].DrawSpline(n, pts);
}
void wxDrawnShape::SetClippingRect(const wxRect& rect)
{
- m_metafile.SetClippingRect(rect);
+ m_metafiles[m_currentAngle].SetClippingRect(rect);
}
void wxDrawnShape::DestroyClippingRect()
{
- m_metafile.DestroyClippingRect();
+ m_metafiles[m_currentAngle].DestroyClippingRect();
}
void wxDrawnShape::SetPen(wxPen* pen, bool isOutline)
{
- m_metafile.SetPen(pen, isOutline);
+ m_metafiles[m_currentAngle].SetPen(pen, isOutline);
}
void wxDrawnShape::SetBrush(wxBrush* brush, bool isFill)
{
- m_metafile.SetBrush(brush, isFill);
+ m_metafiles[m_currentAngle].SetBrush(brush, isFill);
}
void wxDrawnShape::SetFont(wxFont* font)
{
- m_metafile.SetFont(font);
+ m_metafiles[m_currentAngle].SetFont(font);
}
void wxDrawnShape::SetTextColour(const wxColour& colour)
{
- m_metafile.SetTextColour(colour);
+ m_metafiles[m_currentAngle].SetTextColour(colour);
}
void wxDrawnShape::SetBackgroundColour(const wxColour& colour)
{
- m_metafile.SetBackgroundColour(colour);
+ m_metafiles[m_currentAngle].SetBackgroundColour(colour);
}
void wxDrawnShape::SetBackgroundMode(int mode)
{
- m_metafile.SetBackgroundMode(mode);
+ m_metafiles[m_currentAngle].SetBackgroundMode(mode);
}
m_mode = theMode;
}
-void wxOpSetGDI::Do(wxDC& dc, float xoffset, float yoffset)
+void wxOpSetGDI::Do(wxDC& dc, double xoffset, double yoffset)
{
switch (m_op)
{
*
*/
-wxOpSetClipping::wxOpSetClipping(int theOp, float theX1, float theY1,
- float theX2, float theY2):wxDrawOp(theOp)
+wxOpSetClipping::wxOpSetClipping(int theOp, double theX1, double theY1,
+ double theX2, double theY2):wxDrawOp(theOp)
{
m_x1 = theX1;
m_y1 = theY1;
return newOp;
}
-void wxOpSetClipping::Do(wxDC& dc, float xoffset, float yoffset)
+void wxOpSetClipping::Do(wxDC& dc, double xoffset, double yoffset)
{
switch (m_op)
{
}
}
-void wxOpSetClipping::Scale(float xScale, float yScale)
+void wxOpSetClipping::Scale(double xScale, double yScale)
{
m_x1 *= xScale;
m_y1 *= yScale;
m_y2 *= yScale;
}
-void wxOpSetClipping::Translate(float x, float y)
+void wxOpSetClipping::Translate(double x, double y)
{
m_x1 += x;
m_y1 += y;
*
*/
-wxOpDraw::wxOpDraw(int theOp, float theX1, float theY1, float theX2, float theY2,
- float theRadius, char *s):wxDrawOp(theOp)
+wxOpDraw::wxOpDraw(int theOp, double theX1, double theY1, double theX2, double theY2,
+ double theRadius, char *s):wxDrawOp(theOp)
{
m_x1 = theX1;
m_y1 = theY1;
m_x2 = theX2;
m_y2 = theY2;
+ m_x3 = 0.0;
+ m_y3 = 0.0;
m_radius = theRadius;
if (s) m_textString = copystring(s);
else m_textString = NULL;
wxDrawOp *wxOpDraw::Copy(wxPseudoMetaFile *newImage)
{
wxOpDraw *newOp = new wxOpDraw(m_op, m_x1, m_y1, m_x2, m_y2, m_radius, m_textString);
+ newOp->m_x3 = m_x3;
+ newOp->m_y3 = m_y3;
return newOp;
}
-void wxOpDraw::Do(wxDC& dc, float xoffset, float yoffset)
+void wxOpDraw::Do(wxDC& dc, double xoffset, double yoffset)
{
switch (m_op)
{
case DRAWOP_DRAW_LINE:
{
- dc.DrawLine(m_x1+xoffset, m_y1+yoffset, m_x2+xoffset, m_y2+yoffset);
+ dc.DrawLine(WXROUND(m_x1+xoffset), WXROUND(m_y1+yoffset), WXROUND(m_x2+xoffset), WXROUND(m_y2+yoffset));
break;
}
case DRAWOP_DRAW_RECT:
{
- dc.DrawRectangle(m_x1+xoffset, m_y1+yoffset, m_x2, m_y2);
+ dc.DrawRectangle(WXROUND(m_x1+xoffset), WXROUND(m_y1+yoffset), WXROUND(m_x2), WXROUND(m_y2));
break;
}
case DRAWOP_DRAW_ROUNDED_RECT:
{
- dc.DrawRoundedRectangle(m_x1+xoffset, m_y1+yoffset, m_x2, m_y2, m_radius);
+ dc.DrawRoundedRectangle(WXROUND(m_x1+xoffset), WXROUND(m_y1+yoffset), WXROUND(m_x2), WXROUND(m_y2), m_radius);
break;
}
case DRAWOP_DRAW_ELLIPSE:
{
- dc.DrawEllipse(m_x1+xoffset, m_y1+yoffset, m_x2, m_y2);
+ dc.DrawEllipse(WXROUND(m_x1+xoffset), WXROUND(m_y1+yoffset), WXROUND(m_x2), WXROUND(m_y2));
+ break;
+ }
+ case DRAWOP_DRAW_ARC:
+ {
+ dc.DrawArc(WXROUND(m_x2+xoffset), WXROUND(m_y2+yoffset),
+ WXROUND(m_x3+xoffset), WXROUND(m_y3+yoffset),
+ WXROUND(m_x1+xoffset), WXROUND(m_y1+yoffset));
+ break;
+ }
+ case DRAWOP_DRAW_ELLIPTIC_ARC:
+ {
+ const double pi = 3.1415926535897932384626433832795 ;
+
+ // Convert back to degrees
+ dc.DrawEllipticArc(
+ WXROUND(m_x1+xoffset), WXROUND(m_y1+yoffset),
+ WXROUND(m_x2), WXROUND(m_y2),
+ WXROUND(m_x3*(360.0/(2.0*pi))), WXROUND(m_y3*(360.0/(2.0*pi))));
break;
}
case DRAWOP_DRAW_POINT:
{
- dc.DrawPoint(m_x1+xoffset, m_y1+yoffset);
+ dc.DrawPoint(WXROUND(m_x1+xoffset), WXROUND(m_y1+yoffset));
break;
}
case DRAWOP_DRAW_TEXT:
{
- dc.DrawText(m_textString, m_x1+xoffset, m_y1+yoffset);
+ dc.DrawText(m_textString, WXROUND(m_x1+xoffset), WXROUND(m_y1+yoffset));
break;
}
default:
}
}
-void wxOpDraw::Scale(float scaleX, float scaleY)
+void wxOpDraw::Scale(double scaleX, double scaleY)
{
m_x1 *= scaleX;
m_y1 *= scaleY;
m_x2 *= scaleX;
m_y2 *= scaleY;
+
+ if (m_op != DRAWOP_DRAW_ELLIPTIC_ARC)
+ {
+ m_x3 *= scaleX;
+ m_y3 *= scaleY;
+ }
+
m_radius *= scaleX;
}
-void wxOpDraw::Translate(float x, float y)
+void wxOpDraw::Translate(double x, double y)
{
m_x1 += x;
m_y1 += y;
+
+ switch (m_op)
+ {
+ case DRAWOP_DRAW_LINE:
+ {
+ m_x2 += x;
+ m_y2 += y;
+ break;
+ }
+ case DRAWOP_DRAW_ARC:
+ {
+ m_x2 += x;
+ m_y2 += y;
+ m_x3 += x;
+ m_y3 += y;
+ break;
+ }
+ case DRAWOP_DRAW_ELLIPTIC_ARC:
+ {
+ break;
+ }
+ default:
+ break;
+ }
}
-void wxOpDraw::Rotate(float x, float y, float sinTheta, float cosTheta)
+void wxOpDraw::Rotate(double x, double y, double theta, double sinTheta, double cosTheta)
{
- m_x1 = m_x1*cosTheta - m_y1*sinTheta + x*(1 - cosTheta) + y*sinTheta;
- m_y1 = m_x1*sinTheta + m_y1*cosTheta + y*(1 - cosTheta) + x*sinTheta;
+ double newX1 = m_x1*cosTheta - m_y1*sinTheta + x*(1.0 - cosTheta) + y*sinTheta;
+ double newY1 = m_x1*sinTheta + m_y1*cosTheta + y*(1.0 - cosTheta) + x*sinTheta;
switch (m_op)
{
case DRAWOP_DRAW_LINE:
{
- m_x2 = m_x2*cosTheta - m_y2*sinTheta + x*(1 - cosTheta) + y*sinTheta;
- m_y2 = m_x2*sinTheta + m_y2*cosTheta + y*(1 - cosTheta) + x*sinTheta;
+ double newX2 = m_x2*cosTheta - m_y2*sinTheta + x*(1.0 - cosTheta) + y*sinTheta;
+ double newY2 = m_x2*sinTheta + m_y2*cosTheta + y*(1.0 - cosTheta) + x*sinTheta;
+
+ m_x1 = newX1;
+ m_y1 = newY1;
+ m_x2 = newX2;
+ m_y2 = newY2;
+ break;
+ }
+ case DRAWOP_DRAW_RECT:
+ case DRAWOP_DRAW_ROUNDED_RECT:
+ case DRAWOP_DRAW_ELLIPTIC_ARC:
+ {
+ // Assume only 0, 90, 180, 270 degree rotations.
+ // oldX1, oldY1 represents the top left corner. Find the
+ // bottom right, and rotate that. Then the width/height is the difference
+ // between x/y values.
+ double oldBottomRightX = m_x1 + m_x2;
+ double oldBottomRightY = m_y1 + m_y2;
+ double newBottomRightX = oldBottomRightX*cosTheta - oldBottomRightY*sinTheta + x*(1.0 - cosTheta) + y*sinTheta;
+ double newBottomRightY = oldBottomRightX*sinTheta + oldBottomRightY*cosTheta + y*(1.0 - cosTheta) + x*sinTheta;
+
+ // Now find the new top-left, bottom-right coordinates.
+ double minX = wxMin(newX1, newBottomRightX);
+ double minY = wxMin(newY1, newBottomRightY);
+ double maxX = wxMax(newX1, newBottomRightX);
+ double maxY = wxMax(newY1, newBottomRightY);
+
+ m_x1 = minX;
+ m_y1 = minY;
+ m_x2 = maxX - minX; // width
+ m_y2 = maxY - minY; // height
+
+ if (m_op == DRAWOP_DRAW_ELLIPTIC_ARC)
+ {
+ // Add rotation to angles
+ m_x3 += theta;
+ m_y3 += theta;
+ }
+
+ break;
+ }
+ case DRAWOP_DRAW_ARC:
+ {
+ double newX2 = m_x2*cosTheta - m_y2*sinTheta + x*(1.0 - cosTheta) + y*sinTheta;
+ double newY2 = m_x2*sinTheta + m_y2*cosTheta + y*(1.0 - cosTheta) + x*sinTheta;
+ double newX3 = m_x3*cosTheta - m_y3*sinTheta + x*(1.0 - cosTheta) + y*sinTheta;
+ double newY3 = m_x3*sinTheta + m_y3*cosTheta + y*(1.0 - cosTheta) + x*sinTheta;
+
+ m_x1 = newX1;
+ m_y1 = newY1;
+ m_x2 = newX2;
+ m_y2 = newY2;
+ m_x3 = newX3;
+ m_y3 = newY3;
+
break;
}
default:
break;
}
case DRAWOP_DRAW_ARC:
+ case DRAWOP_DRAW_ELLIPTIC_ARC:
+ {
+ expr->Append(new wxExpr(m_x1));
+ expr->Append(new wxExpr(m_y1));
+ expr->Append(new wxExpr(m_x2));
+ expr->Append(new wxExpr(m_y2));
+ expr->Append(new wxExpr(m_x3));
+ expr->Append(new wxExpr(m_y3));
+ break;
+ }
default:
{
break;
{
m_x1 = expr->Nth(1)->RealValue();
m_y1 = expr->Nth(2)->RealValue();
- m_textString = copystring(expr->Nth(3)->StringValue());
+ wxString str(expr->Nth(3)->StringValue());
+ m_textString = copystring((const char*) str);
break;
}
case DRAWOP_DRAW_ARC:
+ case DRAWOP_DRAW_ELLIPTIC_ARC:
+ {
+ m_x1 = expr->Nth(1)->RealValue();
+ m_y1 = expr->Nth(2)->RealValue();
+ m_x2 = expr->Nth(3)->RealValue();
+ m_y2 = expr->Nth(4)->RealValue();
+ m_x3 = expr->Nth(5)->RealValue();
+ m_y3 = expr->Nth(6)->RealValue();
+ break;
+ }
default:
{
break;
return newOp;
}
-void wxOpPolyDraw::Do(wxDC& dc, float xoffset, float yoffset)
+void wxOpPolyDraw::Do(wxDC& dc, double xoffset, double yoffset)
{
switch (m_op)
{
int i;
for (i = 0; i < m_noPoints; i++)
{
- actualPoints[i].x = (long) m_points[i].x;
- actualPoints[i].y = (long) m_points[i].y;
+ actualPoints[i].x = WXROUND(m_points[i].x);
+ actualPoints[i].y = WXROUND(m_points[i].y);
}
- dc.DrawLines(m_noPoints, actualPoints, xoffset, yoffset);
+ dc.DrawLines(m_noPoints, actualPoints, WXROUND(xoffset), WXROUND(yoffset));
delete[] actualPoints;
break;
int i;
for (i = 0; i < m_noPoints; i++)
{
- actualPoints[i].x = (long) m_points[i].x;
- actualPoints[i].y = (long) m_points[i].y;
+ actualPoints[i].x = WXROUND(m_points[i].x);
+ actualPoints[i].y = WXROUND(m_points[i].y);
}
- dc.DrawPolygon(m_noPoints, actualPoints, xoffset, yoffset);
+ dc.DrawPolygon(m_noPoints, actualPoints, WXROUND(xoffset), WXROUND(yoffset));
delete[] actualPoints;
break;
int i;
for (i = 0; i < m_noPoints; i++)
{
- actualPoints[i].x = (long) m_points[i].x;
- actualPoints[i].y = (long) m_points[i].y;
+ actualPoints[i].x = WXROUND(m_points[i].x);
+ actualPoints[i].y = WXROUND(m_points[i].y);
}
dc.DrawSpline(m_noPoints, actualPoints); // no offsets in DrawSpline // , xoffset, yoffset);
}
}
-void wxOpPolyDraw::Scale(float scaleX, float scaleY)
+void wxOpPolyDraw::Scale(double scaleX, double scaleY)
{
for (int i = 0; i < m_noPoints; i++)
{
}
}
-void wxOpPolyDraw::Translate(float x, float y)
+void wxOpPolyDraw::Translate(double x, double y)
{
for (int i = 0; i < m_noPoints; i++)
{
}
}
-void wxOpPolyDraw::Rotate(float x, float y, float sinTheta, float cosTheta)
+void wxOpPolyDraw::Rotate(double x, double y, double theta, double sinTheta, double cosTheta)
{
for (int i = 0; i < m_noPoints; i++)
{
- float x1 = m_points[i].x;
- float y1 = m_points[i].y;
- m_points[i].x = x1*cosTheta - y1*sinTheta + x*(1 - cosTheta) + y*sinTheta;
- m_points[i].y = x1*sinTheta + y1*cosTheta + y*(1 - cosTheta) + x*sinTheta;
+ double x1 = m_points[i].x;
+ double y1 = m_points[i].y;
+ m_points[i].x = x1*cosTheta - y1*sinTheta + x*(1.0 - cosTheta) + y*sinTheta;
+ m_points[i].y = x1*sinTheta + y1*cosTheta + y*(1.0 - cosTheta) + x*sinTheta;
}
}
char buf2[5];
char buf3[5];
- GraphicsBuffer[0] = 0;
-
+ oglBuffer[0] = 0;
+
/*
* Store each coordinate pair in a hex string to save space.
* E.g. "1B9080CD". 4 hex digits per coordinate pair.
// Don't overrun the buffer
if ((i*8) < 3000)
{
- strcat(GraphicsBuffer, buf2);
- strcat(GraphicsBuffer, buf3);
+ strcat(oglBuffer, buf2);
+ strcat(oglBuffer, buf3);
}
}
- expr->Append(new wxExpr(PrologString, GraphicsBuffer));
+ expr->Append(new wxExpr(PrologString, oglBuffer));
return expr;
}
int testY = (signed int)unSignedY;
#endif
- m_points[i].x = (float)(signedX / 100.0);
- m_points[i].y = (float)(signedY / 100.0);
+ m_points[i].x = (double)(signedX / 100.0);
+ m_points[i].y = (double)(signedY / 100.0);
i ++;
}
}
+// Draw an outline using the current operation.
+bool wxOpPolyDraw::OnDrawOutline(wxDC& dc, double x, double y, double w, double h, double oldW, double oldH)
+{
+ dc.SetBrush(wxTRANSPARENT_BRUSH);
+
+ // Multiply all points by proportion of new size to old size
+ double x_proportion = (double)(fabs(w/oldW));
+ double y_proportion = (double)(fabs(h/oldH));
+
+ int n = m_noPoints;
+ wxPoint *intPoints = new wxPoint[n];
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ intPoints[i].x = WXROUND (x_proportion * m_points[i].x);
+ intPoints[i].y = WXROUND (y_proportion * m_points[i].y);
+ }
+ dc.DrawPolygon(n, intPoints, x, y);
+ delete[] intPoints;
+ return TRUE;
+}
+
+// Assume (x1, y1) is centre of box (most generally, line end at box)
+bool wxOpPolyDraw::GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3,
+ double xOffset, double yOffset,
+ bool attachmentMode)
+{
+ int n = m_noPoints;
+
+ // First check for situation where the line is vertical,
+ // and we would want to connect to a point on that vertical --
+ // oglFindEndForPolyline can't cope with this (the arrow
+ // gets drawn to the wrong place).
+ if ((!attachmentMode) && (x1 == x2))
+ {
+ // Look for the point we'd be connecting to. This is
+ // a heuristic...
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ wxRealPoint *point = & (m_points[i]);
+ if (point->x == 0.0)
+ {
+ if ((y2 > y1) && (point->y > 0.0))
+ {
+ *x3 = point->x + xOffset;
+ *y3 = point->y + yOffset;
+ return TRUE;
+ }
+ else if ((y2 < y1) && (point->y < 0.0))
+ {
+ *x3 = point->x + xOffset;
+ *y3 = point->y + yOffset;
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ double *xpoints = new double[n];
+ double *ypoints = new double[n];
+
+ int i = 0;
+ for (i = 0; i < n; i++)
+ {
+ wxRealPoint *point = & (m_points[i]);
+ xpoints[i] = point->x + xOffset;
+ ypoints[i] = point->y + yOffset;
+ }
+
+ oglFindEndForPolyline(n, xpoints, ypoints,
+ x1, y1, x2, y2, x3, y3);
+
+ delete[] xpoints;
+ delete[] ypoints;
+
+ return TRUE;
+}
+
/*
* Utilities
m_height = 0.0;
m_outlinePen = NULL;
m_fillBrush = NULL;
+ m_outlineOp = -1;
}
wxPseudoMetaFile::wxPseudoMetaFile(wxPseudoMetaFile& mf)
m_gdiObjects.Clear();
m_outlineColours.Clear();
m_fillColours.Clear();
+ m_outlineOp = -1;
}
-void wxPseudoMetaFile::Draw(wxDC& dc, float xoffset, float yoffset)
+void wxPseudoMetaFile::Draw(wxDC& dc, double xoffset, double yoffset)
{
wxNode *node = m_ops.First();
while (node)
}
}
-void wxPseudoMetaFile::Scale(float sx, float sy)
+void wxPseudoMetaFile::Scale(double sx, double sy)
{
wxNode *node = m_ops.First();
while (node)
m_height *= sy;
}
-void wxPseudoMetaFile::Translate(float x, float y)
+void wxPseudoMetaFile::Translate(double x, double y)
{
wxNode *node = m_ops.First();
while (node)
}
}
-void wxPseudoMetaFile::Rotate(float x, float y, float theta)
+void wxPseudoMetaFile::Rotate(double x, double y, double theta)
{
- float theta1 = theta-m_currentRotation;
+ double theta1 = theta-m_currentRotation;
if (theta1 == 0.0) return;
- float cosTheta = (float)cos(theta1);
- float sinTheta = (float)sin(theta1);
+ double cosTheta = (double)cos(theta1);
+ double sinTheta = (double)sin(theta1);
wxNode *node = m_ops.First();
while (node)
{
wxDrawOp *op = (wxDrawOp *)node->Data();
- op->Rotate(x, y, sinTheta, cosTheta);
+ op->Rotate(x, y, theta, sinTheta, cosTheta);
node = node->Next();
}
m_currentRotation = theta;
}
#ifdef PROLOGIO
-void wxPseudoMetaFile::WritePrologAttributes(wxExpr *clause)
+void wxPseudoMetaFile::WritePrologAttributes(wxExpr *clause, int whichAngle)
{
+ wxString widthStr;
+ widthStr.Printf("meta_width%d", whichAngle);
+
+ wxString heightStr;
+ heightStr.Printf("meta_height%d", whichAngle);
+
+ wxString outlineStr;
+ outlineStr.Printf("outline_op%d", whichAngle);
+
+ wxString rotateableStr;
+ rotateableStr.Printf("meta_rotateable%d", whichAngle);
+
// Write width and height
- clause->AddAttributeValue("meta_width", m_width);
- clause->AddAttributeValue("meta_height", m_height);
- clause->AddAttributeValue("meta_rotateable", (long)m_rotateable);
+ clause->AddAttributeValue(widthStr, m_width);
+ clause->AddAttributeValue(heightStr, m_height);
+ clause->AddAttributeValue(rotateableStr, (long)m_rotateable);
+ clause->AddAttributeValue(outlineStr, (long)m_outlineOp);
// Write GDI objects
char buf[50];
wxNode *node = m_gdiObjects.First();
while (node)
{
- sprintf(buf, "gdi%d", i);
+ sprintf(buf, "gdi%d_%d", whichAngle, i);
wxObject *obj = (wxObject *)node->Data();
wxExpr *expr = NULL;
if (obj)
node = m_ops.First();
while (node)
{
- sprintf(buf, "op%d", i);
+ sprintf(buf, "op%d_%d", whichAngle, i);
wxDrawOp *op = (wxDrawOp *)node->Data();
wxExpr *expr = op->WriteExpr(this);
if (expr)
outlineExpr->Append(new wxExpr((long)node->Data()));
node = node->Next();
}
- clause->AddAttributeValue("outline_objects", outlineExpr);
+ wxString outlineObjectsStr;
+ outlineObjectsStr.Printf("outline_objects%d", whichAngle);
+
+ clause->AddAttributeValue(outlineObjectsStr, outlineExpr);
}
if (m_fillColours.Number() > 0)
{
fillExpr->Append(new wxExpr((long)node->Data()));
node = node->Next();
}
- clause->AddAttributeValue("fill_objects", fillExpr);
+ wxString fillObjectsStr;
+ fillObjectsStr.Printf("fill_objects%d", whichAngle);
+
+ clause->AddAttributeValue(fillObjectsStr, fillExpr);
}
}
-void wxPseudoMetaFile::ReadPrologAttributes(wxExpr *clause)
+void wxPseudoMetaFile::ReadPrologAttributes(wxExpr *clause, int whichAngle)
{
- clause->AssignAttributeValue("meta_width", &m_width);
- clause->AssignAttributeValue("meta_height", &m_height);
+ wxString widthStr;
+ widthStr.Printf("meta_width%d", whichAngle);
+
+ wxString heightStr;
+ heightStr.Printf("meta_height%d", whichAngle);
+
+ wxString outlineStr;
+ outlineStr.Printf("outline_op%d", whichAngle);
+
+ wxString rotateableStr;
+ rotateableStr.Printf("meta_rotateable%d", whichAngle);
+
+ clause->GetAttributeValue(widthStr, m_width);
+ clause->GetAttributeValue(heightStr, m_height);
+ clause->GetAttributeValue(outlineStr, m_outlineOp);
int iVal = (int) m_rotateable;
- clause->AssignAttributeValue("meta_rotateable", &iVal);
+ clause->GetAttributeValue(rotateableStr, iVal);
m_rotateable = (iVal != 0);
// Read GDI objects
bool keepGoing = TRUE;
while (keepGoing)
{
- sprintf(buf, "gdi%d", i);
+ sprintf(buf, "gdi%d_%d", whichAngle, i);
wxExpr *expr = NULL;
- clause->AssignAttributeValue(buf, &expr);
+ clause->GetAttributeValue(buf, &expr);
if (!expr)
{
keepGoing = FALSE;
i = 1;
while (keepGoing)
{
- sprintf(buf, "op%d", i);
+ sprintf(buf, "op%d_%d", whichAngle, i);
wxExpr *expr = NULL;
- clause->AssignAttributeValue(buf, &expr);
+ clause->GetAttributeValue(buf, &expr);
if (!expr)
{
keepGoing = FALSE;
i ++;
}
+ wxString outlineObjectsStr;
+ outlineObjectsStr.Printf("outline_objects%d", whichAngle);
+
// Now read in the list of outline and fill operations, if any
- wxExpr *expr1 = clause->AttributeValue("outline_objects");
+ wxExpr *expr1 = clause->AttributeValue(outlineObjectsStr);
if (expr1)
{
wxExpr *eachExpr = expr1->GetFirst();
eachExpr = eachExpr->GetNext();
}
}
- expr1 = clause->AttributeValue("fill_objects");
+
+ wxString fillObjectsStr;
+ fillObjectsStr.Printf("fill_objects%d", whichAngle);
+
+ expr1 = clause->AttributeValue(fillObjectsStr);
if (expr1)
{
wxExpr *eachExpr = expr1->GetFirst();
// Does the copying for this object
void wxPseudoMetaFile::Copy(wxPseudoMetaFile& copy)
{
+ copy.Clear();
+
copy.m_currentRotation = m_currentRotation;
copy.m_width = m_width;
copy.m_height = m_height;
copy.m_rotateable = m_rotateable;
copy.m_fillBrush = m_fillBrush;
copy.m_outlinePen = m_outlinePen;
-
- copy.Clear();
+ copy.m_outlineOp = m_outlineOp;
// Copy the GDI objects
wxNode *node = m_gdiObjects.First();
*
*/
-bool wxPseudoMetaFile::LoadFromMetaFile(char *filename, float *rwidth, float *rheight)
+bool wxPseudoMetaFile::LoadFromMetaFile(char *filename, double *rwidth, double *rheight)
{
if (!FileExists(filename))
return NULL;
return FALSE;
}
- float lastX = 0.0;
- float lastY = 0.0;
+ double lastX = 0.0;
+ double lastY = 0.0;
// Convert from metafile records to wxDrawnShape records
wxNode *node = metaFile->metaRecords.First();
// case META_SCALEVIEWPORTEXT:
case META_LINETO:
{
- wxOpDraw *op = new wxOpDraw(DRAWOP_DRAW_LINE, (float)lastX, (float)lastY,
- (float)record->param1, (float)record->param2);
+ wxOpDraw *op = new wxOpDraw(DRAWOP_DRAW_LINE, (double)lastX, (double)lastY,
+ (double)record->param1, (double)record->param2);
m_ops.Append(op);
break;
}
case META_MOVETO:
{
- lastX = (float)record->param1;
- lastY = (float)record->param2;
+ lastX = (double)record->param1;
+ lastY = (double)record->param2;
break;
}
case META_EXCLUDECLIPRECT:
case META_ELLIPSE:
{
wxOpDraw *op = new wxOpDraw(DRAWOP_DRAW_ELLIPSE,
- (float)record->param1, (float)record->param2,
- (float)(record->param3 - record->param1),
- (float)(record->param4 - record->param2));
+ (double)record->param1, (double)record->param2,
+ (double)(record->param3 - record->param1),
+ (double)(record->param4 - record->param2));
m_ops.Append(op);
break;
}
case META_RECTANGLE:
{
wxOpDraw *op = new wxOpDraw(DRAWOP_DRAW_RECT,
- (float)record->param1, (float)record->param2,
- (float)(record->param3 - record->param1),
- (float)(record->param4 - record->param2));
+ (double)record->param1, (double)record->param2,
+ (double)(record->param3 - record->param1),
+ (double)(record->param4 - record->param2));
m_ops.Append(op);
break;
}
case META_ROUNDRECT:
{
wxOpDraw *op = new wxOpDraw(DRAWOP_DRAW_ROUNDED_RECT,
- (float)record->param1, (float)record->param2,
- (float)(record->param3 - record->param1),
- (float)(record->param4 - record->param2), (float)record->param5);
+ (double)record->param1, (double)record->param2,
+ (double)(record->param3 - record->param1),
+ (double)(record->param4 - record->param2), (double)record->param5);
m_ops.Append(op);
break;
}
case META_SETPIXEL:
{
wxOpDraw *op = new wxOpDraw(DRAWOP_DRAW_POINT,
- (float)record->param1, (float)record->param2,
+ (double)record->param1, (double)record->param2,
0.0, 0.0);
// SHOULD SET THE COLOUR - SET PEN?
case META_TEXTOUT:
{
wxOpDraw *op = new wxOpDraw(DRAWOP_DRAW_TEXT,
- (float)record->param1, (float)record->param2,
+ (double)record->param1, (double)record->param2,
0.0, 0.0, 0.0, record->stringParam);
m_ops.Append(op);
break;
}
node = node->Next();
}
- float actualWidth = (float)fabs(metaFile->right - metaFile->left);
- float actualHeight = (float)fabs(metaFile->bottom - metaFile->top);
-
- float initialScaleX = 1.0;
- float initialScaleY = 1.0;
+ double actualWidth = (double)fabs(metaFile->right - metaFile->left);
+ double actualHeight = (double)fabs(metaFile->bottom - metaFile->top);
+
+ double initialScaleX = 1.0;
+ double initialScaleY = 1.0;
- float xoffset, yoffset;
+ double xoffset, yoffset;
// Translate so origin is at centre of rectangle
if (metaFile->bottom > metaFile->top)
- yoffset = - (float)((metaFile->bottom - metaFile->top)/2.0);
+ yoffset = - (double)((metaFile->bottom - metaFile->top)/2.0);
else
- yoffset = - (float)((metaFile->top - metaFile->bottom)/2.0);
+ yoffset = - (double)((metaFile->top - metaFile->bottom)/2.0);
if (metaFile->right > metaFile->left)
- xoffset = - (float)((metaFile->right - metaFile->left)/2.0);
+ xoffset = - (double)((metaFile->right - metaFile->left)/2.0);
else
- xoffset = - (float)((metaFile->left - metaFile->right)/2.0);
+ xoffset = - (double)((metaFile->left - metaFile->right)/2.0);
Translate(xoffset, yoffset);
// as a guide)
if (actualWidth != 0.0)
{
- initialScaleX = (float)((*rwidth) / actualWidth);
+ initialScaleX = (double)((*rwidth) / actualWidth);
initialScaleY = initialScaleX;
(*rheight) = initialScaleY*actualHeight;
}
}
// Scale to fit size
-void wxPseudoMetaFile::ScaleTo(float w, float h)
+void wxPseudoMetaFile::ScaleTo(double w, double h)
{
- float scaleX = (float)(w/m_width);
- float scaleY = (float)(h/m_height);
+ double scaleX = (double)(w/m_width);
+ double scaleY = (double)(h/m_height);
// Do the scaling
Scale(scaleX, scaleY);
}
-void wxPseudoMetaFile::GetBounds(float *boundMinX, float *boundMinY, float *boundMaxX, float *boundMaxY)
+void wxPseudoMetaFile::GetBounds(double *boundMinX, double *boundMinY, double *boundMaxX, double *boundMaxY)
{
- float maxX = (float) -99999.9;
- float maxY = (float) -99999.9;
- float minX = (float) 99999.9;
- float minY = (float) 99999.9;
+ double maxX = (double) -99999.9;
+ double maxY = (double) -99999.9;
+ double minX = (double) 99999.9;
+ double minY = (double) 99999.9;
wxNode *node = m_ops.First();
while (node)
case DRAWOP_DRAW_ROUNDED_RECT:
case DRAWOP_DRAW_ELLIPSE:
case DRAWOP_DRAW_POINT:
- case DRAWOP_DRAW_ARC:
case DRAWOP_DRAW_TEXT:
{
wxOpDraw *opDraw = (wxOpDraw *)op;
}
break;
}
+ case DRAWOP_DRAW_ARC:
+ {
+ // TODO: don't yet know how to calculate the bounding box
+ // for an arc. So pretend it's a line; to get a correct
+ // bounding box, draw a blank rectangle first, of the correct
+ // size.
+ wxOpDraw *opDraw = (wxOpDraw *)op;
+ if (opDraw->m_x1 < minX) minX = opDraw->m_x1;
+ if (opDraw->m_x1 > maxX) maxX = opDraw->m_x1;
+ if (opDraw->m_y1 < minY) minY = opDraw->m_y1;
+ if (opDraw->m_y1 > maxY) maxY = opDraw->m_y1;
+ if (opDraw->m_x2 < minX) minX = opDraw->m_x2;
+ if (opDraw->m_x2 > maxX) maxX = opDraw->m_x2;
+ if (opDraw->m_y2 < minY) minY = opDraw->m_y2;
+ if (opDraw->m_y2 > maxY) maxY = opDraw->m_y2;
+ break;
+ }
case DRAWOP_DRAW_POLYLINE:
case DRAWOP_DRAW_POLYGON:
case DRAWOP_DRAW_SPLINE:
*boundMaxX = maxX;
*boundMaxY = maxY;
/*
- *w = (float)fabs(maxX - minX);
- *h = (float)fabs(maxY - minY);
+ *w = (double)fabs(maxX - minX);
+ *h = (double)fabs(maxY - minY);
*/
}
// Calculate size from current operations
void wxPseudoMetaFile::CalculateSize(wxDrawnShape* shape)
{
- float boundMinX, boundMinY, boundMaxX, boundMaxY;
+ double boundMinX, boundMinY, boundMaxX, boundMaxY;
GetBounds(& boundMinX, & boundMinY, & boundMaxX, & boundMaxY);
m_ops.Append(theOp);
}
+void wxPseudoMetaFile::DrawArc(const wxPoint& centrePt, const wxPoint& startPt, const wxPoint& endPt)
+{
+ wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_ARC,
+ (double) centrePt.x, (double) centrePt.y, (double) startPt.x, (double) startPt.y);
+
+ theOp->m_x3 = (double) endPt.x;
+ theOp->m_y3 = (double) endPt.y;
+
+ m_ops.Append(theOp);
+}
+
+void wxPseudoMetaFile::DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle)
+{
+ const double pi = 3.1415926535897932384626433832795 ;
+
+ double startAngleRadians = startAngle* (pi*2.0/360.0);
+ double endAngleRadians = endAngle* (pi*2.0/360.0);
+
+ wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_ELLIPTIC_ARC,
+ (double) rect.x, (double) rect.y, (double) rect.width, (double) rect.height);
+
+ theOp->m_x3 = startAngleRadians;
+ theOp->m_y3 = endAngleRadians;
+
+ m_ops.Append(theOp);
+}
+
void wxPseudoMetaFile::DrawPoint(const wxPoint& pt)
{
wxOpDraw *theOp = new wxOpDraw(DRAWOP_DRAW_POINT,
m_ops.Append(theOp);
}
-void wxPseudoMetaFile::DrawPolygon(int n, wxPoint pts[])
+void wxPseudoMetaFile::DrawPolygon(int n, wxPoint pts[], int flags)
{
wxRealPoint* realPoints = new wxRealPoint[n];
int i;
}
wxOpPolyDraw* theOp = new wxOpPolyDraw(DRAWOP_DRAW_POLYGON, n, realPoints);
m_ops.Append(theOp);
+
+ if (flags & oglMETAFLAGS_OUTLINE)
+ m_outlineOp = (m_ops.Number() - 1);
}
void wxPseudoMetaFile::DrawSpline(int n, wxPoint pts[])
#include "basic.h"
+#define oglMETAFLAGS_OUTLINE 1
+#define oglMETAFLAGS_ATTACHMENTS 2
+
class wxDrawnShape;
class wxPseudoMetaFile: public wxObject
{
wxPseudoMetaFile(wxPseudoMetaFile& mf);
~wxPseudoMetaFile();
- void Draw(wxDC& dc, float xoffset, float yoffset);
+ void Draw(wxDC& dc, double xoffset, double yoffset);
#ifdef PROLOGIO
- void WritePrologAttributes(wxExpr *clause);
- void ReadPrologAttributes(wxExpr *clause);
+ void WritePrologAttributes(wxExpr *clause, int whichAngle);
+ void ReadPrologAttributes(wxExpr *clause, int whichAngle);
#endif
void Clear();
void Copy(wxPseudoMetaFile& copy);
- void Scale(float sx, float sy);
- void ScaleTo(float w, float h); // Scale to fit size
- void Translate(float x, float y);
+ void Scale(double sx, double sy);
+ void ScaleTo(double w, double h); // Scale to fit size
+ void Translate(double x, double y);
// Rotate about the given axis by theta radians from the x axis.
- void Rotate(float x, float y, float theta);
+ void Rotate(double x, double y, double theta);
- bool LoadFromMetaFile(char *filename, float *width, float *height);
+ bool LoadFromMetaFile(char *filename, double *width, double *height);
- void GetBounds(float *minX, float *minY, float *maxX, float *maxY);
+ void GetBounds(double *minX, double *minY, double *maxX, double *maxY);
// Calculate size from current operations
void CalculateSize(wxDrawnShape* shape);
inline void SetRotateable(bool rot) { m_rotateable = rot; }
inline bool GetRotateable() const { return m_rotateable; }
- inline void SetSize(float w, float h) { m_width = w; m_height = h; }
+ inline void SetSize(double w, double h) { m_width = w; m_height = h; }
inline void SetFillBrush(wxBrush* brush) { m_fillBrush = brush; }
inline wxBrush* GetFillBrush() const { return m_fillBrush; }
inline void SetOutlinePen(wxPen* pen) { m_outlinePen = pen; }
inline wxPen* GetOutlinePen() const { return m_outlinePen; }
+ inline void SetOutlineOp(int op) { m_outlineOp = op; }
+ inline int GetOutlineOp() const { return m_outlineOp; }
+
+ inline wxList& GetOps() const { return (wxList&) m_ops; }
+
+ // Is this a valid (non-empty) metafile?
+ inline bool IsValid() const { return (m_ops.Number() > 0); }
+
public:
/// Set of functions for drawing into a pseudo metafile.
/// They use integers, but doubles are used internally for accuracy
virtual void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
virtual void DrawRectangle(const wxRect& rect);
virtual void DrawRoundedRectangle(const wxRect& rect, double radius);
+ virtual void DrawArc(const wxPoint& centrePt, const wxPoint& startPt, const wxPoint& endPt);
+ virtual void DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle);
virtual void DrawEllipse(const wxRect& rect);
virtual void DrawPoint(const wxPoint& pt);
virtual void DrawText(const wxString& text, const wxPoint& pt);
virtual void DrawLines(int n, wxPoint pts[]);
- virtual void DrawPolygon(int n, wxPoint pts[]);
+ // flags:
+ // oglMETAFLAGS_OUTLINE: will be used for drawing the outline and
+ // also drawing lines/arrows at the circumference.
+ // oglMETAFLAGS_ATTACHMENTS: will be used for initialising attachment points at
+ // the vertices (perhaps a rare case...)
+ virtual void DrawPolygon(int n, wxPoint pts[], int flags = 0);
virtual void DrawSpline(int n, wxPoint pts[]);
virtual void SetClippingRect(const wxRect& rect);
public:
bool m_rotateable;
- float m_width;
- float m_height;
+ double m_width;
+ double m_height;
wxList m_ops; // List of drawing operations (see drawnp.h)
wxList m_gdiObjects; // List of pens, brushes and fonts for this object.
+ int m_outlineOp; // The op representing the outline, if any
// Pen/brush specifying outline/fill colours
// to override operations.
wxBrush* m_fillBrush;
wxList m_outlineColours; // List of the GDI operations that comprise the outline
wxList m_fillColours; // List of the GDI operations that fill the shape
- float m_currentRotation;
+ double m_currentRotation;
};
+#define oglDRAWN_ANGLE_0 0
+#define oglDRAWN_ANGLE_90 1
+#define oglDRAWN_ANGLE_180 2
+#define oglDRAWN_ANGLE_270 3
+
class wxDrawnShape: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxDrawnShape)
// Does the copying for this object
void Copy(wxShape& copy);
- void Scale(float sx, float sy);
- void Translate(float x, float y);
+ void Scale(double sx, double sy);
+ void Translate(double x, double y);
// Rotate about the given axis by theta radians from the x axis.
- void Rotate(float x, float y, float theta);
+ void Rotate(double x, double y, double theta);
// Get current rotation
- inline float GetRotation() const { return m_rotation; }
+ inline double GetRotation() const { return m_rotation; }
- void SetSize(float w, float h, bool recursive = TRUE);
+ void SetSize(double w, double h, bool recursive = TRUE);
bool LoadFromMetaFile(char *filename);
inline void SetSaveToFile(bool save) { m_saveToFile = save; }
- inline wxPseudoMetaFile& GetMetaFile() const { return (wxPseudoMetaFile&) m_metafile; }
+ inline wxPseudoMetaFile& GetMetaFile(int which = 0) const { return (wxPseudoMetaFile&) m_metafiles[which]; }
+
+ void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
+
+ // Get the perimeter point using the special outline op, if there is one,
+ // otherwise use default wxRectangleShape scheme
+ bool GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3);
/// Set of functions for drawing into a pseudo metafile.
/// They use integers, but doubles are used internally for accuracy
virtual void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
virtual void DrawRectangle(const wxRect& rect);
virtual void DrawRoundedRectangle(const wxRect& rect, double radius);
+ virtual void DrawArc(const wxPoint& centrePt, const wxPoint& startPt, const wxPoint& endPt);
+ virtual void DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle);
virtual void DrawEllipse(const wxRect& rect);
virtual void DrawPoint(const wxPoint& pt);
virtual void DrawText(const wxString& text, const wxPoint& pt);
virtual void DrawLines(int n, wxPoint pts[]);
- virtual void DrawPolygon(int n, wxPoint pts[]);
+ virtual void DrawPolygon(int n, wxPoint pts[], int flags = 0);
virtual void DrawSpline(int n, wxPoint pts[]);
virtual void SetClippingRect(const wxRect& rect);
// Set the width/height according to the shapes in the metafile.
// Call this after drawing into the shape.
- inline void CalculateSize() { m_metafile.CalculateSize(this); }
+ inline void CalculateSize() { m_metafiles[m_currentAngle].CalculateSize(this); }
+
+ inline void DrawAtAngle(int angle) { m_currentAngle = angle; };
+
+ inline int GetAngle() const { return m_currentAngle; }
+
+ // Which metafile do we use now? Based on current rotation and validity
+ // of metafiles.
+ int DetermineMetaFile(double rotation);
private:
- wxPseudoMetaFile m_metafile;
+ // One metafile for each 90 degree rotation (or just a single one).
+ wxPseudoMetaFile m_metafiles[4];
// Don't save all wxDrawnShape metafiles to file: sometimes
// we take the metafile data from a symbol library.
bool m_saveToFile;
+
+ // Which angle are we using/drawing into?
+ int m_currentAngle;
};
#endif
#define DRAWOP_DRAW_ARC 27
#define DRAWOP_DRAW_TEXT 28
#define DRAWOP_DRAW_SPLINE 29
+#define DRAWOP_DRAW_ELLIPTIC_ARC 30
/*
* Base, virtual class
public:
inline wxDrawOp(int theOp) { m_op = theOp; }
inline ~wxDrawOp() {}
- inline virtual void Scale(float xScale, float yScale) {};
- inline virtual void Translate(float x, float y) {};
- inline virtual void Rotate(float x, float y, float sinTheta, float cosTheta) {};
- virtual void Do(wxDC& dc, float xoffset, float yoffset) = 0;
+ inline virtual void Scale(double xScale, double yScale) {};
+ inline virtual void Translate(double x, double y) {};
+ inline virtual void Rotate(double x, double y, double theta, double sinTheta, double cosTheta) {};
+ virtual void Do(wxDC& dc, double xoffset, double yoffset) = 0;
virtual wxDrawOp *Copy(wxPseudoMetaFile *newImage) = 0;
virtual wxExpr *WriteExpr(wxPseudoMetaFile *image) = 0;
virtual void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) = 0;
- int GetOp() const { return m_op; }
+ inline int GetOp() const { return m_op; }
+
+ // Draw an outline using the current operation. By default, return FALSE (not drawn)
+ virtual bool OnDrawOutline(wxDC& dc, double x, double y, double w, double h,
+ double oldW, double oldH) { return FALSE; }
+
+ // Get the perimeter point using this data
+ virtual bool GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3,
+ double xOffset, double yOffset,
+ bool attachmentMode)
+ { return FALSE; }
protected:
- int m_op;
+ int m_op;
};
{
public:
wxOpSetGDI(int theOp, wxPseudoMetaFile *theImage, int theGdiIndex, int theMode = 0);
- void Do(wxDC& dc, float xoffset, float yoffset);
+ void Do(wxDC& dc, double xoffset, double yoffset);
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
wxExpr *WriteExpr(wxPseudoMetaFile *image);
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
class wxOpSetClipping: public wxDrawOp
{
public:
- wxOpSetClipping(int theOp, float theX1, float theY1, float theX2, float theY2);
- void Do(wxDC& dc, float xoffset, float yoffset);
- void Scale(float xScale, float yScale);
- void Translate(float x, float y);
+ wxOpSetClipping(int theOp, double theX1, double theY1, double theX2, double theY2);
+ void Do(wxDC& dc, double xoffset, double yoffset);
+ void Scale(double xScale, double yScale);
+ void Translate(double x, double y);
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
wxExpr *WriteExpr(wxPseudoMetaFile *image);
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
public:
- float m_x1;
- float m_y1;
- float m_x2;
- float m_y2;
+ double m_x1;
+ double m_y1;
+ double m_x2;
+ double m_y2;
};
/*
class wxOpDraw: public wxDrawOp
{
public:
- wxOpDraw(int theOp, float theX1, float theY1, float theX2, float theY2,
- float radius = 0.0, char *s = NULL);
+ wxOpDraw(int theOp, double theX1, double theY1, double theX2, double theY2,
+ double radius = 0.0, char *s = NULL);
~wxOpDraw();
- void Do(wxDC& dc, float xoffset, float yoffset);
- void Scale(float scaleX, float scaleY);
- void Translate(float x, float y);
- void Rotate(float x, float y, float sinTheta, float cosTheta);
+ void Do(wxDC& dc, double xoffset, double yoffset);
+ void Scale(double scaleX, double scaleY);
+ void Translate(double x, double y);
+ void Rotate(double x, double y, double theta, double sinTheta, double cosTheta);
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
wxExpr *WriteExpr(wxPseudoMetaFile *image);
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
public:
- float m_x1;
- float m_y1;
- float m_x2;
- float m_y2;
- float m_x3;
- float m_radius;
+ double m_x1;
+ double m_y1;
+ double m_x2;
+ double m_y2;
+ double m_x3;
+ double m_y3;
+ double m_radius;
char* m_textString;
};
public:
wxOpPolyDraw(int theOp, int n, wxRealPoint *thePoints);
~wxOpPolyDraw();
- void Do(wxDC& dc, float xoffset, float yoffset);
- void Scale(float scaleX, float scaleY);
- void Translate(float x, float y);
- void Rotate(float x, float y, float sinTheta, float cosTheta);
+ void Do(wxDC& dc, double xoffset, double yoffset);
+ void Scale(double scaleX, double scaleY);
+ void Translate(double x, double y);
+ void Rotate(double x, double y, double theta, double sinTheta, double cosTheta);
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
wxExpr *WriteExpr(wxPseudoMetaFile *image);
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
+ // Draw an outline using the current operation.
+ virtual bool OnDrawOutline(wxDC& dc, double x, double y, double w, double h,
+ double oldW, double oldH);
+
+ // Get the perimeter point using this data
+ bool GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3,
+ double xOffset, double yOffset,
+ bool attachmentMode);
+
public:
wxRealPoint* m_points;
int m_noPoints;
wxRealPoint *second_last_point = (wxRealPoint *)second_last->Data();
// Choose a point half way between the last and penultimate points
- float line_x = ((last_point->x + second_last_point->x)/2);
- float line_y = ((last_point->y + second_last_point->y)/2);
+ double line_x = ((last_point->x + second_last_point->x)/2);
+ double line_y = ((last_point->y + second_last_point->y)/2);
wxRealPoint *point = new wxRealPoint(line_x, line_y);
wxNode *node = m_lineControlPoints->Insert(last, (wxObject*) point);
wxRealPoint *point = (wxRealPoint *)node->Data();
if (point->x == -999)
{
- float x1, y1, x2, y2;
+ double x1, y1, x2, y2;
if (first_point->x < last_point->x)
{ x1 = first_point->x; x2 = last_point->x; }
else
// strings with positions to region text list
void wxLineShape::FormatText(wxDC& dc, const wxString& s, int i)
{
- float w, h;
+ double w, h;
ClearText(i);
if (m_regions.Number() < 1)
region->SetSize(w, h);
}
- wxList *string_list = ::FormatText(dc, s, (w-5), (h-5), region->GetFormatMode());
+ wxStringList *string_list = oglFormatText(dc, s, (w-5), (h-5), region->GetFormatMode());
node = string_list->First();
while (node)
{
char *s = (char *)node->Data();
wxShapeTextLine *line = new wxShapeTextLine(0.0, 0.0, s);
region->GetFormattedText().Append((wxObject *)line);
- delete node;
- node = string_list->First();
+ node = node->Next();
}
delete string_list;
- float actualW = w;
- float actualH = h;
+ double actualW = w;
+ double actualH = h;
if (region->GetFormatMode() & FORMAT_SIZE_TO_CONTENTS)
{
- GetCentredTextExtent(dc, &(region->GetFormattedText()), m_xpos, m_ypos, w, h, &actualW, &actualH);
+ oglGetCentredTextExtent(dc, &(region->GetFormattedText()), m_xpos, m_ypos, w, h, &actualW, &actualH);
if ((actualW != w ) || (actualH != h))
{
- float xx, yy;
+ double xx, yy;
GetLabelPosition(i, &xx, &yy);
EraseRegion(dc, region, xx, yy);
if (m_labelObjects[i])
}
}
}
- CentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, actualW, actualH, region->GetFormatMode());
+ oglCentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, actualW, actualH, region->GetFormatMode());
m_formatted = TRUE;
}
-void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, float x, float y)
+void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y)
{
if (GetDisableLabel())
return;
- float w, h;
- float xx, yy;
+ double w, h;
+ double xx, yy;
region->GetSize(&w, &h);
// Get offset from x, y
region->GetPosition(&xx, &yy);
- float xp = xx + x;
- float yp = yy + y;
+ double xp = xx + x;
+ double yp = yy + y;
// First, clear a rectangle for the text IF there is any
if (region->GetFormattedText().Number() > 0)
{
- dc.SetPen(white_background_pen);
- dc.SetBrush(white_background_brush);
+ dc.SetPen(g_oglWhiteBackgroundPen);
+ dc.SetBrush(g_oglWhiteBackgroundBrush);
// Now draw the text
if (region->GetFont()) dc.SetFont(region->GetFont());
- dc.DrawRectangle((float)(xp - w/2.0), (float)(yp - h/2.0), (float)w, (float)h);
+ dc.DrawRectangle((double)(xp - w/2.0), (double)(yp - h/2.0), (double)w, (double)h);
if (m_pen) dc.SetPen(m_pen);
dc.SetTextForeground(* region->GetActualColourObject());
#ifdef __WXMSW__
- dc.SetTextBackground(white_background_brush->GetColour());
+ dc.SetTextBackground(g_oglWhiteBackgroundBrush->GetColour());
#endif
- DrawFormattedText(dc, &(region->GetFormattedText()), xp, yp, w, h, region->GetFormatMode());
+ oglDrawFormattedText(dc, &(region->GetFormattedText()), xp, yp, w, h, region->GetFormatMode());
}
}
-void wxLineShape::EraseRegion(wxDC& dc, wxShapeRegion *region, float x, float y)
+void wxLineShape::EraseRegion(wxDC& dc, wxShapeRegion *region, double x, double y)
{
if (GetDisableLabel())
return;
- float w, h;
- float xx, yy;
+ double w, h;
+ double xx, yy;
region->GetSize(&w, &h);
// Get offset from x, y
region->GetPosition(&xx, &yy);
- float xp = xx + x;
- float yp = yy + y;
+ double xp = xx + x;
+ double yp = yy + y;
if (region->GetFormattedText().Number() > 0)
{
- dc.SetPen(white_background_pen);
- dc.SetBrush(white_background_brush);
+ dc.SetPen(g_oglWhiteBackgroundPen);
+ dc.SetBrush(g_oglWhiteBackgroundBrush);
- dc.DrawRectangle((float)(xp - w/2.0), (float)(yp - h/2.0), (float)w, (float)h);
+ dc.DrawRectangle((double)(xp - w/2.0), (double)(yp - h/2.0), (double)w, (double)h);
}
}
// Get the reference point for a label. Region x and y
// are offsets from this.
// position is 0, 1, 2
-void wxLineShape::GetLabelPosition(int position, float *x, float *y)
+void wxLineShape::GetLabelPosition(int position, double *x, double *y)
{
switch (position)
{
wxNode *next_node = node->Next();
wxRealPoint *next_point = (wxRealPoint *)next_node->Data();
- float dx = (next_point->x - point->x);
- float dy = (next_point->y - point->y);
- *x = (float)(point->x + dx/2.0);
- *y = (float)(point->y + dy/2.0);
+ double dx = (next_point->x - point->x);
+ double dy = (next_point->y - point->y);
+ *x = (double)(point->x + dx/2.0);
+ *y = (double)(point->y + dy/2.0);
break;
}
case 1:
*/
void GraphicsStraightenLine(wxRealPoint *point1, wxRealPoint *point2)
{
- float dx = point2->x - point1->x;
- float dy = point2->y - point1->y;
+ double dx = point2->x - point1->x;
+ double dy = point2->y - point1->y;
if (dx == 0.0)
return;
m_from = NULL;
}
-void wxLineShape::SetEnds(float x1, float y1, float x2, float y2)
+void wxLineShape::SetEnds(double x1, double y1, double x2, double y2)
{
// Find centre point
wxNode *first_point_node = m_lineControlPoints->First();
last_point->x = x2;
last_point->y = y2;
- m_xpos = (float)((x1 + x2)/2.0);
- m_ypos = (float)((y1 + y2)/2.0);
+ m_xpos = (double)((x1 + x2)/2.0);
+ m_ypos = (double)((y1 + y2)/2.0);
}
// Get absolute positions of ends
-void wxLineShape::GetEnds(float *x1, float *y1, float *x2, float *y2)
+void wxLineShape::GetEnds(double *x1, double *y1, double *x2, double *y2)
{
wxNode *first_point_node = m_lineControlPoints->First();
wxNode *last_point_node = m_lineControlPoints->Last();
m_attachmentTo = to_attach;
}
-bool wxLineShape::HitTest(float x, float y, int *attachment, float *distance)
+bool wxLineShape::HitTest(double x, double y, int *attachment, double *distance)
{
if (!m_lineControlPoints)
return FALSE;
wxShapeRegion *region = (wxShapeRegion *)regionNode->Data();
if (region->m_formattedText.Number() > 0)
{
- float xp, yp, cx, cy, cw, ch;
+ double xp, yp, cx, cy, cw, ch;
GetLabelPosition(i, &xp, &yp);
// Offset region from default label position
region->GetPosition(&cx, &cy);
region->GetSize(&cw, &ch);
cx += xp;
cy += yp;
- float rLeft = (float)(cx - (cw/2.0));
- float rTop = (float)(cy - (ch/2.0));
- float rRight = (float)(cx + (cw/2.0));
- float rBottom = (float)(cy + (ch/2.0));
+ double rLeft = (double)(cx - (cw/2.0));
+ double rTop = (double)(cy - (ch/2.0));
+ double rRight = (double)(cx + (cw/2.0));
+ double rBottom = (double)(cy + (ch/2.0));
if (x > rLeft && x < rRight && y > rTop && y < rBottom)
{
inLabelRegion = TRUE;
// Allow for inaccurate mousing or vert/horiz lines
int extra = 4;
- float left = wxMin(point1->x, point2->x) - extra;
- float right = wxMax(point1->x, point2->x) + extra;
+ double left = wxMin(point1->x, point2->x) - extra;
+ double right = wxMax(point1->x, point2->x) + extra;
- float bottom = wxMin(point1->y, point2->y) - extra;
- float top = wxMax(point1->y, point2->y) + extra;
+ double bottom = wxMin(point1->y, point2->y) - extra;
+ double top = wxMax(point1->y, point2->y) + extra;
if ((x > left && x < right && y > bottom && y < top) || inLabelRegion)
{
// Work out distance from centre of line
- float centre_x = (float)(left + (right - left)/2.0);
- float centre_y = (float)(bottom + (top - bottom)/2.0);
+ double centre_x = (double)(left + (right - left)/2.0);
+ double centre_y = (double)(bottom + (top - bottom)/2.0);
*attachment = 0;
- *distance = (float)sqrt((centre_x - x)*(centre_x - x) + (centre_y - y)*(centre_y - y));
+ *distance = (double)sqrt((centre_x - x)*(centre_x - x) + (centre_y - y)*(centre_y - y));
return TRUE;
}
void wxLineShape::DrawArrows(wxDC& dc)
{
// Distance along line of each arrow: space them out evenly.
- float startArrowPos = 0.0;
- float endArrowPos = 0.0;
- float middleArrowPos = 0.0;
-
+ double startArrowPos = 0.0;
+ double endArrowPos = 0.0;
+ double middleArrowPos = 0.0;
+
wxNode *node = m_arcArrows.First();
while (node)
{
}
}
-void wxLineShape::DrawArrow(wxDC& dc, wxArrowHead *arrow, float xOffset, bool proportionalOffset)
+void wxLineShape::DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool proportionalOffset)
{
wxNode *first_line_node = m_lineControlPoints->First();
wxRealPoint *first_line_point = (wxRealPoint *)first_line_node->Data();
wxRealPoint *second_last_line_point = (wxRealPoint *)second_last_line_node->Data();
// Position where we want to start drawing
- float positionOnLineX, positionOnLineY;
+ double positionOnLineX, positionOnLineY;
// Position of start point of line, at the end of which we draw the arrow.
- float startPositionX, startPositionY;
+ double startPositionX, startPositionY;
switch (arrow->GetPosition())
{
{
// If we're using a proportional offset, calculate just where this will
// be on the line.
- float realOffset = xOffset;
+ double realOffset = xOffset;
if (proportionalOffset)
{
- float totalLength =
- (float)sqrt((second_line_point->x - first_line_point->x)*(second_line_point->x - first_line_point->x) +
+ double totalLength =
+ (double)sqrt((second_line_point->x - first_line_point->x)*(second_line_point->x - first_line_point->x) +
(second_line_point->y - first_line_point->y)*(second_line_point->y - first_line_point->y));
- realOffset = (float)(xOffset * totalLength);
+ realOffset = (double)(xOffset * totalLength);
}
GetPointOnLine(second_line_point->x, second_line_point->y,
first_line_point->x, first_line_point->y,
{
// If we're using a proportional offset, calculate just where this will
// be on the line.
- float realOffset = xOffset;
+ double realOffset = xOffset;
if (proportionalOffset)
{
- float totalLength =
- (float)sqrt((second_last_line_point->x - last_line_point->x)*(second_last_line_point->x - last_line_point->x) +
+ double totalLength =
+ (double)sqrt((second_last_line_point->x - last_line_point->x)*(second_last_line_point->x - last_line_point->x) +
(second_last_line_point->y - last_line_point->y)*(second_last_line_point->y - last_line_point->y));
- realOffset = (float)(xOffset * totalLength);
+ realOffset = (double)(xOffset * totalLength);
}
GetPointOnLine(second_last_line_point->x, second_last_line_point->y,
last_line_point->x, last_line_point->y,
case ARROW_POSITION_MIDDLE:
{
// Choose a point half way between the last and penultimate points
- float x = ((last_line_point->x + second_last_line_point->x)/2);
- float y = ((last_line_point->y + second_last_line_point->y)/2);
+ double x = ((last_line_point->x + second_last_line_point->x)/2);
+ double y = ((last_line_point->y + second_last_line_point->y)/2);
// If we're using a proportional offset, calculate just where this will
// be on the line.
- float realOffset = xOffset;
+ double realOffset = xOffset;
if (proportionalOffset)
{
- float totalLength =
- (float)sqrt((second_last_line_point->x - x)*(second_last_line_point->x - x) +
+ double totalLength =
+ (double)sqrt((second_last_line_point->x - x)*(second_last_line_point->x - x) +
(second_last_line_point->y - y)*(second_last_line_point->y - y));
- realOffset = (float)(xOffset * totalLength);
+ realOffset = (double)(xOffset * totalLength);
}
GetPointOnLine(second_last_line_point->x, second_last_line_point->y,
* Add yOffset to arrow, if any
*/
- const float myPi = (float) 3.14159265;
+ const double myPi = (double) 3.14159265;
// The translation that the y offset may give
- float deltaX = 0.0;
- float deltaY = 0.0;
+ double deltaX = 0.0;
+ double deltaY = 0.0;
if ((arrow->GetYOffset() != 0.0) && !m_ignoreArrowOffsets)
{
/*
Where theta = tan(-1) of (y3-y1)/(x3-x1)
*/
- float x1 = startPositionX;
- float y1 = startPositionY;
- float x3 = positionOnLineX;
- float y3 = positionOnLineY;
- float d = -arrow->GetYOffset(); // Negate so +offset is above line
+ double x1 = startPositionX;
+ double y1 = startPositionY;
+ double x3 = positionOnLineX;
+ double y3 = positionOnLineY;
+ double d = -arrow->GetYOffset(); // Negate so +offset is above line
- float theta = 0.0;
+ double theta = 0.0;
if (x3 == x1)
- theta = (float)(myPi/2.0);
+ theta = (double)(myPi/2.0);
else
- theta = (float)atan((y3-y1)/(x3-x1));
-
- float x4 = (float)(x3 - (d*sin(theta)));
- float y4 = (float)(y3 + (d*cos(theta)));
+ theta = (double)atan((y3-y1)/(x3-x1));
+
+ double x4 = (double)(x3 - (d*sin(theta)));
+ double y4 = (double)(y3 + (d*cos(theta)));
deltaX = x4 - positionOnLineX;
deltaY = y4 - positionOnLineY;
{
case ARROW_ARROW:
{
- float arrowLength = arrow->GetSize();
- float arrowWidth = (float)(arrowLength/3.0);
+ double arrowLength = arrow->GetSize();
+ double arrowWidth = (double)(arrowLength/3.0);
- float tip_x, tip_y, side1_x, side1_y, side2_x, side2_y;
- get_arrow_points(startPositionX+deltaX, startPositionY+deltaY,
+ double tip_x, tip_y, side1_x, side1_y, side2_x, side2_y;
+ oglGetArrowPoints(startPositionX+deltaX, startPositionY+deltaY,
positionOnLineX+deltaX, positionOnLineY+deltaY,
arrowLength, arrowWidth, &tip_x, &tip_y,
&side1_x, &side1_y, &side2_x, &side2_y);
{
// Find point on line of centre of circle, which is a radius away
// from the end position
- float diameter = (float)(arrow->GetSize());
- float x, y;
+ double diameter = (double)(arrow->GetSize());
+ double x, y;
GetPointOnLine(startPositionX+deltaX, startPositionY+deltaY,
positionOnLineX+deltaX, positionOnLineY+deltaY,
- (float)(diameter/2.0),
+ (double)(diameter/2.0),
&x, &y);
// Convert ellipse centre to top-left coordinates
- float x1 = (float)(x - (diameter/2.0));
- float y1 = (float)(y - (diameter/2.0));
+ double x1 = (double)(x - (diameter/2.0));
+ double y1 = (double)(y - (diameter/2.0));
dc.SetPen(m_pen);
if (arrow->_GetType() == ARROW_HOLLOW_CIRCLE)
- dc.SetBrush(white_background_brush);
+ dc.SetBrush(g_oglWhiteBackgroundBrush);
else
dc.SetBrush(m_brush);
* --------------| x | <-- e.g. rectangular arrowhead
* -----
*/
- float x, y;
+ double x, y;
GetPointOnLine(startPositionX, startPositionY,
positionOnLineX, positionOnLineY,
- (float)(arrow->GetMetaFile()->m_width/2.0),
+ (double)(arrow->GetMetaFile()->m_width/2.0),
&x, &y);
// Calculate theta for rotating the metafile.
| /(x1, y1)
|______________________
*/
- float theta = 0.0;
- float x1 = startPositionX;
- float y1 = startPositionY;
- float x2 = positionOnLineX;
- float y2 = positionOnLineY;
+ double theta = 0.0;
+ double x1 = startPositionX;
+ double y1 = startPositionY;
+ double x2 = positionOnLineX;
+ double y2 = positionOnLineY;
if ((x1 == x2) && (y1 == y2))
theta = 0.0;
else if ((x1 == x2) && (y1 > y2))
- theta = (float)(3.0*myPi/2.0);
+ theta = (double)(3.0*myPi/2.0);
else if ((x1 == x2) && (y2 > y1))
- theta = (float)(myPi/2.0);
+ theta = (double)(myPi/2.0);
else if ((x2 > x1) && (y2 >= y1))
- theta = (float)atan((y2 - y1)/(x2 - x1));
+ theta = (double)atan((y2 - y1)/(x2 - x1));
else if (x2 < x1)
- theta = (float)(myPi + atan((y2 - y1)/(x2 - x1)));
+ theta = (double)(myPi + atan((y2 - y1)/(x2 - x1)));
else if ((x2 > x1) && (y2 < y1))
- theta = (float)(2*myPi + atan((y2 - y1)/(x2 - x1)));
+ theta = (double)(2*myPi + atan((y2 - y1)/(x2 - x1)));
else
{
if (m_erasing)
{
// If erasing, just draw a rectangle.
- float minX, minY, maxX, maxY;
+ double minX, minY, maxX, maxY;
arrow->GetMetaFile()->GetBounds(&minX, &minY, &maxX, &maxY);
// Make erasing rectangle slightly bigger or you get droppings.
int extraPixels = 4;
- dc.DrawRectangle((float)(deltaX + x + minX - (extraPixels/2.0)), (float)(deltaY + y + minY - (extraPixels/2.0)),
- (float)(maxX - minX + extraPixels), (float)(maxY - minY + extraPixels));
+ dc.DrawRectangle((double)(deltaX + x + minX - (extraPixels/2.0)), (double)(deltaY + y + minY - (extraPixels/2.0)),
+ (double)(maxX - minX + extraPixels), (double)(maxY - minY + extraPixels));
}
else
arrow->GetMetaFile()->Draw(dc, x+deltaX, y+deltaY);
{
wxPen *old_pen = m_pen;
wxBrush *old_brush = m_brush;
- SetPen(white_background_pen);
- SetBrush(white_background_brush);
+ SetPen(g_oglWhiteBackgroundPen);
+ SetBrush(g_oglWhiteBackgroundBrush);
- float bound_x, bound_y;
+ double bound_x, bound_y;
GetBoundingBoxMax(&bound_x, &bound_y);
if (m_font) dc.SetFont(m_font);
wxNode *node = m_regions.Nth(i);
if (node)
{
- float x, y;
+ double x, y;
wxShapeRegion *region = (wxShapeRegion *)node->Data();
GetLabelPosition(i, &x, &y);
EraseRegion(dc, region, x, y);
}
// Undraw line
- dc.SetPen(white_background_pen);
- dc.SetBrush(white_background_brush);
+ dc.SetPen(g_oglWhiteBackgroundPen);
+ dc.SetBrush(g_oglWhiteBackgroundBrush);
// Drawing over the line only seems to work if the line has a thickness
// of 1.
if (old_pen && (old_pen->GetWidth() > 1))
{
- dc.DrawRectangle((float)(m_xpos - (bound_x/2.0) - 2.0), (float)(m_ypos - (bound_y/2.0) - 2.0),
- (float)(bound_x+4.0), (float)(bound_y+4.0));
+ dc.DrawRectangle((double)(m_xpos - (bound_x/2.0) - 2.0), (double)(m_ypos - (bound_y/2.0) - 2.0),
+ (double)(bound_x+4.0), (double)(bound_y+4.0));
}
else
{
if (old_brush) SetBrush(old_brush);
}
-void wxLineShape::GetBoundingBoxMin(float *w, float *h)
+void wxLineShape::GetBoundingBoxMin(double *w, double *h)
{
- float x1 = 10000;
- float y1 = 10000;
- float x2 = -10000;
- float y2 = -10000;
+ double x1 = 10000;
+ double y1 = 10000;
+ double x2 = -10000;
+ double y2 = -10000;
wxNode *node = m_lineControlPoints->First();
while (node)
node = node->Next();
}
- *w = (float)(x2 - x1);
- *h = (float)(y2 - y1);
+ *w = (double)(x2 - x1);
+ *h = (double)(y2 - y1);
}
/*
*no_arcs = num;
}
-void wxLineShape::OnDrawOutline(wxDC& dc, float x, float y, float w, float h)
+void wxLineShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double h)
{
wxPen *old_pen = m_pen;
wxBrush *old_brush = m_brush;
SetPen(& dottedPen);
SetBrush( wxTRANSPARENT_BRUSH );
-/*
- if (m_isSpline)
- dc.DrawSpline(m_lineControlPoints);
- else
- dc.DrawLines(m_lineControlPoints);
-*/
GetEventHandler()->OnDraw(dc);
if (old_pen) SetPen(old_pen);
else SetBrush(NULL);
}
-bool wxLineShape::OnMovePre(wxDC& dc, float x, float y, float old_x, float old_y, bool display)
+bool wxLineShape::OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display)
{
- float x_offset = x - old_x;
- float y_offset = y - old_y;
+ double x_offset = x - old_x;
+ double y_offset = y - old_y;
if (m_lineControlPoints && !(x_offset == 0.0 && y_offset == 0.0))
{
if (m_labelObjects[i])
{
m_labelObjects[i]->Erase(dc);
- float xp, yp, xr, yr;
+ double xp, yp, xr, yr;
GetLabelPosition(i, &xp, &yp);
wxNode *node = m_regions.Nth(i);
if (node)
// Do each end - nothing in the middle. User has to move other points
// manually if necessary.
- float end_x, end_y;
- float other_end_x, other_end_y;
+ double end_x, end_y;
+ double other_end_x, other_end_y;
FindLineEndPoints(&end_x, &end_y, &other_end_x, &other_end_y);
last_point->x = other_end_x; last_point->y = other_end_y;
*/
- float oldX = m_xpos;
- float oldY = m_ypos;
+ double oldX = m_xpos;
+ double oldY = m_ypos;
SetEnds(end_x, end_y, other_end_x, other_end_y);
SetEnds(end_x, end_y, other_end_x, other_end_y);
// Try to move control points with the arc
- float x_offset = m_xpos - oldX;
- float y_offset = m_ypos - oldY;
+ double x_offset = m_xpos - oldX;
+ double y_offset = m_ypos - oldY;
// if (moveControlPoints && m_lineControlPoints && !(x_offset == 0.0 && y_offset == 0.0))
// Only move control points if it's a self link. And only works if attachment mode is ON.
// This function can be used by e.g. line-routing routines to
// get the actual points on the two node images where the lines will be drawn
// to/from.
-void wxLineShape::FindLineEndPoints(float *fromX, float *fromY, float *toX, float *toY)
+void wxLineShape::FindLineEndPoints(double *fromX, double *fromY, double *toX, double *toY)
{
if (!m_from || !m_to)
return;
// Do each end - nothing in the middle. User has to move other points
// manually if necessary.
- float end_x, end_y;
- float other_end_x, other_end_y;
+ double end_x, end_y;
+ double other_end_x, other_end_y;
wxNode *first = m_lineControlPoints->First();
wxRealPoint *first_point = (wxRealPoint *)first->Data();
}
else
(void) m_from->GetPerimeterPoint(m_from->GetX(), m_from->GetY(),
- (float)second_point->x, (float)second_point->y,
+ (double)second_point->x, (double)second_point->y,
&end_x, &end_y);
if (m_to->GetAttachmentMode())
}
else
(void) m_to->GetPerimeterPoint(m_to->GetX(), m_to->GetY(),
- (float)second_last_point->x, (float)second_last_point->y,
+ (double)second_last_point->x, (double)second_last_point->y,
&other_end_x, &other_end_y);
}
else
{
- float fromX = m_from->GetX();
- float fromY = m_from->GetY();
- float toX = m_to->GetX();
- float toY = m_to->GetY();
+ double fromX = m_from->GetX();
+ double fromY = m_from->GetY();
+ double toX = m_to->GetX();
+ double toY = m_to->GetY();
if (m_from->GetAttachmentMode())
{
for (i = 0; i < n; i++)
{
wxRealPoint* point = (wxRealPoint*) m_lineControlPoints->Nth(i)->Data();
- points[i].x = (int) point->x;
- points[i].y = (int) point->y;
+ points[i].x = WXROUND(point->x);
+ points[i].y = WXROUND(point->y);
}
if (m_isSpline)
else
dc.DrawLines(n, points);
+#ifdef __WXMSW__
+ // For some reason, last point isn't drawn under Windows.
+ dc.DrawPoint(points[n-1]);
+#endif
+
delete[] points;
+
// Problem with pen - if not a solid pen, does strange things
// to the arrowhead. So make (get) a new pen that's solid.
if (m_pen && (m_pen->GetStyle() != wxSOLID))
wxShape::OnEraseControlPoints(dc);
}
-void wxLineShape::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxLineShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
}
-void wxLineShape::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxLineShape::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
}
-void wxLineShape::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxLineShape::OnEndDragLeft(double x, double y, int keys, int attachment)
{
}
/*
-void wxLineShape::SetArrowSize(float length, float width)
+void wxLineShape::SetArrowSize(double length, double width)
{
arrow_length = length;
arrow_width = width;
if (node)
{
wxShapeRegion *region = (wxShapeRegion *)node->Data();
- float x, y;
+ double x, y;
GetLabelPosition(i, &x, &y);
DrawRegion(dc, region, x, y);
}
{
wxRealPoint *point = (wxRealPoint *)node->Data();
wxExpr *point_list = new wxExpr(PrologList);
- wxExpr *x_expr = new wxExpr((float) point->x);
- wxExpr *y_expr = new wxExpr((float) point->y);
+ wxExpr *x_expr = new wxExpr((double) point->x);
+ wxExpr *y_expr = new wxExpr((double) point->y);
point_list->Append(x_expr);
point_list->Append(y_expr);
list->Append(point_list);
while (node)
{
wxExpr *xexpr = node->value.first;
- float x = xexpr->RealValue();
+ double x = xexpr->RealValue();
wxExpr *yexpr = xexpr->next;
- float y = yexpr->RealValue();
+ double y = yexpr->RealValue();
wxRealPoint *point = new wxRealPoint(x, y);
m_lineControlPoints->Append((wxObject*) point);
{
WXTYPE arrowType = ARROW_ARROW;
int arrowEnd = 0;
- float xOffset = 0.0;
- float arrowSize = 0.0;
+ double xOffset = 0.0;
+ double arrowSize = 0.0;
wxString arrowName("");
long arrowId = -1;
wxLineShape& lineCopy = (wxLineShape&) copy;
+ lineCopy.m_to = m_to;
+ lineCopy.m_from = m_from;
+ lineCopy.m_attachmentTo = m_attachmentTo;
+ lineCopy.m_attachmentFrom = m_attachmentFrom;
lineCopy.m_isSpline = m_isSpline;
lineCopy.m_alignmentStart = m_alignmentStart;
lineCopy.m_alignmentEnd = m_alignmentEnd;
lineCopy.m_maintainStraightLines = m_maintainStraightLines;
lineCopy.m_lineOrientations.Clear();
+
wxNode *node = m_lineOrientations.First();
while (node)
{
node = node->Next();
}
-/*
- lineCopy.start_style = start_style;
- lineCopy.end_style = end_style;
- lineCopy.middle_style = middle_style;
-
- lineCopy.arrow_length = arrow_length;
- lineCopy.arrow_width = arrow_width;
-*/
-
- // Copy new OGL stuff
+ // Copy arrows
lineCopy.ClearArrowsAtPosition(-1);
node = m_arcArrows.First();
while (node)
wxShapeRegion *region = (wxShapeRegion *)node->Data();
if (region->m_formattedText.Number() > 0)
{
- float w, h, x, y, xx, yy;
+ double w, h, x, y, xx, yy;
region->GetSize(&w, &h);
region->GetPosition(&x, &y);
GetLabelPosition(i, &xx, &yy);
m_labelObjects[i]->AddToCanvas(m_canvas);
m_labelObjects[i]->Show(TRUE);
if (dc)
- m_labelObjects[i]->Move(*dc, (float)(x + xx), (float)(y + yy));
+ m_labelObjects[i]->Move(*dc, (double)(x + xx), (double)(y + yy));
m_labelObjects[i]->Select(TRUE);
}
}
IMPLEMENT_DYNAMIC_CLASS(wxLineControlPoint, wxControlPoint)
-wxLineControlPoint::wxLineControlPoint(wxShapeCanvas *theCanvas, wxShape *object, float size, float x, float y, int the_type):
+wxLineControlPoint::wxLineControlPoint(wxShapeCanvas *theCanvas, wxShape *object, double size, double x, double y, int the_type):
wxControlPoint(theCanvas, object, size, x, y, the_type)
{
m_xpos = x;
}
// Implement movement of Line point
-void wxLineControlPoint::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxLineControlPoint::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingDragLeft(this, draw, x, y, keys, attachment);
}
-void wxLineControlPoint::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxLineControlPoint::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingBeginDragLeft(this, x, y, keys, attachment);
}
-void wxLineControlPoint::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxLineControlPoint::OnEndDragLeft(double x, double y, int keys, int attachment)
{
m_shape->GetEventHandler()->OnSizingEndDragLeft(this, x, y, keys, attachment);
}
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
-void wxLineShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys, int attachment)
+void wxLineShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys, int attachment)
{
wxLineControlPoint* lpt = (wxLineControlPoint*) pt;
}
-void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
+void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
{
wxLineControlPoint* lpt = (wxLineControlPoint*) pt;
lineShape->GetTo()->OnDraw(dc);
lineShape->GetTo()->OnDrawContents(dc);
}
- m_canvas->SetCursor(GraphicsBullseyeCursor);
+ m_canvas->SetCursor(g_oglBullseyeCursor);
lpt->m_oldCursor = wxSTANDARD_CURSOR;
}
}
-void wxLineShape::OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys, int attachment)
+void wxLineShape::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment)
{
wxLineControlPoint* lpt = (wxLineControlPoint*) pt;
if (lineShape->GetFrom())
{
lineShape->GetFrom()->MoveLineToNewAttachment(dc, lineShape, x, y);
- lineShape->GetFrom()->MoveLinks(dc);
}
}
if (lpt->m_type == CONTROL_POINT_ENDPOINT_TO)
if (lineShape->GetTo())
{
lineShape->GetTo()->MoveLineToNewAttachment(dc, lineShape, x, y);
- lineShape->GetTo()->MoveLinks(dc);
}
}
+
+ // Needed?
+#if 0
int i = 0;
for (i = 0; i < lineShape->GetLineControlPoints()->Number(); i++)
if (((wxRealPoint *)(lineShape->GetLineControlPoints()->Nth(i)->Data())) == lpt->m_point)
wxShapeCanvas *objCanvas = m_canvas;
lineObj->OnMoveControlPoint(i+1, x, y);
-
- if (!objCanvas->GetQuickEditMode()) objCanvas->Redraw(dc);
+#endif
}
// Implement movement of endpoint to a new attachment
-void wxLineControlPoint::OnDragRight(bool draw, float x, float y, int keys, int attachment)
+// OBSOLETE: done by dragging with the left button.
+
+#if 0
+void wxLineControlPoint::OnDragRight(bool draw, double x, double y, int keys, int attachment)
{
if (m_type == CONTROL_POINT_ENDPOINT_FROM || m_type == CONTROL_POINT_ENDPOINT_TO)
{
}
}
-void wxLineControlPoint::OnBeginDragRight(float x, float y, int keys, int attachment)
+void wxLineControlPoint::OnBeginDragRight(double x, double y, int keys, int attachment)
{
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
lineShape->GetTo()->GetEventHandler()->OnDraw(dc);
lineShape->GetTo()->GetEventHandler()->OnDrawContents(dc);
}
- m_canvas->SetCursor(GraphicsBullseyeCursor);
+ m_canvas->SetCursor(g_oglBullseyeCursor);
m_oldCursor = wxSTANDARD_CURSOR;
}
}
-void wxLineControlPoint::OnEndDragRight(float x, float y, int keys, int attachment)
+void wxLineControlPoint::OnEndDragRight(double x, double y, int keys, int attachment)
{
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
lineShape->GetFrom()->EraseLinks(dc);
int new_attachment;
- float distance;
+ double distance;
if (lineShape->GetFrom()->HitTest(x, y, &new_attachment, &distance))
lineShape->SetAttachments(new_attachment, lineShape->GetAttachmentTo());
lineShape->GetTo()->EraseLinks(dc);
int new_attachment;
- float distance;
+ double distance;
if (lineShape->GetTo()->HitTest(x, y, &new_attachment, &distance))
lineShape->SetAttachments(lineShape->GetAttachmentFrom(), new_attachment);
lineShape->OnMoveControlPoint(i+1, x, y);
if (!m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc);
}
+#endif
/*
* Get the point on the given line (x1, y1) (x2, y2)
* returned values in x and y
*/
-void GetPointOnLine(float x1, float y1, float x2, float y2,
- float length, float *x, float *y)
+void GetPointOnLine(double x1, double y1, double x2, double y2,
+ double length, double *x, double *y)
{
- float l = (float)sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
+ double l = (double)sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
if (l < 0.01)
- l = (float) 0.01;
+ l = (double) 0.01;
- float i_bar = (x2 - x1)/l;
- float j_bar = (y2 - y1)/l;
+ double i_bar = (x2 - x1)/l;
+ double j_bar = (y2 - y1)/l;
*x = (- length*i_bar) + x2;
*y = (- length*j_bar) + y2;
}
-wxArrowHead *wxLineShape::AddArrow(WXTYPE type, int end, float size, float xOffset,
+wxArrowHead *wxLineShape::AddArrow(WXTYPE type, int end, double size, double xOffset,
const wxString& name, wxPseudoMetaFile *mf, long arrowId)
{
wxArrowHead *arrow = new wxArrowHead(type, end, size, xOffset, name, mf, arrowId);
*
*/
-float wxLineShape::FindMinimumWidth()
+double wxLineShape::FindMinimumWidth()
{
- float minWidth = 0.0;
+ double minWidth = 0.0;
wxNode *node = m_arcArrows.First();
while (node)
{
// scale it to give it reasonable aesthetics
// when drawing with line.
if (minWidth > 0.0)
- minWidth = (float)(minWidth * 1.4);
+ minWidth = (double)(minWidth * 1.4);
else
minWidth = 20.0;
// Find which position we're talking about at this (x, y).
// Returns ARROW_POSITION_START, ARROW_POSITION_MIDDLE, ARROW_POSITION_END
-int wxLineShape::FindLinePosition(float x, float y)
+int wxLineShape::FindLinePosition(double x, double y)
{
- float startX, startY, endX, endY;
+ double startX, startY, endX, endY;
GetEnds(&startX, &startY, &endX, &endY);
// Find distances from centre, start and end. The smallest wins.
- float centreDistance = (float)(sqrt((x - m_xpos)*(x - m_xpos) + (y - m_ypos)*(y - m_ypos)));
- float startDistance = (float)(sqrt((x - startX)*(x - startX) + (y - startY)*(y - startY)));
- float endDistance = (float)(sqrt((x - endX)*(x - endX) + (y - endY)*(y - endY)));
+ double centreDistance = (double)(sqrt((x - m_xpos)*(x - m_xpos) + (y - m_ypos)*(y - m_ypos)));
+ double startDistance = (double)(sqrt((x - startX)*(x - startX) + (y - startY)*(y - startY)));
+ double endDistance = (double)(sqrt((x - endX)*(x - endX) + (y - endY)*(y - endY)));
if (centreDistance < startDistance && centreDistance < endDistance)
return ARROW_POSITION_MIDDLE;
IMPLEMENT_DYNAMIC_CLASS(wxArrowHead, wxObject)
-wxArrowHead::wxArrowHead(WXTYPE type, int end, float size, float dist, const wxString& name,
+wxArrowHead::wxArrowHead(WXTYPE type, int end, double size, double dist, const wxString& name,
wxPseudoMetaFile *mf, long arrowId)
{
m_arrowType = type; m_arrowEnd = end; m_arrowSize = size;
if (m_metaFile) delete m_metaFile;
}
-void wxArrowHead::SetSize(float size)
+void wxArrowHead::SetSize(double size)
{
m_arrowSize = size;
if ((m_arrowType == ARROW_METAFILE) && m_metaFile)
{
- float oldWidth = m_metaFile->m_width;
+ double oldWidth = m_metaFile->m_width;
if (oldWidth == 0.0)
return;
- float scale = (float)(size/oldWidth);
+ double scale = (double)(size/oldWidth);
if (scale != 1.0)
m_metaFile->Scale(scale, scale);
}
IMPLEMENT_DYNAMIC_CLASS(wxLabelShape, wxRectangleShape)
-wxLabelShape::wxLabelShape(wxLineShape *parent, wxShapeRegion *region, float w, float h):wxRectangleShape(w, h)
+wxLabelShape::wxLabelShape(wxLineShape *parent, wxShapeRegion *region, double w, double h):wxRectangleShape(w, h)
{
m_lineShape = parent;
m_shapeRegion = region;
if (m_lineShape && !m_lineShape->GetDrawHandles())
return;
- float x1 = (float)(m_xpos - m_width/2.0);
- float y1 = (float)(m_ypos - m_height/2.0);
+ double x1 = (double)(m_xpos - m_width/2.0);
+ double y1 = (double)(m_ypos - m_height/2.0);
if (m_pen)
{
if (m_pen->GetWidth() == 0)
- dc.SetPen(transparent_pen);
+ dc.SetPen(g_oglTransparentPen);
else
dc.SetPen(m_pen);
}
dc.SetBrush(wxTRANSPARENT_BRUSH);
if (m_cornerRadius > 0.0)
- dc.DrawRoundedRectangle(x1, y1, m_width, m_height, m_cornerRadius);
+ dc.DrawRoundedRectangle(WXROUND(x1), WXROUND(y1), WXROUND(m_width), WXROUND(m_height), m_cornerRadius);
else
- dc.DrawRectangle(x1, y1, m_width, m_height);
+ dc.DrawRectangle(WXROUND(x1), WXROUND(y1), WXROUND(m_width), WXROUND(m_height));
}
void wxLabelShape::OnDrawContents(wxDC& dc)
{
}
-void wxLabelShape::OnDragLeft(bool draw, float x, float y, int keys, int attachment)
+void wxLabelShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
{
wxRectangleShape::OnDragLeft(draw, x, y, keys, attachment);
}
-void wxLabelShape::OnBeginDragLeft(float x, float y, int keys, int attachment)
+void wxLabelShape::OnBeginDragLeft(double x, double y, int keys, int attachment)
{
wxRectangleShape::OnBeginDragLeft(x, y, keys, attachment);
}
-void wxLabelShape::OnEndDragLeft(float x, float y, int keys, int attachment)
+void wxLabelShape::OnEndDragLeft(double x, double y, int keys, int attachment)
{
wxRectangleShape::OnEndDragLeft(x, y, keys, attachment);
}
-bool wxLabelShape::OnMovePre(wxDC& dc, float x, float y, float old_x, float old_y, bool display)
+bool wxLabelShape::OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display)
{
m_shapeRegion->SetSize(m_width, m_height);
i ++;
}
}
- float xx, yy;
+ double xx, yy;
m_lineShape->GetLabelPosition(i, &xx, &yy);
// Set the region's offset, relative to the default position for
// each region.
- m_shapeRegion->SetPosition((float)(x - xx), (float)(y - yy));
+ m_shapeRegion->SetPosition((double)(x - xx), (double)(y - yy));
// Need to reformat to fit region.
if (m_shapeRegion->GetText())
}
// Divert left and right clicks to line object
-void wxLabelShape::OnLeftClick(float x, float y, int keys, int attachment)
+void wxLabelShape::OnLeftClick(double x, double y, int keys, int attachment)
{
m_lineShape->GetEventHandler()->OnLeftClick(x, y, keys, attachment);
}
-void wxLabelShape::OnRightClick(float x, float y, int keys, int attachment)
+void wxLabelShape::OnRightClick(double x, double y, int keys, int attachment)
{
m_lineShape->GetEventHandler()->OnRightClick(x, y, keys, attachment);
}
DECLARE_DYNAMIC_CLASS(wxArrowHead)
public:
- wxArrowHead(WXTYPE type = 0, int end = 0, float size = 0.0, float dist = 0.0, const wxString& name = "", wxPseudoMetaFile *mf = NULL,
+ wxArrowHead(WXTYPE type = 0, int end = 0, double size = 0.0, double dist = 0.0, const wxString& name = "", wxPseudoMetaFile *mf = NULL,
long arrowId = -1);
~wxArrowHead();
wxArrowHead(wxArrowHead& toCopy);
inline WXTYPE _GetType() const { return m_arrowType; }
inline int GetPosition() const { return m_arrowEnd; }
inline void SetPosition(int pos) { m_arrowEnd = pos; }
- inline float GetXOffset() const { return m_xOffset; }
- inline float GetYOffset() const { return m_yOffset; }
- inline float GetSpacing() const { return m_spacing; }
- inline float GetSize() const { return m_arrowSize; }
+ inline double GetXOffset() const { return m_xOffset; }
+ inline double GetYOffset() const { return m_yOffset; }
+ inline double GetSpacing() const { return m_spacing; }
+ inline double GetSize() const { return m_arrowSize; }
inline wxString GetName() const { return m_arrowName; }
- inline void SetXOffset(float x) { m_xOffset = x; }
- inline void SetYOffset(float y) { m_yOffset = y; }
+ inline void SetXOffset(double x) { m_xOffset = x; }
+ inline void SetYOffset(double y) { m_yOffset = y; }
inline wxPseudoMetaFile *GetMetaFile() const { return m_metaFile; }
inline long GetId() const { return m_id; }
inline int GetArrowEnd() const { return m_arrowEnd; }
- inline float GetArrowSize() const { return m_arrowSize; }
- void SetSize(float size);
- inline void SetSpacing(float sp) { m_spacing = sp; }
+ inline double GetArrowSize() const { return m_arrowSize; }
+ void SetSize(double size);
+ inline void SetSpacing(double sp) { m_spacing = sp; }
protected:
WXTYPE m_arrowType;
int m_arrowEnd; // Position on line
- float m_xOffset; // Distance from arc start or end, w.r.t. point on arrowhead
+ double m_xOffset; // Distance from arc start or end, w.r.t. point on arrowhead
// nearest start or end. If zero, use default spacing.
- float m_yOffset; // vertical offset (w.r.t. a horizontal line). Normally zero.
- float m_spacing; // Spacing from the last arrowhead
- float m_arrowSize; // Length of arrowhead
+ double m_yOffset; // vertical offset (w.r.t. a horizontal line). Normally zero.
+ double m_spacing; // Spacing from the last arrowhead
+ double m_arrowSize; // Length of arrowhead
wxString m_arrowName; // Name of arrow
bool m_saveToFile; // TRUE if we want to save custom arrowheads to file.
wxPseudoMetaFile* m_metaFile; // Pseudo metafile if this is a custom arrowhead
// moveControlPoints must be disabled when a control point is being
// dragged.
void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
- bool OnMovePre(wxDC& dc, float x, float y, float old_x, float old_y, bool display = TRUE);
+ bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
void OnDrawControlPoints(wxDC& dc);
void OnEraseControlPoints(wxDC& dc);
void OnErase(wxDC& dc);
- virtual inline void OnMoveControlPoint(int WXUNUSED(which), float WXUNUSED(x), float WXUNUSED(y)) {}
- void OnDrawOutline(wxDC& dc, float x, float y, float w, float h);
- void GetBoundingBoxMin(float *w, float *h);
+ virtual inline void OnMoveControlPoint(int WXUNUSED(which), double WXUNUSED(x), double WXUNUSED(y)) {}
+ void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
+ void GetBoundingBoxMin(double *w, double *h);
void FormatText(wxDC& dc, const wxString& s, int regionId = 0);
- virtual void SetEnds(float x1, float y1, float x2, float y2);
- virtual void GetEnds(float *x1, float *y1, float *x2, float *y2);
+ virtual void SetEnds(double x1, double y1, double x2, double y2);
+ virtual void GetEnds(double *x1, double *y1, double *x2, double *y2);
inline virtual wxShape *GetFrom() { return m_from; }
inline virtual wxShape *GetTo() { return m_to; }
inline virtual int GetAttachmentFrom() { return m_attachmentFrom; }
// This function can be used by e.g. line-routing routines to
// get the actual points on the two node images where the lines will be drawn
// to/from.
- void FindLineEndPoints(float *fromX, float *fromY, float *toX, float *toY);
+ void FindLineEndPoints(double *fromX, double *fromY, double *toX, double *toY);
// Format one region at this position
- void DrawRegion(wxDC& dc, wxShapeRegion *region, float x, float y);
+ void DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y);
// Erase one region at this position
- void EraseRegion(wxDC& dc, wxShapeRegion *region, float x, float y);
+ void EraseRegion(wxDC& dc, wxShapeRegion *region, double x, double y);
// Get the reference point for a label. Region x and y
// are offsets from this.
// position is 0 (middle), 1 (start), 2 (end)
- void GetLabelPosition(int position, float *x, float *y);
+ void GetLabelPosition(int position, double *x, double *y);
// Straighten verticals and horizontals
virtual void Straighten(wxDC& dc);
inline wxList *GetLineControlPoints() { return m_lineControlPoints; }
// Override dragging behaviour - don't want to be able to drag lines!
- void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0);
- void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
- void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
+ void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
+ void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
+ void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
- virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, float x, float y, int keys=0, int attachment = 0);
- virtual void OnSizingBeginDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
- virtual void OnSizingEndDragLeft(wxControlPoint* pt, float x, float y, int keys=0, int attachment = 0);
+ virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
+ virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
+ virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
// Override select, to create/delete temporary label-moving objects
void Select(bool select = TRUE, wxDC* dc = NULL);
void Unlink();
void SetAttachments(int from_attach, int to_attach);
+ inline void SetAttachmentFrom(int attach) { m_attachmentFrom = attach; }
+ inline void SetAttachmentTo(int attach) { m_attachmentTo = attach; }
- bool HitTest(float x, float y, int *attachment, float *distance);
+ bool HitTest(double x, double y, int *attachment, double *distance);
#ifdef PROLOGIO
// Prolog database stuff
// Find which position we're talking about at this (x, y).
// Returns ARROW_POSITION_START, ARROW_POSITION_MIDDLE, ARROW_POSITION_END
- int FindLinePosition(float x, float y);
+ int FindLinePosition(double x, double y);
// This is really to distinguish between lines and other images.
// For lines, want to pass drag to canvas, since lines tend to prevent
// Add an arrowhead.
wxArrowHead *AddArrow(WXTYPE type, int end = ARROW_POSITION_END,
- float arrowSize = 10.0, float xOffset = 0.0, const wxString& name = "",
+ double arrowSize = 10.0, double xOffset = 0.0, const wxString& name = "",
wxPseudoMetaFile *mf = NULL, long arrowId = -1);
// Add an arrowhead in the position indicated by the reference
wxArrowHead *FindArrowHead(long arrowId);
bool DeleteArrowHead(int position, const wxString& name);
bool DeleteArrowHead(long arrowId);
- void DrawArrow(wxDC& dc, wxArrowHead *arrow, float xOffset, bool proportionalOffset);
+ void DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool proportionalOffset);
inline void SetIgnoreOffsets(bool ignore) { m_ignoreArrowOffsets = ignore; }
inline wxList& GetArrows() const { return (wxList&) m_arcArrows; }
// Find horizontal width for drawing a line with
// arrows in minimum space. Assume arrows at
// END only
- float FindMinimumWidth();
+ double FindMinimumWidth();
// Set alignment flags. ALIGNMENT NOT IMPLEMENTED.
void SetAlignmentOrientation(bool isEnd, bool isHoriz);
// probably be the same)
wxList* m_lineControlPoints;
- float m_arrowSpacing; // Separation between adjacent arrows
+ double m_arrowSpacing; // Separation between adjacent arrows
wxShape* m_to;
wxShape* m_from;
/*
- float m_actualTextWidth; // Space the text takes up
- float m_actualTextHeight; // (depends on text content unlike nodes)
+ double m_actualTextWidth; // Space the text takes up
+ double m_actualTextHeight; // (depends on text content unlike nodes)
*/
int m_attachmentTo; // Attachment point at one end
int m_attachmentFrom; // Attachment point at other end
friend class wxLineShape;
public:
- wxLineControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0,
- float x = 0.0, float y = 0.0, int the_type = 0);
+ wxLineControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0,
+ double x = 0.0, double y = 0.0, int the_type = 0);
~wxLineControlPoint();
void OnDraw(wxDC& dc);
- void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0);
- void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
- void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
-
- void OnDragRight(bool draw, float x, float y, int keys=0, int attachment = 0);
- void OnBeginDragRight(float x, float y, int keys=0, int attachment = 0);
- void OnEndDragRight(float x, float y, int keys=0, int attachment = 0);
+ void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
+ void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
+ void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
+
+ // Obsolete (left-dragging now moves attachment point to new relative position OR new
+ // attachment id)
+#if 0
+ void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0);
+ void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
+ void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
+#endif
public:
DECLARE_DYNAMIC_CLASS(wxLabelShape)
public:
- wxLabelShape(wxLineShape *parent = NULL, wxShapeRegion *region = NULL, float w = 0.0, float h = 0.0);
+ wxLabelShape(wxLineShape *parent = NULL, wxShapeRegion *region = NULL, double w = 0.0, double h = 0.0);
~wxLabelShape();
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
- void OnLeftClick(float x, float y, int keys = 0, int attachment = 0);
- void OnRightClick(float x, float y, int keys = 0, int attachment = 0);
- void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0);
- void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
- void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
- bool OnMovePre(wxDC& dc, float x, float y, float old_x, float old_y, bool display = TRUE);
+ void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
+ void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
+ void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
+ void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
+ void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
+ bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
public:
wxLineShape* m_lineShape;
* returned values in x and y
*/
-void GetPointOnLine(float x1, float y1, float x2, float y2,
- float length, float *x, float *y);
+void GetPointOnLine(double x1, double y1, double x2, double y2,
+ double length, double *x, double *y);
#endif
// _OGL_LINESP_H_
iRight = getsignedshort(handle);
iBottom = getsignedshort(handle);
- left = (float)iLeft;
- top = (float)iTop;
- right = (float)iRight;
- bottom = (float)iBottom;
+ left = (double)iLeft;
+ top = (double)iTop;
+ right = (double)iRight;
+ bottom = (double)iBottom;
int inch = getshort(handle);
long reserved = getint(handle);
int checksum = getshort(handle);
/*
- float widthInUnits = (float)right - left;
- float heightInUnits = (float)bottom - top;
+ double widthInUnits = (double)right - left;
+ double heightInUnits = (double)bottom - top;
*width = (int)((widthInUnits*1440.0)/inch);
*height = (int)((heightInUnits*1440.0)/inch);
*/
{
long x1 = rec->param1;
long y1 = rec->param2;
- dc->DrawLine(lastX, lastY, (float)x1, (float)y1);
+ dc->DrawLine(lastX, lastY, (double)x1, (double)y1);
break;
}
case META_MOVETO:
{
- lastX = (float)rec->param1;
- lastY = (float)rec->param2;
+ lastX = (double)rec->param1;
+ lastY = (double)rec->param2;
break;
}
case META_EXCLUDECLIPRECT:
// case META_PIE: // DO!!!
case META_RECTANGLE:
{
- dc->DrawRectangle((float)rec->param1, (float)rec->param2,
- (float)rec->param3 - rec->param1,
- (float)rec->param4 - rec->param2);
+ dc->DrawRectangle((double)rec->param1, (double)rec->param2,
+ (double)rec->param3 - rec->param1,
+ (double)rec->param4 - rec->param2);
break;
}
case META_ROUNDRECT:
{
- dc->DrawRoundedRectangle((float)rec->param1, (float)rec->param2,
- (float)rec->param3 - rec->param1,
- (float)rec->param4 - rec->param2,
- (float)rec->param5);
+ dc->DrawRoundedRectangle((double)rec->param1, (double)rec->param2,
+ (double)rec->param3 - rec->param1,
+ (double)rec->param4 - rec->param2,
+ (double)rec->param5);
break;
}
// case META_PATBLT:
class wxXMetaFile: public wxObject
{
public:
- float lastX;
- float lastY;
+ double lastX;
+ double lastY;
bool ok;
- float left;
- float top;
- float right;
- float bottom;
-
+ double left;
+ double top;
+ double right;
+ double bottom;
+
wxList metaRecords;
wxList gdiObjects; // List of wxMetaRecord objects created with Create...,
// referenced by position in list by SelectObject
#include "constrnt.h"
#include "composit.h"
-wxFont *g_oglNormalFont;
+wxFont* g_oglNormalFont;
+wxPen* g_oglBlackPen;
+wxPen* g_oglWhiteBackgroundPen;
+wxPen* g_oglTransparentPen;
+wxBrush* g_oglWhiteBackgroundBrush;
+wxPen* g_oglBlackForegroundPen;
+wxCursor* g_oglBullseyeCursor = NULL;
-wxPen *black_pen;
-wxPen *white_background_pen;
-wxPen *transparent_pen;
-wxBrush *white_background_brush;
-wxPen *black_foreground_pen;
+char* oglBuffer = NULL;
-char *GraphicsBuffer = NULL;
-wxCursor *GraphicsBullseyeCursor = NULL;
-
-wxList wxObjectCopyMapping(wxKEY_INTEGER);
+wxList oglObjectCopyMapping(wxKEY_INTEGER);
void wxOGLInitialize()
{
- GraphicsBullseyeCursor = new wxCursor(wxCURSOR_BULLSEYE);
+ g_oglBullseyeCursor = new wxCursor(wxCURSOR_BULLSEYE);
g_oglNormalFont = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
- black_pen = new wxPen("BLACK", 1, wxSOLID);
+ g_oglBlackPen = new wxPen("BLACK", 1, wxSOLID);
- white_background_pen = new wxPen("WHITE", 1, wxSOLID);
- transparent_pen = new wxPen("WHITE", 1, wxTRANSPARENT);
- white_background_brush = new wxBrush("WHITE", wxSOLID);
- black_foreground_pen = new wxPen("BLACK", 1, wxSOLID);
+ g_oglWhiteBackgroundPen = new wxPen("WHITE", 1, wxSOLID);
+ g_oglTransparentPen = new wxPen("WHITE", 1, wxTRANSPARENT);
+ g_oglWhiteBackgroundBrush = new wxBrush("WHITE", wxSOLID);
+ g_oglBlackForegroundPen = new wxPen("BLACK", 1, wxSOLID);
OGLInitializeConstraintTypes();
// Initialize big buffer used when writing images
- GraphicsBuffer = new char[3000];
+ oglBuffer = new char[3000];
if (!oglPopupDivisionMenu)
{
void wxOGLCleanUp()
{
- if (GraphicsBuffer)
+ if (oglBuffer)
{
- delete[] GraphicsBuffer;
- GraphicsBuffer = NULL;
+ delete[] oglBuffer;
+ oglBuffer = NULL;
}
- GraphicsBuffer = NULL;
+ oglBuffer = NULL;
if (oglPopupDivisionMenu)
{
delete oglPopupDivisionMenu;
oglPopupDivisionMenu = NULL;
}
+ if (g_oglBullseyeCursor)
+ {
+ delete g_oglBullseyeCursor;
+ g_oglBullseyeCursor = NULL;
+ }
+
if (g_oglNormalFont)
{
delete g_oglNormalFont;
g_oglNormalFont = NULL;
}
- if (black_pen)
+ if (g_oglBlackPen)
{
- delete black_pen;
- black_pen = NULL;
+ delete g_oglBlackPen;
+ g_oglBlackPen = NULL;
}
- if (white_background_pen)
+ if (g_oglWhiteBackgroundPen)
{
- delete white_background_pen;
- white_background_pen = NULL;
+ delete g_oglWhiteBackgroundPen;
+ g_oglWhiteBackgroundPen = NULL;
}
- if (transparent_pen)
+ if (g_oglTransparentPen)
{
- delete transparent_pen;
- transparent_pen = NULL;
+ delete g_oglTransparentPen;
+ g_oglTransparentPen = NULL;
}
- if (white_background_brush)
+ if (g_oglWhiteBackgroundBrush)
{
- delete white_background_brush;
- white_background_brush = NULL;
+ delete g_oglWhiteBackgroundBrush;
+ g_oglWhiteBackgroundBrush = NULL;
}
- if (black_foreground_pen)
+ if (g_oglBlackForegroundPen)
{
- delete black_foreground_pen;
- black_foreground_pen = NULL;
+ delete g_oglBlackForegroundPen;
+ g_oglBlackForegroundPen = NULL;
}
OGLCleanUpConstraintTypes();
}
-wxFont *MatchFont(int point_size)
+wxFont *oglMatchFont(int point_size)
{
wxFont *font = wxTheFontList->FindOrCreateFont(point_size, wxSWISS, wxNORMAL, wxNORMAL);
#if 0
{
int size;
sscanf(ans, "%d", &size);
- return MatchFont(size);
+ return oglMatchFont(size);
}
else return NULL;
*/
// Centre a list of strings in the given box. xOffset and yOffset are the
// the positions that these lines should be relative to, and this might be
// the same as m_xpos, m_ypos, but might be zero if formatting from left-justifying.
-void CentreText(wxDC& dc, wxList *text_list,
- float m_xpos, float m_ypos, float width, float height,
+void oglCentreText(wxDC& dc, wxList *text_list,
+ double m_xpos, double m_ypos, double width, double height,
int formatMode)
{
int n = text_list->Number();
// First, get maximum dimensions of box enclosing text
- float char_height = 0;
- float max_width = 0;
- float current_width = 0;
+ long char_height = 0;
+ long max_width = 0;
+ long current_width = 0;
// Store text extents for speed
- float *widths = new float[n];
+ double *widths = new double[n];
wxNode *current = text_list->First();
int i = 0;
i ++;
}
- float max_height = n*char_height;
+ double max_height = n*char_height;
- float xoffset, yoffset, xOffset, yOffset;
+ double xoffset, yoffset, xOffset, yOffset;
if (formatMode & FORMAT_CENTRE_VERT)
{
if (max_height < height)
- yoffset = (float)(m_ypos - (height/2.0) + (height - max_height)/2.0);
+ yoffset = (double)(m_ypos - (height/2.0) + (height - max_height)/2.0);
else
- yoffset = (float)(m_ypos - (height/2.0));
+ yoffset = (double)(m_ypos - (height/2.0));
yOffset = m_ypos;
}
else
if (formatMode & FORMAT_CENTRE_HORIZ)
{
- xoffset = (float)(m_xpos - width/2.0);
+ xoffset = (double)(m_xpos - width/2.0);
xOffset = m_xpos;
}
else
{
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
- float x;
+ double x;
if ((formatMode & FORMAT_CENTRE_HORIZ) && (widths[i] < width))
- x = (float)((width - widths[i])/2.0 + xoffset);
+ x = (double)((width - widths[i])/2.0 + xoffset);
else
x = xoffset;
- float y = (float)(i*char_height + yoffset);
+ double y = (double)(i*char_height + yoffset);
line->SetX( x - xOffset ); line->SetY( y - yOffset );
current = current->Next();
}
// Centre a list of strings in the given box
-void CentreTextNoClipping(wxDC& dc, wxList *text_list,
- float m_xpos, float m_ypos, float width, float height)
+void oglCentreTextNoClipping(wxDC& dc, wxList *text_list,
+ double m_xpos, double m_ypos, double width, double height)
{
int n = text_list->Number();
// First, get maximum dimensions of box enclosing text
- float char_height = 0;
- float max_width = 0;
- float current_width = 0;
+ long char_height = 0;
+ long max_width = 0;
+ long current_width = 0;
// Store text extents for speed
- float *widths = new float[n];
+ double *widths = new double[n];
wxNode *current = text_list->First();
int i = 0;
i ++;
}
- float max_height = n*char_height;
+ double max_height = n*char_height;
- float yoffset = (float)(m_ypos - (height/2.0) + (height - max_height)/2.0);
+ double yoffset = (double)(m_ypos - (height/2.0) + (height - max_height)/2.0);
- float xoffset = (float)(m_xpos - width/2.0);
+ double xoffset = (double)(m_xpos - width/2.0);
current = text_list->First();
i = 0;
{
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
- float x = (float)((width - widths[i])/2.0 + xoffset);
- float y = (float)(i*char_height + yoffset);
+ double x = (double)((width - widths[i])/2.0 + xoffset);
+ double y = (double)(i*char_height + yoffset);
line->SetX( x - m_xpos ); line->SetY( y - m_ypos );
current = current->Next();
delete widths;
}
-void GetCentredTextExtent(wxDC& dc, wxList *text_list,
- float m_xpos, float m_ypos, float width, float height,
- float *actual_width, float *actual_height)
+void oglGetCentredTextExtent(wxDC& dc, wxList *text_list,
+ double m_xpos, double m_ypos, double width, double height,
+ double *actual_width, double *actual_height)
{
int n = text_list->Number();
// First, get maximum dimensions of box enclosing text
- float char_height = 0;
- float max_width = 0;
- float current_width = 0;
+ long char_height = 0;
+ long max_width = 0;
+ long current_width = 0;
wxNode *current = text_list->First();
int i = 0;
// Format a string to a list of strings that fit in the given box.
// Interpret %n and 10 or 13 as a new line.
-wxList *FormatText(wxDC& dc, const wxString& text, float width, float height, int formatMode)
+wxStringList *oglFormatText(wxDC& dc, const wxString& text, double width, double height, int formatMode)
{
// First, parse the string into a list of words
- wxList word_list;
+ wxStringList word_list;
// Make new lines into NULL strings at this point
int i = 0; int j = 0; int len = strlen(text);
}
}
// Now, make a list of strings which can fit in the box
- wxList *string_list = new wxList;
+ wxStringList *string_list = new wxStringList;
char buffer[400];
buffer[0] = 0;
wxNode *node = word_list.First();
- float x, y;
+ long x, y;
while (node)
{
- char *keep_string = copystring(buffer);
+ wxString oldBuffer(buffer);
char *s = (char *)node->Data();
if (!s)
{
// FORCE NEW LINE
- if (strlen(keep_string) > 0)
- string_list->Append((wxObject *)keep_string);
- else
- delete[] keep_string;
+ if (strlen(buffer) > 0)
+ string_list->Add(buffer);
buffer[0] = 0;
}
if ((x > width) && !(formatMode & FORMAT_SIZE_TO_CONTENTS))
{
// Deal with first word being wider than box
- if (strlen(keep_string) > 0)
- string_list->Append((wxObject *)keep_string);
- else
- delete[] keep_string;
+ if (oldBuffer.Length() > 0)
+ string_list->Add(oldBuffer);
buffer[0] = 0;
strcat(buffer, s);
- delete[] s;
}
- else
- delete[] keep_string;
}
node = node->Next();
}
if (buffer[0] != 0)
- string_list->Append((wxObject *)copystring(buffer));
+ string_list->Add(buffer);
return string_list;
}
-void DrawFormattedText(wxDC& dc, wxList *text_list,
- float m_xpos, float m_ypos, float width, float height,
+void oglDrawFormattedText(wxDC& dc, wxList *text_list,
+ double m_xpos, double m_ypos, double width, double height,
int formatMode)
{
- float xoffset, yoffset;
+ double xoffset, yoffset;
if (formatMode & FORMAT_CENTRE_HORIZ)
xoffset = m_xpos;
else
- xoffset = (float)(m_xpos - (width / 2.0));
+ xoffset = (double)(m_xpos - (width / 2.0));
if (formatMode & FORMAT_CENTRE_VERT)
yoffset = m_ypos;
else
- yoffset = (float)(m_ypos - (height / 2.0));
+ yoffset = (double)(m_ypos - (height / 2.0));
dc.SetClippingRegion(
- (float)(m_xpos - width/2.0), (float)(m_ypos - height/2.0),
- (float)width, (float)height);
+ (double)(m_xpos - width/2.0), (double)(m_ypos - height/2.0),
+ (double)width, (double)height);
wxNode *current = text_list->First();
while (current)
{
wxShapeTextLine *line = (wxShapeTextLine *)current->Data();
- dc.DrawText(line->GetText(), xoffset + line->GetX(), yoffset + line->GetY());
+ dc.DrawText(line->GetText(), WXROUND(xoffset + line->GetX()), WXROUND(yoffset + line->GetY()));
current = current->Next();
}
*
*/
-void find_polyline_centroid(wxList *points, float *x, float *y)
+void oglFindPolylineCentroid(wxList *points, double *x, double *y)
{
- float xcount = 0;
- float ycount = 0;
+ double xcount = 0;
+ double ycount = 0;
wxNode *node = points->First();
while (node)
* Used by functions below.
*
*/
-void check_line_intersection(float x1, float y1, float x2, float y2,
- float x3, float y3, float x4, float y4,
- float *ratio1, float *ratio2)
+void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
+ double x3, double y3, double x4, double y4,
+ double *ratio1, double *ratio2)
{
- float denominator_term = (y4 - y3)*(x2 - x1) - (y2 - y1)*(x4 - x3);
- float numerator_term = (x3 - x1)*(y4 - y3) + (x4 - x3)*(y1 - y3);
+ double denominator_term = (y4 - y3)*(x2 - x1) - (y2 - y1)*(x4 - x3);
+ double numerator_term = (x3 - x1)*(y4 - y3) + (x4 - x3)*(y1 - y3);
- float line_constant;
- float length_ratio = 1.0;
- float k_line = 1.0;
+ double line_constant;
+ double length_ratio = 1.0;
+ double k_line = 1.0;
// Check for parallel lines
if ((denominator_term < 0.005) && (denominator_term > -0.005))
* (*x3, *y3) is the point where it hits.
*
*/
-void find_end_for_polyline(float n, float xvec[], float yvec[],
- float x1, float y1, float x2, float y2, float *x3, float *y3)
+void oglFindEndForPolyline(double n, double xvec[], double yvec[],
+ double x1, double y1, double x2, double y2, double *x3, double *y3)
{
int i;
- float lastx = xvec[0];
- float lasty = yvec[0];
+ double lastx = xvec[0];
+ double lasty = yvec[0];
- float min_ratio = 1.0;
- float line_ratio;
- float other_ratio;
+ double min_ratio = 1.0;
+ double line_ratio;
+ double other_ratio;
for (i = 1; i < n; i++)
{
- check_line_intersection(x1, y1, x2, y2, lastx, lasty, xvec[i], yvec[i],
+ oglCheckLineIntersection(x1, y1, x2, y2, lastx, lasty, xvec[i], yvec[i],
&line_ratio, &other_ratio);
lastx = xvec[i];
lasty = yvec[i];
min_ratio = line_ratio;
}
- // Do last (implicit) line if last and first floats are not identical
+ // Do last (implicit) line if last and first doubles are not identical
if (!(xvec[0] == lastx && yvec[0] == lasty))
{
- check_line_intersection(x1, y1, x2, y2, lastx, lasty, xvec[0], yvec[0],
+ oglCheckLineIntersection(x1, y1, x2, y2, lastx, lasty, xvec[0], yvec[0],
&line_ratio, &other_ratio);
if (line_ratio < min_ratio)
*
*/
-void find_end_for_box(float width, float height,
- float x1, float y1, // Centre of box (possibly)
- float x2, float y2, // other end of line
- float *x3, float *y3) // End on box edge
+void oglFindEndForBox(double width, double height,
+ double x1, double y1, // Centre of box (possibly)
+ double x2, double y2, // other end of line
+ double *x3, double *y3) // End on box edge
{
- float xvec[5];
- float yvec[5];
-
- xvec[0] = (float)(x1 - width/2.0);
- yvec[0] = (float)(y1 - height/2.0);
- xvec[1] = (float)(x1 - width/2.0);
- yvec[1] = (float)(y1 + height/2.0);
- xvec[2] = (float)(x1 + width/2.0);
- yvec[2] = (float)(y1 + height/2.0);
- xvec[3] = (float)(x1 + width/2.0);
- yvec[3] = (float)(y1 - height/2.0);
- xvec[4] = (float)(x1 - width/2.0);
- yvec[4] = (float)(y1 - height/2.0);
-
- find_end_for_polyline(5, xvec, yvec, x2, y2, x1, y1, x3, y3);
+ double xvec[5];
+ double yvec[5];
+
+ xvec[0] = (double)(x1 - width/2.0);
+ yvec[0] = (double)(y1 - height/2.0);
+ xvec[1] = (double)(x1 - width/2.0);
+ yvec[1] = (double)(y1 + height/2.0);
+ xvec[2] = (double)(x1 + width/2.0);
+ yvec[2] = (double)(y1 + height/2.0);
+ xvec[3] = (double)(x1 + width/2.0);
+ yvec[3] = (double)(y1 - height/2.0);
+ xvec[4] = (double)(x1 - width/2.0);
+ yvec[4] = (double)(y1 - height/2.0);
+
+ oglFindEndForPolyline(5, xvec, yvec, x2, y2, x1, y1, x3, y3);
}
/*
*
*/
-void find_end_for_circle(float radius,
- float x1, float y1, // Centre of circle
- float x2, float y2, // Other end of line
- float *x3, float *y3)
+void oglFindEndForCircle(double radius,
+ double x1, double y1, // Centre of circle
+ double x2, double y2, // Other end of line
+ double *x3, double *y3)
{
- float H = (float)sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
+ double H = (double)sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
if (H == 0.0)
{
*
*/
-void get_arrow_points(float x1, float y1, float x2, float y2,
- float length, float width,
- float *tip_x, float *tip_y,
- float *side1_x, float *side1_y,
- float *side2_x, float *side2_y)
+void oglGetArrowPoints(double x1, double y1, double x2, double y2,
+ double length, double width,
+ double *tip_x, double *tip_y,
+ double *side1_x, double *side1_y,
+ double *side2_x, double *side2_y)
{
- float l = (float)sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
+ double l = (double)sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
if (l < 0.01)
- l = (float) 0.01;
+ l = (double) 0.01;
- float i_bar = (x2 - x1)/l;
- float j_bar = (y2 - y1)/l;
+ double i_bar = (x2 - x1)/l;
+ double j_bar = (y2 - y1)/l;
- float x3 = (- length*i_bar) + x2;
- float y3 = (- length*j_bar) + y2;
+ double x3 = (- length*i_bar) + x2;
+ double y3 = (- length*j_bar) + y2;
*side1_x = width*(-j_bar) + x3;
*side1_y = width*i_bar + y3;
* Author: Ian Harrison
*/
-void draw_arc_to_ellipse(float x1, float y1, float width1, float height1, float x2, float y2, float x3, float y3,
- float *x4, float *y4)
+void oglDrawArcToEllipse(double x1, double y1, double width1, double height1, double x2, double y2, double x3, double y3,
+ double *x4, double *y4)
{
- float a1 = (float)(width1/2.0);
- float b1 = (float)(height1/2.0);
+ double a1 = (double)(width1/2.0);
+ double b1 = (double)(height1/2.0);
// These are required to give top left x and y coordinates for DrawEllipse
-// float top_left_x1 = (float)(x1 - a1);
-// float top_left_y1 = (float)(y1 - b1);
+// double top_left_x1 = (double)(x1 - a1);
+// double top_left_y1 = (double)(y1 - b1);
/*
// Check for vertical line
if (fabs(x2 - x3) < 0.05)
{
*x4 = x3;
if (y2 < y3)
- *y4 = (float)(y1 - b1);
+ *y4 = (double)(y1 - b1);
else
- *y4 = (float)(y1 + b1);
+ *y4 = (double)(y1 + b1);
return;
}
*/
{
*x4 = x2;
if (y3 > y2)
- *y4 = (float)(y1 - sqrt((b1*b1 - (((x2-x1)*(x2-x1))*(b1*b1)/(a1*a1)))));
+ *y4 = (double)(y1 - sqrt((b1*b1 - (((x2-x1)*(x2-x1))*(b1*b1)/(a1*a1)))));
else
- *y4 = (float)(y1 + sqrt((b1*b1 - (((x2-x1)*(x2-x1))*(b1*b1)/(a1*a1)))));
+ *y4 = (double)(y1 + sqrt((b1*b1 - (((x2-x1)*(x2-x1))*(b1*b1)/(a1*a1)))));
return;
}
// Calculate the x and y coordinates of the point where arc intersects ellipse
- float A, B, C, D, E, F, G, H, K;
- float ellipse1_x, ellipse1_y;
+ double A, B, C, D, E, F, G, H, K;
+ double ellipse1_x, ellipse1_y;
- A = (float)(1/(a1 * a1));
- B = (float)((y3 - y2) * (y3 - y2)) / ((x3 - x2) * (x3 - x2) * b1 * b1);
- C = (float)(2 * (y3 - y2) * (y2 - y1)) / ((x3 - x2) * b1 * b1);
- D = (float)((y2 - y1) * (y2 - y1)) / (b1 * b1);
- E = (float)(A + B);
- F = (float)(C - (2 * A * x1) - (2 * B * x2));
- G = (float)((A * x1 * x1) + (B * x2 * x2) - (C * x2) + D - 1);
- H = (float)((y3 - y2) / (x3 - x2));
- K = (float)((F * F) - (4 * E * G));
+ A = (double)(1/(a1 * a1));
+ B = (double)((y3 - y2) * (y3 - y2)) / ((x3 - x2) * (x3 - x2) * b1 * b1);
+ C = (double)(2 * (y3 - y2) * (y2 - y1)) / ((x3 - x2) * b1 * b1);
+ D = (double)((y2 - y1) * (y2 - y1)) / (b1 * b1);
+ E = (double)(A + B);
+ F = (double)(C - (2 * A * x1) - (2 * B * x2));
+ G = (double)((A * x1 * x1) + (B * x2 * x2) - (C * x2) + D - 1);
+ H = (double)((y3 - y2) / (x3 - x2));
+ K = (double)((F * F) - (4 * E * G));
if (K >= 0)
// In this case the line intersects the ellipse, so calculate intersection
{
if(x2 >= x1)
{
- ellipse1_x = (float)(((F * -1) + sqrt(K)) / (2 * E));
- ellipse1_y = (float)((H * (ellipse1_x - x2)) + y2);
+ ellipse1_x = (double)(((F * -1) + sqrt(K)) / (2 * E));
+ ellipse1_y = (double)((H * (ellipse1_x - x2)) + y2);
}
else
{
- ellipse1_x = (float)(((F * -1) - sqrt(K)) / (2 * E));
- ellipse1_y = (float)((H * (ellipse1_x - x2)) + y2);
+ ellipse1_x = (double)(((F * -1) - sqrt(K)) / (2 * E));
+ ellipse1_y = (double)((H * (ellipse1_x - x2)) + y2);
}
}
else
// Draw a little circle (radius = 2) at the end of the arc where it hits
// the ellipse .
- float circle_x = ellipse1_x - 2.0;
- float circle_y = ellipse1_y - 2.0;
+ double circle_x = ellipse1_x - 2.0;
+ double circle_y = ellipse1_y - 2.0;
m_canvas->DrawEllipse(circle_x, circle_y, 4.0, 4.0);
*/
}
}
}
+bool oglRoughlyEqual(double val1, double val2, double tol)
+{
+ return ( (val1 < (val2 + tol)) && (val1 > (val2 - tol)) &&
+ (val2 < (val1 + tol)) && (val2 > (val1 - tol)));
+}
+
/*
* Hex<->Dec conversion
*/
// List to use when copying objects; may need to associate elements of new objects
// with elements of old objects, e.g. when copying constraint.s
-extern wxList wxObjectCopyMapping;
+extern wxList oglObjectCopyMapping;
/*
* TEXT FORMATTING FUNCTIONS
// Centres the given list of wxShapeTextLine strings in the given box
// (changing the positions in situ). Doesn't actually draw into the DC.
-void CentreText(wxDC& dc, wxList *text, float m_xpos, float m_ypos,
- float width, float height,
+void oglCentreText(wxDC& dc, wxList *text, double m_xpos, double m_ypos,
+ double width, double height,
int formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT);
// Given a string, returns a list of strings that fit within the given
// width of box. Height is ignored.
-wxList *FormatText(wxDC& dc, const wxString& text, float width, float height, int formatMode = 0);
+wxStringList *oglFormatText(wxDC& dc, const wxString& text, double width, double height, int formatMode = 0);
// Centres the list of wxShapeTextLine strings, doesn't clip.
// Doesn't actually draw into the DC.
-void CentreTextNoClipping(wxDC& dc, wxList *text_list,
- float m_xpos, float m_ypos, float width, float height);
+void oglCentreTextNoClipping(wxDC& dc, wxList *text_list,
+ double m_xpos, double m_ypos, double width, double height);
// Gets the maximum width and height of the given list of wxShapeTextLines.
-void GetCentredTextExtent(wxDC& dc, wxList *text_list,
- float m_xpos, float m_ypos, float width, float height,
- float *actual_width, float *actual_height);
+void oglGetCentredTextExtent(wxDC& dc, wxList *text_list,
+ double m_xpos, double m_ypos, double width, double height,
+ double *actual_width, double *actual_height);
// Actually draw the preformatted list of wxShapeTextLines.
-void DrawFormattedText(wxDC& context, wxList *text_list,
- float m_xpos, float m_ypos, float width, float height,
+void oglDrawFormattedText(wxDC& context, wxList *text_list,
+ double m_xpos, double m_ypos, double width, double height,
int formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT);
// Give it a list of points, finds the centre.
-void find_polyline_centroid(wxList *points, float *x, float *y);
+void oglFindPolylineCentroid(wxList *points, double *x, double *y);
-void check_line_intersection(float x1, float y1, float x2, float y2,
- float x3, float y3, float x4, float y4,
- float *ratio1, float *ratio2);
+void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
+ double x3, double y3, double x4, double y4,
+ double *ratio1, double *ratio2);
-void find_end_for_polyline(float n, float xvec[], float yvec[],
- float x1, float y1, float x2, float y2, float *x3, float *y3);
+void oglFindEndForPolyline(double n, double xvec[], double yvec[],
+ double x1, double y1, double x2, double y2, double *x3, double *y3);
-void find_end_for_box(float width, float height,
- float x1, float y1, // Centre of box (possibly)
- float x2, float y2, // other end of line
- float *x3, float *y3); // End on box edge
+void oglFindEndForBox(double width, double height,
+ double x1, double y1, // Centre of box (possibly)
+ double x2, double y2, // other end of line
+ double *x3, double *y3); // End on box edge
-void find_end_for_circle(float radius,
- float x1, float y1, // Centre of circle
- float x2, float y2, // Other end of line
- float *x3, float *y3);
+void oglFindEndForCircle(double radius,
+ double x1, double y1, // Centre of circle
+ double x2, double y2, // Other end of line
+ double *x3, double *y3);
-void get_arrow_points(float x1, float y1, float x2, float y2,
- float length, float width,
- float *tip_x, float *tip_y,
- float *side1_x, float *side1_y,
- float *side2_x, float *side2_y);
+void oglGetArrowPoints(double x1, double y1, double x2, double y2,
+ double length, double width,
+ double *tip_x, double *tip_y,
+ double *side1_x, double *side1_y,
+ double *side2_x, double *side2_y);
/*
* Given an ellipse and endpoints of a line, returns the point at which
* Author: Ian Harrison
*/
-void draw_arc_to_ellipse(float x1, float y1, float a1, float b1, float x2, float y2, float x3, float y3,
- float *x4, float *y4);
+void oglDrawArcToEllipse(double x1, double y1, double a1, double b1, double x2, double y2, double x3, double y3,
+ double *x4, double *y4);
-extern wxFont *g_oglNormalFont;
-extern wxPen *black_pen;
+bool oglRoughlyEqual(double val1, double val2, double tol = 0.00001);
-extern wxPen *white_background_pen;
-extern wxPen *transparent_pen;
-extern wxBrush *white_background_brush;
-extern wxPen *black_foreground_pen;
+extern wxFont* g_oglNormalFont;
+extern wxPen* g_oglBlackPen;
+extern wxPen* g_oglWhiteBackgroundPen;
+extern wxPen* g_oglTransparentPen;
+extern wxBrush* g_oglWhiteBackgroundBrush;
+extern wxPen* g_oglBlackForegroundPen;
+extern wxCursor* g_oglBullseyeCursor;
-extern wxCursor *GraphicsBullseyeCursor;
+extern wxFont* oglMatchFont(int point_size);
-extern wxFont *MatchFont(int point_size);
-
-extern wxString oglColourToHex(const wxColour& colour);
-extern wxColour oglHexToColour(const wxString& hex);
-extern void oglDecToHex(unsigned int dec, char *buf);
-extern unsigned int oglHexToDec(char* buf);
+extern wxString oglColourToHex(const wxColour& colour);
+extern wxColour oglHexToColour(const wxString& hex);
+extern void oglDecToHex(unsigned int dec, char *buf);
+extern unsigned int oglHexToDec(char* buf);
#endif
m_snapToGrid = snap;
}
-void wxDiagram::SetGridSpacing(float spacing)
+void wxDiagram::SetGridSpacing(double spacing)
{
m_gridSpacing = spacing;
}
-void wxDiagram::Snap(float *x, float *y)
+void wxDiagram::Snap(double *x, double *y)
{
if (m_snapToGrid)
{
}
}
-void wxDiagram::DrawOutline(wxDC& dc, float x1, float y1, float x2, float y2)
+void wxDiagram::DrawOutline(wxDC& dc, double x1, double y1, double x2, double y2)
{
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
dc.SetPen(dottedPen);
virtual void Redraw(wxDC& dc);
virtual void Clear(wxDC& dc);
- virtual void DrawOutline(wxDC& dc, float x1, float y1, float x2, float y2);
+ virtual void DrawOutline(wxDC& dc, double x1, double y1, double x2, double y2);
// Add object to end of object list (if addAfter is NULL)
// or just after addAfter.
virtual void InsertShape(wxShape *object);
void SetSnapToGrid(bool snap);
- void SetGridSpacing(float spacing);
- inline float GetGridSpacing() { return m_gridSpacing; }
+ void SetGridSpacing(double spacing);
+ inline double GetGridSpacing() { return m_gridSpacing; }
inline bool GetSnapToGrid() const { return m_snapToGrid; }
- void Snap(float *x, float *y);
+ void Snap(double *x, double *y);
inline void SetQuickEditMode(bool qem) { m_quickEditMode = qem; }
inline bool GetQuickEditMode() const { return m_quickEditMode; }
wxShapeCanvas* m_diagramCanvas;
bool m_quickEditMode;
bool m_snapToGrid;
- float m_gridSpacing;
+ double m_gridSpacing;
int m_mouseTolerance;
wxList* m_shapeList;
};