DiscussionsIssue archiveOther usage issues

Archived discussion

Undo/Redo freeze

Other usage issuesSat, 03/26/2011 - 11:595 replies

Browse this forum
QuestionAuthor

Hello,

i want to add Undo/Redo functionality to my OCAF-based project. Functiondrivers etc. are working correctly, but it seems i cannot start new commands. TDocSTd_Document->NewCommand never returns (but also dosn't give an error). Shouldn't this minimal code work?

Handle_TDocStd_Document doc;
Handle(OcafApp) app = new OcafApp();
app->NewDocument ( "Standard", doc );

doc->NewCommand();
//execute the command

As I'm quite new to OCC it's possible that I miss something funtamental about the initialising, but couldn't find any hint in the docs and papers.

Any help would be appreciated.

Thanks,
Author

Discussion

5 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hello Author,
By default Undo is disabled.
Enabling it will take effect with the next call to NewCommand.
See documentation of TDocStd_Document class.
Regards
Commenter-1

02Author

Hello Sregey,

thanks for your answer. I enabled undo by setting the undolimit and calling new command, but still no progress, it never returns from the newcommand() function. here my code and it's behaviour as comments:

Handle_TDocStd_Document doc;
Handle(OcafApp) app = new OcafApp();
app->NewDocument ( "MDTV-Standard", doc );

//this code gets executet, no problems here
doc->SetUndoLimit(100);

//calling this function should activate the undo mechanism
doc->NewCommand();
//it never get here. doc->NewCommand() never returns, no error's or exeptions. Only killing the application helps

Any further ideas?

Greedings,
Author

03Commenter-1

Hello Author,
I checked your code with few modifications:
Handle(TDocStd_Document) doc;
Handle(AppStd_Application) app = new AppStd_Application();
app->NewDocument ( "MDTV-Standard", doc );

//this code gets executet, no problems here
if(doc.IsNull()) return 1;
doc->SetUndoLimit(100);

//calling this function should activate the undo mechanism
doc->NewCommand();
cout << "New Command1 is opened" <Main(), 171);
doc->NewCommand();
cout << "New Command2 is opened: val = " << att->Get() <

04Author

Hello Sergey,

your code works, thanks for posting. Seems that the problem lies within my overloaded TDocStd_Application. I thought it is necesarry to create one's one class to overrite the Formats() and ResourceName() functions, never before read about AppStd_Application(). If I intend to use only the standart format, can i use this application or are there any limitations?

Again, thank you for your help, you safed me hours and hours of frustrating testing.

Greetings,
Author

05Commenter-1

Hello Author,
You can use it (AppStdL_Application or AppStd_Application if you need geometry ) or you may create your own inheriting from TDocStd_Application (consider AppStdL_Application as prototype).
Regards