User Area Dial?

  • On 25/12/2015 at 12:25, xxxxxxxx wrote:

    C4D's API is wanting in many areas.  If you looked at my code, you see that I had to draw the circle for the dial myself using the Symmetric Midpoint algorithm.  Worse is that since there is no DrawPoint() or DrawPixel() method for the GeUserArea, I had to use DrawLine() and double the coordinates.  Hackish at best.

    Speaking of hackish, maybe a possible solution is in bit-blitting sub-images?  You could make an image containing a block for each dial position (360 little composite does suck).  Then you simply index into the image to get the block that represents the dial angle.  Trade time doing rotation transforms with memory to store the bitmap image.  Just a thought.

  • On 25/12/2015 at 12:51, xxxxxxxx wrote:

    Yeah. I noticed there's not even a circle or ellipse function for it. It's really awful.
    But since this thing was written back in the 90's. I sort of give it a break. It was probably state of the art back in it's day.
    I wish Maxon would just bite the bullet and partner with Qt like Autodesk did. And allow Qt handle all of it's gui stuff. But that's probably never going to happen.

    Perhaps someone from Maxon support could tell me if it's even possible to create an object with transforms for the UA?
    The docs say that we can use the UA to host our own objects. But nothing on how to actually do it.


  • On 29/12/2015 at 08:13, xxxxxxxx wrote:


    To draw to bitmaps you can use the BaseBitmap class low-level drawing functions (SetPixel(), SetAlphaPixel()).
    Also don't forget GeClipMap class exists to draw even more stuff.
    Then draw the bitmap using GeUserArea::DrawBitmap() with the appropriate mode.

    Originally posted by xxxxxxxx

    Perhaps someone from Maxon support could tell me if it's even possible to create an object with transforms for the UA?
    The docs say that we can use the UA to host our own objects. But nothing on how to actually do it.

    If you want to draw a bitmap with special transform that's something completely up to your implementation.
    The GeUserArea only draws pixels and doesn't know what's really drawn. It doesn't keep any information on the drawn lines, bitmaps, text, etc.
    To draw a bitmap with different transforms implement a struct or class to hold the bitmap and the special setup for its transform (just like Robert already told you).
    Then use this information to draw the transformed bitmap (by your own algorithm, the API doesn't provide this).

  • On 29/12/2015 at 08:34, xxxxxxxx wrote:

    If I wanted to create my own UA object with it's own transforms. The first thing I need to know is what base class do I extend?
    And If I create my own object. And then add instances of it to the UA. Can I get at all of those instances by iterating through the UA class somehow?
    Or do I need to create my own container to hosts all of the instances?

    I need more information than "Create a class".


  • On 29/12/2015 at 09:56, xxxxxxxx wrote:

    I don't know where you got the idea of a UA 'object'.  The UserArea is simply a UI region into which you can draw and respond to user input.  The objects, if we can say that, are simply your own class instances reacting within the UA.  For instance, my one excursion used a UserArea as a realm for nodes (much like Xpresso's system).  Each node was an instance of my node class containing its parameters and information on the location, size, states of the node for display in the UA as well the connections between them.  All of the display code was part of the methods in the node class called from the UA as it iterated through the node list.  When the user clicked over, say, the head of the node, I would find out if the click was over a node, where in the node, and react appropriately.  Over the head, move the node.  Over a input-output connection, either start a connection line or disconnect if one existed already, etc.

    Summarily, all of the 'interface' in the UserArea is just about the same as it would need to be if you were designing your own window system over a basic shell.

  • On 29/12/2015 at 12:02, xxxxxxxx wrote:

    I guess it's not possible to create a UA object the way I'm thinking.

    Sure. We can make our own classes.
    But ultimately these class objects must get drawn onto the UA using one of the SDK draw functions.
    Those draw functions are what create the "object" that I want to make myself. But it doesn't seem possible.


  • On 30/12/2015 at 08:41, xxxxxxxx wrote:

    Wow. I'm really stunned at how hard this is to do.
    I never would have thought that something as simple as rotating a gizmo would be so difficult.

    It turns out that rotating an image is very difficult to do. And it requires some advanced sampling of the nearest pixels. Which require special libraries.
    So I thought that I'd try to rotate the gizmo by moving it's four corners in an arc like manner instead. Like rotating a polygon.
    But the DrawBitmap() function does not provide the four corners of the gizmo that can be moved. It provides only one corner. And then the width&height.

    From the docs:
    The region ( x , y ) to ( x + w , y +h) from the bitmap will be scaled and transformed into the region ( wx , wy ) to ( wx + ww , wy + wh ) of the destination area.

    This makes it very, very hard to understand what's going on.
    Is there a way to get and change the four corner positions for this thing so I can move them in an arc like fashion to rotate it?

    I have studied your line rotate code Robert. But I'm not seeing how I can use that to rotate an image. If it's there I'm just not seeing it.


  • On 31/12/2015 at 12:16, xxxxxxxx wrote:

    I think that 'scaled and transformed' means that it will be scaled (width and height) to fit the destination and transformed simply means moved from x,y to wx,wy.  That is it.

    My code was not intended to show how to rotate an image but as a procedural means to draw and handle a rotating object (line) as an interface.  As you noted, arbitrarily rotating a bitmap requires some hefty algorithmic manipulation.  Photoshop (CS4 here) has a very responsive image rotation: Select All, then Move tool, then simply get the cursor to the rotation cursor and interactively drag rotate.

    If I find some reasonable code that would rotate a bitmap image quickly, I will post back here.

  • On 31/12/2015 at 13:04, xxxxxxxx wrote:

    Thanks for trying Robert.
    I don't think I'm going to get anywhere with this. It doesn't seem to be possible.


  • On 06/01/2016 at 20:18, xxxxxxxx wrote:

    Just an update to let you know that I figured out a way to do it using the OpenCV library.
    It works slicker than gorilla snot.😉
    I would have preferred to do this with the SDK. But it just isn't possible.


  • On 06/01/2016 at 20:32, xxxxxxxx wrote:

    Glad to hear that you found a pre-existing solution.  I truly did not find anything past the shear-technique (which is already a bit archaic temporally) as a means of arbitrarily rotating bitmaps. We can land a human on the moon but Bresenham takes decades to surpass.  Thus is technological advance.  Good ventures!

Log in to reply