Skip to content

Commit

Permalink
git-svn-id: svn+ssh://orchestra.med.harvard.edu/svn/megason/Code/GoFi…
Browse files Browse the repository at this point in the history
…gure2@1010 ef826fda-c0ae-4237-af8e-f8dcbcf7929c
  • Loading branch information
Arnaud Gelas committed Mar 18, 2009
1 parent c0cbd63 commit 8aa807b
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 28 deletions.
96 changes: 81 additions & 15 deletions trunk/QGoMainWindow.cxx
@@ -1,14 +1,16 @@
#include "QGoMainWindow.h"

#include <iostream>

#include <qfiledialog.h>
#include <qmessagebox.h>
#include <qcolordialog.h>

#include <itkImageFileReader.h>
#include <iostream>
#include <qprogressdialog.h>
#include <qprogressbar.h>

#include <itkImageFileReader.h>
#include <vnl/vnl_random.h>

// *****************************************************************************
// *****************************************************************************
// *****************************************************************************
Expand Down Expand Up @@ -108,8 +110,7 @@ void QGoMainWindow::on_actionClose_activated( )
int idx = this->CentralImageTabWidget->currentIndex();
this->CentralImageTabWidget->removeTab( idx );
delete m_PageView[idx];
// m_PageView.erase( m_PageView.begin()+ idx );
m_PageView[idx] = 0;
m_PageView.remove( idx );
}

// *****************************************************************************
Expand Down Expand Up @@ -282,20 +283,85 @@ void QGoMainWindow::ChangeLookupTable( )
// *****************************************************************************
// *****************************************************************************
// *****************************************************************************
void QGoMainWindow::SetColorForGivenId( )
void QGoMainWindow::SetColorForGivenId( const bool& iSelect )
{
// unsigned int cell_id = IdContourBox->value();
unsigned int cell_id = IdContourBox->value();

// m_PageView->
// m_IdColorMap[ cell_id ] =
// QColorDialog::getColor( Qt::red, this );
vnl_random random( 12 );
QColor color;

if( cell_id < 7 )
{
switch( cell_id )
{
default:
case 1:
color.setHsv( 0, 255, 255 );
break;
case 2:
color.setHsv( 60, 255, 255 );
break;
case 3:
color.setHsv( 120, 255, 255 );
break;
case 4:
color.setHsv( 180, 255, 255 );
break;
case 5:
color.setHsv( 240, 255, 255 );
break;
case 6:
color.setHsv( 300, 255, 255 );
break;
}
}
else
{
switch( cell_id % 6 )
{
case 0:
color.setHsv( random.lrand32( 0, 60 ), random.lrand32( 0, 255 ), random.lrand32( 0, 255 ) );
break;
case 1:
color.setHsv( random.lrand32( 60, 120 ), random.lrand32( 0, 255 ), random.lrand32( 0, 255 ) );
break;
case 2:
color.setHsv( random.lrand32( 120, 180 ), random.lrand32( 0, 255 ), random.lrand32( 0, 255 ) );
break;
case 3:
color.setHsv( random.lrand32( 180, 240 ), random.lrand32( 0, 255 ), random.lrand32( 0, 255 ) );
break;
case 4:
color.setHsv( random.lrand32( 240, 300 ), random.lrand32( 0, 255 ), random.lrand32( 0, 255 ) );
break;
case 5:
color.setHsv( random.lrand32( 300, 360 ), random.lrand32( 0, 255 ), random.lrand32( 0, 255 ) );
break;
}
}

if( iSelect )
{
m_IdColorMap[ cell_id ] = QColorDialog::getColor( color, this );
}
else
{
m_IdColorMap[ cell_id ] = color;
}

}

void QGoMainWindow::ValidateContourTracer( )
{
int idx = this->CentralImageTabWidget->currentIndex();
m_PageView[idx]->SetCellId( IdContourBox->value() );
m_PageView[idx]->ValidateContour();
unsigned int cell_id = IdContourBox->value();
m_PageView[idx]->SetCellId( cell_id );

if( m_IdColorMap.find( cell_id ) == m_IdColorMap.end() )
SetColorForGivenId( false );

m_PageView[idx]->ValidateContour( m_IdColorMap[ cell_id ] );
}
// *****************************************************************************
// *****************************************************************************
Expand Down Expand Up @@ -478,18 +544,18 @@ void QGoMainWindow::showprogressloading ()
statusbar->addWidget(message,0);
statusbar->addWidget(bar,0);
//statusbar->insertWidget(1,bar,0);

//Progressloading.setWindowModality(Qt::WindowModal);
for (int i = 0; i < 100; i++)

for (int i = 0; i < 100; i++)
{
Progressloading->setValue(i);

if (Progressloading->wasCanceled())
{
break;
}

bar->update();
bar->show();

Expand Down
11 changes: 6 additions & 5 deletions trunk/QGoMainWindow.h
Expand Up @@ -8,9 +8,10 @@

#include <QImagePageViewTracer.h>
#include <itkImageToVTKImageFilter.h>
#include <qactiongroup.h>

#include <vector>
#include <qactiongroup.h>
#include <qvector.h>
#include <qhash.h>

#include "QGoLUTDialog.h"
#include "ui_go.h"
Expand Down Expand Up @@ -67,7 +68,7 @@ protected slots:

void ChangeLookupTable( );

void SetColorForGivenId();
void SetColorForGivenId( const bool& iSelected = true );
void ValidateContourTracer();
void openRecentFile();

Expand All @@ -76,15 +77,15 @@ protected slots:
vtkImageData* m_VTKImage;

/** \brief Quad View*/
std::vector< QImagePageViewTracer* > m_PageView;
QVector< QImagePageViewTracer* > m_PageView;

/** \brief Convert itk::Image format to vtkImageData */
VTKConvertImagePointer m_Convert;

/** \brief Look-up Table dialog */
QGoLUTDialog* m_LUTDialog;

std::map< unsigned int, QColor > m_IdColorMap;
QHash< unsigned int, QColor > m_IdColorMap;
QActionGroup* m_FullscreenGroup;

/** \brief */
Expand Down
16 changes: 8 additions & 8 deletions trunk/go.ui
Expand Up @@ -185,14 +185,14 @@
</property>
<property name="minimumSize" >
<size>
<width>184</width>
<height>87</height>
<width>190</width>
<height>90</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>287</width>
<height>572</height>
<width>293</width>
<height>575</height>
</size>
</property>
<property name="floating" >
Expand Down Expand Up @@ -811,8 +811,8 @@ Component</string>
<widget class="QDockWidget" name="ManualSegmentationDockWidget" >
<property name="minimumSize" >
<size>
<width>184</width>
<height>64</height>
<width>190</width>
<height>67</height>
</size>
</property>
<property name="windowTitle" >
Expand Down Expand Up @@ -1067,7 +1067,7 @@ Component</string>
<bool>true</bool>
</property>
<property name="checked" >
<bool>true</bool>
<bool>false</bool>
</property>
<property name="enabled" >
<bool>false</bool>
Expand Down Expand Up @@ -1200,7 +1200,7 @@ Component</string>
<bool>true</bool>
</property>
<property name="checked" >
<bool>true</bool>
<bool>false</bool>
</property>
<property name="enabled" >
<bool>true</bool>
Expand Down

0 comments on commit 8aa807b

Please sign in to comment.