GeClipMap



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/12/2012 at 21:54, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R14 
    Platform:   Windows  ;   
    Language(s) :

    ---------
    Hi All,
     
    I'm trying to draw an image in the MSG_DESCRIPTION_GETBITMAP message area. Everything works until I try getting a bitmap from a GeClipMap. Cinema crashes. Code below.

    DescriptionGetBitmap *dgb = static_cast<DescriptionGetBitmap*>(data);
     
    AutoAlloc<GeClipMap> Map;
    Map->Init(100,100,32);
    Map->BeginDraw();
    // drawing here... all seems to work fine when I display it in the picture viewer using ShowBitmap()...
    Map->EndDraw();
     
    AutoAlloc<BaseBitmap> Bitmap= Map->GetBitmap();  // seems to crash here...
    Bitmap->Init(100,100,32,INITBITMAPFLAGS_0);
    dgb->bmp = Bitmap->Release();
    

    I was initially using AutoAlloc<BaseBitmap> to draw my image (which was all working as intended) but the drawing functions seem limited - i.e. no rectangle draws etc. Looking around led me to GeClipMap. I've tried some variations of manually allocating the bitmap also. But nothing seems to work without crashing.
     
    Where am I going wrong here?
     
    WP.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/12/2012 at 01:54, xxxxxxxx wrote:

    Don't allocate it, just do:

      
    BaseBitmap *bmp = Map->GetBitmap();   
    

    Steve



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/12/2012 at 02:03, xxxxxxxx wrote:

    Thanks Steve,
     
    I've just tried doing that, but without adding it to the dgb (DescriptionGetBitmap) part it doesn't seem to want to show. It compiles though.
     
    How do I add this to the dgb? I can't seem to use

    dgb->bmp = Bitmap.Release()?
    

    WP.
     
    Update: I've just autoallocated another Bitmap and tried cloning the bitmap. This compiles and doesn't crash, but I only get a black bitmap in the tag display, whereas the pictureviewer shows the right image. The pictureviewer is being sent the GeClipMap, so something doesn't seem to be clicking between the BaseBitmap and the GeClipMap.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/12/2012 at 02:38, xxxxxxxx wrote:

    I think you might have to make the GeClipMap a class-level variable, i.e. declare it in the class declaration. You can still use AutoAlloc to do this. Then you won't have to release the bitmap at all. Just set dgb->bmp to the pointer returned from GetBitmap().

    I haven't tried it so I have no idea if it works though.

    Steve



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/12/2012 at 03:26, xxxxxxxx wrote:

    Ahh, I was just typing up a "Hmm, it still doesn't want to show" post, but then decided to go back over it one more time. It's showing now without any need for the BaseBitmap.
     
    As you've suggested Steve, I declared AutoAlloc<GeClipMap> at the class declaration level, and then pointed dgb->bmp straight to the GetBitmap().
     
    I don't think I could have come up with any more variations of code! Thanks Steve, I can now go on holidays tomorrow a happy camper!
     
    WP.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/12/2012 at 03:36, xxxxxxxx wrote:

    Argh, I may have spoken too soon. The image now displays in the tag's AM tab, but Cinema doesn't want to close without a Ctrl+Alt+Del.
     
    WP.
     
    Update: something still doesn't seem right with the GeClipMap. When 'refreshing' the tab (or when MSG_DESCRIPTION_GETBITMAP is resent for whatever reason) it's crashing Cinema. The first time it's drawn though it's fine?? Any ideas?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/12/2012 at 06:41, xxxxxxxx wrote:

    Hm. I'm out of ideas now I'm afraid. As I say, I didn't try it personally, it just seemed as if it ought to work.

    Maybe someone else can spot the problem?



  • On 06/01/2013 at 04:34, xxxxxxxx wrote:

    Thanks for your efforts Steve, you got me most of the way!!
     
    Is anyone (support? =) ) able to give an idea of what might be going on here? Below is a stripped down version of the bitmap related code.

    class MyTag : public TagData  
    {  
    AutoAlloc<GeClipMap> Tab_Image;
    private:  
    public:
    virtual Bool Message(GeListNode *node, LONG type, void *data)  
    {  
      if(type == MSG_DESCRIPTION_GETBITMAP)  
      {  
          DescriptionCommand *dc_Bitmap = (DescriptionCommand* )data;  
          LONG Button_Bitmap = dc_Bitmap->id[0].id;   
      
          if(Button_Bitmap == ID_TAB_TILES_PREVIEW_TILE)  
         {  
              DescriptionGetBitmap *DGB_Bitmap = static_cast<DescriptionGetBitmap*>(data);
                  //Tab_Image->Destroy();    // tried this first off, didn't help  
              Tab_Image->Init(204,204,32);  
              Tab_Image->BeginDraw();  
              Tab_Image->EndDraw();
                  //Tab_Image.Release();    // tried this here, didn't help  
              DGB_Bitmap->bmp = Tab_Image->GetBitmap();
                  //Tab_Image.Release();    // tried this here too, didn't help  
          }  
      }  
    }
    };  // End of class
    

    The code has been heavily stripped... but that's the gist of it. I've tried removing all the external things that might influence it - such as some lines I had being drawn in it with if and else statements etc.
     
    It'll draw the first time you go into the tab, but after that if the tab is updated, or you go out then back into the tab, Cinema crashes. Any ideas anyone? Anyway I can get what might be happening out of the crash report?
     
    WP.



  • On 06/01/2013 at 11:45, xxxxxxxx wrote:

    I've posted a couple of C++ plugin examples about using images with tags:
    https://sites.google.com/site/scottayersmedia/plugins

    They're for buttons though. And it looks like you're trying to put images on TABS?
    But maybe there's some code in there that will help you out.

    -ScottA



  • On 06/01/2013 at 18:17, xxxxxxxx wrote:

    Hi Scott,
     
    Thanks for the link - there's a couple of natty little test plugins you've got there to play around with!One for the fav's list.
     
    The problem seems to occur though when a GeClipMap is used. When MSG_DESCRIPTION_GETBITMAP is called the first time, it 'seems' OK, but when it's refreshed, or you go out and back into the tab with the description element in it, Cinema crashes. When you use a plain BaseBitmap to draw with it seems fine. But I can't use that in this case. So issue seems to be with GeClipMap and custom description elements.
     
    I thought I could try making my own custom Message() to keep the draw seperate from MSG_DESCRIPTION_GETBITMAP, but didn't work. I tried using a custom function to draw the GeClipMap in and passing the drawn GeClipMap to another autoallocated bitmap, but didn't work. I tried drawing the image in the SetDParameter but it didn't seem to want to do that either. I don't know where to go from here.
     
    WP.



  • On 07/01/2013 at 02:30, xxxxxxxx wrote:

    May be try some thin like this.

      
        
        
        virtual Bool Message(GeListNode *node, LONG type, void *data)  
        {  
          if(type == MSG_DESCRIPTION_GETBITMAP)  
          {  
              DescriptionCommand *dc_Bitmap = (DescriptionCommand* )data;  
              LONG Button_Bitmap = dc_Bitmap->id[0].id;   
          
              if(Button_Bitmap == ID_TAB_TILES_PREVIEW_TILE)  
              {  
                  DescriptionGetBitmap *DGB_Bitmap = static_cast<DescriptionGetBitmap*>(data);
        
          
                  BaseBitmap *Tab_Image_Bmp = Tab_Image->GetBitmap();  
                  if(Tab_Image_Bmp!=nullptr && DGB_Bitmap->bmp!=nullptr)   
                  {  
                      Tab_Image_Bmp->CopyTo(DGB_Bitmap->bmp);  
                  }  
              }  
        
        
            }  
        }
      
    


  • On 07/01/2013 at 03:52, xxxxxxxx wrote:

    Please disregarded previous post, it's still not working correctly. I just got a warning that said my tag is not in sync. Maybe it's something else causing the problem? What does something like this mean?
     
    WP.



  • On 10/01/2013 at 20:41, xxxxxxxx wrote:

    Hi All,
     
    just giving this one a selfish bump (hope that's OK..) as I wasn't sure if anyone would've seen my updated post above.
     
    What is Cinema referring too when it says the tag is not in sync?
     
    Kind regards,
     
    WP.



  • On 11/01/2013 at 01:37, xxxxxxxx wrote:

    I think there's an error in your code. When you receive a MSG_DESCRIPTION_GETBITMAP, you're casting 'data' to a DescriptionCommand*, then using that to get the ID of the element concerned. You shouldn't do that. You need to cast it to a DescriptionGetBitmap* and use the ID from that.

    You should cast to DescriptionCommand* when you receive a MSG_DESCRIPTION_COMMAND message, but that happens when the user clicks a button. MSG_DESCRIPTION_GETBITMAP is sent by Cinema to check if the bitmap needs to be changed - it doesn't get sent on a button click.

    It may be that it doesn't matter and that the erroneous cast gives the same ID anyway, but you could change it and see what happens.

    Steve



  • On 11/01/2013 at 03:38, xxxxxxxx wrote:

    Thanks Steve,
     
    you are indeed correct that I had DescriptionCommand instead of DescriptionGetbitmap. I've changed that over, but it unfortunately hasn't made much difference. However..
     
    I took the AutoAllocated GeClipMap out from the class level and put it into my own custom function that was doing the drawing. This seems to have (albeit temporarily!!) solved my crashing problem.
     
    Not knowing a lot about what I'm doing probably means my word doesn't mean much, but it looks like either a GeClipMap bug/error, or that drawing a GeClipMap (or even referring to one) in a MSG_DESCRIPTION_GETBITMAP seems to be unstable. Of course it could still well be something else in my code. But it just seems odd to me that anywhere that Message and GeClipMap came into contact, Cinema didn't like. Particularly when I have other Bitmap buttons in my tag that seem to work fine.
     
    Thanks for your patience everyone. I'll hesitantly say I can move on...!!
     
    WP.



  • On 11/01/2013 at 04:00, xxxxxxxx wrote:

    Ehh..
    Is support able to let me/us know what this business below is about? Quoting from an error message popup I keep recieving:

    A problem with this project has been detected:
    Object "MyObject" - Tag 5712 not in sync.
    Please save and contact MAXON Support
    with a description of the last used commands, actions or plugins.
    

    WP.



  • On 11/01/2013 at 07:53, xxxxxxxx wrote:

    I'm probably way off base.
    But are you trying to use Map->BeginDraw(); from inside of your Message() function?
    I don't think we can do this.

    AFAIK. All drawing must be done within the overridden Draw() function.

    -ScottA



  • On 11/01/2013 at 14:06, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    I'm probably way off base.
    But are you trying to use Map->BeginDraw(); from inside of your Message() function?
    I don't think we can do this.

    AFAIK. All drawing must be done within the overridden Draw() function.

    -ScottA

    at least in python a GeClipMap neither provides a overrideable Draw() method, nor is it bound 
    to plugin types which provide such method.

    as a wild guess, might this be somehow conncetd to threading ? from my understanding 
    events are threaded, so there might be multiple calls to your message method at the same time.
    this might cause some problems with the memory allocation done by GeClipMap.Init() ? have you
    tried to move the whole GeClipMap code into a seperate method and just call this method
    from within Message() (the GeClipMap should then be private to this new method of course) ?

    but i am just guessing into the blue, i am most likely completely wrong :)



  • On 11/01/2013 at 15:11, xxxxxxxx wrote:

    ^I think you misunderstood.

    I never said that GeClipmap class has a Draw() function.
    What I said is there is a Draw() function available for plugins that needs to be used (overriden) when doing any drawing. And it works the same way in both Python & C++.

    For example:
    I wrote my own spline class that lets me draw custom splines on the screen. And one of things I learned when writing it is that the actual drawing must be done inside the overriden Draw() function.
    The class code can be written anywhere in the plugin. But the instance of each spline object had to be done inside of the overriden Draw() function for the drawing to work properly.
    This is also how any of the SDK drawing functions like BeginDraw(), EndDraw(), Line(),TextAT(), etc. works too.

    In short.
    In my experience. Anything drawn has to be done inside Draw().

    -ScottA



  • On 11/01/2013 at 15:28, xxxxxxxx wrote:

    hm, all i can say is, that in the plugin i am currently working on, i am using a GeUserArea which again
    has a GeClipMap as a member. All the drawing in the GeClipMap is done outisde of the Daw function
    of the GeUserArea and it is working fine. Also neither the cpp, nor the python documentation are
    mentioning something like that (that a GeClipMap is bound to overridden Draw methods).

    that was, what I meant in my first post  with :> ... , nor is it bound to plugin types which provide such method.

    or i am still misunderstanding you, then i'll have to apologize :) (language barrier and so on :) )


Log in to reply