The first thing I found was using the SetAxisOrientation function before any function call inside wxMathplot's GDI function call.
So, I did some test, here is the test code:
Code: Select all
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/dcclient.h>
#include <wx/dcbuffer.h>
class Drawing1Frame : public wxFrame
{
public:
Drawing1Frame(const wxString& title);
private:
void OnPaint(wxPaintEvent& evt);
wxDECLARE_EVENT_TABLE();
};
wxBEGIN_EVENT_TABLE(Drawing1Frame, wxFrame)
EVT_PAINT(Drawing1Frame::OnPaint)
wxEND_EVENT_TABLE()
class Drawing1App : public wxApp
{
public:
virtual bool OnInit();
};
wxIMPLEMENT_APP(Drawing1App);
bool Drawing1App::OnInit()
{
Drawing1Frame* frame = new Drawing1Frame("Drawing1");
frame->Show(true);
return true;
}
Drawing1Frame::Drawing1Frame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600), wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|wxFULL_REPAINT_ON_RESIZE)
{
SetBackgroundColour(*wxWHITE);
}
void Drawing1Frame::OnPaint(wxPaintEvent& evt)
{
//wxPaintDC bufDC(this);
wxBufferedPaintDC bufDC(this);
PrepareDC(bufDC);
bufDC.SetDeviceOrigin( bufDC.GetSize().GetWidth()/2, bufDC.GetSize().GetHeight()/2);
//bufDC.SetLogicalOrigin(400, 400);
bufDC.SetAxisOrientation(false, false);
//bufDC.SetUserScale(1.0, 1.0);
//bufDC.SetMapMode(wxMM_TEXT);
bufDC.SetBackgroundMode(wxBRUSHSTYLE_SOLID);
bufDC.Clear();
bufDC.SetBrush(*wxTRANSPARENT_BRUSH);
bufDC.SetPen(*wxRED_PEN);
/// draw red rectangle
bufDC.DrawRectangle(50, 50, 200, 100);
/// draw blue rectangle
bufDC.SetPen(*wxBLUE_PEN);
bufDC.DrawRectangle(100, 100, 250, 150);
}
Any idea how to make a reversed Y axis on wxMathplot control?
Thanks.