Undoable tool parameters changes



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

    On 23/09/2006 at 13:54, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   9.6 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Im writing a Tool plugin, and I want to make it possible to undo changes in its parameters.
    How to do it?
    I have tried:

        
        
        doc->StartUndo() ;  
        doc->AddUndo( UNDO_CHANGE, (ToolData* )this) ;
    

    or

        
        
        doc->StartUndo() ;  
        doc->AddUndo( UNDO_CHANGE_SMALL, (DescriptionToolData* )this) ;
    

    and other combinations. But Cinema crash on this strings.



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

    On 23/09/2006 at 14:26, xxxxxxxx wrote:

    hmm
    "ToolData*" type is unambiguously wrong. There I need something like "BaseTool*" :)



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

    On 23/09/2006 at 15:12, xxxxxxxx wrote:

    Have you added doc->EndUndo()?

    If that doesn't work, try implementing Message() (R9+ only for ToolData) and checking for MSG_DESCRIPTION_INITUNDO. With this, you do not need to do doc-StartUndo() and doc->EndUndo(), just doc->AddUndo().



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

    On 23/09/2006 at 23:59, xxxxxxxx wrote:

    Yes, I have added EndUndo()
    How can messages help me? I have problems just with doc->AddUndo(...). I dont know what write inside it.  Thank you anyway. .... but ... You give me a good idea. I just need to catch messages which indicate undo command, and perform undo manually. I dont know which constant correspond to it. But it`s value is 200000096 :)



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

    On 24/09/2006 at 00:11, xxxxxxxx wrote:

    I find it`s name
    MSG_TOOL_RESTART



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

    On 24/09/2006 at 01:02, xxxxxxxx wrote:

    But in this case there is a problem with redo...
    There is no message sending when user choose redo.



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

    On 24/09/2006 at 01:18, xxxxxxxx wrote:

    Changing parameters:

    BaseContainer *writeback = GetToolData(doc,GetToolPluginId());
    (writeback)
    {
                        writeback->SetLong(TOOLID, subdiv);
                        GeSyncMessage(EVMSG_TOOLCHANGED, 0);
                   }
                   DrawViews(DA_ONLY_ACTIVE_VIEW|DA_NO_THREAD|DA_NO_ANIMATION);

    Before you do it another time call:
    InteractiveModeling_Restart(doc);

    Check the SDK edge cut example for detailed information.



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

    On 24/09/2006 at 01:40, xxxxxxxx wrote:

    Thank you anyway. But how this code can make tool parameters undoable?
    I use code like you wrote, and I have checked SDK edge cut example.
    And in SDK edge cut example parameters is not undoable! For example: I choose edge cut tool, and drag in editor, subdivision parameter grows, and new points added. Then I press Ctrl+Z - points disappers but subdivision parameter not changes.



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

    On 24/09/2006 at 02:06, xxxxxxxx wrote:

    Your problem is that you are adding the ToolData as the undo object. The undo must be on an 'object' - BaseList2D base-class. For an Attribute Manager value, this is the same - you must set an undo for the 'object' that is affected by the value. For instance, when I change a morph value using an AM slider, the correct path is to store an undo on the polygon object:

    // Store undo for IPPBase
         else if (type == MSG_DESCRIPTION_INITUNDO)
         {
              BaseDocument*     doc =     node->GetDocument();
              if (!doc)          return FALSE;
              //doc->AddUndo(UNDO_CHANGE, node);
              BaseContainer*     bc =     ((BaseObject* )node)->GetDataInstance();
              if (!bc)          return FALSE;
              BaseObject*          orig =     bc->GetObjectLink(IPP_ROOT, doc);
              if (!orig)          return FALSE;
              doc->AddUndo(UNDO_CHANGE, orig);
         }

    There is no 'undo for the tool', there is only an undo for the affected object! Supposedly, C4D stores undo for AM changes - but only in accordance with the object that is affected by the change. That must be made clear and precise - you are not storing an undo for a slider, but for the affect that the slider causes.



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

    On 24/09/2006 at 02:17, xxxxxxxx wrote:

    it is a slightly pity (I want to storing an undo for a slider)
    Thank you, Robert.



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

    On 24/09/2006 at 02:24, xxxxxxxx wrote:

    I think the slider should undo by default (test this - don't take my work on it), but the affect must be undone as well. So if the slider changes, say translation for simplicity, you store an undo for the change in translation on the object - AddUndo(UND0_CHANGE, obj) - so that the undo will also prompt the obj undo. The slider undo should be automatic (as stated in the documentation - This is already automatically handled for keys, tags, objects etc. ). This is definitely one of those weird areas of the SDK where an AM undo isn't exactly a complete undo unless you specify the connection literally.



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

    On 24/09/2006 at 03:09, xxxxxxxx wrote:

    I think for tool with traditional c4d style there is no need to undo sliders (it has no sence).
    But simply I try to write something else :)


Log in to reply