Applied patch [ 774837 ] OGL wxLineShape::HitTest: smaller region
Also fixed .dsp file to reflect oglmisc.cpp name Fixed some warnings Added test for wxUSE_PROLOGIO git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22237 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
6ee3c06421
commit
1dde66dda6
@ -87,6 +87,8 @@ wxSTD istream& DiagramDocument::LoadObject(wxSTD istream& stream)
|
||||
|
||||
wxOutputStream& DiagramDocument::SaveObject(wxOutputStream& stream)
|
||||
{
|
||||
#if wxUSE_PROLOGIO
|
||||
|
||||
wxDocument::SaveObject(stream);
|
||||
char buf[400];
|
||||
(void) wxGetTempFileName("diag", buf);
|
||||
@ -96,16 +98,17 @@ wxOutputStream& DiagramDocument::SaveObject(wxOutputStream& stream)
|
||||
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);
|
||||
|
||||
@ -114,6 +117,7 @@ wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream)
|
||||
diagram.DeleteAllShapes();
|
||||
diagram.LoadFile(buf);
|
||||
wxRemoveFile(buf);
|
||||
#endif
|
||||
|
||||
return stream;
|
||||
}
|
||||
@ -546,6 +550,8 @@ void MyEvtHandler::OnEndSize(double x, double y)
|
||||
/*
|
||||
* Diagram
|
||||
*/
|
||||
|
||||
#if wxUSE_PROLOGIO
|
||||
|
||||
bool MyDiagram::OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr)
|
||||
{
|
||||
@ -568,6 +574,8 @@ bool MyDiagram::OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* New shapes
|
||||
*/
|
||||
|
@ -21,7 +21,11 @@
|
||||
#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
|
||||
@ -36,8 +40,10 @@ class MyDiagram: public wxDiagram
|
||||
{
|
||||
public:
|
||||
MyDiagram(void) {}
|
||||
#if wxUSE_PROLOGIO
|
||||
bool OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
|
||||
bool OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -124,11 +124,11 @@ SOURCE=.\mfutils.cpp
|
||||
# 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
|
||||
|
@ -1621,7 +1621,7 @@ void wxShape::AddLine(wxLineShape *line, wxShape *other,
|
||||
{
|
||||
// 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);
|
||||
@ -1639,7 +1639,7 @@ void wxShape::AddLine(wxLineShape *line, wxShape *other,
|
||||
{
|
||||
// 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);
|
||||
@ -2904,7 +2904,7 @@ wxRealPoint wxShape::CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPo
|
||||
// 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;
|
||||
|
@ -396,7 +396,7 @@ void wxPolygonShape::AddPolygonPoint(int pos)
|
||||
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);
|
||||
@ -784,7 +784,7 @@ int wxPolygonShape::GetNumberOfAttachments() const
|
||||
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;
|
||||
@ -800,7 +800,7 @@ bool wxPolygonShape::AttachmentIsValid(int attachment) const
|
||||
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();
|
||||
|
@ -509,22 +509,23 @@ bool wxLineShape::HitTest(double x, double y, int *attachment, double *distance)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -613,7 +613,7 @@ void wxLineCrossings::FindCrossings(wxDiagram& diagram)
|
||||
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());
|
||||
@ -633,7 +633,7 @@ void wxLineCrossings::FindCrossings(wxDiagram& diagram)
|
||||
// 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());
|
||||
|
Loading…
Reference in New Issue
Block a user