Page 1 of 1

global scale and shift

Posted: Thu Nov 10, 2016 9:30 am
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);
}

Re: global scale and shift

Posted: Thu Nov 10, 2016 11:21 am
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?

Re: global scale and shift

Posted: Fri Nov 11, 2016 10:05 am
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.

Re: global scale and shift

Posted: Fri Nov 11, 2016 11:05 am
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.

Re: global scale and shift

Posted: Fri Nov 11, 2016 12:39 pm
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?

Re: global scale and shift

Posted: Fri Nov 11, 2016 12:44 pm
by vinayan
okay understood now..I misunderstood the thing about the static variable..let me try that..thank you for the help.

Re: global scale and shift

Posted: Fri Nov 11, 2016 1:56 pm
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.

Re: global scale and shift

Posted: Mon Nov 14, 2016 7:51 am
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!