Difference between revisions of "NA-MIC/Projects/Collaboration/Slicer3 Theme"

From NAMIC Wiki
Jump to: navigation, search
 
(One intermediate revision 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:MeshBuildingBlock.png|thumb|320px|Building Block shown with number of mesh seeds color coded.]]
+
|[[Image:IA-FEMeshNoTheme.png|thumb|320px|IA-FEMesh with no installed theme.]]
|[[Image:MeshQuality.png|thumb|320px|Mesh quality visualization.]]
+
|[[Image:IA-FEMeshSlicer3Theme.png|thumb|320px|IA-FEMesh with Slicer3 theme installed.]]
 
|}
 
|}
  
Line 200: Line 200:
  
 
<h1>Results</h1>
 
<h1>Results</h1>
*The slicer3 Theme has now been installed in both the IA-FEMesh and BRAINSTracer applications using these changes.
+
*The Slicer3 Theme has now been installed in both the IA-FEMesh and BRAINSTracer applications using these changes.
 
 
===References===
 
* Grosland NM, Brown TD. A voxel-based formulation for contact finite element analysis. Comput Methods Biomech Biomed Engin. 5(1):21-32, 2002.
 
* Grosland NM, Bafna R, Magnotta VA. Automated Hexahedral Meshing of Anatomical structures using Deformable Registration. Computer Methods  in Biomechanics and Biomedical Engineering. Accepted.
 
* Grosland NM, Shivanna KH, Magnotta VM, Kallemeyn NA, DeVries NA, Tadepalli SC. IA-FEMesh: An open-source,  interactive, multiblock approach to musculoskeletal finite element model development. Submitted.
 
* P. P. P'ebay and D. C. Thompson and J. Shepherd and P. Knupp and C. Lisle and V. A. Magnotta and N. M. Grosland, New Applications of the Verdict Library for Standardized Mesh Verification. Pre, Post, and End-to-End Processing, Proc. 16th International Meshing Roundtable,Seattle, WA, 2007
 
 
 
=Description=
 
 
 
The Musculoskeletal Imaging, Modeling, and EXperimentation (MIMX)  Program is a collaborative effort directed at computational modeling of anatomic structures. A primary objective is to automate the development of patient-/subject- specific models using a combination of imaging and modeling techniques, with particular emphasis on finite element modeling.
 
 
 
 
 
 
 
= [http://www.ccad.uiowa.edu/mimx/publications/ Publications]=
 
 
 
 
 
= Links =
 
 
 
* [http://www.ccad.uiowa.edu/mimx/ MIMX Group]
 
 
 
 
 
Project Week Results:  [http://www.na-mic.org/Wiki/index.php/2008_Winter_Project_Week:Meshing_Techniques_into_NA-MIC_Toolkit Winter 2008], [http://www.na-mic.org/Wiki/index.php/Collaboration/Iowa/Meshing/Adding_VTK_Interactive_WWidgets_to_Slicer3 June 2007]
 

Latest revision as of 16:59, 30 June 2008

Home < NA-MIC < Projects < Collaboration < Slicer3 Theme
IA-FEMesh with no installed theme.
IA-FEMesh with Slicer3 theme installed.



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.