ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Halbtransparentes Rechteck im Graphen als Toleranzband darstellen

Solved!
Go to solution

Hallo Forum,

 

hat irgendjemand eine Idee, wie ich ein halbtransparentes Rechteck in einem Graphen darstellen kann? Ich habe eine Kurve, deren Min-, Max-, und Wendpunktwerte innerhalb einer Toleranz liegen müssen. Diese Toleranz möchte ich als Rechteck(Toleranzband) im Graphen darstellen. Damit die Kurve aber nicht komplett verdeckt ist, soll das Rechteck halbtransparent oder idealerweise von 0 bis 100%-Transparenz einstelbar sein. Im Anhang habe ich mal ein Bild eingefügt, wie ich es mir ungefähr vorstelle. Ist so etwas in CVI möglich? Wenn ja wie?

 

 

Gruß Thomas

0 Kudos
Message 1 of 4
(4,366 Views)

Hallo Thomas,

 

halb- oder teiltransparent gibt es in CVI leider nicht... Vielleicht mal einen Produktvorschlag unterbreiten, ich hatte das neulich für Plotlinien gemacht.

 

Als eine mögliche Lösung könnte ich mir vorstellen:

 

1. Graph mit transparentem Hintergrund

2. Rechtecke in der gewünschten Farbe zeichnen und nach hinten setzen (z-Wert)

 

Damit werden die Plots oberhalb der rechtecke gezeichnet, so sieht man dann immerhin, ob die Kurven im Toleranzbreich sind.

 

Wolfgang

0 Kudos
Message 2 of 4
(4,360 Views)
Solution
Accepted by topic author ceridwen

Hello Thomas,

 

(I apologize for not writing in German, but my German is barely good enough to read. Attempting to write would have been comical).

 

If I understand your request correctly, I would imagine that Wolfgang's suggestion of placing the rectangles behind your line plot should do the job. However, if you really need the rectangles to be partially transparent you can still do so. This is how you would do it:

 

  1. Create a bitmap with an alpha channel using the NewBitmapEx. The values in the alpha channel determine the level of transparency that you would like to have. Because your bitmap is just a simple rectangle, setting the values for the bitmap should be trivial. The exact width/height dimensions of the bitmap are not very important, since it will be stretched to fit the exact areas of the graph that you need it to occupy.
  2. Create an empty bitmap plot, using  PlotBitmap. Normally you pass the filename that contains the bitmap. But by passing NULL as the filename, you can then set the bitmap later on, from memory.
  3. Set the bitmap programmatically, using SetCtrlBitmap.
  4. Discard the bitmap.

 

Here's some example code:

 

#define COLOR        VAL_RED
#define TRANSPARENCY 128

#define WIDTH        100
#define HEIGHT       20
   
unsigned char        alpha[WIDTH*HEIGHT];
unsigned int         data[WIDTH*HEIGHT], i, j;
int                  bitmap, plot;

 

for (i = 0; i < WIDTH; i++)
    for (j = 0; j < HEIGHT; j++)
    {
        data[i+j*WIDTH] = COLOR;
        alpha[i+j*WIDTH] = TRANSPARENCY;
    }
NewBitmapEx (WIDTH*sizeof(int), 32, WIDTH, HEIGHT, 0, (unsigned char *)data, 0, alpha, &bitmap);
plot = PlotBitmap (panelHandle, PANEL_GRAPH, 0.0, 1.5, 120.0, 0.5, 0);
SetCtrlBitmap (panelHandle, PANEL_GRAPH, plot, bitmap);
DiscardBitmap (bitmap);

Message Edited by LuisG on 04-29-2010 11:46 AM
0 Kudos
Message 3 of 4
(4,350 Views)

Hello LuisG,

 

This is the solution! Many Thanks. I 've attached one curve with the tolerance width. But now by using the example code and not by using GIMP. Reading english is possible for me and i try my best to answer in english. Maybe it is a little bit comical. :smileywink:

 

 

Hallo Wolfgang,

 

auch Dir vielen Dank für Deinen Lösungsvorschlag und für die superschnelle Antwort.

 

 

 

 

Thank you very much!

 

Thomas

0 Kudos
Message 4 of 4
(4,324 Views)