05-07-2010 01:17 PM
Solved! Go to Solution.
05-07-2010 02:36 PM
Hello Annees,
a good starting point are the examples provided with CVI. For plotting, you might want to have a look at the 'graph' sample demonstrating how to plot lines etc.
05-10-2010 05:02 PM
I have managed to draw the lines, thanks for the help!
Now I need to attach to an image a callback using code?
I have tried to use status = InstallCtrlCallback (panelHandle, PANEL_PICTURE, getCeva, 0); but
I receive this: 58, 71 Initializer must be constant
What should I do?
Please help!
05-11-2010 12:21 AM
I do not understand your result: what is 58, 71? status should be defined as an integer. If an error occurs, status will be negative.
Of course, if you are not using the interactive execution window, you need to start your program with main(){...}
05-11-2010 09:03 AM
58,71 reprezented the line and column where the error appeared... but never mind...i have this code...and please help me do this instead....
This is my code:
#include <ansi_c.h>
#include <cvirte.h>
#include <userint.h>
#include "map.h"
#include "configuration.h"
static int panelHandle;
char imageRoute[30];
char coordonnees_x[30];
char coordonnees_y[30];
double latMaxima , latMinima , longMinima, longMaxima;
double c_x,c_y;
int status;
int Test,Test_1;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1;
if ((panelHandle = LoadPanel (0, "map.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
Test = NewCtrl (panelHandle, CTRL_PICTURE, "", -3, -3);
DisplayImageFile (panelHandle, Test, "image.png");
SetCtrlAttribute (panelHandle, Test, ATTR_FRAME_VISIBLE, 0);
status = SetCtrlAttribute (panelHandle, Test, ATTR_HEIGHT, 690);
status = SetCtrlAttribute (panelHandle, Test, ATTR_WIDTH, 690);
//here I tried to associate to a "image.png" a callback "callbackName"
status = InstallCtrlCallback (panelHandle, Test, callbackName, 1);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
int CVICALLBACK callbackName (int panel, int event, void *callbackData,
int eventData1, int eventData2)
{
if (event == EVENT_RIGHT_CLICK) {
Test = NewCtrl (panelHandle, CTRL_PICTURE, "", 60, 60);
DisplayImageFile (panelHandle, Test, "maison.png");
}
return 0;
}
///It shows this :
Type error in argument 3 to `InstallCtrlCallback'; found 'int' expected 'CtrlCallbackPtr'.
Type error in argument 3 to `InstallCtrlCallback'; found 'int' expected 'CtrlCallbackPtr'.
What should I do? Please help
05-11-2010 09:33 AM
Hi,
the help of InstallCtrlCallback says: The event function, type CtrlCallbackPtr, takes the following form:
int CVICALLBACK EventFunctionName (int panelHandle, int controlID, int event, void *callbackData, int eventData1, int eventData2);
As you can see, this is different from your definition
callbackName (int panel, int event, void *callbackData, int eventData1, int eventData2)
You miss the int controlID as an argument in your callback function.
05-11-2010 11:00 AM
As evidenced by Wolfgang there is a problem in callback definition. InstallCtrlCallback wants a standard control callback as a parameter: apparently you have structured your callbackName callback on the prototype for a panel callback, which obviously is missing the 'control' parameter.
Additionally, the control callback should be declared somewhere before it can be used. That is, you must add its declaration before your main {} function, either in one of your include files or directly in the code. This is the reason for the "found int, expected CtrlCallbackPtr" error.
Third item: you are creating a new picture control in the callback assigned to the picture control! And you are reusing 'Test' variable which is already holding a valid control ID...
Finally: what are you expecting to do by passing '1' in callbackData parameter since you are not using it anyway? Unless you want to tailor callback behaviour based on some condition passed in callbackData, you should pass NULL as this parameter.
05-11-2010 01:35 PM