octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handle graphics plotting functions


From: Sebastien Loisel
Subject: Re: Handle graphics plotting functions
Date: Mon, 13 Feb 2006 11:31:25 +0100

Ok, I just spent half an hour giving careful thought to Shay's private email and writing an answer, and now you have another great proposition.

I don't understand what this "props" is in relation to oplot and the underlying C++ GUI? It's the C++ GUI part? Does it support 3d data with OpenGL efficiently? What I really like is that you've apparently started on adding buttons to the plot, which was far off in my application in my mind.

If this is what you've done, I would really like to foist the plotting widget onto you! Do you want to look at QT4 and implement a stripped-down pure-QT4 plotting widget with your props? I want to use this in MinGW so it really has to be clean portable non-linux QT4 code. No calling "gettimeofday" or any other unix OS calls.

This is currently how my brain-dead plotting widget (you can see it in the screenshot) works, so let me tell you how I got mine to work.

First off, the .oct file doesn't actually contain any GUI code. The .oct file just parses its octave_value inputs and groks it, then it calls another function, which is not in the .oct file. Like so:

========FILE internal_my_plot.cpp===========
#include <octave/oct.h>
#include <octave/Cell.h>
#include <iostream>
using namespace std;
void makeplot(int, const Cell &);


DEFUN_DLD(internal_my_plot, args, ,
          "Make a plot (internal function -- do not call!)")
{
  if(args.length()!=2 || !args(0).is_real_scalar() || !args(1).is_cell())
    {
      error("internal_my_plot: internal error-- bad arguments.");
      cout<<args.length()<<" "<<args(0).is_real_scalar()<<" "<<args(1).is_cell()<<endl;
      return octave_value();
    }
  int id=args(0).int_value();
  makeplot(id,args(1).cell_value());
  return octave_value();
}
======================================

The makeplot() function is already linked to the mygui program, which embeds octave. When I compile internal_my_plot.cpp, I use mkoctfile and I don't tell it anything about QT (if you see above, it doesn't have any QT includes or anything). This makes it easier to build the oct file.

To get your own working, you would take mygui-0.2.tar.gz, add some .cpp and .h files to the mygui.pro file like this

HEADERS += props.h
SOURCES += props.cpp

and then you would add whatever .oct files you want to build (on line 30 or so). For instance, if you have props_oct1.cpp and props_oct2.cpp, you would do

OCT0 += props_oct1 props_oct2

(notice there is no extension!)

If you want to know how such a QT4/OpenGL widget is implemented, check out plotter.h and plotter.cpp, total 169 lines of code:

$ wc -l plotter.h plotter.cpp
  58 plotter.h
 111 plotter.cpp
 169 total

That's a complete implementation.

How much time do you need to get this working?

Sébastien Loisel


reply via email to

[Prev in Thread] Current Thread [Next in Thread]