global scale and shift

Any question about the main GUI application (frontend)
Post Reply
vinayan
Posts: 27
Joined: Thu Nov 03, 2016 4:11 pm

global scale and shift

Post by vinayan »

hi Daniel,

I have written a pluign to import data from a csv file. I referred the AsciiFilter class to accomplish this. I would like to suppress the shift/scale dialog while importing this file. So i used the ccGlobalShiftManager::NO_DIALOG_AUTO_SHIFT in the plugin. Now, after I import this csv through my plugin, I tried to open another ascii file using the cloudcompare open dialog(File -> Open). But it did not use the previous shift/scale settings from the plugin. The last import option was not seen and the points shifted using a different value. Is there anything I have missed? Code below.

Code: Select all

double scale = 1.0;
CCVector3d P(0,0,0);
CCVector3d Pshift(0,0,0);

if (ccGlobalShiftManager::Handle(P, 0, ccGlobalShiftManager::NO_DIALOG_AUTO_SHIFT, true, Pshift, &scale))
{
    cloudDesc.cloud->setGlobalShift(Pshift);
    cloudDesc.cloud->setGlobalScale(scale);
}
vinayan
Posts: 27
Joined: Thu Nov 03, 2016 4:11 pm

Re: global scale and shift

Post by vinayan »

After peeking the source code, it seems that the lastSettings are only updated when the UI, ccShiftAndScaleCloudDlg is invoked, which does not happen when ccGlobalShiftManager::NO_DIALOG_AUTO_SHIFT is set. What would be another alternative to save the last scale settings when no dialog is selected? Would I have to refactor the source code?
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: global scale and shift

Post by daniel »

Indeed the 'use last shift & scale info' mechanism is a feature of the dialog. Therefore if you don't use the dialog the first time, it's quite logical that the dialog doesn't know about it afterwards.

You could add a static member to the ccShiftAndScaleCloudDlg to force the 'last' stored info (see the static 's_lastInfo' variable in the cpp file). However as you are in a plugin, I'm not sure this will cross the DLL boundary and that the main application will share the same 'static' context. Let's try this first and if this works you can make a pull request to integrate this in the official branch.
Daniel, CloudCompare admin
vinayan
Posts: 27
Joined: Thu Nov 03, 2016 4:11 pm

Re: global scale and shift

Post by vinayan »

but I believe ccGlobalShiftManager does not store the scale and shift anywhere if mode is NO_DIALOG_AUTO_SHIFT. So forcing last stored info might not be useful. Probably the information needs to be saved to some other place than the dialog.
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: global scale and shift

Post by daniel »

Not sure to understand: you seems to know what is the right shift and scale, don't you? Or do you trust the 'auto' shift? Anyway in both cases after loading the file, you can call something like ccShiftAndScaleCloudDlg::SetLastInfo(shift, scale), that internally will simply set the global 's_lastInfo' variable.

Am I missing something?
Daniel, CloudCompare admin
vinayan
Posts: 27
Joined: Thu Nov 03, 2016 4:11 pm

Re: global scale and shift

Post by vinayan »

okay understood now..I misunderstood the thing about the static variable..let me try that..thank you for the help.
daniel
Site Admin
Posts: 7330
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: global scale and shift

Post by daniel »

If it works, don't forget to make a pull request. If it doesn't work, we'll have to find another solution.
Daniel, CloudCompare admin
vinayan
Posts: 27
Joined: Thu Nov 03, 2016 4:11 pm

Re: global scale and shift

Post by vinayan »

hi Daniel..this is working from the plugin. Seems like there is no dll boundary issues. Please review the pull request. Thank you again!
Post Reply