wxOGL vs. wxArt2D

Well, like you probaly saw in a old post I was trying to use wxOGL and did some advance on it, but then in turn into wxArt2D and must say that if you want to do some drawing or ploting you must be in that path. My experience with wxArt2D has been good, the project is in actual development and you can get quickly answers from their mailing list. So take a look and use it, at least for me has worked.

You can download the wxArt2D package from http://wxart2d.sourceforge.net

February 7, 2007 at 9:33 am 2 comments

QCad Fluid Power Library

Hi all, I create a fluid power library for QCad based on the ISO1219 standard in the fluid power technology for the automation industry.

Here is a screeshot of what you can do:

QCad example

Another screenshot showing QCad and the library.

QCad screenshot

At the moment I can’t upload the file here. So please post here and I’ll send you the library. Bye.

January 27, 2007 at 12:20 pm Leave a comment

Adding a Lexer to wxStyledTextCtrl

This is my 2 days work to create a new lexer for wxStyledTextCtrl (wxSTC). The first think you should now is that wxSTC is a wrapper around a widely know text control named scintilla. So if you want to add a lexer you really are adding it to the scintilla distribution that wxSTC comes with.

There is this web page http://scintilla.sourceforge.net/SciTELexer.html where you can found how to add a lexer to scintilla and his Text Editing application called SciTE. The first step are basically the same.

You should have a $(wxDIR)/contrib/src/stc dir where you have all the thinks that goes with the control, I not a expert in this just I saw what I needed to add the lexer, in the documentation you will find more information. for the moment you shold go to that directory and follow the step. We supposed we’re adding some language call it foo.

1. So go to the scintilla/include dir and open the SciLexer.h file, ther you will add a ID value:
#define SCLEX_FOO=79, (supposed the last ID was 78)
And any lexical class IDs:
#define SCE_FOO_DEFAULT=0
#define SCE_FOO_COMMENT=1

2. Now you should add the ID value to stc.h locate in $(wxDIR)/contrib/include/wx/stc.
#define wxSTC_LEX_FOO 79 and
#define wxSTC_FOO_DEFAULT 0
#define wxSTC_FOO_COMMENT 1

I think you should be able to recognize a order in the file so you can do it that way.

3. In the scintilla/src/LexOthers.cxx write a ColouriseFooDoc function similar to one of the other functions such as ColouriseLatexDoc. For a more detailed guide open the file LexCpp.cxx and see the ColouriseCppDoc. What I did just to copy and paste that function and fit it to my needs.

LexerModule lmfoo(SCLEX_FOO, ColouriseFooDoc, “conf”);

4. If this is a complex lexer then it may be better off in its own file, in which case clone one of the current files and then add the file to all of the make files where LexOthers is currently referenced

5. You should be able to compile wxSTC and does all.

That was the steps I followed to get the lexer working, you should see this page to understand what the Colourise function does: [http://www.scintilla.org/Lexer.txt]

To get the lexer working we would modify the sample that comes with wxSTC, you should find it in $(wxDIR)/contrib/samples/stc, here what we need to do is to modify the prefs.cpp file, this contains all the preferences for the lexers:

1. If you have some Keywords you should added just follow the way C++ and Python does.

2. To the g_LanguagePrefs const add _T(“FOO”) with your definitions.

That’s all you should be able to compile the sample and select the Foo language from the View->Highlight Language->Foo

I hope that serves you.

January 26, 2007 at 3:23 am 1 comment

wxOGL

This is just a adaption from the one existing in wxPyWiki to the c++ language. It will include al least the information posted there and any other you will like to contributed. Some parts has been just copy-paste, my apologize if this violate some copyrights. Anyway I like to thanks the contributors from the wiki described above.

Status

Development Status

  • OGL development appears to be dead.
  • There does not appear to be OGL maintenance.
  • Object Graphics Library (OGL) is a C++ library supporting the creation and manipulation of simple and complex graphic images on a canvas. It can be found in the directory $WX_PATH/contrib/ogl/src in the wxWidgets distribution. The file ogl.h must be included to make use of the library.

    Documentation Status

    The standard OGL documentation is old and erronius.

  • http://biolpc22.york.ac.uk/wx/contrib/docs/html/ogl/ogl.htm
  • Standard OGL docs consist of:

  • class library documentation
  • notes
  • a complicated sample
  • This wiki entry is an effort to fix the situation.

    If you are using OGL, please post your notes and corrections to this wiki page..!

    Sample code

    Minimal wxOGL Application

    This is a minimal application demonstrating wxOGL, contributed by LionKimbro


    #include "wx/wx.h"
    #include "wx/ogl/ogl.h"class MyApp: public wxApp
    {
    virtual bool OnInit();
    };
    class MyFrame: public wxFrame
    {
    public:
    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
    };
    IMPLEMENT_APP(MyApp)
    bool MyApp::OnInit()
    {
    MyFrame *frame = new MyFrame( "wxWidgets - Object Graphics Library", wxPoint(50,50), wxSize(450,340) );
    frame->Show(TRUE);
    SetTopWindow(frame);
    return TRUE;
    }
    MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
    : wxFrame((wxFrame *)NULL, -1, title, pos, size)
    {
    wxShapeCanvas *canvas = new wxShapeCanvas(this, wxID_ANY, pos, size, 0, wxT("a"));
    canvas->SetBackgroundColour(*wxWHITE);
    canvas->SetCursor(wxCursor(wxCURSOR_CROSS));
    wxDiagram *diagram = new wxDiagram();
    canvas->SetDiagram(diagram);
    wxCircleShape *shape = new wxCircleShape(20.0);
    shape->SetX(25.0);
    shape->SetY(25.0);
    canvas->AddShape(shape);
    diagram->ShowAll(1);
    }

    The above code just create the wxShapeCanvas and graph a circle on it. Although that not so much that will help you get started.

    Mouse event in circle

    This example code, let you define some events in the shape, for example It has implemented the left ans right click.

    #include "wx/wx.h"
    #include "wx/ogl/ogl.h"
    class MyApp: public wxApp
    {
    virtual bool OnInit();
    };
    class OGLFrame: public wxFrame
    {
    public:
    OGLFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
    };
    class OGLCanvas: public wxShapeCanvas
    {
    public:
    OGLCanvas(wxWindow *parent = NULL, wxWindowID id = wxID_ANY,const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,long style = wxRETAINED);
    ~OGLCanvas(void);
    };
    class MyEvtHandler: public wxShapeEvtHandler
    {
    public:
    MyEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL,
    const wxString& lab = wxEmptyString):wxShapeEvtHandler(prev, shape) {}
    ~MyEvtHandler(void) {}
    void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
    void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
    };
    IMPLEMENT_APP(MyApp)
    bool MyApp::OnInit()
    {
    OGLFrame *frame = new OGLFrame( "wxOGL", wxPoint(50,50), wxSize(450,340) );
    frame->Show(TRUE);
    SetTopWindow(frame);
    return TRUE;
    }
    OGLFrame::OGLFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
    : wxFrame((wxFrame *)NULL, -1, title, pos, size)
    {
    OGLCanvas *canvas = new OGLCanvas(this);
    }
    OGLCanvas::OGLCanvas(wxWindow *parent, wxWindowID id, const wxPoint& pos,
    const wxSize& size, long style):
    wxShapeCanvas(parent, id, pos, size, style)
    {
    SetBackgroundColour(*wxWHITE);
    SetCursor(wxCursor(wxCURSOR_CROSS));
    wxDiagram *diagram = new wxDiagram();
    SetDiagram(diagram);
    wxCircleShape *circle = new wxCircleShape(100);
    circle->SetX(200);
    circle->SetY(200);
    AddShape(circle);
    diagram->ShowAll(1);
    MyEvtHandler *evthandler = new MyEvtHandler();
    evthandler->SetShape(circle);
    evthandler->SetPreviousHandler(circle->GetEventHandler());
    circle->SetEventHandler(evthandler);
    }
    OGLCanvas::~OGLCanvas(void)
    {
    }
    void MyEvtHandler::OnLeftClick(double WXUNUSED(x), double WXUNUSED(y), int keys, int WXUNUSED(attachment))
    {
    wxMessageBox(wxT("Left click"),
    wxT("wxOGL"), wxOK | wxICON_INFORMATION);
    }
    void MyEvtHandler::OnRightClick(double WXUNUSED(x), double WXUNUSED(y), int keys, int WXUNUSED(attachment))
    {
    wxMessageBox(wxT("Right click"),
    wxT("wxOGL"), wxOK | wxICON_INFORMATION);
    }

    Compiling sample code

    Although this is a very basic thing, maybe some newbies like I was (or am?) need it.

    g++ ogl.cpp -o ogl `wx-config --libs` `wx-config --cxxflags` -lwx_gtk2_ogl-2.8

    January 26, 2007 at 12:48 am Leave a comment

    Hello world!

    Welcome to Mechatronics Things. This is my first try to do thid kid of thing. I will like to share here anything I’m learning this days like a Mechatronics Engineer, in the other hand this blog will be a opportunity to share with the Open Software Community.

    January 25, 2007 at 5:15 pm Leave a comment

    Newer Posts


    Recent Posts