Skip to content

Commit

Permalink
Merge pull request #1201 from AlexanderGetka-cbica/confetti-change-mi…
Browse files Browse the repository at this point in the history
…sc-fixes

Confetti change misc fixes
  • Loading branch information
ashishsingh18 committed Jul 21, 2020
2 parents 3b08389 + c3dca77 commit bdb669a
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 43 deletions.
3 changes: 1 addition & 2 deletions scripts/linux-makeself
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ install_captk () {
fi

echo "Done."
echo "To run CaPTk, locate to where CaPTk is installed and enter the command \"./CaPTk/${ver}/captk\" in your console."

echo "To run CaPTk, change to the directory where CaPTk is installed and enter the command \"./CaPTk/${ver}/captk\" in your console."
}

# Print license with a reader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,54 @@
import ctypes
from ctypes import CFUNCTYPE, c_int,c_char,c_char_p
import numpy
# Update 7/2/2020: Modified ConfettiCore.py to accommodate nuitka packaging.
class ConfettiApi():
def __init__(self):
try:
self.libraryName =self.getCoreModulePath()
self.CoreModule = ctypes.cdll.LoadLibrary(self.libraryName)
self.listner= None
self.txtCallback_ref = None
except:
self.libraryName = os.path.normpath(self.getCoreModulePath())
self.CoreModule = ctypes.cdll.LoadLibrary(self.libraryName)
print "Successfully loaded the ConfettiCore binary."
self.listner= None
self.txtCallback_ref = None
except Exception as e:
self.CoreModule= None
print("Failed to load ConfettiCore binary")
print("Failed to load ConfettiCore binary. Exception: ")
print(e)
def getCoreModulePath(self):
if os.name is 'nt':
libraryName = "ConfettiCore.dll"
else:
libraryName = "libConfettiCore.so"
if getattr(sys, 'frozen', False):
if (getattr(sys, 'frozen', False)):
application_path = os.path.dirname(sys.executable)
elif __file__:
application_path = os.path.dirname(__file__)
baseDir=os.path.join(application_path, '..' )
print "Using __file__"
if os.name is 'nt':
application_path = self.attemptWindowsLongPathFix(os.path.dirname(__file__))
else:
application_path = os.path.dirname(__file__)
baseDir=os.path.join(application_path, '..' ) # use to search directory above dist
# match if dll found in either this or one-higher directory
for root, dirs, files in os.walk(application_path):
for file in files:
if libraryName in file:
return (os.path.join(root, file))
for root, dirs, files in os.walk(baseDir):
for file in files:
if libraryName in file:
return (os.path.join(root, file))
return (os.path.join(root, file))

def attemptWindowsLongPathFix(self, in_path):
# Do not call this on non-Windows platforms.
try:
path = unicode(in_path)
except Exception as e:
print(e)
GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW
buffer = ctypes.create_unicode_buffer(GetLongPathName(path, 0, 0))
GetLongPathName(path, buffer, len(buffer))
print buffer.value
return buffer.value

def registerCppCallback(self):
if self.CoreModule is None:
Expand Down
61 changes: 58 additions & 3 deletions src/view/gui/Slicer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,64 @@ void Slicer::SetInitPosition()

void Slicer::SetCurrentPosition(double x, double y, double z)
{
mCursor[0] = x;
mCursor[1] = y;
mCursor[2] = z;
double X = (x - this->GetInput()->GetOrigin()[0]) / this->GetInput()->GetSpacing()[0];
double Y = (y - this->GetInput()->GetOrigin()[1]) / this->GetInput()->GetSpacing()[1];
double Z = (z - this->GetInput()->GetOrigin()[2]) / this->GetInput()->GetSpacing()[2];

// round up pixel values
X = ROUND(X);
Y = ROUND(Y);
Z = ROUND(Z);

// Force pixel pos within bounds of image if not already
#if VTK_MAJOR_VERSION <= 5
int minX = this->GetInput()->GetWholeExtent()[0];
int maxX = this->GetInput()->GetWholeExtent()[1];
int minY = this->GetInput()->GetWholeExtent()[2];
int maxY = this->GetInput()->GetWholeExtent()[3];
int minZ = this->GetInput()->GetWholeExtent()[4];
int maxZ = this->GetInput()->GetWholeExtent()[5];
#else
int minX = this->GetInput()->GetExtent()[0];
int maxX = this->GetInput()->GetExtent()[1];
int minY = this->GetInput()->GetExtent()[2];
int maxY = this->GetInput()->GetExtent()[3];
int minZ = this->GetInput()->GetExtent()[4];
int maxZ = this->GetInput()->GetExtent()[5];
#endif
if (X < minX)
{
X = minX;
}
else if (X > maxX)
{
X = maxX;
}
if (Y < minY)
{
Y = minY;
}
else if (Y > maxY)
{
Y = maxY;
}
if (Z < minZ)
{
Z = minZ;
}
else if (Z > maxZ)
{
Z = maxZ;
}
// Re-update world pos to match new pixel pos
x = X * this->GetInput()->GetSpacing()[0] + this->GetInput()->GetOrigin()[0];
y = Y * this->GetInput()->GetSpacing()[1] + this->GetInput()->GetOrigin()[1];
z = Z * this->GetInput()->GetSpacing()[2] + this->GetInput()->GetOrigin()[2];

// Set cursor to match new world pos
mCursor[0] = x;
mCursor[1] = y;
mCursor[2] = z;
}

void Slicer::SetInteractorStyle(vtkInteractorStyle * style)
Expand Down
18 changes: 4 additions & 14 deletions src/view/gui/SlicerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,21 +601,11 @@ void SlicerManager::UpdateInfoOnCursorPosition(int slicer)
z = Z * mSlicers[slicer]->GetInput()->GetSpacing()[2] + mSlicers[slicer]->GetInput()->GetOrigin()[2];
//
double value = -VTK_DOUBLE_MAX;
#if VTK_MAJOR_VERSION <= 5
if (X >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] && X <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] &&
Y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] && Y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] &&
Z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] && Z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5])
#else
if (X >= mSlicers[slicer]->GetInput()->GetExtent()[0] && X <= mSlicers[slicer]->GetInput()->GetExtent()[1] &&
Y >= mSlicers[slicer]->GetInput()->GetExtent()[2] && Y <= mSlicers[slicer]->GetInput()->GetExtent()[3] &&
Z >= mSlicers[slicer]->GetInput()->GetExtent()[4] && Z <= mSlicers[slicer]->GetInput()->GetExtent()[5])
#endif
{
// mSlicers[slicer]->GetInput()
value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z);

emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(), x, y, z, X, Y, Z, value);
}
value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z);
// Update position to specified or bounded coords
emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(), x, y, z, X, Y, Z, value);

}

void SlicerManager::Activated()
Expand Down
2 changes: 1 addition & 1 deletion src/view/gui/fHelpTutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fHelpTutorial::fHelpTutorial()

if (!cbica::fileExists(m_helpFileFullPath))
{
cbica::Logging(loggerFile, "Unable to start help page, file '" + m_helpFileFullPath + "' not found");
cbica::Logging(loggerFile, "Unable to start about page, file '" + m_helpFileFullPath + "' not found");
}
else
{
Expand Down
28 changes: 16 additions & 12 deletions src/view/gui/fMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ fMainWindow::fMainWindow()
{
nonNativeAppPaths_wrap.erase(0, 1);
}
nonNativeAppPaths_wrap = nonNativeAppPaths_wrap + " itksnap";
nonNativeAppPaths_wrap = nonNativeAppPaths_wrap + " itksnap" + " confetti";
m_pyGUIApps = cbica::stringSplit(nonNativeAppPaths_wrap, " ");
nonNativeAppPaths_wrap = std::string(CAPTK_APP_LIST_PY_CLI);
if (nonNativeAppPaths_wrap[0] == ' ')
Expand All @@ -356,10 +356,6 @@ fMainWindow::fMainWindow()
size_t allAppCounter = 0;
for (size_t i = 0; i < m_pyGUIApps.size(); i++)
{
if (m_pyGUIApps[i] == "confetti")
{
m_pyGUIApps[i] = "ConfettiGUI";
}
if ((m_pyGUIApps[i] == "librabatch") || (m_pyGUIApps[i] == "librasingle"))
{
m_pyGUIApps[i] = "libra";
Expand Down Expand Up @@ -582,10 +578,13 @@ fMainWindow::fMainWindow()
connect(supportMenu, SIGNAL(triggered(QAction*)), this, SLOT(help_Download(QAction*)));

connect(actionModelLibrary, SIGNAL(triggered()), this, SLOT(OpenModelLibrary()));

mHelpDlg = new fHelpDialog();
mHelpTutorial = new fHelpTutorial();

connect(help_systeminformation, SIGNAL(triggered()), this, SLOT(OnSystemInformationMenuClicked()));

connect(&mHelpTutorial, SIGNAL(skipTutorialOnNextRun(bool)), this, SLOT(skipTutorial(bool)));
connect(mHelpTutorial, SIGNAL(skipTutorialOnNextRun(bool)), this, SLOT(skipTutorial(bool)));

for (size_t i = 0; i < vectorOfGBMApps.size(); i++)
{
Expand Down Expand Up @@ -944,7 +943,7 @@ fMainWindow::fMainWindow()
statusBar()->addPermanentWidget(m_progressBar);
m_progressBar->setValue(0);

mHelpDlg = new fHelpDialog();


recurrencePanel.SetCurrentLoggerPath(m_tempFolderLocation);
msubtypePanel.SetCurrentLoggerPath(m_tempFolderLocation);
Expand Down Expand Up @@ -1014,6 +1013,9 @@ fMainWindow::~fMainWindow()
file.close();
}

if (mHelpTutorial)
delete mHelpTutorial;

if (mHelpDlg)
delete mHelpDlg;

Expand Down Expand Up @@ -1133,7 +1135,7 @@ std::string fMainWindow::ConversionFrom2Dto3D(const std::string &fileName)
void fMainWindow::about()
{
//#if CAPTK_PACKAGE_PROJECT
mHelpTutorial.show();
mHelpTutorial->show();
//#endif
}

Expand Down Expand Up @@ -2290,6 +2292,7 @@ void fMainWindow::CloseImage(QTableWidgetItem* item)

void fMainWindow::MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z, double value)
{

infoPanel->setCurrentInfo(visibility, x, y, z, X, Y, Z, value);
tumorPanel->HighlightCurrentSelctedPoints(x, y, z, X, Y, Z, value);
}
Expand Down Expand Up @@ -2725,9 +2728,10 @@ void fMainWindow::MoveSlicerCursor(double x, double y, double z, int mode)
mSlicerManagers[mCurrentPickedImageIndex]->GetSlicer(0)->SetCurrentPosition(x, y, z);
//
mSlicerManagers[mCurrentPickedImageIndex]->Picked();
mSlicerManagers[mCurrentPickedImageIndex]->UpdateInfoOnCursorPosition(0);
mSlicerManagers[mCurrentPickedImageIndex]->UpdateViews(0);
mSlicerManagers[mCurrentPickedImageIndex]->UpdateLinked(0);
mSlicerManagers[mCurrentPickedImageIndex]->UpdateInfoOnCursorPosition(0);

}
else if (mode == 1)
{
Expand All @@ -2739,9 +2743,9 @@ void fMainWindow::MoveSlicerCursor(double x, double y, double z, int mode)
mSlicerManagers[mCurrentPickedImageIndex]->GetSlicer(0)->SetCurrentPosition(x, y, z);
//
mSlicerManagers[mCurrentPickedImageIndex]->Picked();
mSlicerManagers[mCurrentPickedImageIndex]->UpdateInfoOnCursorPosition(0);
mSlicerManagers[mCurrentPickedImageIndex]->UpdateViews(0);
mSlicerManagers[mCurrentPickedImageIndex]->UpdateLinked(0);
mSlicerManagers[mCurrentPickedImageIndex]->UpdateInfoOnCursorPosition(0);
}
propogateSlicerPosition();
}
Expand Down Expand Up @@ -6124,8 +6128,8 @@ void fMainWindow::ApplicationLIBRASingle()

void fMainWindow::ApplicationConfetti()
{
std::string scriptToCall = m_allNonNativeApps["ConfettiGUI"];

std::string scriptToCall = m_allNonNativeApps["confetti"];
if (startExternalProcess(scriptToCall.c_str(), QStringList()) != 0)
{
ShowErrorMessage("Confetti failed to execute. Please check installation requirements and retry.", this);
Expand Down
2 changes: 1 addition & 1 deletion src/view/gui/fMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ public slots:
Fetalbrain mfetalbrain;

fHelpDialog* mHelpDlg;
fHelpTutorial mHelpTutorial;
fHelpTutorial* mHelpTutorial;

std::string t1cePath;
std::string m_imagetype_string;
Expand Down

0 comments on commit bdb669a

Please sign in to comment.