how to access image property list and manipulate in MITK - c++

I am developing a plugin for MITK, which is a tookit for medical imaging. I want to access the full path of image that is loaded in the data manager.
There are properties of images like name, opacity, path etc.
I searched MITK documentation but I could not find any proper information related to that.
Can you please help me?

If you want to see the 'path' in the UI, you can use the Properties plugin, available in the MITK Workbench and in your own app if you decided to include it.
If you want to access the content of the 'path' property in the code, then you need a mitk::DataNode in the current scope, because properties are usually related to node.
std::string path;
node->GetStringProperty("path", path);
Note that this won't give you the full path though. For some reason, MITK decided to remove the extension in this property, thus giving something like D://Data/brain instead of the D://Data/brain.nii.gz that I wanted.
AFAIK, there's currently no 100% safe way to get the real full path in MITK, but one could easily search on the file system using path + ".*" and hoping that it returns only one result :)

The property is not on the DataNode but in the BaseData in it. There is a 'path' property there. You can see its value when right-click the image and selecting 'details'

Related

Get app icon URL in Qt on Linux

I am trying to get the icon of an app (doesn't matter which one). I noticed Qt doesn't have something like GDesktopAppInfo and therefore I tried getting it through QSettings from /usr/share/applications/appname.desktop. That's already a problem, because the desktop file might not be there. Anyway, going further to extract the Icon key. Now I dunno how to find the url (notice that I need the url, sure I could make a QIcon, but I need to export it to QML, which would mean another QQuickImageProvider class, anyway, I don't wanna go that way). Is it possible, or is the aforementioned QQuickImageProvider my only solution?
Here is a little guide that might help you find your way. Keep one thing in mind: start with the basic case, get code running and extend it to more difficult cases later.
For now, lets assume the following:
.desktop file is in /usr/share/applications
App icon is in SVG or PNG format
App icon path is absolute
App name is lower case and does not contain whitespace
Input: App name "git-cola"
Read /usr/share/applications/git-cola.desktop
Use a QRegularExpression to get the Icon value
You get an absolute iconPath, e.g. /usr/share/git-cola/icons/git.svg
Have an invokable C++ function that exposes a QUrl to QML
In QML, set the source property of an Image to getIconUrl("Target App")
where 4. looks something like
QUrl MyClass::getIconUrl(QString appName)
{
// get iconPath from appName
return QUrl::​fromLocalFile(iconPath);
}
If things are running, you can add support for
Multiple .desktop locations (there might be a handful or so)
Add support for relative paths
Add support for XPM files
You can use QIcon::fromTheme(QString iconName) to find the icon. It works most of the time but it's not as reliable as gtk

Path shortener with MFC

I need to display paths in the context menu in my app and need to find a way to shorted them. For instance, what Microsoft apps do in their "Recently Used" list, if the original path is c:\ClientName\ProjectName\ProgramName\ComponentName\SomeFileName.cpp I need it to be converted into something like c:\ClientName\...\SomeFileName.cpp.
So I'm curious if there's any built-in means to do this with C++/MFC or maybe a WinAPI?
Use PathCompacPathEx that will truncate a path by replacing path components with ellipses.
There is Win32 API to get short path name called GetShortPathName, read below. It may help.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364989(v=vs.85).aspx

How can I know which themepack is applied on my system?

Normally when we double click on a themepack file it is applied on our system and a corresponding folder with the same name as the themepack is saved in
C:\Users\<username>\AppData\Local\Microsoft\Windows\Themes
Now if I have multiple themepack files and I have applied each of them at least once, then all the themepacks will have a corresponding folder in the Themes folder. Now I want to know which particular theme is applied on my machine, programmatically.
(When we use a themepack file Custom.theme file is not updated)
I'm pretty sure there's no API that can retrieve that information. Which makes sense, it isn't really relevant. An application never needs to know the name of the theme pack that the user selected.
What you can get using an API, and what is useful, is the name and properties of the theme that the user has enabled. For example, calling the GetCurrentThemeName() function and/or the GetThemeDocumentationProperty() function.aspx) with SZ_THDOCPROP_DISPLAYNAME will tell you whether the user has enabled the Aero theme or not. Or if they're using a custom theme that is not Aero. Just to be sure, though, I tested it, and neither of those functions returns the name of my currently selected theme pack.
However, you can read the registry to obtain the information you desire. Find it in the following location:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\CurrentTheme
That value will contain a string corresponding to the full path to the currently selected theme pack, e.g.:
C:\Users\billg\AppData\Local\Microsoft\Windows\Themes\Pink Polka Dots.theme
If you want, you can strip out the path spec and extension, using just the file name as the name of the theme pack, e.g. Pink Polka Dots.
But that isn't a complete solution because it doesn't take localization into account. Especially with system-provided theme packs, the file name is going to be in English, but the name of the theme pack is going to be localized in the UI. The user sees something different when they pick themes.

Inkscape inx param defaults

I am developing a extension for Inkscape and would like to set a param value based on a value that is set on a object. For example if the ID of the selected object is set to "myRect" how would I display that value in the extension dialog? Seems to me that there should be a way to tell Inkscape that I want a value displayed here from attribute "id", I have read through the documentation on Inkscapes wiki and searched the web but couldn't find any answers.
I don't think it's possible.
The extension UI is built from the static .inx file. There's no way for your extension code to modify that AFAIK.
It might be possible to have your extension rewrite the .inx file all the time. But I imagine that this would be a horrible horrible approach. Also I'm not sure how frequently inkscape reloads the .inx file.

Magento - locate specific core files

I am familiar with theming and using template hints in the Magento back office to locate .phtml files.
What I am not really familiar with are the core files such as app/code/core/Mage/Catalog/Model
What I need to do is override a core file like I would a core phtml file by copying it to 'my theme'.
I basically want to amend some labels which appear on the order summary page of the Magento checkout process - domain.com/checkout/cart/
I followed the trail to the phtml files using template hints. Within the app/design/frontend/default/mytheme/template/checkout/cart I found the code
renderTotals(); ?>
Now I managed, by accident, to stumble upon two of the files I wanted to change:
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Grand.php
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Shipping.php
I made local copies of these files (http://www.magentocommerce.com/wiki/how_to/how_to_create_a_local_copy_of_app_code_core_mage) to override the default labels, like I would if I was overriding a template file.
My question is, how can you locate core files which pertain to the 'stuff' you want to change, located in function calls such as renderTotals(); ?> in the phtml files?
Not being able to pinpoint stuff like I can with template hints is slowing me down, and I am struggling to find a solution as I am not up on all the vocab surrounding Magento yet.
Hope this makes sense and thanks in advance!
From the same settings page where you turn on Template Path Hints, also turn on the "Add Block Names to Hints" setting. This will show you PHP class names such as: Mage_Sales_Model_Quote_Address_Total_Grand to which you can deduce the folder path (underscores represent a subfolder, and the last piece represents the file name).
If you're getting a block such as Mage_Sales_Model_Quote_Address_Total_Default then sometimes it just takes a little common sense to see that it's pulling in other files from the same folder (such as Grand.php and Shipping.php). But there are generally only a couple files in the same folder, so this is pretty easy to see.
As Sid Vel said, a good Search Project functionality is helpful. But if you find yourself looking at Abstract.php of some class, often you need to look in a subfolder in that directory with the proper name to find the concrete implementations. But still, it gets you very close to where you need to be.
I always use Dreamweaver's site / directory search function. It will scan through all the files in the Core folder and tell you where the function is from. In your case, I would search for "renderTotals". You need to enable PHTML editing in Dreamweaver.
Most IDE's will allow this kind of search option. In Aptana you can Ctrl + Click on the function to open the file it is coming from. Magento takes ages to index itself on Aptana, due to its sheer size.