Original Post
Dear All, I really can't figure out what is going on with this piece of code. It gives an access violation in a list of double's, XAxisValues, whenever I try to add something to it. I have two similar lists, and they do exactly what I want them to. please help me with this one, I'm getting frustrated :( ; [Edited by - twoaterisn on May 10, 2010 5:51:14 AM]
//IRPanel.h
#include <wx/wx.h>
#include <list>;
class IRPanel : public wxPanel
{
public:
IRPanel(wxWindow* parent);
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent & event);
void CalcAxisValues();
private:
wxString XLabel;
wxString YLabel;
std::list<double> XAxisValues;
std::list<double> YAxisValues;
std::list<wxString> XAxisLabels;
std::list<wxString> YAxislabels;
std::list<int> XAxisLabelsXPos;
std::list<int> YAxisLabelsYPos;
int XAxisLabelsYPos;
int YAxisLabelsXPos;
int ClientWidth, ClientHeighth;
int XLabelLength, XLabelHeighth,YLabelWidth, YLabelHeighth,LabelSpacer,AxisSpacer,NumXLabels;
int AxisLabelFontSize, AxisValuesFontSize, AxisArrowSize;
double FirstX,LastX,MinX,MaxX,FirstY,LastY,MinY,MaxY, XDif, YDif, AbsXDif, AbsYDif;
};
//IRPanel.cpp, only constructor for now
#include "IRPanel.h"
IRPanel::IRPanel(wxWindow* parent)
: wxPanel (parent, wxID_ANY,wxDefaultPosition, wxDefaultSize,wxFULL_REPAINT_ON_RESIZE,wxT(""))
{
this->Connect(wxEVT_PAINT, wxPaintEventHandler(IRPanel::OnPaint));
this->Connect(wxEVT_SIZE, wxSizeEventHandler(IRPanel::OnSize));
XLabel=wxT("X-Label");
YLabel=wxT("Y-Label");
GetTextExtent(XLabel, &XLabelLength, &XLabelHeighth,(int*)0, (int*)0,wxSWISS_FONT);
GetTextExtent(YLabel, &YLabelWidth, &YLabelHeighth,(int*)0, (int*)0,wxSWISS_FONT);
LabelSpacer=5;
AxisSpacer=2*YLabelHeighth+3*LabelSpacer; //distance of axis to window border
AxisLabelFontSize=10;
AxisValuesFontSize=10;
AxisArrowSize=5;
FirstX=-1400;
LastX=400;
MinX=0;
MaxX=1;
FirstY=0;
LastY=1;
MinY=0;
MaxY=100;
XAxisValues.push_back(FirstX); //here it all goes wrong
XAxisLabels.push_back(wxT("label"));//this works!
XAxisLabelsXPos.push_back(AxisSpacer);//this too.
}