wxOutputStream& DiagramDocument::SaveObject(wxOutputStream& stream)
{
+#if wxUSE_PROLOGIO
+
wxDocument::SaveObject(stream);
char buf[400];
(void) wxGetTempFileName("diag", buf);
wxTransferFileToStream(buf, stream);
wxRemoveFile(buf);
-
+
+#endif
return stream;
}
wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream)
{
+#if wxUSE_PROLOGIO
wxDocument::LoadObject(stream);
-
char buf[400];
(void) wxGetTempFileName("diag", buf);
diagram.DeleteAllShapes();
diagram.LoadFile(buf);
wxRemoveFile(buf);
+#endif
return stream;
}
/*
* Diagram
*/
+
+#if wxUSE_PROLOGIO
bool MyDiagram::OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr)
{
return TRUE;
}
+#endif
+
/*
* New shapes
*/
#include <wx/string.h>
#include <wx/deprecated/setup.h>
+
+#if wxUSE_PROLOGIO
#include <wx/deprecated/wxexpr.h>
+#endif
+
#include <wx/ogl/ogl.h>
#if wxUSE_STD_IOSTREAM
{
public:
MyDiagram(void) {}
+#if wxUSE_PROLOGIO
bool OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
bool OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
+#endif
};
/*
# End Source File
# Begin Source File
-SOURCE=.\misc.cpp
+SOURCE=.\ogldiag.cpp
# End Source File
# Begin Source File
-SOURCE=.\ogldiag.cpp
+SOURCE=.\oglmisc.cpp
# End Source File
# End Target
# End Project
{
// Don't preserve old ordering if we have new ordering instructions
m_lines.DeleteObject(line);
- if (positionFrom < m_lines.GetCount())
+ if (positionFrom < (int) m_lines.GetCount())
{
wxNode* node = m_lines.Item(positionFrom);
m_lines.Insert(node, line);
{
// Don't preserve old ordering if we have new ordering instructions
other->m_lines.DeleteObject(line);
- if (positionTo < other->m_lines.GetCount())
+ if (positionTo < (int) other->m_lines.GetCount())
{
wxNode* node = other->m_lines.Item(positionTo);
other->m_lines.Insert(node, line);
// Return the zero-based position in m_lines of line.
int wxShape::GetLinePosition(wxLineShape* line)
{
- int i = 0;
+ size_t i = 0;
for (i = 0; i < m_lines.GetCount(); i++)
if ((wxLineShape*) (m_lines.Item(i)->GetData()) == line)
return i;
double y = (double)((secondPoint->y - firstPoint->y)/2.0 + firstPoint->y);
wxRealPoint *point = new wxRealPoint(x, y);
- if (pos >= (m_points->GetCount() - 1))
+ if (pos >= (int) (m_points->GetCount() - 1))
m_points->Append((wxObject*) point);
else
m_points->Insert(node2, (wxObject*) point);
bool wxPolygonShape::GetAttachmentPosition(int attachment, double *x, double *y,
int nth, int no_arcs, wxLineShape *line)
{
- if ((m_attachmentMode == ATTACHMENT_MODE_EDGE) && m_points && attachment < m_points->GetCount())
+ if ((m_attachmentMode == ATTACHMENT_MODE_EDGE) && m_points && attachment < (int) m_points->GetCount())
{
wxRealPoint *point = (wxRealPoint *)m_points->Item(attachment)->GetData();
*x = point->x + m_xpos;
if (!m_points)
return FALSE;
- if ((attachment >= 0) && (attachment < m_points->GetCount()))
+ if ((attachment >= 0) && (attachment < (int) m_points->GetCount()))
return TRUE;
wxNode *node = m_attachmentPoints.GetFirst();
wxRealPoint *point1 = (wxRealPoint *)node->GetData();
wxRealPoint *point2 = (wxRealPoint *)node->GetNext()->GetData();
- // Allow for inaccurate mousing or vert/horiz lines
+ // For inaccurate mousing allow 8 pixel corridor
int extra = 4;
- double left = wxMin(point1->x, point2->x) - extra;
- double right = wxMax(point1->x, point2->x) + 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)
+ double dx = point2->x - point1->x;
+ double dy = point2->y - point1->y;
+ double seg_len = sqrt(dx*dx+dy*dy);
+ double distance_from_seg =
+ seg_len*((x-point1->x)*dy-(y-point1->y)*dx)/(dy*dy+dx*dx);
+ double distance_from_prev =
+ seg_len*((y-point1->y)*dy+(x-point1->x)*dx)/(dy*dy+dx*dx);
+
+ if ((fabs(distance_from_seg) < extra &&
+ distance_from_prev >= 0 && distance_from_prev <= seg_len)
+ || inLabelRegion)
{
- // Work out distance from centre of line
- double centre_x = (double)(left + (right - left)/2.0);
- double centre_y = (double)(bottom + (top - bottom)/2.0);
-
*attachment = 0;
- *distance = (double)sqrt((centre_x - x)*(centre_x - x) + (centre_y - y)*(centre_y - y));
+ *distance = distance_from_seg;
return TRUE;
}
wxLineShape* lineShape1 = (wxLineShape*) shape1;
// Iterate through the segments
wxList* pts1 = lineShape1->GetLineControlPoints();
- int i;
+ size_t i;
for (i = 0; i < (pts1->GetCount() - 1); i++)
{
wxRealPoint* pt1_a = (wxRealPoint*) (pts1->Item(i)->GetData());
// Iterate through the segments
wxList* pts2 = lineShape2->GetLineControlPoints();
int j;
- for (j = 0; j < (pts2->GetCount() - 1); j++)
+ for (j = 0; j < (int) (pts2->GetCount() - 1); j++)
{
wxRealPoint* pt2_a = (wxRealPoint*) (pts2->Item(j)->GetData());
wxRealPoint* pt2_b = (wxRealPoint*) (pts2->Item(j+1)->GetData());