From 0ec1dda064e173f024248479bbfbe116de28f21b Mon Sep 17 00:00:00 2001 From: dsarrut Date: Mon, 29 Mar 2010 11:25:21 +0000 Subject: [PATCH] - convert tool --- vv/icons/1b.png | Bin 0 -> 696 bytes vv/icons/2b.png | Bin 0 -> 955 bytes vv/icons/4b.png | Bin 0 -> 849 bytes vv/icons/8b.png | Bin 0 -> 1071 bytes vv/icons/arithm.png | Bin 0 -> 1260 bytes vv/icons/green-arrow.png | Bin 0 -> 1966 bytes vv/vvToolConvert.cxx | 135 +++++++++++++++++++++++++++++++++++++++ vv/vvToolConvert.h | 49 ++++++++++++++ 8 files changed, 184 insertions(+) create mode 100644 vv/icons/1b.png create mode 100644 vv/icons/2b.png create mode 100644 vv/icons/4b.png create mode 100644 vv/icons/8b.png create mode 100644 vv/icons/arithm.png create mode 100644 vv/icons/green-arrow.png create mode 100644 vv/vvToolConvert.cxx create mode 100644 vv/vvToolConvert.h diff --git a/vv/icons/1b.png b/vv/icons/1b.png new file mode 100644 index 0000000000000000000000000000000000000000..3f9b7768680e914e054cc0523cc781c04873874a GIT binary patch literal 696 zcmV;p0!RIcP);w1|QP!GKjXUSeekK?OzBycWBg%o+A}WSR5Az+B#M z=GkRu_8XH#mdvaU+yVN4r;^TRn%80mfNM_I4N22QajBA&S%3?G;&M07>%{DJVgwA8 ziAyWBoHuX~xb$C7T#-`YVz6h?J956wf!2s$>#mstuo4|p#(RiwvS%;Yo z18->t`viPz4_2f)Fh_J$xVjCT1YQH3RW4{|{lHeD&t?I5C+TmN-`)0Kf#c4x@R5p+ z65t3hD0?znw!$4=oLRG+h_S$p681Nu| zDL&-c)wv25ssb)4AAsGS*MKX)isSp8_(H+W0vmE-j(Ps6+}~HlIxT52Yf#cH;JMSa z-^_M~fSZ!^xPbHwE5A-+^aN`-h~XW_BMq6~iYI@DdmW eMkM`lC;A5kHt*hwKz?li0000w#)B*gzxD z47_vNmH?Z8t%hGUFbEuvn9OMA%)AtsWM<}rKxK-Qt^>vl|0$qkHY1wl=&b=)bPuR% zTZ+lG0EdmH7;rGNkOiBNh+uNoFGDYI_-x=l&Gs5C0&)%E?GYx~0TepVg(4DH)v3@C z63GLKfox~ey?*#OiS=~~$al)K2tt2b^_asKBya<845+ZWhDD?aIIXHZuAX#L;iR^o znY0dsNc|z;68=YBvit&SJ%d)L$V2dvjD(VSoxZk6H--?J zEMI|D9{xvxX~S;{D9=P_y*2O)A3ral-9UZ{?roO;)3k&F`z)d{pe%yWEg{BevoK{* zMOIm-(Sm#;G1VWk7U`sBC-~Ej$7m_pdv$&;J*9>nK}NjOQ?vf z25tj$jpq9#F3|&N%kv)G*F+=+6c|mN=He{}zT;l}mw|Ycvo>HeJqU^0Vd3^BJLZx2 zsx&)Kq$@Cm&}pDJ029M~H2nl}lbwwg;mu4%`Uq8^7bx)Y7vQAje_mA)U@`CpFxTrf z67TS+R;#L`$%=>+IhnHUJ+K>SSLY{&h%5ju0-FuLK458*^Q_0L(=B-c5pA;Sqd+Ur z<-s)!EHk)x@*jnk09QirbOEI%SDeHf!1vQQqD@%!af|zhs_qeydn7)$S6coZz*XRa ds!p06e*o^wLIC65h@=1j002ovPDHLkV1h_UrY!&f literal 0 HcmV?d00001 diff --git a/vv/icons/4b.png b/vv/icons/4b.png new file mode 100644 index 0000000000000000000000000000000000000000..908f11328006f1a488631f867f256e35b6b9c406 GIT binary patch literal 849 zcmV-X1FrmuP)rFB}&eZKQPX5LJ1 z-uuIad(Zu!dwM zXi12)O~86re;;K&tE!0pOJpD`s?eY!vJW^=MwUQ@0u_-}z~wTt1ga>ghzM{4XmFvw zlauI0}kxmim7LkOAH2RuVwO|2i zfl)wRIpyLHO>D$3-;6VE{P$d}9e8Ep=`s&I1={k)37FuV8DI#gjsp}pSpcw5xd=!g zD3AdDxP&>N+4PkH`Yi|M4R95>2D~l=>kA6h0q>0Ya87?Ipy@ITbQbXLbr;5Z+xVq!iE@pdmy~ z3*L(*op+`R7T-QMfqFdMQPsP|uOU_aUd*Jb6F}00+R_{TF}%GE;1kdjFW;gjBY5qR zu(?V^T7fueOZq8qpFStq`QSsv7MFL=1WibU3I7z;6*5##<7tWPcjX0$r*)4bgu}@C8-P b`iT4o15<>^OiNkZ00000NkvXXu0mjfw6$-A literal 0 HcmV?d00001 diff --git a/vv/icons/8b.png b/vv/icons/8b.png new file mode 100644 index 0000000000000000000000000000000000000000..2736e97536884f3ccb38758ef2a2f12a10354b1b GIT binary patch literal 1071 zcmV+~1kn45P)RnCKhLY%M57iu&9W^f!xST(f4~;Di()Dc z)=h$nB;rk=cw>R6s5f4T1R)N~2)fz8z?)huoC<-}bmbpR6h*Xfu2;9Arq1mR$r~_KuCSr^ST1BMpnXa%DxE;>|{^sefZvZs~PG=SHkFos)$c@EGHUkrk z_I0Xyy}+j0fP-deA<;?yZ-_M_Mx901O+WKY3T;wUf(%qwF5F3B8xDovyS%YnWOfjvNNiEp<8y90c_@q8B8$v26j z%op^;U2EFgeF&%s6nO`DAwXokx6Yn;qJb!l*vYSf1;7MnGZk1#6jau(6POqv@<`}2 z2;4S)-vg8Z*S(W_zX(A&(CP_25Fm122_n0V-&KH(-hz7rNXp!I8T&j0Uda%-xdf5+ zyX?;qMRbfoU>6xs)gfSu8L9wQXSn6Fcn$ut+&N&T891k^j{=FhiPA-ktV-y`Kwf~C z%W<9122J?-N~TjMp+;rew@pRGZ)V957%8szO;rWE?Qf3=I^rb?}RlVyH2{ zdvdtwaabZEWr0L>Bn#y$8TQR?V?`k%O+>{;j2{8ElZ@_lff4wH=hqnU;?H>eS%@&v|H@CfFNiG pj=T1r8+#l0Hbv}N$2+R3`WM<^34yu|OFIAn002ovPDHLkV1l$^990~~f8S;sn;2WsVnEQocxmZ_T9rZttCV1+ z2o=mGwy{JDR{NrYh(b|oiWjhgps2-Ss>WoqRHc++y%9xGidEW&g7{QKtwC#0v9Za{ z--pc3o@94sXSN$Vlzgxc|I0b&`}SPt9GMwm&>k(J$WYnA8tb&-ohO&!^EUlc3oo)O; zYe?)bP5>8H3u#z40k0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TuEALH3LeTA@(v%B(Qad<9#F!n2I;;_N@qqDI$XTXg3c zX8vO-$fPjMP0d5=MdKdJReb~fciGck{_x4)D)WFYZ!9~8e{^@k&e+%&|Jp@K^6hjw z{Z_f&2j=^C+umK(>K{9NlW(ky#->m_76%Ar-$}twmeL>xGj8AO#kJn+_(FIsc28+O zBO%|mZTpw&)~y@)OfUd&;>3yi&TPjIJ}_M`rIEIyu^1we2$ZEjK*diM*K?5^8N{9b zK14Wz9aX!sOYP-HnfbkRI{nu6?c1}JbUjif?C$OkC6mdWiLtg +#include +#include +#include + +//------------------------------------------------------------------------------ +// Create the tool and automagically (I like this word) insert it in +// the main window menu. +ADD_TOOL(vvToolConvert); +//------------------------------------------------------------------------------ + +QAction * vvToolConvert::a = NULL; +QAction * vvToolConvert::b = NULL; +std::vector vvToolConvert::mListOfPixelTypeNames; +std::vector vvToolConvert::mListOfPixelTypeIcons; +std::map vvToolConvert::mMapOfPixelType; + +//------------------------------------------------------------------------------ +vvToolConvert::vvToolConvert(vvMainWindowBase * parent, Qt::WindowFlags f): + vvToolBase(parent) +{ +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvToolConvert::~vvToolConvert() { +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolConvert::Initialize() { + SetToolName("Convert"); + SetToolMenuName("Convert with WidgetBase"); + SetToolIconFilename(":/common/icons/ducky.png"); + SetToolTip("Make 'foo' on an image."); + + // Create a menu to choose the convert image + QMenu * m = new QMenu(); + m->setTitle("Convert to "); + m->setIcon(QIcon(QString::fromUtf8(":/common/icons/green-arrow.png"))); + + mListOfPixelTypeNames.push_back("char"); + mListOfPixelTypeNames.push_back("unsigned_char"); + mListOfPixelTypeNames.push_back("short"); + mListOfPixelTypeNames.push_back("unsigned_short"); + mListOfPixelTypeNames.push_back("int"); + mListOfPixelTypeNames.push_back("float"); + mListOfPixelTypeNames.push_back("double"); + + mListOfPixelTypeIcons.push_back(":/common/icons/1b.png"); + mListOfPixelTypeIcons.push_back(":/common/icons/1b.png"); + mListOfPixelTypeIcons.push_back(":/common/icons/2b.png"); + mListOfPixelTypeIcons.push_back(":/common/icons/2b.png"); + mListOfPixelTypeIcons.push_back(":/common/icons/4b.png"); + mListOfPixelTypeIcons.push_back(":/common/icons/4b.png"); + mListOfPixelTypeIcons.push_back(":/common/icons/4b.png"); + mListOfPixelTypeIcons.push_back(":/common/icons/8b.png"); + + for(unsigned int i=0; iaddAction(QIcon(QString::fromUtf8(mListOfPixelTypeIcons[i].c_str())), + tr(s.c_str())); + m->addAction(mMapOfPixelType[s]); + } + + CREATOR(vvToolConvert)->addMenuToContextMenu(m); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolConvert::show() { + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + // Get action menu name + QAction * cc = dynamic_cast(mSender); + std::string type = cc->text().toStdString(); + // Get current image + int index = mMainWindowBase->GetSlicerManagerCurrentIndex(); + vvSlicerManager * m = mMainWindowBase->GetSlicerManagers()[index]; + assert(m != NULL); // Should no occur + + // Create filter and run ! + clitk::ImageConvertGenericFilter * filter = new clitk::ImageConvertGenericFilter; + filter->SetInputVVImage(m->GetImage()); + filter->SetOutputPixelType(type); + filter->EnableDisplayWarning(false); + filter->Update(); + + // Manage warning + if (filter->IsWarningOccur()) { + QApplication::restoreOverrideCursor(); + QMessageBox::warning(mMainWindowBase, "Warning", filter->GetWarning().c_str()); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + } + + // Output + vvImage::Pointer output = filter->GetOutputVVImage(); + std::ostringstream osstream; + osstream << "Convert_" << type << "_" << m->GetSlicer(0)->GetFileName() << ".mhd"; + AddImage(output,osstream.str()); + QApplication::restoreOverrideCursor(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolConvert::apply() { + // nothing !! +} +//------------------------------------------------------------------------------ + + diff --git a/vv/vvToolConvert.h b/vv/vvToolConvert.h new file mode 100644 index 0000000..b8e4afc --- /dev/null +++ b/vv/vvToolConvert.h @@ -0,0 +1,49 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ + +#ifndef VVTOOLCONVERT_H +#define VVTOOLCONVERT_H + +#include "vvToolBase.h" + +//------------------------------------------------------------------------------ +class vvToolConvert: public QObject, public vvToolBase +{ + Q_OBJECT + public: + vvToolConvert(vvMainWindowBase* parent, Qt::WindowFlags f=0); + ~vvToolConvert(); + + static void Initialize(); + +public slots: + virtual void apply(); + void show(); + + protected: + static std::vector mListOfPixelTypeNames; + static std::vector mListOfPixelTypeIcons; + static std::map mMapOfPixelType; + static QAction * a; + static QAction * b; + +}; // end class vvToolConvert +//------------------------------------------------------------------------------ + +#endif + -- 2.47.1