Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8784147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:01:03+00:00 2026-06-13T21:01:03+00:00

I have written a win32 api-based GUI app which uses GDI+ features such as

  • 0

I have written a win32 api-based GUI app which uses GDI+ features such as DrawCurve() and DrawLine().

This app draws lines and curves that represent a multigraph.

The data structure for the edge is simply a struct of five int’s. (x1, y1, x2, y2, and id)

If there is only one edge between two vertices, a straight line segment is drawn using DrawLine().
If there are more than one edges, curves are drawn using DrawCurve() — Here, I spread straight-line edges about the midpoint of two vertices, making them curves. A point some unit pixels apart from it is calculated using the normal line equation. If more edges are added then a pixel two unit pixels apart from the midpoint is selected, then next time 3 unit pixels, and so on.

Now I have two questions on detecting the click on edges.

  1. In finding straight-line edges, to minimize the search time, what should I do?
    It’s quite simple to check if the pixel clicked is on the line segment but comparing all edges would be inefficient if the number of edges large. It seems possible to do it in O(log n), where n is the number of edges.
    EDIT: at this point the edges (class Edge) are stored in std::map that maps edge id (int)’s
    to Edge objects and I’m considering declaring another container that maps pixels to edge id’s.
    I’m considering using binary search trees but what can be the key? Or should I use just a 2D pixel array?

  2. Can I get the array of points used by DrawCurve()? If this is impossible, then I should re-calculate the cardinal spline, get the array of points, and check if the point clicked by the user matches any point in that array.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:01:04+00:00Added an answer on June 13, 2026 at 9:01 pm

    If you have complex shaped lines you can do as follows:

    • Create an internal bitmap the size of your graph and fill it with black.
    • When you render your graph also render to this bitmap the edges you want to have click-able, but, render them with a different color. Store these color values in a table together with the corresponding ID. The important thing here is that the colors are different (unique).
    • When the graph is clicked, transfer the X and Y co-ordinates to your internal bitmap and read the pixel. If non-black, look up the color value in your table and get the associated ID.

    This way do don’t need to worry about the shape at all, neither is there a need to use your own curve algorithm and so forth. The cost is extra memory, this will a consideration, but unless it is a huge graph (in which case you can buffer the drawing) it is in most cases not an issue. You can render the internal bitmap in a second pass to have main graphics appear faster (as usual).

    Hope this helps!

    (tip: you can render the “internal” lines with a wider Pen so it gets more sensitive).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have written this little class, which generates a UUID every time an object of
I have written a Word add-in in C++ using plain Win32 API. It opens
I have two Win32 API programs written in plain C: Program A and program
I have recently begun learning the Win32 API using this tutorial: http://www.winprog.org/tutorial/ (though I'm
I have written child command execution code for Win32 using CreateProcess: CreateProcessW(NULL, // app
I have a native multithreaded Win32 application written in C++ which has about 3
I've written an application that uses the WIN32 api to create a temporarily directory
I have a C++ Win32 application written using Win32 API and I wish to
I have a simple Win32 console (no vcl) app written in Borland C++ 5,
I have a third-party (Win32) DLL, written in C, that exposes the following interface:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.