On 12/03/2013 04:25 PM, Miguel Nunes wrote:
> Markus,
>
> m_Window is a QmitkRenderWinow.
>
> What I have right now is a class I implemented which was based on the 
> Interaction example class I found on the documentation, but I still dont know 
> how to connect the registration and m_Window. It seems that the registration 
> knows that there is a QmitkRenderWindow that will be the target mouse clicks 
> and key presses?

The interactor is attached to a mitk::DataNode, not an individual render 
window. The render window association for the UI events happens 
automatically in the innards of MITK.

>
> Sascha, all the points that u pointed out are correct. I double checked. 
> Right now, every thing builds and compiles correctly.
There has to be a mistake at some place, because the strings in 
LIBRARY_NAME of usFunctionEmbedResources() and the second argument of 
US_INITIALIZE_MODULE are different. The are required to be the same (the 
name of the library). Unless we are talking about two different plug-ins.

>   But when I start my plugin I get the following error:
>
>   Part initialization error: 
> D:\src\MITK2013.09.0\Core\Code\Interactions\mitkStateMachineContainer.cpp:73:
> Resource not valid. State machine pattern not found:StatemachineTest.xml
Very likely because the LIBRARY_NAME argument is incorrect.

- Sascha

>
> Best,
> Miguel
>
>
>
> On Tuesday, December 3, 2013 15:48 CET, Markus Engel 
> <[email protected]> wrote:
>
>> Hi Miguel,
>>
>> Concerning your issue #5, I'm not sure which type your m_Window is but it 
>> sounds like it's a vtkRenderWindow.
>> If this is the case, GetInteractor() will return a vtkRenderWindowInteractor 
>> and NOT an MITK interactor.
>>
>> The MITK interaction-framework is set on top of VTK. For a more detailed 
>> description please see 
>> http://docs.mitk.org/nightly-qt4/DataInteractionTechnicalPage.html.
>>
>> A QmitkRenderWindow in 2D-mode is not supposed to work with VTK interactors. 
>> It might work, but that's not how
>> it's supposed to be. The usual way to interact in this case is to use an 
>> mitk interactor.
>>
>> Greets,
>> Markus
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Sascha Zelzer [mailto:[email protected]]
>> Gesendet: Dienstag, 3. Dezember 2013 15:38
>> An: Miguel Nunes; Alyson Roger
>> Cc: [email protected]
>> Betreff: Re: [mitk-users] Add a new state machine
>>
>> Hi,
>>
>> On 12/03/2013 11:36 AM, Miguel Nunes wrote:
>>> Hello again,
>>> I have been trying to implement this in my plugin but I am encountering 
>>> some issues.
>>>
>>> step by step:
>>>
>>> 1) I added the xml files to the correct resoures/Interaction folder.
>> I guess you have a spelling error in your email here, since it should be 
>> "resources/Interactions".
>>
>>> 2) on the files.cmake I added the following
>>>
>>> set(RESOURCE_FILES
>>>     Interactions/StatemachineTest.xml
>>> )
>> The RESOURCE_FILES CMake variable is not evaluated by any of the MITK CMake 
>> macros used for a MITK plug-in (just for MITK modules). Since you do not 
>> seem to use that variable yourself later on, you might as well remove it.
>>
>>> set(CPP_FILES )
>>>
>>> usFunctionEmbedResources(CPP_FILES
>>>     LIBRARY_NAME "org_my_plugin"
>>>     ROOT_DIR resources
>>>     FILES
>>>       Interactions/StatemachineTest.xml
>>>       Interactions/StatemachineTestConfig.xml
>>> )
>>>
>>> foreach(file ${SRC_CPP_FILES}) ....
>> This looks okay in principal. Make sure to use the correct LIBRARY_NAME 
>> argument (especially since the second argument to US_INITIALIZE_MODULE below 
>> is different which is wrong).
>>
>>> 3) on my org_mitk_plugin_Activator I added these lines with success:
>>> #include <usModuleInitialization.h>
>>>
>>> US_INITIALIZE_MODULE("My Module", "org_mycompany_myplugin")
>> Is "org_mycompany_myplugin" the correct name of the shared library of
>> your plugin?
>>
>>> namespace mitk { ....
>>>
>>> 4) on my cpp file I dont know where to add the us::ModuleContext* 
>>> moduleContext = us::GetModuleContext(); stuff...
>>> Right now I have it on the CreateQtPartControl( QWidget *parent ){} method.
>>>
>>> Is this correct?
>> There is not one correct way. It depends when you want to create and add
>> your interactor. It is probably a good place to do. If you are
>> registering an InteractionEventObserver, remember to unregister the
>> observer in the destructor of your view.
>>
>>>
>>> 5) I am not sure about the  someInteractor = mitk::MyOwnInteractor::New();
>>> How do I define my own interactor for my QmitkRenderWindow? shouldn I just 
>>> use
>>>
>>>
>>>     m_Controls.m_window->GetInteractor(); ?
>>>
>> It really depends want you actually want to do. The "MyOwnInteractor"
>> class is typically used to associate custom actions with state machine
>> transitions. Maybe you can re-state your intent in the first place?
>>
>>
>> Best,
>>
>> Sascha
>>
>>> Thank you again for such fast replies, Sascha and Markus!
>>> Your insights on this topic are invaluable!
>>>
>>>
>>> On Monday, December 2, 2013 19:53 CET, Alyson Roger 
>>> <[email protected]> wrote:
>>>
>>>> It worked!
>>>>
>>>> I embedded the resources files into the CPP_FILES by declaring :
>>>>
>>>>
>>>> set(CPP_FILES )
>>>>
>>>> usFunctionEmbedResources(CPP_FILES
>>>> LIBRARY_NAME "org_mycompany_myplugin"
>>>> ROOT_DIR resources
>>>> FILES Interactions/MyStateMachine.xml Interactions/MyStateMachineConfig.xml
>>>> )
>>>>
>>>>
>>>> then the SRC_CPP_FILES  extracts them from CPP_FILES.
>>>>
>>>> Now the DataNode acts in the QmitkRenderWindows as I defined it in my own
>>>> state machine.
>>>>
>>>>
>>>> Thank you very everyone for the help!
>>>>
>>>>
>>>>
>>>> 2013/12/2 Sascha Zelzer <[email protected]>
>>>>
>>>>>    Hi,
>>>>>
>>>>> I added the mitk-users list CC so other people might benefit from the
>>>>> discussion.
>>>>>
>>>>> As Markus wrote, the relative paths are important to keep, since the MITK
>>>>> libraries will look at the resource tree of each loaded module and extract
>>>>> all Interactions/*.xml files which are considered to contain interaction
>>>>> state machine or event config xml files.
>>>>>
>>>>> Try the following:
>>>>>
>>>>> usFunctionEmbedResources(SRC_CPP_FILES
>>>>>                            LIBRARY_NAME "org_mycompany_myplugin"
>>>>>                            ROOT_DIR resources
>>>>>                            FILES Interactions/MyStateMachine.xml 
>>>>> Interactions/MyStateMachineConfig.xml
>>>>>                           )
>>>>>
>>>>>
>>>>> The generated C++ file will be appended to the SRC_CPP_FILES variable,
>>>>> which generally holds all the cpp files for your plug-in (filled in the
>>>>> files.cmake file). Do not clear it before calling the
>>>>> usFunctionEmbedResources macro.
>>>>>
>>>>> Best,
>>>>>
>>>>> Sascha
>>>>>
>>>>>
>>>>>
>>>>> On 12/02/2013 07:14 PM, Alyson Roger wrote:
>>>>>
>>>>>    Thank you Sascha. I think that the third solution is the most 
>>>>> convenient
>>>>> for me. Where do I have to call the usFunctionEmbedResources() ?
>>>>>    I tried to use it into the files.cmake of my project this way :
>>>>>
>>>>> set(module_srcs)
>>>>> usFunctionEmbedResources(module_srcs
>>>>> LIBRARY_NAME "org_mycompany_myplugin"
>>>>> ROOT_DIR resources/Interactions
>>>>> FILES   MyStateMachine.xml  MyStateMachineConfig.xml
>>>>> )
>>>>>
>>>>>    But it still doesn't find the resources.
>>>>>
>>>>>    Thanks,
>>>>>
>>>>>
>>>>>
>>>>> 2013/12/2 Sascha Zelzer <[email protected]>
>>>>>
>>>>>>    Hi,
>>>>>>
>>>>>> the explanations from Markus and Christian were tailored for MITK
>>>>>> "Modules" which automatically get a module context via our CMake build
>>>>>> system.
>>>>>>
>>>>>> In your case, you are developing a plug-in, which is not a traditional
>>>>>> MITK Module and hence does not get a module context automatically and 
>>>>>> also
>>>>>> does not evaluate the RESOURCE_FILES CMake variable in the files.cmake 
>>>>>> file.
>>>>>>
>>>>>> You have three options:
>>>>>>
>>>>>> 1.) Split your code into a module and a plug-in. The module will contain
>>>>>> the Qt independent interaction stuff.
>>>>>>
>>>>>> 2.) Embed your xml file as a Qt resource and nag the MITK developers to
>>>>>> enhance the interaction API such that it can also handle std::istream
>>>>>> objects to read xml files from.
>>>>>>
>>>>>> 3.) Make your plug-in a hybrid by manually adding "module capabilities".
>>>>>> This is what you already did partially by giving it a module context. For
>>>>>> embedding resources "the module way", you need to call the
>>>>>> usFunctionEmbedResources() CMake function yourself to embed your xml 
>>>>>> files.
>>>>>> See its documentation here:
>>>>>>
>>>>>>
>>>>>> http://docs.mitk.org/nightly-qt4/group__MicroServicesCMake.html#ga28d86dce8ac374e6563ba3d5fbca225a
>>>>>>
>>>>>>
>>>>>> Best,
>>>>>> Sascha
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 12/02/2013 05:51 PM, Alyson Roger wrote:
>>>>>>
>>>>>>    Thank you Markus. The problem I find now is that the linker does not
>>>>>> find the definition of GetModuleContext() in my plugin. After reading a
>>>>>> little more, I've tried to configure a module context in my plugin this 
>>>>>> way:
>>>>>>
>>>>>> #include <usModuleInitialization.h>
>>>>>>
>>>>>> US_INITIALIZE_MODULE("My Module", "org_mycompany_myplugin")
>>>>>>
>>>>>>    I added those two lines in my plugin activator source file. Now the
>>>>>> linked finds the definition of GetModuleContext, but following the code 
>>>>>> in
>>>>>> debug mode I get to usModule.cpp line 269:
>>>>>>
>>>>>> if (d->resourceTreePtrs.empty())
>>>>>>     {
>>>>>>       return ModuleResource();
>>>>>>     }
>>>>>>
>>>>>>    where it finds an empty resource tree.
>>>>>>
>>>>>>    I don't know if I'm not adding correctly the xml files (I'm doing it
>>>>>> exactly as you specified) or I'm not defining the module in my plugin
>>>>>> correctly in the activator.
>>>>>>
>>>>>>    Thanks,
>>>>>>
>>>>>> Aly
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2013/12/2 Markus Engel <[email protected]>
>>>>>>
>>>>>>>    Hi Alyson and Miguel,
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> In order for MITK to correctly find your statmachine patterns you need
>>>>>>> to use the MITK resource mechanism as described in
>>>>>>>
>>>>>>> http://docs.mitk.org/nightly-qt4/InteractionMigration.html#IncludeFiles.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> What you basically have to do is put your XML file in a folder following
>>>>>>> this pattern:
>>>>>>>
>>>>>>> <your-plugin-folder>/resources/Interactions/
>>>>>>>
>>>>>>> (By the way, the names of the folders have to be like that!)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> In your files.cmake of your plugin you need to put the following line:
>>>>>>>
>>>>>>> set(RESOURCE_FILES Interactions/dummyStatemachine.xml )
>>>>>>>
>>>>>>> Note that you must NOT add the ‘resources’ to this path!
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> When you have instantiated your interactor and try to load the
>>>>>>> statemachine you will use the method LoadStateMachine()
>>>>>>>
>>>>>>> that has two parameters. The first one is the name of the XML file, the
>>>>>>> second one is the module in which the XML file is actually located.
>>>>>>>
>>>>>>> The code you posted below will look for the XML file in the Core as no
>>>>>>> module has been given.
>>>>>>>
>>>>>>> The correct way to do it would be:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> us::ModuleContext* moduleContext = us::GetModuleContext();
>>>>>>>
>>>>>>> someInteractor = mitk::MyOwnInteractor::New();
>>>>>>>
>>>>>>> someInteractor->LoadStateMachine( “MyPattern.xml”,
>>>>>>> moduleContext->GetModule() );
>>>>>>>
>>>>>>> someInteractor-> SetEventConfig ( “MyConfig.xml”,
>>>>>>> moduleContext->GetModule() );
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> In order for your interactor to receive events from the renderwindow you
>>>>>>> need to register it with the cppMicroServices:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> us::GetModuleContext()->RegisterService<mitk::InteractionEventObserver>(
>>>>>>> someInteractor.GetPointer(), us::ServiceProperties() );
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> This should make your interactor work correctly.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I hope this helps you on your way to your first interactor!
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Greets,
>>>>>>>
>>>>>>> Markus
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> *Von:* Alyson Roger [mailto:[email protected]]
>>>>>>> *Gesendet:* Montag, 2. Dezember 2013 14:55
>>>>>>> *Cc:* [email protected]
>>>>>>> *Betreff:* Re: [mitk-users] Add a new state machine
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Hello Mitk users,
>>>>>>>
>>>>>>> I have been through the mitk code and I can't find where the
>>>>>>> PointSet.xml is referenced to be found in the Qt project.
>>>>>>>
>>>>>>> Does someone have a clue to help us solving this state machine issue?
>>>>>>>
>>>>>>> Thank you,
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2013/11/29 Miguel Nunes <[email protected]>
>>>>>>>
>>>>>>> Hello MITK Team,
>>>>>>>
>>>>>>> I also have this problem, but unfortunately I haven't reach Alyson
>>>>>>> stage.
>>>>>>>
>>>>>>> I have gone through the step10 example and the documentation but I have
>>>>>>> no idea how to configure the interaction for my own QmitkRenderWindow. I
>>>>>>> tried setting it up with a  VtkInteractor that I have in my stand alone 
>>>>>>> vtk
>>>>>>> application, but it seems mitk ignores that, and goes back in using the
>>>>>>> interactor found in stdmultiwidget thing.
>>>>>>>
>>>>>>> so, my questions are:
>>>>>>> 1) Where should the xml files be for my plugin?
>>>>>>> 2) what have I to do to connect to those xml files?
>>>>>>> 3) what have I to do to connect those interactions (mouse and keyboard)
>>>>>>> with the qmitkrenderwindow of my plgin?
>>>>>>>
>>>>>>> Thank you,
>>>>>>> Miguel
>>>>>>>
>>>>>>>    Em 29-11-2013 16:53, Alyson Roger escreveu:
>>>>>>>
>>>>>>>     Hi Mailing List,
>>>>>>>
>>>>>>> I am trying to do something simple : use my own State Machine in a .xml
>>>>>>> file for my plug in in  the mitkWorkBench. A part in the tutorial that 
>>>>>>> is
>>>>>>> not clear to me is how I include my state machine into the
>>>>>>> GlobalInteraction. I know the code must be in the form
>>>>>>>
>>>>>>> m_CurrentInteractor = mitk::PointSetDataInteractor::New();
>>>>>>> m_CurrentInteractor->LoadStateMachine("PointSet.xml");
>>>>>>>
>>>>>>> m_CurrentInteractor->SetEventConfig("PointSetConfig.xml");
>>>>>>>
>>>>>>>
>>>>>>> As Step 10 of the tutorial.
>>>>>>> But I would like to know where do I have to put my .xml file so the
>>>>>>> LoadStateMachine does not crash when I run my Plug In with my state
>>>>>>> machine. I intended to use InteractionEventHandler::AddEventConfig but 
>>>>>>> it
>>>>>>> didn't work.
>>>>>>>
>>>>>>> I really hope that someone will be able to help me because I have been
>>>>>>> stuck during days with the interaction part, which is new for me.
>>>>>>>
>>>>>>> Thank you very much
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> *Alyson ROGER*
>>>>>>>
>>>>>>> *[email protected] <[email protected]>*
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>>
>>>>>>> Rapidly troubleshoot problems before they affect your business. Most IT
>>>>>>>
>>>>>>> organizations don't have a clear picture of how application performance
>>>>>>>
>>>>>>> affects their revenue. With AppDynamics, you get 100% visibility into 
>>>>>>> your
>>>>>>>
>>>>>>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of 
>>>>>>> AppDynamics Pro!
>>>>>>>
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>>
>>>>>>> mitk-users mailing list
>>>>>>>
>>>>>>> [email protected]
>>>>>>>
>>>>>>> https://lists.sourceforge.net/lists/listinfo/mitk-users
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Rapidly troubleshoot problems before they affect your business. Most IT
>>>>>>> organizations don't have a clear picture of how application performance
>>>>>>> affects their revenue. With AppDynamics, you get 100% visibility into
>>>>>>> your
>>>>>>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of
>>>>>>> AppDynamics Pro!
>>>>>>>
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> mitk-users mailing list
>>>>>>> [email protected]
>>>>>>> https://lists.sourceforge.net/lists/listinfo/mitk-users
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> *Alyson ROGER*
>>>>>>>
>>>>>>> ingénieur diplômée INSA de Lyon
>>>>>>> Génie Electronique
>>>>>>>
>>>>>>> 06 20 60 07 47
>>>>>>>
>>>>>>> *[email protected] <[email protected]>*
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> *Alyson ROGER*
>>>>>>
>>>>>> ingénieur diplômée INSA de Lyon
>>>>>> Génie Electronique
>>>>>>
>>>>>> 06 20 60 07 47
>>>>>>
>>>>>> *[email protected] <[email protected]>*
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>>> *Alyson ROGER*
>>>>>
>>>>> ingénieur diplômée INSA de Lyon
>>>>> Génie Electronique
>>>>>
>>>>> 06 20 60 07 47
>>>>>
>>>>> *[email protected] <[email protected]>*
>>>>>
>>>>>
>>>>>
>>>>>
>>>> --
>>>> *Alyson ROGER*
>>>>
>>>> ingénieur diplômée INSA de Lyon
>>>> Génie Electronique
>>>>
>>>> 06 20 60 07 47
>>>>
>>>> *[email protected] <[email protected]>*
>>>
>>> --
>>> VRVis Zentrum fuer Virtual Reality und Visualisierung
>>> Forschungs-GmbH                  FN: 195369h, HG Wien
>>> Donau-City-Strasse 1              +43(0)1 20501 30100
>>> A-1220 Wien, Austria        web:<http://www.vrvis.at>
>>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics 
>> Pro!
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
>> _______________________________________________
>> mitk-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/mitk-users
> --
> VRVis Zentrum fuer Virtual Reality und Visualisierung
> Forschungs-GmbH                  FN: 195369h, HG Wien
> Donau-City-Strasse 1              +43(0)1 20501 30100
> A-1220 Wien, Austria        web:<http://www.vrvis.at>
>


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to