sceneSaveStarting() not working?

pcicconepciccone Posts: 634

Hello again.

I'm trying to intercept when a Studio scene is saved. For that I connected to the signal sceneSaveStarting( const QString &) of DzScene.
My slot is not getting called when I use File | Save. Is there some other signal to use or is this a broken signal?
I tried this with both 4.6.1 and 4.6.2.

Thanks in advance.

Comments

  • rbtwhizrbtwhiz Posts: 1,603
    edited December 1969

    You cannot "intercept" the scene save; you cannot prevent it from happening. You can, however, "detect" a scene save and use that to trigger your own subroutine(s). Scene saving is no longer done with the saving functions/slots/signals on DzScene; those are for the deprecated *.daz format. Asset saving, in the DSON formats (i.e. *.duf/*.dsf), is done using DzAssetIOMgr; be sure to look at the header, as there is an assetSaved() signal but the docs need to be updated to represent the evolution of that class.

    -Rob

  • pcicconepciccone Posts: 634
    edited December 1969

    Didn't mean "intercept" as in preventing, I meant to receive a signal before the saving happens so that I have the opportunity to add the Reality data to the duf.

    I looked at the header but there is nothing that explains how to use it or what the class does. How is the assetSaved() signal going to help?

    Basically I need to be notified when the save event happens so that I can update the data in the Reality node. The data are saved to the file, I have verified it though another event, so it's not a matter of creating subclasses. All I need is the right event.

    Thanks in advance.

  • rbtwhizrbtwhiz Posts: 1,603
    edited December 1969

    In that case, you should review the included Custom Scene Data Loading Saving and/or the Custom Element Loading Saving samples.

    -Rob

  • pcicconepciccone Posts: 634
    edited December 1969

    Thank you again. The example is interesting but not what I'm trying to do. I already have the saving working, as the data format goes. The issue is about timing.

    Reality saves its data in its own internal format. When the Studio user saves the scene then that is the moment that Reality needs to copy all its data in the Studio node. I'm trying to optimize the operation so that the program doesn't need to update the Studio container with every edit.

    That's why a "File | Save" event is needed.

    If that is not available then I will have to write the data to Studio with every edit.

    Thanks in advance.

  • rbtwhizrbtwhiz Posts: 1,603
    edited December 1969

    It is what you are trying to do... its just not done the way you are thinking it is.


    In the Custom Scene Data Loading Saving sample, is a file named myscenemodel.h. In that file is the declaration of a DzExtraSceneDataIO subclass, named MySceneModelIO. This class implements virtual functions named shouldWrite(...) and writeExtraInstance(...), from DzAssetExtraObjectIO. The shouldWrite(...) function is called before writing starts, and so can be used to update your custom data... before the writing of said data starts. Custom data can also be updated within the writeExtraInstance(...) definition, as the implementer of the class controls what happens within the function.

    The relationship between the custom DzSceneData subclass and the DzExtraSceneDataIO subclass is established thus, in pluginmain.cpp...

    DZ_PLUGIN_CLASS_GUID( MySceneModel,      F820DACE-1D55-44a5-89C4-69492E2D2F69 );
    DZ_PLUGIN_CLASS_GUID( MySceneModelIO,    562B5DF6-0F2A-432f-A78F-53263F53538B );
    DZ_PLUGIN_REGISTER_SCENEDATA_EXTRA_OBJECT_IO("my_scene_data", MySceneModelIO,  MySceneModel);

    Loading and saving element data is mostly the same... except you subclass DzExtraElementDataIO instead of DzExtraSceneDataIO. The difference between the two is in the function signature of createDataItem(...) - the one for DzExtraElementDataIO takes a DzElement pointer as its first argument, in addition to the DzFileIOSettings pointer.

    In establishing the relationship between your DzCustomData subclass and your DzExtraElementDataIO subclass, instead of using the DZ_PLUGIN_REGISTER_SCENEDATA_EXTRA_OBJECT_IO macro, use the DZ_PLUGIN_REGISTER_ELEMENTDATA_EXTRA_OBJECT_IO macro, as you are hanging data on the node.


    -Rob

  • pcicconepciccone Posts: 634
    edited December 1969

    Hi Rob.
    Thank you for the detailed explanation, I appreciate it.

  • pcicconepciccone Posts: 634
    edited December 1969

    Hi Rob.

    I have one more question, if you please.
    One of the reasons I use a custom element, instead of attaching Reality's data to the DzScene, is to be able to handle the merging of Studio's scenes, a common workflow with Studio.

    What happens to custom scene data when the File | Merge option is used? Is it possible to drive a merge of plugin data if said data is attached to DzScene?

    Thanks in advance.

  • pcicconepciccone Posts: 634
    edited December 1969

    Hi Rob.

    Never mind, I figure it out :)

    Cheers.

  • pcicconepciccone Posts: 634
    edited December 1969

    Hi Rob.

    The writing of data works great, I just reported it in my blog: http://preta3d.com/reality-studio-update-20140225/
    Thanks again for the information.

    I'm working on reading the data now and I need some more details. I got the overall series of events with the context/model/IO classes.
    The issue that I have is that the information that Reality saves is structured with sub-objects and arrays. I redefined the virtual methods for addMember() and that works, but I don't know how to do the same for the startMemberObject(), startMemberArray(), startObject() startArray() methods. Some need to return a DzAssetJsonItem*. I tried returning "this" but so far I get inside the first array of the first sub-object and then Studio crashes.

    Any information will be greatly appreciated.

  • rbtwhizrbtwhiz Posts: 1,603
    edited December 1969

    Take a look at the "Custom Element Loading Saving" example, more specifically mycustomshape .cpp/.h in that example, as it provides code that deals with reading/writing structured data.

    -Rob

  • pcicconepciccone Posts: 634
    edited December 1969

    Thanks, I figured it out on my own.

    Cheers.

Sign In or Register to comment.