LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to draw a line between 2 specific points ,over an image inserted in a panel? Please help!

Solved!
Go to solution
I am a begginer in working with LabWindows/CVI and I want to draw a line between 2 specific points ,over an image inserted in a panel? Please some help or some code examples.
0 Kudos
Message 1 of 8
(4,915 Views)

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.

0 Kudos
Message 2 of 8
(4,905 Views)

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!

0 Kudos
Message 3 of 8
(4,872 Views)

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(){...}

0 Kudos
Message 4 of 8
(4,857 Views)

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 

 

0 Kudos
Message 5 of 8
(4,833 Views)

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.


0 Kudos
Message 6 of 8
(4,825 Views)
Solution
Accepted by topic author Annees

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 7 of 8
(4,815 Views)
Thanks for the help! I`ve done it!
0 Kudos
Message 8 of 8
(4,801 Views)