Difference between revisions of "NA-MIC/Projects/Collaboration/Slicer3 Theme"
From NAMIC Wiki
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{| | {| | ||
|[[Image:ProjectWeek-2008.png|thumb|320px|Return to [[2008_Summer_Project_Week|Project Week Main Page]] ]] | |[[Image:ProjectWeek-2008.png|thumb|320px|Return to [[2008_Summer_Project_Week|Project Week Main Page]] ]] | ||
− | |[[Image: | + | |[[Image:IA-FEMeshNoTheme.png|thumb|320px|IA-FEMesh with no installed theme.]] |
− | |[[Image: | + | |[[Image:IA-FEMeshSlicer3Theme.png|thumb|320px|IA-FEMesh with Slicer3 theme installed.]] |
|} | |} | ||
Line 9: | Line 9: | ||
===Key Investigators=== | ===Key Investigators=== | ||
− | * Iowa: Nicole Grosland | + | * Iowa: Vincent Magnotta, Nicole Grosland, Hans Johnson |
<h1>Objective</h1> | <h1>Objective</h1> | ||
− | This page describes how to incorporate the Slicer3 Theme into any KWWidgets based application. | + | This page describes how to incorporate the Slicer3 Theme into any KWWidgets based application. Hopefully this will develop into a Slicer3 Theme library that one can link against. |
− | <h1> | + | <h1>Getting the Slicer3 Theme Files</h1> |
The Slicer3 theme is a clean and nice looking user interface. This page describes how to incroporate the theme into any KWWidgets application. | The Slicer3 theme is a clean and nice looking user interface. This page describes how to incroporate the theme into any KWWidgets application. | ||
Line 31: | Line 31: | ||
**vtkSlicerCheckRadioButton_ImageData.h | **vtkSlicerCheckRadioButton_ImageData.h | ||
− | + | <h1>Slicer3 Theme Modifications</h1> | |
+ | '''Modify vtkSlicerTheme.cxx''' | ||
+ | * Change line 5 from | ||
+ | #include vtkSlicerApplication.h | ||
+ | to | ||
+ | #include vtkMyApplication.h | ||
+ | * Change line 61 and 108 from | ||
+ | vtkSlicerApplication *app = vtkSlicerApplication::SafeDownCast(this->GetApplication() ); | ||
+ | to | ||
+ | vtkKWMyApplication *app = vtkKWMyApplication::SafeDownCast(this->GetApplication() ); | ||
+ | |||
+ | |||
+ | <h1>Your Application Modifications</h1> | ||
+ | <h2>Application class header file </h2> | ||
#ifndef __vtkKWMyApplication_h | #ifndef __vtkKWMyApplication_h | ||
#define __vtkKWMyApplication_h | #define __vtkKWMyApplication_h | ||
Line 75: | Line 88: | ||
}; | }; | ||
− | + | <h2>Application class source file </h2> | |
vtkKWMyApplication::vtkKWMimxApplication() | vtkKWMyApplication::vtkKWMimxApplication() | ||
{ | { | ||
Line 87: | Line 100: | ||
. | . | ||
} | } | ||
− | + | ||
//--------------------------------------------------------------------------- | //--------------------------------------------------------------------------- | ||
void vtkKWMimxApplication::InstallDefaultTheme ( ) | void vtkKWMimxApplication::InstallDefaultTheme ( ) | ||
Line 93: | Line 106: | ||
InstallTheme( this->SlicerTheme ); | InstallTheme( this->SlicerTheme ); | ||
} | } | ||
− | + | ||
//--------------------------------------------------------------------------- | //--------------------------------------------------------------------------- | ||
void vtkKWMimxApplication::InstallTheme ( vtkKWTheme *theme ) | void vtkKWMimxApplication::InstallTheme ( vtkKWTheme *theme ) | ||
Line 106: | Line 119: | ||
} | } | ||
} | } | ||
− | + | ||
//--------------------------------------------------------------------------- | //--------------------------------------------------------------------------- | ||
vtkSlicerTheme *vtkKWMimxApplication::GetSlicerTheme ( ) | vtkSlicerTheme *vtkKWMimxApplication::GetSlicerTheme ( ) | ||
Line 112: | Line 125: | ||
return this->SlicerTheme; | return this->SlicerTheme; | ||
} | } | ||
− | + | ||
//---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||
void vtkKWMimxApplication::SetApplicationFontFamily ( const char *font) | void vtkKWMimxApplication::SetApplicationFontFamily ( const char *font) | ||
Line 130: | Line 143: | ||
} | } | ||
− | + | ||
//---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||
const char *vtkKWMimxApplication::GetApplicationFontFamily () const | const char *vtkKWMimxApplication::GetApplicationFontFamily () const | ||
Line 136: | Line 149: | ||
return this->ApplicationFontFamily; | return this->ApplicationFontFamily; | ||
} | } | ||
− | + | ||
//---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||
void vtkKWMimxApplication::SetApplicationFontSize ( const char *size) | void vtkKWMimxApplication::SetApplicationFontSize ( const char *size) | ||
Line 165: | Line 178: | ||
} | } | ||
} | } | ||
− | + | ||
//---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||
const char *vtkKWMimxApplication::GetApplicationFontSize () const | const char *vtkKWMimxApplication::GetApplicationFontSize () const | ||
Line 171: | Line 184: | ||
return this->ApplicationFontSize; | return this->ApplicationFontSize; | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <h2>Main Program </h2> | |
+ | In your main program will need the following lines. You probably already have the first line to create the application. The second line will install the Slicer3 theme for you. | ||
− | * | + | vtkKWMyApplication *app = vtkKWMyApplication::New(); |
+ | app->InstallDefaultTheme( ); | ||
+ | <h2>CMakeLists.txt File</h2> | ||
+ | The following files will now need to be added to your CMakeLists.txt file and built either as part of a library or your application | ||
+ | *vtkSlicerTheme.cxx | ||
+ | *vtkSlicerColor.cxx | ||
+ | *vtkSlicerFont.cxx | ||
+ | *vtkSlicerCheckRadioButtonIcons.cxx | ||
+ | *vtkSlicerIcons.cxx | ||
− | + | <h1>Results</h1> | |
+ | *The Slicer3 Theme has now been installed in both the IA-FEMesh and BRAINSTracer applications using these changes. |
Latest revision as of 16:59, 30 June 2008
Home < NA-MIC < Projects < Collaboration < Slicer3 Theme
Key Investigators
- Iowa: Vincent Magnotta, Nicole Grosland, Hans Johnson
Objective
This page describes how to incorporate the Slicer3 Theme into any KWWidgets based application. Hopefully this will develop into a Slicer3 Theme library that one can link against.
Getting the Slicer3 Theme Files
The Slicer3 theme is a clean and nice looking user interface. This page describes how to incroporate the theme into any KWWidgets application.
- The following source code files are needed from the Slicer3 code base. These are located in Slicer3/Base/GUI
- vtkSlicerCheckRadioButtonIcons.cxx vtkSlicerCheckRadioButtonIcons.h
- vtkSlicerFont.cxx vtkSlicerFont.h
- vtkSlicerTheme.cxx vtkSlicerTheme.h
- vtkSlicerColor.cxx vtkSlicerColor.h
- vtkSlicerIcons.cxx vtkSlicerIcons.h
- The following icons are needed. These are located in Slicer3/Base/GUI/Resources. This file needs to be put in a directory called Resources that is in the same directory as vtkSlicerCheckRadioButtonIcons.h
- vtkSlicerCheckRadioButton_ImageData.h
Slicer3 Theme Modifications
Modify vtkSlicerTheme.cxx
- Change line 5 from
#include vtkSlicerApplication.h
to
#include vtkMyApplication.h
- Change line 61 and 108 from
vtkSlicerApplication *app = vtkSlicerApplication::SafeDownCast(this->GetApplication() );
to
vtkKWMyApplication *app = vtkKWMyApplication::SafeDownCast(this->GetApplication() );
Your Application Modifications
Application class header file
#ifndef __vtkKWMyApplication_h #define __vtkKWMyApplication_h #include "vtkKWApplication.h" #include "vtkKWRegistryHelper.h" class vtkSlicerTheme; class vtkKWMyApplication : public vtkKWApplication { public: static vtkKWMyApplication* New(); vtkTypeRevisionMacro(vtkKWMyApplication,vtkKWApplication); virtual void InstallTheme ( vtkKWTheme *theme ); virtual void InstallDefaultTheme ( ); vtkSlicerTheme *GetSlicerTheme ( ); // Description: // Set/Get the application font family void SetApplicationFontFamily ( const char *family); const char *GetApplicationFontFamily ( ) const; // Description: // Set/Get the application font size void SetApplicationFontSize ( const char *size ); const char *GetApplicationFontSize ( ) const; . . . protected: vtkKWMyApplication(); ~vtkKWMyApplication(); vtkSlicerTheme *SlicerTheme; char ApplicationFontSize [vtkKWRegistryHelper::RegistryKeyValueSizeMax]; char ApplicationFontFamily [vtkKWRegistryHelper::RegistryKeyValueSizeMax]; . . . };
Application class source file
vtkKWMyApplication::vtkKWMimxApplication() { vtkKWFrameWithLabel::SetDefaultLabelFontWeightToNormal( ); this->SlicerTheme = vtkSlicerTheme::New ( ); strcpy ( this->ApplicationFontSize, "small" ); strcpy ( this->ApplicationFontFamily, "Arial" ); . . . } //--------------------------------------------------------------------------- void vtkKWMimxApplication::InstallDefaultTheme ( ) { InstallTheme( this->SlicerTheme ); } //--------------------------------------------------------------------------- void vtkKWMimxApplication::InstallTheme ( vtkKWTheme *theme ) { if ( theme != NULL ) { if ( vtkSlicerTheme::SafeDownCast (theme) == this->SlicerTheme ) { this->SetTheme (this->SlicerTheme ); } else { this->SetTheme ( theme ); } } } //--------------------------------------------------------------------------- vtkSlicerTheme *vtkKWMimxApplication::GetSlicerTheme ( ) { return this->SlicerTheme; } //---------------------------------------------------------------------------- void vtkKWMimxApplication::SetApplicationFontFamily ( const char *font) { char localFont[32]; strcpy(localFont, font); if ( this->SlicerTheme ) { this->SlicerTheme->SetFontFamily ( localFont ); this->Script ( "font configure %s -family %s", this->SlicerTheme->GetApplicationFont2(), localFont ); this->Script ( "font configure %s -family %s", this->SlicerTheme->GetApplicationFont1(), localFont ); this->Script ( "font configure %s -family %s", this->SlicerTheme->GetApplicationFont0(), localFont ); strcpy ( this->ApplicationFontFamily, localFont ); this->SetRegistryValue(1, "Font", "Family", localFont); } } //---------------------------------------------------------------------------- const char *vtkKWMimxApplication::GetApplicationFontFamily () const { return this->ApplicationFontFamily; } //---------------------------------------------------------------------------- void vtkKWMimxApplication::SetApplicationFontSize ( const char *size) { char localSize[32]; strcpy(localSize, size); if (this->SlicerTheme) { vtkSlicerFont *font = this->SlicerTheme->GetSlicerFonts(); if ( font ) { // check to see if m has a valid value: if ( font->IsValidFontSize ( localSize ) ) { int f2 = font->GetFontSize2( localSize ); int f1 = font->GetFontSize1( localSize ); int f0 = font->GetFontSize0( localSize ); this->Script ( "font configure %s -size %d", this->SlicerTheme->GetApplicationFont2(), f2); this->Script ( "font configure %s -size %d", this->SlicerTheme->GetApplicationFont1(), f1); this->Script ( "font configure %s -size %d", this->SlicerTheme->GetApplicationFont0(), f0); strcpy (this->ApplicationFontSize, localSize ); this->SetRegistryValue(1, "Font", "Size", localSize); } } } } //---------------------------------------------------------------------------- const char *vtkKWMimxApplication::GetApplicationFontSize () const { return this->ApplicationFontSize; }
Main Program
In your main program will need the following lines. You probably already have the first line to create the application. The second line will install the Slicer3 theme for you.
vtkKWMyApplication *app = vtkKWMyApplication::New(); app->InstallDefaultTheme( );
CMakeLists.txt File
The following files will now need to be added to your CMakeLists.txt file and built either as part of a library or your application
- vtkSlicerTheme.cxx
- vtkSlicerColor.cxx
- vtkSlicerFont.cxx
- vtkSlicerCheckRadioButtonIcons.cxx
- vtkSlicerIcons.cxx
Results
- The Slicer3 Theme has now been installed in both the IA-FEMesh and BRAINSTracer applications using these changes.