Jump to content
Sign in to follow this  
badderjet

Vector Gauge for ND (with C)

Recommended Posts

Guest taku

My question is what is the best way to make Vector Gauge for such as Naviagtion Display which have route display. I read further posts about GDI+ and tried some, however I cannot find out that GDI+ is the best way to take.I image ND and those functions of 767PIC or 737DF and want to create similar to those.I tried GDI+ but lines are disappeared when resize gauges on FS.If there are any GDI+ tutorial other than fs2k2sdkwithgdi+ and MS SDK, please tell me.

Share this post


Link to post
Share on other sites

GDI+ is kinda the way to go IMHO, although it seems a bit slow to me sometimes. Anyway, this is speculation, but PIC and DF used GDI it seems. No other tutorial available for GDI+, I'm afraid.

Share this post


Link to post
Share on other sites

For the lines to stop disappearing when you resize, change PANEL_SERVICE_PRE_KILL to PANEL_SERVICE_DISCONNECT Many thanks to Matt for helping me on this one.Sincerely,Tiberiu Brasov

Share this post


Link to post
Share on other sites
Guest bartels

I don't had time to write anything down for the use of GDI+. But if you want post your code here and we can have a look or mail it to me privately.Arne Bartelsarne.bartels@nwn.de

Share this post


Link to post
Share on other sites
Guest bartels

I had a look in the example (fs2k2sdkwithgdi+) and I suggest a slightly changed gauge callback function like:void FSAPI PFDCallBack ( PGAUGEHDR pgauge, SINT32 service_id, UINT32 extra_data ){ switch (service_id) { case PANEL_SERVICE_CONNECT_TO_WINDOW: GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); break; case PANEL_SERVICE_PRE_DRAW: { PELEMENT_STATIC_IMAGE pelement=(PELEMENT_STATIC_IMAGE)(pgauge->elements_list[0]->next_element[0]); if (pelement) { HDC hdc = pelement->hdc; PIXPOINT dim = pelement->image_data.final->dim; if (hdc) { Graphics graphics(hdc); Pen pen(Color(255, 0, 0, 255)); graphics.DrawLine(&pen, 0, 0, 200, 100); } SET_OFF_SCREEN (pelement); } } break; case PANEL_SERVICE_DISCONNECT: GdiplusShutdown(gdiplusToken); break; }}as you already suggested.Arne Bartels

Share this post


Link to post
Share on other sites

Arne, This is the "Dim" version of Fred's code. It just adds dim for resizing issues. Did you get my e-mail?void FSAPI PFDCallBack ( PGAUGEHDR pgauge, SINT32 service_id, UINT32 extra_data ){ if(!init) { GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); init = true; } switch (service_id) { case PANEL_SERVICE_PRE_DRAW: { PELEMENT_STATIC_IMAGE pelement = (PELEMENT_STATIC_IMAGE)(pgauge->elements_list[0]->next_element[0]); if (pelement) { HDC hdc = pelement->hdc; PIXPOINT dim = pelement->image_data.final->dim; dx = ((float)dim.x) / 312; //added by mat for resizing issues dy = ((float)dim.y) / 417; if (hdc) { Graphics graphics(hdc); Pen pen(Color(255, 0, 0, 255)); graphics.DrawLine(&pen, 0, 0, 200, 100); } SET_OFF_SCREEN (pelement); } } break; case PANEL_SERVICE_DISCONNECT: GdiplusShutdown(gdiplusToken); break; }}Sincerely,Tiberiu Brasov

Share this post


Link to post
Share on other sites
Guest bartels

Did you look in your inbox?I'm not sure how the GDI scaling supposes to go on, you can either resize all coordinates with dx and dy, or to get rid of all resizing calculations use something like:...Graphics graphics(hdc);graphics.ScaleTransform(dx,dy);Pen......and draw everything in the coordinates of BMP_PFD_BLANK.Arne Bartels

Share this post


Link to post
Share on other sites

Well yeah but it would be cool to know (definately) what would be faster... Calculating everything with dx/dy (unprobable, huh...?) or ScaleTransform... :-hmmm

Share this post


Link to post
Share on other sites
Guest taku

First of all, Thanks to everyone who replies my question!I understand GDI+ is reasonable way to use for Navigation gauge.Then, thanks for the way to prevent disappear lines when resizing.I sucessed to do so.I have still several question on using GDI+...1.When shrink the size, part of lines were disappeared. Is there any way to display lines as same as original size?2.how do you know information as, PANEL_SERVICE_PRE_KILL to PANEL_SERVICE_DISCONNECT would work? I read FS2K2SDK and sd2gau14 but no discription about those.3.Lines of my gauge with GDI+ is releatively thick than 767PIC. I choose line most thin such as follows. > Pen white_thin_pen(Color(255, 0, 255, 255), 1); How can I make lines as 767PIC.Thanks so much in advance.

Share this post


Link to post
Share on other sites

Edit: I am sorry for forgetting this:Pen pen(Color(255, 0, 0, 255));graphics.DrawLine(&pen, 0*dx, 0*dy, 200*dx, 100*dy);Sincerely,Tiberiu Brasov

Share this post


Link to post
Share on other sites

1. If you did what I showed you in my example, then multiply the x coordonates with dx and y coordonates with dy. so this:graphics.DrawLine(&whitePen, 130, 230, 230, 230);should look like thisgraphics.DrawLine(&whitePen, 130*dx, 230*dy, 230*dx, 230*dy);That will fic your resizing problem. I apologize for forgetting this.2. I am also looking for an answer, but it is PANEL_SERVICE_DISCONNECT that is required, unless, if you resize your gauge, your code will dissapear for ever.3. Pen white_thin_pen(Color(255, 0, 255, 255), 1);try this:Pen white_thin_pen(Color(255, 0, 255, 255));I can not guarantee that it will work.

Share this post


Link to post
Share on other sites
Guest taku

Tiberiu,Thanks for quick reply and adequate answers.I understood and resolved by your comment about Q1 and Q2.However, I couldn't resolved Q3. The lines are still thick than other vectoring gauges.

Share this post


Link to post
Share on other sites
Guest bartels

You can use a bigger bitmap, so that the overall scale goes down, you can use different Pen widths, e.g. Pen(..., 4.0f); Pen(..., .25f), whatever. If you don't use ScaleTransform, which will also scale the Pen widths, you have to rescale the widths with dx or dy anyway.Arne Bartels

Share this post


Link to post
Share on other sites
Guest _ak

>>graphics.DrawLine(&whitePen, 130*dx, 230*dy, 230*dx, 230*dy);>There is much more easy way:

case PANEL_SERVICE_PRE_DRAW:	pelement = (PELEMENT_STATIC_IMAGE)(pgauge->elements_list[0]);	if (pelement) 	{		HDC hdc = pelement->hdc;		PIXPOINT dim = pelement->image_data.final->dim;		if (hdc) 		{			SetMapMode (hdc, MM_ANISOTROPIC);			SetWindowExtEx (hdc, 200, 200, NULL);			SetViewportExtEx (hdc, dim.x, dim.y, NULL);			//Paint here			SET_OFF_SCREEN(pelement);		}	}break;

With this code you should do nothing when gauge resized

Share this post


Link to post
Share on other sites

>2.how do you know information as,> PANEL_SERVICE_PRE_KILL to PANEL_SERVICE_DISCONNECT would>work?> I read FS2K2SDK and sd2gau14 but no discription about>those.Hey ya.Well go and have a look in gauges.h. You will find all these events there (do a search for 'em). But you won't find any information about them anywhere, however, some if not all of them have been figured out by some smart people (Arne Bartels for example, I think ;)). Anyway, SERVICE_DISCONNECT should be the only one which is really just called *once*, being at the time of closing the panel.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...