Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienTs authored Oct 2, 2020
1 parent bfba511 commit 62ee1b9
Showing 1 changed file with 90 additions and 72 deletions.
162 changes: 90 additions & 72 deletions MosaicExplorerJ_v1_0.ijm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ CAMOverlay = false;
Steps = 1;
BigSteps = 5;
NudgeMode = false;
SpaceMode = false;

// Load tile grid alignment parameters from configuration file (if present)
if(UseFileParams)
Expand Down Expand Up @@ -456,101 +457,110 @@ while(isOpen(BoardID))
ReDraw = false;
}

// Swap between single and big steps for Z nudging
// Adjust Z adjustment direction + switch between 1/BigSteps
if(isKeyDown("space"))
{
if(Steps == 1)
{
Steps = BigSteps;
showStatus("Steps: "+d2s(BigSteps,0));
}
else

// Alsways flip Z step direction
Steps = -Steps;

// If space is pressed twice in a row, swicth between 1 and BigSteps
if(SpaceMode == true)
{
if(Steps == BigSteps)
{
Steps = 1;
showStatus("Steps: 1");
}
if(abs(Steps) == 1)Steps = Steps*BigSteps;
else Steps = Steps/abs(Steps);
SpaceMode = false;
}
else SpaceMode = true;
showStatus("Steps: "+d2s(Steps,0));

// Wait space to be released
while(isKeyDown("space"))wait(50);
while(isKeyDown("space"))wait(50);
}

// Shortcut to nudge Z slice and Z correction
if(isKeyDown("shift"))
{
// Exit "Space mode" (adjusting step)
SpaceMode = false;

// Use mouse coordinates to locate active tile
getCursorLoc(x, y, z, flags);

// Use to avoid the nasty behaviour of IJ to "lose" cursor coordinates after pressing space
if(x == -1)
{
x = LastX;
y = LastY;
}
else
{
LastX = x;
LastY = y;
}

// Avoid pressing space returns -1/-1 coordinate
if(x>-1)
mindst = 1/0;
minidx = 0;
N = lengthOf(XTile)/2;
for(i=(SidCur-1)*N;i<SidCur*N;i++)
{
mindst = 1/0;
minidx = 0;
N = lengthOf(XTile)/2;
for(i=(SidCur-1)*N;i<SidCur*N;i++)
dst = sqrt(pow(x-XTile[i],2)+pow(y-YTile[i],2));
if(dst<mindst)
{
dst = sqrt(pow(x-XTile[i],2)+pow(y-YTile[i],2));
if(dst<mindst)
{
mindst = dst;
minidx = i;
}
mindst = dst;
minidx = i;
}

// Nudge CorrZx (global or column)
if(XiTile[minidx]>XdMin)
}

// Nudge CorrZx (global or column)
if(XiTile[minidx]>XdMin)
{
if(x<XTile[minidx])
{
if(x<XTile[minidx])
XdMin = XiTile[minidx]-1;
YdMin = YiTile[minidx];
XdMax = XiTile[minidx];
YdMax = YiTile[minidx];
if(NudgeMode == true)
{
XdMin = XiTile[minidx]-1;
YdMin = YiTile[minidx];
XdMax = XiTile[minidx];
YdMax = YiTile[minidx];
if(NudgeMode == true)
{
if(FreeZxyCorr==false)CorrZX[CamCur-1+2*(SidCur-1)] = CorrZX[CamCur-1+2*(SidCur-1)] + (-Steps+2*Steps*(y<=YTile[minidx]));
else for(i=XiTile[minidx];i<=(XMax-XMin);i++)for(j=YiTile[minidx];j<=(YMax-YMin);j++)ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] = ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] + (-Steps+2*Steps*(y<=YTile[minidx]));
//else for(i=XiTile[minidx];i<=(XMax-XMin);i++)for(j=0;j<=(YMax-YMin);j++)ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] = ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] + (-Steps+2*Steps*(y<=YTile[minidx]));
}
else showStatus("Tile adjustment mode");
ShowDual = false;
ReDraw = true;
NudgeMode = true;
if(FreeZxyCorr==false)CorrZX[CamCur-1+2*(SidCur-1)] = CorrZX[CamCur-1+2*(SidCur-1)] + Steps;
else for(i=XiTile[minidx];i<=(XMax-XMin);i++)for(j=YiTile[minidx];j<=(YMax-YMin);j++)ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] = ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] + Steps;
}
else showStatus("Tile adjustment mode");
ShowDual = false;
ReDraw = true;
NudgeMode = true;
}

// Nudge CorrZy (global or row)
if(YiTile[minidx]>YdMin)
}

// Nudge CorrZy (global or row)
if(YiTile[minidx]>YdMin)
{
if(y<YTile[minidx])
{
if(y<YTile[minidx])
XdMin = XiTile[minidx];
YdMin = YiTile[minidx]-1;
XdMax = XiTile[minidx];
YdMax = YiTile[minidx];
if(NudgeMode == true)
{
XdMin = XiTile[minidx];
YdMin = YiTile[minidx]-1;
XdMax = XiTile[minidx];
YdMax = YiTile[minidx];
if(NudgeMode == true)
{
if(FreeZxyCorr==false)CorrZY[CamCur-1+2*(SidCur-1)] = CorrZY[CamCur-1+2*(SidCur-1)] + (-Steps+2*Steps*(x>XTile[minidx]));
else for(j=YiTile[minidx];j<=(YMax-YMin);j++)for(i=XiTile[minidx];i<=(XMax-XMin);i++)ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] = ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] + (-Steps+2*Steps*(x>XTile[minidx]));
//else for(j=YiTile[minidx];j<=(YMax-YMin);j++)for(i=0;i<=(XMax-XMin);i++)ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] = ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] + (-Steps+2*Steps*(x>XTile[minidx]));
}
ShowDual = false;
ReDraw = true;
NudgeMode = true;
if(FreeZxyCorr==false)CorrZY[CamCur-1+2*(SidCur-1)] = CorrZY[CamCur-1+2*(SidCur-1)] + Steps;
else for(j=YiTile[minidx];j<=(YMax-YMin);j++)for(i=XiTile[minidx];i<=(XMax-XMin);i++)ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] = ZManOffs[j+i*(YMax+1-YMin)+(SidCur-1)*(YMax+1-YMin)*(XMax+1-XMin)] + Steps;
}
}

// Actions from left uppermost visible tile
if((XiTile[minidx]==XdMin)&&(YiTile[minidx]==YdMin))
{
// Nudge current Z slice
ZCur = ZCur + (-1+2*(x>XTile[minidx]))*Steps;
ReDraw = true;
ShowDual = false;
ReDraw = true;
NudgeMode = true;
}
}
else showStatus("Move mouse");

// Actions from left uppermost visible tile
if((XiTile[minidx]==XdMin)&&(YiTile[minidx]==YdMin))
{
// Nudge current Z slice
ZCur = ZCur + (-1+2*(x>XTile[minidx]))*Steps;
ReDraw = true;
}


// Wait shift to be released
while(isKeyDown("shift"))wait(50);
Expand All @@ -576,6 +586,7 @@ while(isOpen(BoardID))
CamCurOld = CamCur;
CCurOld = CCur;
SidCurOld = SidCur;
BigStepsOld = BigSteps;
Dialog.create("Control Panel");
Dialog.addSlider("ZPos", ZMin, ZMax, ZCur);
Dialog.addSlider("CPos", 0, CMax, CCur);
Expand Down Expand Up @@ -609,6 +620,7 @@ while(isOpen(BoardID))
}
}
if(DualSide)Dialog.addNumber("ZRLCor", RLZCor[CamCur-1]);
Dialog.addNumber("BigSteps", BigSteps);
if(DualSide)Dialog.addCheckbox("Dual side mode", ShowDual);
if(EnableColorMode == true)Dialog.addCheckbox("Color mode", ColorMode);
Dialog.addCheckbox("Free Zxy Correction", FreeZxyCorr);
Expand Down Expand Up @@ -659,6 +671,7 @@ while(isOpen(BoardID))
}
}
if(DualSide)RLZCor[CamCurOld-1] = Dialog.getNumber();
BigSteps = Dialog.getNumber();
if(DualSide)ShowDual = Dialog.getCheckbox();
if(EnableColorMode == true)ColorMode = Dialog.getCheckbox();
FreeZxyCorr = Dialog.getCheckbox();
Expand All @@ -667,9 +680,16 @@ while(isOpen(BoardID))
ShowExtra = Dialog.getCheckbox();
ExportStack = Dialog.getCheckbox();
Exit = Dialog.getCheckbox();

// Wait alt to be released
while(isKeyDown("alt"))wait(50);

// Adjust BigSteps
if(BigSteps != BigStepsOld)
{
Steps = Steps/abs(Steps)*BigSteps;
showStatus("Steps ="+d2s(Steps,0));
}

// Trigger board redraw
ReDraw = true;
Expand All @@ -682,7 +702,6 @@ while(isOpen(BoardID))
Dialog.addSlider("XdMax", XMin, XMax, XdMax);
Dialog.addSlider("YdMin", YMin, YMax, YdMin);
Dialog.addSlider("YdMax", YMin, YMax, YdMax);
Dialog.addNumber("BigSteps", BigSteps);
Dialog.addMessage("CAM2 registration");
Dialog.addNumber("CAM2XCor", CAMXCor[SidCurOld-1]);
Dialog.addNumber("CAM2YCor", CAMYCor[SidCurOld-1]);
Expand Down Expand Up @@ -716,7 +735,6 @@ while(isOpen(BoardID))
XdMax = Dialog.getNumber();
YdMin = Dialog.getNumber();
YdMax = Dialog.getNumber();
BigSteps = Dialog.getNumber();
CAMXCor[SidCurOld-1] = Dialog.getNumber();
CAMYCor[SidCurOld-1] = Dialog.getNumber();
CAMAng[SidCurOld-1] = Dialog.getNumber();
Expand Down

0 comments on commit 62ee1b9

Please sign in to comment.