CMAKE_POLICY(SET CMP0005 NEW)
ENDIF(COMMAND cmake_policy AND ${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
-PROJECT(CreaContours)
+PROJECT(creaContours)
SET(PROJECT_MAJOR_VERSION 1)
SET(PROJECT_MINOR_VERSION 0)
SUBDIRS(appli)
SUBDIRS(bbtk)
SUBDIRS(data)
+SUBDIRS(install)
--- /dev/null
+CeCILL-B FREE SOFTWARE LICENSE AGREEMENT
+
+
+ Notice
+
+This Agreement is a Free Software license agreement that is the result
+of discussions between its authors in order to ensure compliance with
+the two main principles guiding its drafting:
+
+ * firstly, compliance with the principles governing the distribution
+ of Free Software: access to source code, broad rights granted to
+ users,
+ * secondly, the election of a governing law, French law, with which
+ it is conformant, both as regards the law of torts and
+ intellectual property law, and the protection that it offers to
+ both authors and holders of the economic rights over software.
+
+The authors of the CeCILL-B (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre])
+license are:
+
+Commissariat à l'Energie Atomique - CEA, a public scientific, technical
+and industrial research establishment, having its principal place of
+business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France.
+
+Centre National de la Recherche Scientifique - CNRS, a public scientific
+and technological establishment, having its principal place of business
+at 3 rue Michel-Ange, 75794 Paris cedex 16, France.
+
+Institut National de Recherche en Informatique et en Automatique -
+INRIA, a public scientific and technological establishment, having its
+principal place of business at Domaine de Voluceau, Rocquencourt, BP
+105, 78153 Le Chesnay cedex, France.
+
+
+ Preamble
+
+This Agreement is an open source software license intended to give users
+significant freedom to modify and redistribute the software licensed
+hereunder.
+
+The exercising of this freedom is conditional upon a strong obligation
+of giving credits for everybody that distributes a software
+incorporating a software ruled by the current license so as all
+contributions to be properly identified and acknowledged.
+
+In consideration of access to the source code and the rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty and the software's author, the holder of the
+economic rights, and the successive licensors only have limited liability.
+
+In this respect, the risks associated with loading, using, modifying
+and/or developing or reproducing the software by the user are brought to
+the user's attention, given its Free Software status, which may make it
+complicated to use, with the result that its use is reserved for
+developers and experienced professionals having in-depth computer
+knowledge. Users are therefore encouraged to load and test the
+suitability of the software as regards their requirements in conditions
+enabling the security of their systems and/or data to be ensured and,
+more generally, to use and operate it in the same conditions of
+security. This Agreement may be freely reproduced and published,
+provided it is not altered, and that no provisions are either added or
+removed herefrom.
+
+This Agreement may apply to any or all software for which the holder of
+the economic rights decides to submit the use thereof to its provisions.
+
+
+ Article 1 - DEFINITIONS
+
+For the purpose of this Agreement, when the following expressions
+commence with a capital letter, they shall have the following meaning:
+
+Agreement: means this license agreement, and its possible subsequent
+versions and annexes.
+
+Software: means the software in its Object Code and/or Source Code form
+and, where applicable, its documentation, "as is" when the Licensee
+accepts the Agreement.
+
+Initial Software: means the Software in its Source Code and possibly its
+Object Code form and, where applicable, its documentation, "as is" when
+it is first distributed under the terms and conditions of the Agreement.
+
+Modified Software: means the Software modified by at least one
+Contribution.
+
+Source Code: means all the Software's instructions and program lines to
+which access is required so as to modify the Software.
+
+Object Code: means the binary files originating from the compilation of
+the Source Code.
+
+Holder: means the holder(s) of the economic rights over the Initial
+Software.
+
+Licensee: means the Software user(s) having accepted the Agreement.
+
+Contributor: means a Licensee having made at least one Contribution.
+
+Licensor: means the Holder, or any other individual or legal entity, who
+distributes the Software under the Agreement.
+
+Contribution: means any or all modifications, corrections, translations,
+adaptations and/or new functions integrated into the Software by any or
+all Contributors, as well as any or all Internal Modules.
+
+Module: means a set of sources files including their documentation that
+enables supplementary functions or services in addition to those offered
+by the Software.
+
+External Module: means any or all Modules, not derived from the
+Software, so that this Module and the Software run in separate address
+spaces, with one calling the other when they are run.
+
+Internal Module: means any or all Module, connected to the Software so
+that they both execute in the same address space.
+
+Parties: mean both the Licensee and the Licensor.
+
+These expressions may be used both in singular and plural form.
+
+
+ Article 2 - PURPOSE
+
+The purpose of the Agreement is the grant by the Licensor to the
+Licensee of a non-exclusive, transferable and worldwide license for the
+Software as set forth in Article 5 hereinafter for the whole term of the
+protection granted by the rights over said Software.
+
+
+ Article 3 - ACCEPTANCE
+
+3.1 The Licensee shall be deemed as having accepted the terms and
+conditions of this Agreement upon the occurrence of the first of the
+following events:
+
+ * (i) loading the Software by any or all means, notably, by
+ downloading from a remote server, or by loading from a physical
+ medium;
+ * (ii) the first time the Licensee exercises any of the rights
+ granted hereunder.
+
+3.2 One copy of the Agreement, containing a notice relating to the
+characteristics of the Software, to the limited warranty, and to the
+fact that its use is restricted to experienced users has been provided
+to the Licensee prior to its acceptance as set forth in Article 3.1
+hereinabove, and the Licensee hereby acknowledges that it has read and
+understood it.
+
+
+ Article 4 - EFFECTIVE DATE AND TERM
+
+
+ 4.1 EFFECTIVE DATE
+
+The Agreement shall become effective on the date when it is accepted by
+the Licensee as set forth in Article 3.1.
+
+
+ 4.2 TERM
+
+The Agreement shall remain in force for the entire legal term of
+protection of the economic rights over the Software.
+
+
+ Article 5 - SCOPE OF RIGHTS GRANTED
+
+The Licensor hereby grants to the Licensee, who accepts, the following
+rights over the Software for any or all use, and for the term of the
+Agreement, on the basis of the terms and conditions set forth hereinafter.
+
+Besides, if the Licensor owns or comes to own one or more patents
+protecting all or part of the functions of the Software or of its
+components, the Licensor undertakes not to enforce the rights granted by
+these patents against successive Licensees using, exploiting or
+modifying the Software. If these patents are transferred, the Licensor
+undertakes to have the transferees subscribe to the obligations set
+forth in this paragraph.
+
+
+ 5.1 RIGHT OF USE
+
+The Licensee is authorized to use the Software, without any limitation
+as to its fields of application, with it being hereinafter specified
+that this comprises:
+
+ 1. permanent or temporary reproduction of all or part of the Software
+ by any or all means and in any or all form.
+
+ 2. loading, displaying, running, or storing the Software on any or
+ all medium.
+
+ 3. entitlement to observe, study or test its operation so as to
+ determine the ideas and principles behind any or all constituent
+ elements of said Software. This shall apply when the Licensee
+ carries out any or all loading, displaying, running, transmission
+ or storage operation as regards the Software, that it is entitled
+ to carry out hereunder.
+
+
+ 5.2 ENTITLEMENT TO MAKE CONTRIBUTIONS
+
+The right to make Contributions includes the right to translate, adapt,
+arrange, or make any or all modifications to the Software, and the right
+to reproduce the resulting software.
+
+The Licensee is authorized to make any or all Contributions to the
+Software provided that it includes an explicit notice that it is the
+author of said Contribution and indicates the date of the creation thereof.
+
+
+ 5.3 RIGHT OF DISTRIBUTION
+
+In particular, the right of distribution includes the right to publish,
+transmit and communicate the Software to the general public on any or
+all medium, and by any or all means, and the right to market, either in
+consideration of a fee, or free of charge, one or more copies of the
+Software by any means.
+
+The Licensee is further authorized to distribute copies of the modified
+or unmodified Software to third parties according to the terms and
+conditions set forth hereinafter.
+
+
+ 5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION
+
+The Licensee is authorized to distribute true copies of the Software in
+Source Code or Object Code form, provided that said distribution
+complies with all the provisions of the Agreement and is accompanied by:
+
+ 1. a copy of the Agreement,
+
+ 2. a notice relating to the limitation of both the Licensor's
+ warranty and liability as set forth in Articles 8 and 9,
+
+and that, in the event that only the Object Code of the Software is
+redistributed, the Licensee allows effective access to the full Source
+Code of the Software at a minimum during the entire period of its
+distribution of the Software, it being understood that the additional
+cost of acquiring the Source Code shall not exceed the cost of
+transferring the data.
+
+
+ 5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE
+
+If the Licensee makes any Contribution to the Software, the resulting
+Modified Software may be distributed under a license agreement other
+than this Agreement subject to compliance with the provisions of Article
+5.3.4.
+
+
+ 5.3.3 DISTRIBUTION OF EXTERNAL MODULES
+
+When the Licensee has developed an External Module, the terms and
+conditions of this Agreement do not apply to said External Module, that
+may be distributed under a separate license agreement.
+
+
+ 5.3.4 CREDITS
+
+Any Licensee who may distribute a Modified Software hereby expressly
+agrees to:
+
+ 1. indicate in the related documentation that it is based on the
+ Software licensed hereunder, and reproduce the intellectual
+ property notice for the Software,
+
+ 2. ensure that written indications of the Software intended use,
+ intellectual property notice and license hereunder are included in
+ easily accessible format from the Modified Software interface,
+
+ 3. mention, on a freely accessible website describing the Modified
+ Software, at least throughout the distribution term thereof, that
+ it is based on the Software licensed hereunder, and reproduce the
+ Software intellectual property notice,
+
+ 4. where it is distributed to a third party that may distribute a
+ Modified Software without having to make its source code
+ available, make its best efforts to ensure that said third party
+ agrees to comply with the obligations set forth in this Article .
+
+If the Software, whether or not modified, is distributed with an
+External Module designed for use in connection with the Software, the
+Licensee shall submit said External Module to the foregoing obligations.
+
+
+ 5.3.5 COMPATIBILITY WITH THE CeCILL AND CeCILL-C LICENSES
+
+Where a Modified Software contains a Contribution subject to the CeCILL
+license, the provisions set forth in Article 5.3.4 shall be optional.
+
+A Modified Software may be distributed under the CeCILL-C license. In
+such a case the provisions set forth in Article 5.3.4 shall be optional.
+
+
+ Article 6 - INTELLECTUAL PROPERTY
+
+
+ 6.1 OVER THE INITIAL SOFTWARE
+
+The Holder owns the economic rights over the Initial Software. Any or
+all use of the Initial Software is subject to compliance with the terms
+and conditions under which the Holder has elected to distribute its work
+and no one shall be entitled to modify the terms and conditions for the
+distribution of said Initial Software.
+
+The Holder undertakes that the Initial Software will remain ruled at
+least by this Agreement, for the duration set forth in Article 4.2.
+
+
+ 6.2 OVER THE CONTRIBUTIONS
+
+The Licensee who develops a Contribution is the owner of the
+intellectual property rights over this Contribution as defined by
+applicable law.
+
+
+ 6.3 OVER THE EXTERNAL MODULES
+
+The Licensee who develops an External Module is the owner of the
+intellectual property rights over this External Module as defined by
+applicable law and is free to choose the type of agreement that shall
+govern its distribution.
+
+
+ 6.4 JOINT PROVISIONS
+
+The Licensee expressly undertakes:
+
+ 1. not to remove, or modify, in any manner, the intellectual property
+ notices attached to the Software;
+
+ 2. to reproduce said notices, in an identical manner, in the copies
+ of the Software modified or not.
+
+The Licensee undertakes not to directly or indirectly infringe the
+intellectual property rights of the Holder and/or Contributors on the
+Software and to take, where applicable, vis-à-vis its staff, any and all
+measures required to ensure respect of said intellectual property rights
+of the Holder and/or Contributors.
+
+
+ Article 7 - RELATED SERVICES
+
+7.1 Under no circumstances shall the Agreement oblige the Licensor to
+provide technical assistance or maintenance services for the Software.
+
+However, the Licensor is entitled to offer this type of services. The
+terms and conditions of such technical assistance, and/or such
+maintenance, shall be set forth in a separate instrument. Only the
+Licensor offering said maintenance and/or technical assistance services
+shall incur liability therefor.
+
+7.2 Similarly, any Licensor is entitled to offer to its licensees, under
+its sole responsibility, a warranty, that shall only be binding upon
+itself, for the redistribution of the Software and/or the Modified
+Software, under terms and conditions that it is free to decide. Said
+warranty, and the financial terms and conditions of its application,
+shall be subject of a separate instrument executed between the Licensor
+and the Licensee.
+
+
+ Article 8 - LIABILITY
+
+8.1 Subject to the provisions of Article 8.2, the Licensee shall be
+entitled to claim compensation for any direct loss it may have suffered
+from the Software as a result of a fault on the part of the relevant
+Licensor, subject to providing evidence thereof.
+
+8.2 The Licensor's liability is limited to the commitments made under
+this Agreement and shall not be incurred as a result of in particular:
+(i) loss due the Licensee's total or partial failure to fulfill its
+obligations, (ii) direct or consequential loss that is suffered by the
+Licensee due to the use or performance of the Software, and (iii) more
+generally, any consequential loss. In particular the Parties expressly
+agree that any or all pecuniary or business loss (i.e. loss of data,
+loss of profits, operating loss, loss of customers or orders,
+opportunity cost, any disturbance to business activities) or any or all
+legal proceedings instituted against the Licensee by a third party,
+shall constitute consequential loss and shall not provide entitlement to
+any or all compensation from the Licensor.
+
+
+ Article 9 - WARRANTY
+
+9.1 The Licensee acknowledges that the scientific and technical
+state-of-the-art when the Software was distributed did not enable all
+possible uses to be tested and verified, nor for the presence of
+possible defects to be detected. In this respect, the Licensee's
+attention has been drawn to the risks associated with loading, using,
+modifying and/or developing and reproducing the Software which are
+reserved for experienced users.
+
+The Licensee shall be responsible for verifying, by any or all means,
+the suitability of the product for its requirements, its good working
+order, and for ensuring that it shall not cause damage to either persons
+or properties.
+
+9.2 The Licensor hereby represents, in good faith, that it is entitled
+to grant all the rights over the Software (including in particular the
+rights set forth in Article 5).
+
+9.3 The Licensee acknowledges that the Software is supplied "as is" by
+the Licensor without any other express or tacit warranty, other than
+that provided for in Article 9.2 and, in particular, without any warranty
+as to its commercial value, its secured, safe, innovative or relevant
+nature.
+
+Specifically, the Licensor does not warrant that the Software is free
+from any error, that it will operate without interruption, that it will
+be compatible with the Licensee's own equipment and software
+configuration, nor that it will meet the Licensee's requirements.
+
+9.4 The Licensor does not either expressly or tacitly warrant that the
+Software does not infringe any third party intellectual property right
+relating to a patent, software or any other property right. Therefore,
+the Licensor disclaims any and all liability towards the Licensee
+arising out of any or all proceedings for infringement that may be
+instituted in respect of the use, modification and redistribution of the
+Software. Nevertheless, should such proceedings be instituted against
+the Licensee, the Licensor shall provide it with technical and legal
+assistance for its defense. Such technical and legal assistance shall be
+decided on a case-by-case basis between the relevant Licensor and the
+Licensee pursuant to a memorandum of understanding. The Licensor
+disclaims any and all liability as regards the Licensee's use of the
+name of the Software. No warranty is given as regards the existence of
+prior rights over the name of the Software or as regards the existence
+of a trademark.
+
+
+ Article 10 - TERMINATION
+
+10.1 In the event of a breach by the Licensee of its obligations
+hereunder, the Licensor may automatically terminate this Agreement
+thirty (30) days after notice has been sent to the Licensee and has
+remained ineffective.
+
+10.2 A Licensee whose Agreement is terminated shall no longer be
+authorized to use, modify or distribute the Software. However, any
+licenses that it may have granted prior to termination of the Agreement
+shall remain valid subject to their having been granted in compliance
+with the terms and conditions hereof.
+
+
+ Article 11 - MISCELLANEOUS
+
+
+ 11.1 EXCUSABLE EVENTS
+
+Neither Party shall be liable for any or all delay, or failure to
+perform the Agreement, that may be attributable to an event of force
+majeure, an act of God or an outside cause, such as defective
+functioning or interruptions of the electricity or telecommunications
+networks, network paralysis following a virus attack, intervention by
+government authorities, natural disasters, water damage, earthquakes,
+fire, explosions, strikes and labor unrest, war, etc.
+
+11.2 Any failure by either Party, on one or more occasions, to invoke
+one or more of the provisions hereof, shall under no circumstances be
+interpreted as being a waiver by the interested Party of its right to
+invoke said provision(s) subsequently.
+
+11.3 The Agreement cancels and replaces any or all previous agreements,
+whether written or oral, between the Parties and having the same
+purpose, and constitutes the entirety of the agreement between said
+Parties concerning said purpose. No supplement or modification to the
+terms and conditions hereof shall be effective as between the Parties
+unless it is made in writing and signed by their duly authorized
+representatives.
+
+11.4 In the event that one or more of the provisions hereof were to
+conflict with a current or future applicable act or legislative text,
+said act or legislative text shall prevail, and the Parties shall make
+the necessary amendments so as to comply with said act or legislative
+text. All other provisions shall remain effective. Similarly, invalidity
+of a provision of the Agreement, for any reason whatsoever, shall not
+cause the Agreement as a whole to be invalid.
+
+
+ 11.5 LANGUAGE
+
+The Agreement is drafted in both French and English and both versions
+are deemed authentic.
+
+
+ Article 12 - NEW VERSIONS OF THE AGREEMENT
+
+12.1 Any person is authorized to duplicate and distribute copies of this
+Agreement.
+
+12.2 So as to ensure coherence, the wording of this Agreement is
+protected and may only be modified by the authors of the License, who
+reserve the right to periodically publish updates or new versions of the
+Agreement, each with a separate number. These subsequent versions may
+address new issues encountered by Free Software.
+
+12.3 Any Software distributed under a given version of the Agreement may
+only be subsequently distributed under the same version of the Agreement
+or a subsequent version.
+
+
+ Article 13 - GOVERNING LAW AND JURISDICTION
+
+13.1 The Agreement is governed by French law. The Parties agree to
+endeavor to seek an amicable solution to any disagreements or disputes
+that may arise during the performance of the Agreement.
+
+13.2 Failing an amicable solution within two (2) months as from their
+occurrence, and unless emergency proceedings are necessary, the
+disagreements or disputes shall be referred to the Paris Courts having
+jurisdiction, by the more diligent Party.
+
+
+Version 1.0 dated 2006-09-05.
--- /dev/null
+creaContours
+(c) CREATIS-LRMN 2008
\ No newline at end of file
Interface_Icons_NDimensions_lib
Interface_ManagerContour_NDimensions_lib
kernel_ManagerContour_NDimensions_lib
-
# ${WXWIDGETS_LIBRARIES}
${VTK_LIBRARIES}
${creaEnvironment_LIBRARIES}
#include "wxContourGUIExample.h"
#include "wxContourMainFrame.h"
-#include "OutlineModelManager.h"
-#include "wxContourEventHandler.h"
+//#include "OutlineModelManager.h"
+//#include "wxContourEventHandler.h"
-#include "wxContourMainPanel.h"
+
+#include <creaImageIOWxGimmickDialog.h>
+
+#include <creaVtkBasicSlicer.h>
+//#include "wxContourMainPanel.h"
#include "vtkMetaImageReader.h"
#include <map>
#include "vtkImageData.h"
-#include "OutlineModelBuilder.h"
-#include "ContourThing.h"
-#include "AxeThing.h"
-#include "ImageSourceThing.h"
-#include "ImageSectionThing.h"
-#include "SomeEnvironment.h"
-#include "ReaderEnvironment.h"
#include "wx/artprov.h"
#include <wx/filedlg.h>
+//#include "OutlineModelBuilder.h"
+//#include "ContourThing.h"
+//#include "AxeThing.h"
+//#include "ImageSourceThing.h"
+//#include "ImageSectionThing.h"
+//#include "SomeEnvironment.h"
+//#include "ReaderEnvironment.h"
-#include "interfMainPanel.h"
-#include <creaImageIOWxGimmickDialog.h>
-#include <creaVtkBasicSlicer.h>
+//#include "interfMainPanel.h"
+
wxContourMainFrame* wxTheApplication::frame = 0;
//----------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------
// Doing what is done by the bbtk boxes
- /*vtkMetaImageReader *reader = vtkMetaImageReader::New();
+ //vtkMetaImageReader *reader = vtkMetaImageReader::New();
// reader->SetFileName( "data\\hola.mhd" );
// reader->SetFileName( "C:/Program Files/bbtk-1.0/data/vtk/img02.maracas.mhd" );
// reader->SetFileName( "C:/Program Files/bbtk-1.0/data/vtk/test01.maracas.mhd" );
// reader->SetFileName( "C:/download/Elise/Elise_IRM_Helium/A/test01b.maracas.mhd" );
- wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.mhd"), wxOPEN );
- if (dialog.ShowModal() == wxID_OK)
- {
- std::string filename = (const char *)(dialog.GetPath().mb_str());
- reader->SetFileName( filename.c_str() );
- } else {
- reader->SetFileName( "data\\hola.mhd" );
+ //wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.mhd"), wxOPEN );
+ //if (dialog.ShowModal() == wxID_OK)
+ //{
+ // std::string filename = (const char *)(dialog.GetPath().mb_str());
+ // reader->SetFileName( filename.c_str() );
+ //} else {
+ // reader->SetFileName( "data\\hola.mhd" );
// Halt(0);
- }
-
- reader->Update();*/
+ //}
+ //reader->Update();
+/*JCP 17-10-2008
wxInitAllImageHandlers();
int image_type = GIMMICK_3D_IMAGE_SELECTION;
//-------------------------------------------------------------
- /*frame = new wxContourMainFrame(_builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv(),NULL, wxID_ANY, wxT("ROI Application Sample"), wxPoint(50,50), wxSize(800, 600));
- frame->Show(TRUE);*/
+ //frame = new wxContourMainFrame(_builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv(),NULL, wxID_ANY, wxT("ROI Application Sample"), wxPoint(50,50), wxSize(800, 600));
+ //frame->Show(TRUE);
//Creating the evtHandler of the panels
wxContourEventHandler * eventHandler = new wxContourEventHandler();
//frame->Show(TRUE);
frame1->Show(TRUE);
- /*JCP 17 - 10 - 08
- if ( successConfiuration )
- {
- frame->Show(TRUE);
- }*/
+ //JCP 17 - 10 - 08
+ //if ( successConfiuration )
+ //{
+ // frame->Show(TRUE);
+ //}
// SetTopWindow(frame);
//pannew->addContourCheckBox("contour4");
//JCP -- new Interface
+JCP 17-10-2008*/
+
+
+ wxInitAllImageHandlers();
+
+ int image_type = GIMMICK_3D_IMAGE_SELECTION;
+ int threads = 1;
+
+ creaImageIO::WxGimmickDialog w(0,
+ -1,
+ _T("WxGimmickDialog test"),
+ wxDefaultPosition,
+ wxSize(1200,800),
+ image_type,
+ threads);
+ w.ShowModal();
+
+ //vtkImageData* selectedimage=NULL;
+ std::vector<vtkImageData*> images;
+ if(w.GetReturnCode() == wxID_OK){
+
+ std::vector<std::string> s;
+ w.GetSelectedFiles(s);
+ std::vector<std::string>::iterator i;
+ for (i=s.begin();i!=s.end();++i){
+ std::cout << *i << std::endl;
+ }
+
+ std::cout << "$$$$ "<<std::endl;
+ w.GetSelectedImages(images);
+ //selectedimage = images[0];
+ //crea::VtkBasicSlicer(images.front());
+ //images.front()->Delete();
+
+ }else if (w.GetReturnCode() == wxID_CANCEL){
+ vtkMetaImageReader *reader = vtkMetaImageReader::New();
+ reader->SetFileName( "data/hola.mhd" );
+ reader->Update();
+ images.push_back(reader->GetOutput());
+ }else{
+ return -1;
+ }
+
+
+ wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 23 Oct 2008 "), wxPoint(400,50), wxSize(800, 600) );
+ //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images );
+ frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images );
+ frame1->CreateStatusBar();
+ frame1->Show(TRUE);
+
return TRUE;
}
if(bbGetInputGet()==1){
bbSetInputGet(0);
- eventHandler->checkInformationPanel();
- eventHandler->getValuesXYZ(vectx, vecty, vectz, &size);
- eventHandler->getMaskValue(mask, value);
+ //eventHandler->checkInformationPanel();
+ //eventHandler->getValuesXYZ(vectx, vecty, vectz, &size);
+ //eventHandler->getMaskValue(mask, value);
}
bbSetOutputX(vectx);
}
void nDimensions::CreateWidget()
{
- std::string s = "data";
-
- std::string conceptsFN = s + "/holaConceptsFile.cf";
- std::string imageSourcesFN = s + "/holaImagesInstantsFile.of";
- std::string imageSectionsFN = "";
- std::string axeThingsFN = "";
-
- std::map<std::string, ImageSourceThing *> * sourcesMap = new std::map<std::string, ImageSourceThing *>();
- std::map<std::string, ImageSectionThing *>* sectionsMap = new std::map<std::string, ImageSectionThing *>();
- std::map<std::string, AxeThing *>* axesMap = new std::map<std::string, AxeThing *>();
- std::map<std::string, ContourThing *>* outlinesMap = new std::map<std::string, ContourThing *>();
-
+
vtkImageData* img = bbGetInputIn();
- if(img==NULL){
- vtkMetaImageReader *reader = vtkMetaImageReader::New();
- reader->SetFileName( "data/hola.mhd" );
- reader->Update();
- img = reader->GetOutput();
- }
- ImageSourceThing * thing = new ImageSourceThing(img);
- sourcesMap->insert(std::pair<std::string, ImageSourceThing *>( "Source Image 1", thing));
+ std::vector<vtkImageData*> selectedimages;
+ selectedimages.push_back(img);
- OutlineModelBuilder * _builder = new OutlineModelBuilder( conceptsFN, s );
- _builder->buildImageSource_Envornment( imageSourcesFN, sourcesMap );
- _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap );
- _builder->buildAxe_Envornment(axeThingsFN, axesMap );
- _builder->buildCountour_Envornment( imageSectionsFN, outlinesMap );
-
- wxFrame* frame1 = new wxFrame(bbGetWxParent(), wxID_ANY, wxT("ROI Application - Evaluation version, 23 Oct 2008 "), wxPoint(50,50), wxSize(800, 600) );
- frame = new wxContourMainFrame( frame1, wxID_ANY, _T(""), wxPoint(50,50), wxSize(800, 600) );
+ wxFrame* frame1 = new wxFrame(bbGetWxParent(), wxID_ANY, wxT("ROI Application - Evaluation version, 23 Oct 2008 "), wxPoint(400,50), wxSize(800, 600) );
+ frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(100,50), wxSize(800, 600), selectedimages );
+ //new wxContourMainFrame( frame1, wxID_ANY, _T(""), wxPoint(50,50), wxSize(800, 600),selectedimages );
frame1->CreateStatusBar();
-
- wxAuiNotebook * parent = frame->createNotebook();
-
- OutlineModelManager * modelManager = new OutlineModelManager( _builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv() );
-
- std::string xxx1("Instant Chooser");
- wxInstantChooserPanel * instantPanel = new wxInstantChooserPanel( parent,
- xxx1,
- true );
- //ImageSourceThing * imageSource = modelManager->getImageSourceThingByKeyName( wxT("Source Image 1") );
- std::string xxx2("Source Image 1");
- ImageSourceThing * imageSource = modelManager->getImageSourceThingByKeyName( xxx2);
- wxContourViewPanel * theViewPanel = new wxContourViewPanel( imageSource->getSourceImage(), parent );
-
- eventHandler = new wxContourEventHandler();
- eventHandler->setModelManager( modelManager );
- eventHandler->setViewPanel( theViewPanel );
- eventHandler->setInstantChooserPanel( instantPanel );
-
- bool successConfiuration = eventHandler->configureEventsHandling();
-
- frame->setViewPanel( theViewPanel );
- frame->setInstantChooserPanel( instantPanel );
-
- successConfiuration &= frame->configurePanels( parent );
-
-
- //interfMainPanel* pannew = interfMainPanel::getInstance(frame1, eventHandler, s+"/Icons");
-
bbSetOutputWidget( frame1 );
#include "bbtkWxBlackBox.h"
#include "wxContourMainFrame.h"
-#include "OutlineModelManager.h"
-#include "wxContourEventHandler.h"
-#include "wxContourMainPanel.h"
+
#include <map>
#include "vtkImageData.h"
-#include "OutlineModelBuilder.h"
-#include "ContourThing.h"
-#include "AxeThing.h"
-#include "ImageSourceThing.h"
-#include "ImageSectionThing.h"
-#include "SomeEnvironment.h"
-#include "ReaderEnvironment.h"
#include "wx/artprov.h"
#include <wx/filedlg.h>
-#include "interfMainPanel.h"
#include <vtkImageData.h>
#include <vtkMetaImageReader.h>
private:
wxContourMainFrame* frame;
- wxContourEventHandler * eventHandler;
+ //wxContourEventHandler * eventHandler;
};
--- /dev/null
+
+
+
+
+
+#-----------------------------------------------------------------------------
+# CPACK+NSIS PACKAGING
+#-----------------------------------------------------------------------------
+
+#---Documentation-------------
+#http://www.cmake.org/Wiki/CMake:Packaging_With_CPack
+#http://www.cmake.org/Wiki/CMake:CPackConfiguration
+#http://www.cmake.org/Wiki/CMake:Install_Commands
+
+
+INCLUDE(InstallRequiredSystemLibraries)
+
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "creaContours - CREATIS-LRMN")
+SET(CPACK_PACKAGE_VENDOR "CREATIS-LRMN")
+SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.txt")
+SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt")
+SET(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_MAJOR_VERSION})
+SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_MINOR_VERSION})
+SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_BUILD_VERSION})
+
+
+
+SET(DATA_DIR ${PROJECT_SOURCE_DIR}/data )
+FILE(GLOB DATA_FILES "${DATA_DIR}/*.*")
+FOREACH( iLST ${DATA_FILES} )
+ INSTALL(
+ FILES ${iLST}
+ DESTINATION bin/data
+ )
+ENDFOREACH(iLST)
+SET(DATA_DIR ${PROJECT_SOURCE_DIR}/data/Icons )
+FILE(GLOB DATA_FILES "${DATA_DIR}/*.*")
+FOREACH( iLST ${DATA_FILES} )
+ INSTALL(
+ FILES ${iLST}
+ DESTINATION bin/data/Icons
+ )
+ENDFOREACH(iLST)
+
+
+#SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CreaTools\\\\creaContours-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+
+
+
+#IF (BUILD_BBTK_PACKAGE_creaContours)
+#
+# SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CreaTools\\\\bbtk-${BBTK_VERSION}")
+# IF(WIN32)
+# SET(CMAKE_INSTALL_PREFIX C:/CreaTools/bbtk-${BBTK_VERSION})
+# ENDIF(WIN32)
+
+#ELSE (BUILD_BBTK_PACKAGE_creaContours)
+
+ SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CreaTools\\\\creaContours-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+ IF(WIN32)
+ SET(CMAKE_INSTALL_PREFIX C:/CreaTools/creaContours)
+ ENDIF(WIN32)
+
+
+#ENDIF (BUILD_BBTK_PACKAGE_creaContours)
+
+
+
+IF(WIN32 AND NOT UNIX)
+ # There is a bug in NSI that does not handle full unix paths properly. Make
+ # sure there is at least one set of four (4) backlasshes.
+#EED SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/kernel/install/gnome/bbi-icon2.bmp")
+# SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin/BBI_EXE.exe")
+ SET(CPACK_NSIS_DISPLAY_NAME "creaContours")
+ SET(CPACK_NSIS_HELP_LINK "http://www.creatis.insa-lyon.fr/creatools/creaContours")
+ SET(CPACK_NSIS_URL_INFO_ABOUT "http://www.creatis.insa-lyon.fr/creatools/creaContours")
+ SET(CPACK_NSIS_CONTACT "info-dev@creatis.insa-lyon.fr")
+ SET(CPACK_NSIS_MODIFY_PATH ON)
+ELSE(WIN32 AND NOT UNIX)
+# SET(CPACK_STRIP_FILES "bin/bbi")
+ SET(CPACK_SOURCE_STRIP_FILES "")
+ENDIF(WIN32 AND NOT UNIX)
+SET(CPACK_PACKAGE_EXECUTABLES "wxContourGUIExample" "creaContours")
+
+
+INCLUDE(CPack)
+
+
+# Aditional INSTALL for CPACK mecanism.
+IF (WIN32)
+
+# INSTALL( FILES ${PROJECT_SOURCE_DIR}/win32/sqlite3.dll DESTINATION bin )
+
+ENDIF (WIN32)
+
+
+
+
+
+
+
+IF(EXWIN32)
+
+OPTION(BBTK_STANDALONE_INSTALLER "Install and add to installer all dlls needed, including from external toolkits (wx,itk,vtk)?" OFF)
+
+IF(BBTK_STANDALONE_INSTALLER)
+ STRING(REGEX REPLACE "\\\\" "/" WINDIR "$ENV{WINDIR}")
+ INSTALL( FILES ${WINDIR}/system32/msvcp71d.dll DESTINATION bin/ )
+ INSTALL( FILES ${WINDIR}/system32/msvcr71d.dll DESTINATION bin/ )
+
+ IF(USE_VTK)
+ SET(VTK_BIN_DIR ${VTK_DIR}/../../bin )
+
+ FILE(GLOB LST_FILE_VTKDLL "${VTK_BIN_DIR}/*.dll")
+ FOREACH( iLST ${LST_FILE_VTKDLL} )
+ INSTALL(
+ FILES ${iLST}
+ DESTINATION bin/
+ )
+ ENDFOREACH(iLST)
+ ENDIF(USE_VTK)
+
+ IF(USE_ITK)
+ INSTALL( FILES ${ITK_DIR}/bin/ITKCommon.dll DESTINATION bin/ )
+ ENDIF(USE_ITK)
+
+ IF(USE_WXWIDGETS)
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_xrc_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_richtext_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_qa_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_media_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_html_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_gl_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_core_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_aui_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxmsw28d_adv_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_xml_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_odbc_vc_custom.dll DESTINATION bin/ )
+ INSTALL( FILES ${WXWIDGETS_ROOT_DIR}/lib/vc_dll/wxbase28d_net_vc_custom.dll DESTINATION bin/ )
+ ENDIF(USE_WXWIDGETS)
+ENDIF(BBTK_STANDALONE_INSTALLER)
+
+ENDIF(EXWIN32)
: interfMenuBar(parent, sizex, sizey)
{
this->datadir = datdir;
- initButtons(evtHandler);
+ initButtons(this);
}
void interfDeleteMenu::initButtons(wxEvtHandler* evtHandler) {
path.push_back(datadir + "/DeleteContour.png");
nom.push_back("Delete the selected contour");
- funct.push_back(wxCommandEventHandler(wxContourEventHandler::onDeleteContour));
+ funct.push_back((wxObjectEventFunction)&interfDeleteMenu::onDeleteContour);
path.push_back(datadir + "/DeleteAllContourSlide.png");
nom.push_back("Delete all contours in the current slide");
- funct.push_back(wxCommandEventHandler(wxContourEventHandler::onDeleteContoursActSlice));
+ funct.push_back((wxObjectEventFunction)&interfDeleteMenu::onDeleteContoursActSlice);
path.push_back(datadir + "/DeleteAll.png");
nom.push_back("Delete all contours in all slides");
- funct.push_back(wxCommandEventHandler(wxContourEventHandler::onDeleteAllContours));
+ funct.push_back((wxObjectEventFunction)&interfDeleteMenu::onDeleteAllContours);
this->addButtons(path, nom);
{
}
+
+void interfDeleteMenu::onDeleteContour(wxCommandEvent& event){
+ interfMainPanel::getInstance()->onDeleteContour();
+}
+void interfDeleteMenu::onDeleteContoursActSlice(wxCommandEvent& event){
+ interfMainPanel::getInstance()->onDeleteContoursActSlice();
+}
+void interfDeleteMenu::onDeleteAllContours(wxCommandEvent& event){
+ interfMainPanel::getInstance()->onDeleteAllContours();
+}
\ No newline at end of file
#include <wx/wx.h>
#include "interfMenuBar.h"
+#include "interfMainPanel.h"
class interfDeleteMenu
: public interfMenuBar
~interfDeleteMenu();
virtual void initButtons(wxEvtHandler* evtHandler) ;
+
+private:
+ /**
+ ** This methods are in charge of responding to the events of button click by the delete panel
+ ** @params wxCommandEvent& the event that call the function
+ **/
+ void onDeleteContour(wxCommandEvent& event);
+ void onDeleteContoursActSlice(wxCommandEvent& event);
+ void onDeleteAllContours(wxCommandEvent& event);
};
: interfMenuBar(parent, sizex, sizey)
{
this->datadir = datdir;
- eventHandler = evtHandler;
+// eventHandler = evtHandler;
initButtons(this);
}
path.push_back(datadir + "/copy.png");
nom.push_back("Copy the selected contour");
- funct.push_back((wxObjectEventFunction) &interfMenuBar:: onActionButtonPressed);
+ funct.push_back((wxObjectEventFunction) &interfEditMenu:: onCopy);
path.push_back(datadir + "/paste.png");
nom.push_back("Paste the copied contour");
- funct.push_back((wxObjectEventFunction) &interfMenuBar:: onActionButtonPressed);
+ funct.push_back((wxObjectEventFunction) &interfEditMenu:: onPaste);
path.push_back(datadir + "/undo.png");
nom.push_back("Undo");
this->addButtons(path, nom);
this->setVectorFunction(funct);
- this->setButtonName(0, wxContour_ActionCommandsID::COPY_TOOL);
- this->setButtonName(1, wxContour_ActionCommandsID::PASTE_TOOL);
+ this->setButtonName(0, 'C');
+ this->setButtonName(1, 'P');
this->setButtonName(2, '-');
this->setButtonName(3, '-');
this->connectEvents(evtHandler);
}
+void interfEditMenu::onCopy(wxCommandEvent& event){
+ interfMainPanel::getInstance()->onCopy();
+}
+void interfEditMenu::onPaste(wxCommandEvent& event){
+ interfMainPanel::getInstance()->onPaste();
+}
void interfEditMenu::onUndo(wxCommandEvent& event){
- ((wxContourEventHandler*)this->eventHandler)->onUNDO();
+ interfMainPanel::getInstance()->onUndo();
}
void interfEditMenu::onRedo(wxCommandEvent& event){
- ((wxContourEventHandler*)this->eventHandler)->onREDO();
+ interfMainPanel::getInstance()->onRedo();
}
interfEditMenu::~interfEditMenu()
#include <wx/wx.h>
#include "interfMenuBar.h"
+#include "interfMainPanel.h"
class interfEditMenu
: public interfMenuBar
virtual void initButtons(wxEvtHandler* evtHandler) ;
+
+ void onCopy(wxCommandEvent& event);
+ void onPaste(wxCommandEvent& event);
void onUndo(wxCommandEvent& event);
void onRedo(wxCommandEvent& event);
#include "interfIOMenu.h"
+#include "interfMainPanel.h"
interfIOMenu::interfIOMenu(wxWindow * parent, int sizex, int sizey,wxEvtHandler* evtHandler, std::string datdir)
: interfMenuBar(parent, sizex, sizey)
{
this->datadir = datdir;
- eventHandler = evtHandler;
+// eventHandler = evtHandler;
initButtons(this);
}
path.push_back(datadir + "/Open.png");
nom.push_back("Open a previously saved file that contains contours information");
- funct.push_back((wxObjectEventFunction) &interfMenuBar:: onActionButtonPressed);
+ funct.push_back((wxObjectEventFunction) &interfIOMenu:: onLoad);
path.push_back(datadir + "/Save.png");
nom.push_back("Save all contours created");
- funct.push_back((wxObjectEventFunction) &interfMenuBar:: onActionButtonPressed);
+ funct.push_back((wxObjectEventFunction) &interfIOMenu:: onSave);
this->addButtons(path, nom);
this->setVectorFunction(funct);
- this->setButtonName(0, wxContour_ActionCommandsID::OPEN_TOOL);
- this->setButtonName(1, wxContour_ActionCommandsID::SAVE_TOOL);
+ //this->setButtonName(0, 'O');
+ //this->setButtonName(1, ');
this->connectEvents(evtHandler);
}
-
+void interfIOMenu::onLoad(wxCommandEvent& event){
+ interfMainPanel::getInstance()->onLoad();
+}
+void interfIOMenu::onSave(wxCommandEvent& event){
+ interfMainPanel::getInstance()->onSave();
+}
interfIOMenu::~interfIOMenu()
{
}
#include <wx/wx.h>
#include "interfMenuBar.h"
+
class interfIOMenu
: public interfMenuBar
{
void onActionButtonPressed( wxCommandEvent& event );
+ void onLoad(wxCommandEvent& event);
+ void onSave(wxCommandEvent& event);
+
private:
//wxEvtHandler* eventHandler;
#include "interfMainPanel.h"
-
+/*
#include "interfNewContourMenu.h"
#include "interfIOMenu.h"
#include "interfEditMenu.h"
#include "interfToolsSpreadPanel.h"
#include "interfMenuBar.h"
#include "interfSegmentationMenu.h"
-
+*/
interfMainPanel* interfMainPanel::interfmainpanel=NULL;
PANEL3 = "Delete";
PANEL4 = "Tools";
PANEL5 = "Segmentation";
-
+ segmentPanel = NULL;
+ segmentPanelITK = NULL;
+ configPanel = NULL;
+ spreadPanel = NULL;
+ infoWin=NULL;
+ informationPanel=NULL;
+
splitterwindow = new wxSplitterWindow(this,-1, wxDefaultPosition, wxSize(sizex, sizey), wxSP_3DSASH, wxString(_T("")));
sizey = sizey/8;
{
}
-interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler, std::string datadir){
+interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler){
wxFrame* newframe = new wxFrame(parent, -1, wxT("New Interface"), wxPoint(1,1), wxSize(380,750),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT);
}
void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event ){
+ //((interfToolsMenu*)menubar4)->hideAxis();
wxButton* b = (wxButton*)event.GetEventObject();
wxPanel* dmenu;
wxStaticText* text;
** Shows the panel in the
**/
void interfMainPanel::showPanel(wxWindow* panel){
-
+ wxContourMainFrame::getInstance()->showAxis(false);
wxSizer* sizer = infoPanel->GetSizer();
if(currentWindow != NULL){
splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
+ infoPanel->Layout();
+ infoPanel->Refresh();
this->Layout();
this->Refresh();
wxPanel* interfMainPanel::getInfoPanel(){
return infoPanel;
}
+
+void interfMainPanel::onCreateContourSpline( ){
+ wxContourMainFrame::getInstance()->showAxis(false);
+ wxContourMainFrame::getInstance()->onCreateContourSpline();
+}
+void interfMainPanel::onCreateContourRectangle( ){
+ wxContourMainFrame::getInstance()->showAxis(false);
+ wxContourMainFrame::getInstance()->onCreateContourRectangle();
+}
+void interfMainPanel::onCreateContourCircle( ){
+ wxContourMainFrame::getInstance()->showAxis(false);
+ wxContourMainFrame::getInstance()->onCreateContourCircle();
+}
+void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull){
+ wxContourMainFrame::getInstance()->showAxis(false);
+ wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
+}
+void interfMainPanel::onDeleteContour(){
+ wxContourMainFrame::getInstance()->showAxis(false);
+ wxContourMainFrame::getInstance()->onDeleteContour();
+}
+void interfMainPanel::onDeleteContoursActSlice(){
+ wxContourMainFrame::getInstance()->showAxis(false);
+ wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
+}
+void interfMainPanel::onDeleteAllContours(){
+ wxContourMainFrame::getInstance()->showAxis(false);
+ wxContourMainFrame::getInstance()->onDeleteAllContours();
+}
+
+void interfMainPanel::onCopy(){
+ wxContourMainFrame::getInstance()->onCopy();
+}
+void interfMainPanel::onPaste(){
+ wxContourMainFrame::getInstance()->onPaste();
+}
+void interfMainPanel::onUndo(){
+ wxContourMainFrame::getInstance()->onUndo();
+}
+void interfMainPanel::onRedo(){
+ wxContourMainFrame::getInstance()->onRedo();
+}
+void interfMainPanel::onLoad(){
+ wxContourMainFrame::getInstance()->onLoad();
+}
+void interfMainPanel::onSave(){
+ wxContourMainFrame::getInstance()-> onSave();
+}
+void interfMainPanel::RefreshInterface(){
+ wxContourMainFrame::getInstance()->RefreshInterface();
+}
+
+vtkImageData* interfMainPanel::getImageData(){
+ return wxContourMainFrame::getInstance()->getImageData();
+}
+
+void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method){
+ wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
+}
+
+int interfMainPanel::GetImageDataSizeZ(){
+ return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
+}
+
+void interfMainPanel::GetImageDataRange(double *range){
+ wxContourMainFrame::getInstance()->GetImageDataRange(range);
+}
+
+void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method){
+ wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
+}
+
+void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString){
+ ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
+}
+void interfMainPanel::onSegmentationPressed(){
+ if(segmentPanel == NULL){
+ segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
+ wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
+ segmentPanel->SetSizer(flexsizer, true);
+ segmentPanel->SetAutoLayout( true );
+ segmentPanel->SetEventHandler(this);
+
+ //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
+ segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
+
+
+ wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T(" Automatic Segmentation ")), wxDefaultPosition,
+ wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+
+ flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
+ flexsizer->Add(segmentationPanel, wxEXPAND);
+ segmentPanel->Layout();
+ }
+ showPanel(segmentPanel);
+ wxContourMainFrame::getInstance()->showAxis(true);
+ axisshown = true;
+}
+
+void interfMainPanel::onSegmentationPressedITK(){
+ if(segmentPanelITK == NULL){
+ segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
+
+
+ wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
+ segmentPanelITK->SetSizer(flexsizer, true);
+ segmentPanelITK->SetAutoLayout( true );
+ //segmentPanelITK->SetEventHandler(this->contourevent);
+
+ //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
+ wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
+
+
+ wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
+ wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+
+ flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
+ flexsizer->Add(panel, wxEXPAND);
+ segmentPanelITK->Layout();
+ }
+ showPanel(segmentPanelITK);
+ //contourevent->showAxis(true);
+ //axisshown = true;
+}
+
+void interfMainPanel::onRigidPressed(){
+ wxContourMainFrame::getInstance()->onRigidPressed();
+}
+
+void interfMainPanel::onWidthOfContour(double width){
+ wxContourMainFrame::getInstance()->onWidthOfContour(width);
+}
+
+int interfMainPanel::getColorWindow(){
+ return wxContourMainFrame::getInstance()->getColorWindow();
+}
+int interfMainPanel::getWindowLevel(){
+ return wxContourMainFrame::getInstance()->getWindowLevel();
+}
+void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel){
+ wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
+}
+
+void interfMainPanel::onInterpolation(bool interpolate){
+ wxContourMainFrame::getInstance()->onInterpolation(interpolate);
+}
+
+void interfMainPanel::onConfigurationPressed(){
+
+ if(configPanel == NULL){
+ configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
+ wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
+ configPanel->SetSizer(flexsizer, true);
+ configPanel->SetAutoLayout( true );
+ //configPanel->SetEventHandler(this->contourevent);
+
+ wxPanel* panel = new interfConfigurationPanel(configPanel);
+
+ wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T(" Interface Configuration ")), wxDefaultPosition,
+ wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+
+ flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
+
+ flexsizer->Add(panel, wxEXPAND);
+ configPanel->Layout();
+
+ }
+ showPanel(configPanel);
+}
+
+void interfMainPanel::onSpreadPressed(){
+ if(spreadPanel==NULL){
+
+ spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
+ wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
+ spreadPanel->SetSizer(flexsizer, true);
+ spreadPanel->SetAutoLayout( true );
+ //spreadPanel->SetEventHandler(this->contourevent);
+
+ //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
+ panelSpread = new interfSpreadPanel(spreadPanel);
+
+
+ wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T(" Automatic Spread ")), wxDefaultPosition,
+ wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+
+ flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
+ flexsizer->Add(panelSpread, wxEXPAND);
+ spreadPanel->Layout();
+ }
+ showPanel(spreadPanel);
+ //hideAxis();
+}
+
+void interfMainPanel::resetAppend(){
+ wxContourMainFrame::getInstance()->resetAppend();
+}
+
+void interfMainPanel::onSpreadAdd(){
+ wxContourMainFrame::getInstance()->onSpreadAdd();
+}
+
+void interfMainPanel::appendStringSpread(std::string val){
+ panelSpread->appendStringSpread(val);
+}
+
+void interfMainPanel::onSpreadGo(int type){
+ wxContourMainFrame::getInstance()->onSpreadGo(type);
+}
+void interfMainPanel::setStringSpread(std::string stringtemp){
+ panelSpread->setStringSpread(stringtemp);
+}
+
+void interfMainPanel::onInformationPressed(){
+ if(infoWin ==NULL){
+ infoWin = new wxFrame (this, -1,_T(" Spread "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
+ infoWin->SetSize( wxSize(500,450) );
+
+ wxSize sizepanel(200,300);
+ informationPanel = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
+
+ wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
+ sizerPanel -> Add( informationPanel , 1, wxEXPAND ,0);
+
+ infoWin->SetSizer( sizerPanel );
+ infoWin->SetAutoLayout( true );
+ infoWin->Layout();
+
+ infoWin->Show();
+
+ }else {
+
+ if (infoWin->IsShown()==true)
+ {
+ infoWin->Show(false);
+ } else {
+ //contourevent->FillGridWithContoursInformation();
+ infoWin->Show(true);
+ }
+ }
+}
+
+void interfMainPanel::getInstantVector(std::vector<int>& tempVector){
+ wxContourMainFrame::getInstance()->getInstantVector(tempVector);
+}
+
+std::vector<std::string> interfMainPanel::getOutlinesName(int slide){
+ return wxContourMainFrame::getInstance()->getOutlinesName(slide);
+}
+
+void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ){
+ wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ);
+}
+
+void interfMainPanel::setStringInfoPanel(wxString tmpString){
+ ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
+}
+
+void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString){
+ ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
+}
+
+int interfMainPanel::getNumberColsInformationPanel(){
+ return ((interfInformationPanel*)informationPanel)->getNumberCols();
+}
+
+void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics){
+ ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
+}
+
+void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString){
+ ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
+}
+
+void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString){
+ ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
+
+}
+
+void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename, int typeContourGroup){
+ wxContourMainFrame::getInstance()->onSaveResults(directory, namefile,filename, typeContourGroup);
+}
+
+wxString interfMainPanel::getCellValue(int j,int i){
+ return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
+}
+
#pragma once
#include <wx/wx.h>
-#include "wxContourEventHandler.h"
+//#include "wxContourEventHandler.h"
#include "interfNewContourMenu.h"
#include "interfIOMenu.h"
#include "interfDeleteMenu.h"
#include "interfToolsMenu.h"
#include "interfToolsSpreadPanel.h"
+#include "interfSegmentationMenu.h"
#include "interfMenuBar.h"
+#include "interfSegmentationPanels.h"
+#include "interfToolsPanels.h"
#include <wx/treebook.h>
#include <wx/sizer.h>
#include <wx/splitter.h>
#include <wx/statline.h>
+#include "vtkImageData.h"
+
class interfMainPanel : public wxPanel {
public:
/** This method should be called the first time by the parent class
** in creates all the panels the first time
**/
- static interfMainPanel* getInstance(wxWindow* parent, wxEvtHandler * evtHandler, std::string datadir);
+ static interfMainPanel* getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler=NULL );
/** This method should be called the first time by the parent class
** in creates all the panels the first time
**/
- static interfMainPanel* getInstance(wxWindow* parent, wxEvtHandler * evtHandler);
+ static interfMainPanel* getInstance(wxWindow* parent, wxEvtHandler * evtHandler=NULL);
/**
** Gets the instance of the class
**/
**/
wxPanel* getInfoPanel();
+ /**
+ ** This methods connect the event in the class interfNewContourMenu with the world of the appli
+ **/
+ void onCreateContourSpline( );
+ void onCreateContourRectangle( );
+ void onCreateContourCircle( );
+ void onCreateContoursBullEye(wxPanel* panBull);
+ /////////////////////////////////
+ void onDeleteContour();
+ void onDeleteContoursActSlice();
+ void onDeleteAllContours();
+ /////////////////////////
+ void onCopy();
+ void onPaste();
+ void onUndo();
+ void onRedo();
+
+ //////////////////////////
+ void onLoad();
+ void onSave();
+/////////////////////////////7
+ void RefreshInterface();
+
+ vtkImageData* getImageData();
+
+ void onSegmentationOneSlice(int isovalue,int sampling,int method);
+
+ int GetImageDataSizeZ();
+
+ void GetImageDataRange(double *range);
+
+ void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
+
+ void setLabelSegmentationPanelVTK(wxString tmpString);
+
+ void onSegmentationPressed();
+
+ void onSegmentationPressedITK();
+
+ void onRigidPressed();
+
+ void onWidthOfContour(double width);
+
+ int getColorWindow();
+ int getWindowLevel();
+
+ void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
+
+ void onInterpolation(bool interpolate);
+
+ void onSpreadPressed();
+
+ void onConfigurationPressed();
+
+ void resetAppend();
+ void onSpreadAdd();
+
+ void appendStringSpread(std::string val);
+
+ void onSpreadGo(int type);
+
+ void setStringSpread(std::string stringtemp);
+
+ void onInformationPressed();
+
+
+ void getInstantVector(std::vector<int>& tempVector);
+
+ std::vector<std::string> getOutlinesName(int slide);
+
+ void onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ);
+
+ void setStringInfoPanel(wxString tmpString);
+
+ void setRowLabelInfoPanel(int z, wxString tempString);
+
+ int getNumberColsInformationPanel();
+
+ void appendColsInformationPanel(int _numberOfVariablesStatistics);
+
+ void setCellValueInfoPanel(int z,int tmpIntA,wxString tempString);
+
+ void setColLableInfoPanel(int tmpIntB ,wxString tmpTitleString);
+
+ void onSaveResults(std::string directory,std::string namefile, std::string filename,int typeContourGroup);
+
+ wxString getCellValue(int j,int i);
private:
std::string PANEL4;
std::string PANEL5;
+ wxPanel* segmentPanel;
+ wxPanel* segmentationPanel;
+ wxPanel* segmentPanelITK;
+ wxPanel* configPanel;
+ wxPanel* spreadPanel;
+ interfSpreadPanel* panelSpread;
+ wxWindow* infoWin;
+ wxPanel* informationPanel;
+
+ bool axisshown;
+
//This attribute contains the panel in charge of adding and removing the corresponding checkboxes in
//list of contours
wxPanel* setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text);
-
};
#include <wx/sizer.h>
//#include "interfMainPanel.h"
-#include "wxContourEventHandler.h"
+//#include "wxContourEventHandler.h"
class interfMenuBar :
**/
void onActionButtonPressed( wxCommandEvent& event )
{
- if(eventHandler!=NULL)
+ if(true)//if(eventHandler!=NULL)
{
std::string theStr = std::string( ((wxButton *)event.GetEventObject())->GetName().ToAscii());
const char * toolCommand = theStr.c_str();
event.SetId( GetId() );
event.SetEventObject( this );
event.SetClientData( (void *) toolCommand);
- eventHandler->ProcessEvent( event );
+ //eventHandler->ProcessEvent( event );
}
}
wxFlexGridSizer* flexsizer;
protected:
- wxEvtHandler* eventHandler;
+ //wxEvtHandler* eventHandler;
std::string datadir;
: interfMenuBar(parent, sizex, sizey)
{
this->datadir = datdir;
- eventHandler = (wxContourEventHandler*)evtHandler;
+ //eventHandler = (wxContourEventHandler*)evtHandler;
panBull = NULL;
created = false;
- initButtons(evtHandler);
+ initButtons(this);
}
void interfNewContourMenu::initButtons(wxEvtHandler* evtHandler) {
path.push_back(datadir + "/Spline.png");
nom.push_back("Create a contour using splines");
- funct.push_back(wxCommandEventHandler(wxContourEventHandler::onCreateContourSpline));
+ funct.push_back((wxObjectEventFunction)&interfNewContourMenu::onCreateContourSpline);
hand.push_back(evtHandler);
path.push_back(datadir+"/Rectangle.png");
nom.push_back("Create a contour using the basic shape of a rectangle");
- funct.push_back(wxCommandEventHandler(wxContourEventHandler::onCreateContourRectangle));
+ funct.push_back((wxObjectEventFunction)&interfNewContourMenu::onCreateContourRectangle);
hand.push_back(evtHandler);
path.push_back(datadir + "/Circle.png");
nom.push_back("Create a contour using the basic shape of a Circle");
- funct.push_back(wxCommandEventHandler(wxContourEventHandler::onCreateContourCircle));
+ funct.push_back((wxObjectEventFunction)&interfNewContourMenu::onCreateContourCircle);
hand.push_back(evtHandler);
path.push_back(datadir + "/bullseye.png");
{
}
-void interfNewContourMenu::onCreateContourBullseye(wxEvtHandler* evtHandler){
+void interfNewContourMenu::onCreateContourBullseye(wxCommandEvent& event){
if(!created){
wxSize(100,200));
created = true;
}
- eventHandler->createContourBullsEye(panBull);
+ interfMainPanel::getInstance()->onCreateContoursBullEye(panBull);
+ //eventHandler->createContourBullsEye(panBull);
interfMainPanel::getInstance()->showPanel(panBull);
}
+void interfNewContourMenu::onCreateContourSpline( wxCommandEvent& event ){
+ interfMainPanel::getInstance()->onCreateContourSpline();
+}
+void interfNewContourMenu::onCreateContourRectangle( wxCommandEvent& event ){
+ interfMainPanel::getInstance()->onCreateContourRectangle();
+}
+void interfNewContourMenu::onCreateContourCircle( wxCommandEvent& event ){
+ interfMainPanel::getInstance()->onCreateContourCircle();
+}
+
#include "interfMenuBar.h"
#include "interfMainPanel.h"
-#include <wxContourEventHandler.h>
+#include "PanelBullEyeOptions.h"
+//#include <wxContourEventHandler.h>
class interfNewContourMenu
: public interfMenuBar
virtual void initButtons(wxEvtHandler* evtHandler) ;
- void onCreateContourBullseye(wxEvtHandler* evtHandler);
-
private:
- wxContourEventHandler* eventHandler;
- PanelBullEyeOptions* panBull;
+ //wxContourEventHandler* eventHandler;
+ wxPanel* panBull;
bool created;
-
-
+ /**
+ ** This method is in charge of capturing the event when the button is clicked
+ **/
+ void onCreateContourBullseye(wxCommandEvent& event);
+ /**
+ ** This method is in charge of capturing the event when the button is clicked
+ **/
+ void onCreateContourSpline( wxCommandEvent& event );
+ /**
+ ** This method is in charge of capturing the event when the button is clicked
+ **/
+ void onCreateContourRectangle( wxCommandEvent& event );
+ /**
+ ** This method is in charge of capturing the event when the button is clicked
+ **/
+ void onCreateContourCircle( wxCommandEvent& event );
};
#endif
: interfMenuBar(parent, sizex, sizey)
{
this->datadir = datdir;
- contourevent = (wxContourEventHandler*)evtHandler;
+ //contourevent = (wxContourEventHandler*)evtHandler;
infoWin = NULL;
configPanel = NULL;
- segmentPanel = NULL;
spreadPanel = NULL;
segmentPanelITK = NULL;
- eventHandler = evtHandler;
+ //eventHandler = evtHandler;
initButtons(this);
}
void interfSegmentationMenu::onSegmentationPressed(wxCommandEvent& event){
- if(segmentPanel == NULL){
- segmentPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
-
-
- wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
- segmentPanel->SetSizer(flexsizer, true);
- segmentPanel->SetAutoLayout( true );
- segmentPanel->SetEventHandler(this->contourevent);
-
- wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
-
-
- wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T(" Automatic Segmentation ")), wxDefaultPosition,
- wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
- flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
- flexsizer->Add(panel, wxEXPAND);
- segmentPanel->Layout();
- }
- interfMainPanel::getInstance()->showPanel(segmentPanel);
- contourevent->showAxis(true);
- axisshown = true;
+ interfMainPanel::getInstance()->onSegmentationPressed();
}
-void interfSegmentationMenu::hideAxis(){
- if(axisshown){
- axisshown = false;
- contourevent->showAxis(axisshown);
- }
-}
void interfSegmentationMenu::onSegmentationPressedITK(wxCommandEvent& event){
- if(segmentPanelITK == NULL){
- segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
-
-
- wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
- segmentPanelITK->SetSizer(flexsizer, true);
- segmentPanelITK->SetAutoLayout( true );
- segmentPanelITK->SetEventHandler(this->contourevent);
-
- wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
-
- wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
- wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+ interfMainPanel::getInstance()->onSegmentationPressedITK();
- flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
- flexsizer->Add(panel, wxEXPAND);
- segmentPanelITK->Layout();
- }
- interfMainPanel::getInstance()->showPanel(segmentPanelITK);
- //contourevent->showAxis(true);
- //axisshown = true;
+
}
void interfSegmentationMenu::onSnakePressed(wxCommandEvent& event){
- contourevent->onSnakePressed(this);
+ //contourevent->onSnakePressed(this);
}
+
+//------------------------------------------------------------------------------------------------------------
+
private:
- wxContourEventHandler* contourevent;
+ //wxContourEventHandler* contourevent;
wxPanel* configPanel;
wxWindow* infoWin;
- wxPanel* segmentPanel;
+
wxPanel* spreadPanel;
wxPanel* segmentPanelITK;
bool axisshown;
- void hideAxis();
+ wxPanel* getSegmentationPanel(wxWindow* parent);
+
+ void onSegmentationOneSlice( wxCommandEvent& event );
+
+ void onSegmentationAllSlice( wxCommandEvent& event );
+
+
};
--- /dev/null
+#include "interfSegmentationPanels.h"
+#include "interfMainPanel.h"
+
+interfSegmentationPanelVTK::interfSegmentationPanelVTK(wxWindow * parent)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
+{
+ int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
+ //int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ double range[2];
+ //_theViewPanel->getSceneManager()->GetImageDataRange(range);
+ interfMainPanel::getInstance()->GetImageDataRange(range);
+
+ wxButton *segmentationOneSliceBtn = new wxButton(this,-1,_T("Current slice"), wxDefaultPosition, wxSize(200,35) );
+ wxButton *segmentationAllSliceBtn = new wxButton(this,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
+ _isovalue = new wxSlider(this, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ _sampling = new wxSlider(this, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ wxString lstOptions[3];
+ lstOptions[0]=_T("A");
+ lstOptions[1]=_T("B");
+ lstOptions[2]=_T("C");
+ methodRadiobox = new wxRadioBox(this, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+ methodRadiobox->SetSelection(2);
+ _staticTextSegmentation = new wxStaticText(this,-1,_T(" "));
+
+ _mbarrange = new mBarRange(this,70, 65);
+ _mbarrange->SetMin(0);
+ _mbarrange->SetStart(0);
+
+ _mbarrange-> SetOrientation( true );
+ _mbarrange-> setActiveStateTo(true);
+ _mbarrange-> setVisibleLabels( true );
+ _mbarrange-> setDeviceEndMargin(10);
+ _mbarrange-> setRepresentedValues( 0 , sizeZ );
+ _mbarrange-> setDeviceBlitStart(10,10);
+ _mbarrange-> setIfWithActualDrawed( false );
+ _mbarrange-> SetStart( 0 );
+ _mbarrange-> SetEnd( sizeZ );
+
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(this,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
+ sizer -> Add( _isovalue , 1, wxGROW );
+ sizer -> Add( methodRadiobox , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T("Sampling (%)")) , 1, wxGROW );
+ sizer -> Add( _sampling , 1, wxGROW );
+ sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( _staticTextSegmentation , 1, wxGROW );
+ sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
+ sizer -> Add( _mbarrange , 1, wxGROW );
+
+ this->SetSizer( sizer );
+// panel->SetSize( sizePanel );
+ this->SetSize( wxDefaultSize );
+ this->SetAutoLayout( true );
+ this->Layout();
+
+//_segmentationFrame->SetEventHandler( this );
+ //segmentationOneSliceBtn->SetEventHandler( this );
+ //segmentationAllSliceBtn->SetEventHandler( this );
+ //panel->SetEventHandler(this);
+ Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationOneSlice);
+ Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationAllSlice);
+}
+
+
+interfSegmentationPanelVTK::~interfSegmentationPanelVTK()
+{
+}
+
+/**
+ ** Responds to the events of the buttons, when the same panel is responsible for it. It gets the name
+ ** of the button corresponding to the method that has to be executed,
+ ** it uses attribute eventHandler to call the methods define by the application.
+ ** see setEventHandler(wxEventHandler*)
+ **/
+
+void interfSegmentationPanelVTK::onSegmentationPressedITK(wxCommandEvent& event){
+ if(segmentPanelITK == NULL){
+ segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
+
+
+ wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
+ segmentPanelITK->SetSizer(flexsizer, true);
+ segmentPanelITK->SetAutoLayout( true );
+
+ wxPanel* panel = new wxPanel(this, -1);//contourevent->getSegmentationPanelITK(segmentPanelITK);
+
+
+ wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
+ wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
+
+ flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
+ flexsizer->Add(panel, wxEXPAND);
+ segmentPanelITK->Layout();
+ }
+ interfMainPanel::getInstance()->showPanel(segmentPanelITK);
+ //contourevent->showAxis(true);
+ //axisshown = true;
+}
+
+void interfSegmentationPanelVTK::onSnakePressed(wxCommandEvent& event){
+
+ //contourevent->onSnakePressed(this);
+
+}
+void interfSegmentationPanelVTK::onSegmentationOneSlice( wxCommandEvent& event )
+{
+
+
+ int isovalue = _isovalue->GetValue();
+ int sampling = _sampling->GetValue();
+ int method = methodRadiobox->GetSelection();
+ interfMainPanel::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
+
+}
+void interfSegmentationPanelVTK::onSegmentationAllSlice( wxCommandEvent& event )
+{
+
+ int minZ=_mbarrange->GetStart();
+ int maxZ=_mbarrange->GetEnd();
+
+ int isovalue = _isovalue->GetValue();
+ int sampling = _sampling->GetValue();
+ int method = methodRadiobox->GetSelection();
+
+
+ interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);
+
+}
+
+void interfSegmentationPanelVTK::setLabel(wxString tmpString){
+ _staticTextSegmentation->SetLabel(tmpString);
+}
+/**
+** start of new implementation
+** interfSegmentationPanelITK
+**/
+interfSegmentationPanelITK::interfSegmentationPanelITK(wxWindow * parent)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
+{
+ int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
+ //int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ double range[2];
+ //_theViewPanel->getSceneManager()->GetImageDataRange(range);
+ interfMainPanel::getInstance()->GetImageDataRange(range);
+
+ wxButton *segmentationOneSliceBtn = new wxButton(this,-1,_T("Current slice"), wxDefaultPosition, wxSize(200,35) );
+ wxButton *segmentationAllSliceBtn = new wxButton(this,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
+ _isovalue = new wxSlider(this, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ _sampling = new wxSlider(this, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ wxString lstOptions[3];
+ lstOptions[0]=_T("A");
+ lstOptions[1]=_T("B");
+ lstOptions[2]=_T("C");
+ methodRadiobox = new wxRadioBox(this, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+ methodRadiobox->SetSelection(2);
+ _staticTextSegmentation = new wxStaticText(this,-1,_T(" "));
+
+ _mbarrange = new mBarRange(this,70, 65);
+ _mbarrange->SetMin(0);
+ _mbarrange->SetStart(0);
+
+ _mbarrange-> SetOrientation( true );
+ _mbarrange-> setActiveStateTo(true);
+ _mbarrange-> setVisibleLabels( true );
+ _mbarrange-> setDeviceEndMargin(10);
+ _mbarrange-> setRepresentedValues( 0 , sizeZ );
+ _mbarrange-> setDeviceBlitStart(10,10);
+ _mbarrange-> setIfWithActualDrawed( false );
+ _mbarrange-> SetStart( 0 );
+ _mbarrange-> SetEnd( sizeZ );
+
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(this,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
+ sizer -> Add( _isovalue , 1, wxGROW );
+ sizer -> Add( methodRadiobox , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T("Sampling (%)")) , 1, wxGROW );
+ sizer -> Add( _sampling , 1, wxGROW );
+ sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( _staticTextSegmentation , 1, wxGROW );
+ sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
+ sizer -> Add( _mbarrange , 1, wxGROW );
+
+ this->SetSizer( sizer );
+// panel->SetSize( sizePanel );
+ this->SetSize( wxDefaultSize );
+ this->SetAutoLayout( true );
+ this->Layout();
+
+}
+interfSegmentationPanelITK::~interfSegmentationPanelITK(){
+
+}
+//------------------------------------------------------------------------------------------------------------
+
--- /dev/null
+#ifndef __interfSegmentationPanelsH__
+#define __interfSegmentationPanelsH__
+
+#include <wx/wx.h>
+#include "mBarRange.h"
+
+
+class interfSegmentationPanelVTK
+ : public wxPanel
+{
+public:
+ interfSegmentationPanelVTK(wxWindow * parent);
+ ~interfSegmentationPanelVTK();
+
+ /**
+ ** Responds to the events of the buttons, when the same panel is responsible for it. It gets the name
+ ** of the button corresponding to the method that has to be executed,
+ ** it uses attribute eventHandler to call the methods define by the application.
+ ** see setEventHandler(wxEventHandler*)
+ **/
+
+ void onSegmentationPressed(wxCommandEvent& event);
+
+ void onSegmentationPressedITK(wxCommandEvent& event);
+
+ void onSnakePressed(wxCommandEvent& event);
+
+ void setLabel(wxString tmpString);
+
+private:
+
+ //wxContourEventHandler* contourevent;
+ wxPanel* configPanel;
+ wxWindow* infoWin;
+ wxPanel* segmentPanel;
+ wxPanel* spreadPanel;
+ wxPanel* segmentPanelITK;
+ bool axisshown;
+
+ void hideAxis();
+
+ wxPanel* getSegmentationPanel(wxWindow* parent);
+
+ void onSegmentationOneSlice( wxCommandEvent& event );
+
+ void onSegmentationAllSlice( wxCommandEvent& event );
+
+ wxSlider* _isovalue;
+
+ mBarRange* _mbarrange;
+
+ wxSlider* _sampling;
+
+ wxStaticText* _staticTextSegmentation;
+
+ wxRadioBox* methodRadiobox;
+};
+
+class interfSegmentationPanelITK
+ : public wxPanel
+{
+public:
+ interfSegmentationPanelITK(wxWindow * parent);
+ ~interfSegmentationPanelITK();
+
+
+private:
+
+ wxSlider* _isovalue;
+
+ mBarRange* _mbarrange;
+
+ wxSlider* _sampling;
+
+ wxStaticText* _staticTextSegmentation;
+
+ wxRadioBox* methodRadiobox;
+};
+
+#endif
+
+
: interfMenuBar(parent, sizex, sizey)
{
this->datadir = datdir;
- contourevent = (wxContourEventHandler*)evtHandler;
- infoWin = NULL;
+ //contourevent = (wxContourEventHandler*)evtHandler;
+ //infoWin = NULL;
configPanel = NULL;
segmentPanel = NULL;
spreadPanel = NULL;
segmentPanelITK = NULL;
- eventHandler = evtHandler;
+// eventHandler = evtHandler;
initButtons(this);
}
path.push_back(datadir + "/Spread.png");
nom.push_back("The selected contour will spread through all slides");
- funct.push_back((wxObjectEventFunction) &interfMenuBar:: onActionButtonPressed);
+ funct.push_back((wxObjectEventFunction) &interfToolsMenu:: onRigidPressed);
path.push_back(datadir + "/Spread1.png");
nom.push_back("Select more than one contour and find the contours between them");
this->addButtons(path, nom);
this->setVectorFunction(funct);
- this->setButtonName(0, wxContour_ActionCommandsID::CHANGE_TOOL);
+ //this->setButtonName(0, wxContour_ActionCommandsID::CHANGE_TOOL);
this->connectEvents(evtHandler);
** see setEventHandler(wxEventHandler*)
**/
void interfToolsMenu::onRigidPressed(wxCommandEvent& event){
-
+ interfMainPanel::getInstance()->onRigidPressed();
}
void interfToolsMenu::onSpreadPressed(wxCommandEvent& event){
+ interfMainPanel::getInstance()->onSpreadPressed();
- if(spreadPanel==NULL){
-
- spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
- wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
- spreadPanel->SetSizer(flexsizer, true);
- spreadPanel->SetAutoLayout( true );
- spreadPanel->SetEventHandler(this->contourevent);
-
- wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
-
- wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T(" Automatic Spread ")), wxDefaultPosition,
- wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
-
- flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
- flexsizer->Add(panel, wxEXPAND);
- spreadPanel->Layout();
- }
- interfMainPanel::getInstance()->showPanel(spreadPanel);
- hideAxis();
}
void interfToolsMenu::onInformationPressed(wxCommandEvent& event){
- if(infoWin ==NULL){
- infoWin = new wxFrame (interfMainPanel::getInstance()->getInfoPanel(), -1,_T(" Spread "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
- infoWin->SetSize( wxSize(500,450) );
-
- wxSize sizepanel(200,300);
- wxPanel *panel = contourevent->getInformationPanel(infoWin);
-
- wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
- sizerPanel -> Add( panel->GetSizer() , 1, wxEXPAND ,0);
-
- infoWin->SetSizer( sizerPanel );
- infoWin->SetAutoLayout( true );
- infoWin->Layout();
-
- infoWin->Show();
+ interfMainPanel::getInstance()->onInformationPressed();
- }else {
-
- if (infoWin->IsShown()==true)
- {
- infoWin->Show(false);
- } else {
- contourevent->FillGridWithContoursInformation();
- infoWin->Show(true);
- }
- }
+
}
void interfToolsMenu::onConfigurationPressed(wxCommandEvent& event){
- if(configPanel == NULL){
- configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
- wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
- configPanel->SetSizer(flexsizer, true);
- configPanel->SetAutoLayout( true );
- configPanel->SetEventHandler(this->contourevent);
-
- wxPanel* panel = contourevent->getConfigurationPanel(configPanel);
-
- wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T(" Interface Configuration ")), wxDefaultPosition,
- wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
-
- flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
+ interfMainPanel::getInstance()->onConfigurationPressed();
- flexsizer->Add(panel, wxEXPAND);
- configPanel->Layout();
-
- }
- interfMainPanel::getInstance()->showPanel(configPanel);
-
- hideAxis();
}
-void interfToolsMenu::hideAxis(){
- if(axisshown){
- axisshown = false;
- contourevent->showAxis(axisshown);
- }
-}
void onConfigurationPressed(wxCommandEvent& event);
-
private:
- wxContourEventHandler* contourevent;
+ //wxContourEventHandler* contourevent;
wxPanel* configPanel;
- wxWindow* infoWin;
wxPanel* segmentPanel;
wxPanel* spreadPanel;
wxPanel* segmentPanelITK;
bool axisshown;
- void hideAxis();
+
};
--- /dev/null
+#include "interfToolsPanels.h"
+#include "interfMainPanel.h"
+
+interfConfigurationPanel::interfConfigurationPanel(wxWindow * parent)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
+{
+// wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString(_T("")));
+ _withOfContourLine = new wxSlider(this, -1, 1 , 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ double range[2];
+ interfMainPanel::getInstance()->GetImageDataRange(range);
+ //this->_theViewPanel->getSceneManager()->GetImageDataRange(range);
+
+ //wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
+ //vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
+ //int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
+ //int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
+
+ int colorwindow = interfMainPanel::getInstance()->getColorWindow();
+ int windowlevel = interfMainPanel::getInstance()->getWindowLevel();
+
+
+ _brithtnessWindowLevel = new wxSlider(this, -1, windowlevel , 1, range[1], wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ _brithtnessColorLevel = new wxSlider(this, -1, colorwindow , 1, range[1], wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
+ _interpolationCheckBox->SetValue(true);
+
+ Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &interfConfigurationPanel::onWidthOfContour );
+ Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &interfConfigurationPanel::onWidthOfContour );
+
+ Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel );
+ Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel );
+ Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel );
+ Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel );
+ Connect( _interpolationCheckBox->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &interfConfigurationPanel::OnInterpolation );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(this,-1,_T("Contour width")) , 1, wxGROW );
+ sizer -> Add( _withOfContourLine , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T("Brightness of the image")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T("--Window level--")) , 1, wxGROW );
+ sizer -> Add( _brithtnessWindowLevel , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T("--Color level--")) , 1, wxGROW );
+ sizer -> Add( _brithtnessColorLevel, 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( _interpolationCheckBox , 1, wxGROW );
+
+ this->SetSizer( sizer );
+ //JCP 13-10-08
+ //panel->SetSize( sizepanel );
+ //13-10-08
+ this->SetAutoLayout( true );
+ this->Layout();
+
+}
+
+
+interfConfigurationPanel::~interfConfigurationPanel()
+{
+}
+
+void interfConfigurationPanel::onWidthOfContour(wxScrollEvent& event){
+
+ double width = (double)_withOfContourLine->GetValue() / 2.0;
+ interfMainPanel::getInstance()->onWidthOfContour(width);
+}
+
+void interfConfigurationPanel::onBrigthnessColorWindowLevel(wxScrollEvent& event){
+ int colorwindow = _brithtnessColorLevel->GetValue();
+ int windowlevel = _brithtnessWindowLevel->GetValue();
+
+
+ interfMainPanel::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
+
+}
+
+void interfConfigurationPanel::OnInterpolation(wxCommandEvent& event)
+{
+
+ interfMainPanel::getInstance()->onInterpolation(_interpolationCheckBox->GetValue());
+
+
+}
+
+/**
+** Begin of the spread panel
+**/
+
+interfSpreadPanel::interfSpreadPanel(wxWindow* parent)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
+{
+
+ //wxPanel *panel = new wxPanel(parent,-1);
+
+ //_contourPropagation = new ContourPropagation();
+
+ //wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString("",wxConvUTF8));
+
+ wxButton *spreadResetBtn = new wxButton(this,-1,_T("Reset"),wxDefaultPosition, wxDefaultSize );
+ wxButton *spreadAddBtn = new wxButton(this,-1,_T("Add"),wxDefaultPosition, wxDefaultSize);
+
+ wxString lstOptions[3];
+ lstOptions[0]=_T("A");
+ lstOptions[1]=_T("B");
+ lstOptions[2]=_T("C");
+ _spreadMethodRadiobox = new wxRadioBox(this, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxDefaultSize, 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+ _spreadMethodRadiobox->SetSelection(2);
+
+ wxButton *spreadGoBtn = new wxButton(this,-1,_T("Go"),wxDefaultPosition, wxDefaultSize);
+ _staticTextSpread = new wxStaticText(this,-1,_T(" "));
+
+ _wxtextctrlSpread = new wxTextCtrl(this,-1, _T(""),wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
+ _wxtextctrlSpread->SetEditable(false);
+
+ Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSpreadPanel::onSpreadReset );
+ Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSpreadPanel::onSpreadAdd );
+ Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSpreadPanel::onSpreadGo );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( spreadResetBtn , 1, wxGROW );
+ sizer -> Add( spreadAddBtn , 1, wxGROW );
+ sizer -> Add( _spreadMethodRadiobox , 1, wxGROW );
+ sizer -> Add( spreadGoBtn , 1, wxGROW );
+ sizer -> Add( _staticTextSpread , 1, wxGROW );
+ sizer -> Add( _wxtextctrlSpread , 1, wxGROW );
+
+
+ this->SetSizer( sizer );
+ //this->SetSize( wxDefaultSize );
+ this->SetAutoLayout( true );
+ this->Layout();
+ //return panel;
+}
+
+interfSpreadPanel::~interfSpreadPanel(){
+}
+
+void interfSpreadPanel::onSpreadReset(wxCommandEvent& event){
+ setStringSpread(" ");
+ _wxtextctrlSpread->SetValue(wxString("",wxConvUTF8));
+ interfMainPanel::getInstance()->resetAppend();
+}
+void interfSpreadPanel::onSpreadAdd(wxCommandEvent& event){
+ interfMainPanel::getInstance()->onSpreadAdd();
+}
+void interfSpreadPanel::onSpreadGo(wxCommandEvent& event){
+
+
+ setStringSpread(" ");
+ int typeMethodFindCtrlPoints=_spreadMethodRadiobox->GetSelection();
+
+ interfMainPanel::getInstance()->onSpreadGo(typeMethodFindCtrlPoints);
+
+}
+
+void interfSpreadPanel::appendStringSpread(std::string val){
+ /* // if */
+ wxString newstring;
+ //newstring.Printf("%s %d -",_wxtextctrlSpread->GetValue(), actualSlice );
+ newstring.append(wxString(_wxtextctrlSpread->GetValue(),wxConvUTF8));
+ newstring.append(wxString(" ",wxConvUTF8));
+ newstring.append(wxString(val.c_str(),wxConvUTF8));
+ _wxtextctrlSpread->SetValue(newstring);
+}
+
+void interfSpreadPanel::setStringSpread(std::string stringtemp){
+
+ wxString newstring(stringtemp.c_str(),wxConvUTF8);
+ //_wxtextctrlSpread->SetEditable(true);
+ _staticTextSpread->SetLabel(newstring);
+ //_wxtextctrlSpread->SetEditable(false);
+}
+
+/**
+** Begin of information panel
+**/
+interfInformationPanel::interfInformationPanel(wxWindow * parent)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN){
+
+ //wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
+ wxString lstOptions[4];
+ lstOptions[0]=_T("Current Slice");
+ lstOptions[1]=_T("Range Slices");
+ lstOptions[2]=_T("All Slices");
+ _informationRadiobox = new wxRadioBox(this, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+
+ wxString lstOptContOperation[5];
+ lstOptContOperation[0]=_T("AND");
+ lstOptContOperation[1]=_T("OR");
+ lstOptContOperation[2]=_T("XOR");
+ lstOptContOperation[3]=_T("ALL");
+ _radiolstboxContourGroup = new wxRadioBox(this, -1, _T("Contour group"), wxDefaultPosition, wxSize(270,45), 4 , lstOptContOperation, 4, wxRA_SPECIFY_COLS);
+
+ wxButton *informationContourLabelsBtn = new wxButton(this,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
+ informationContourLabelsBtn->SetEventHandler( this );
+ Connect( informationContourLabelsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onInformationContourLabels );
+
+ wxButton *statisticsContourBtn = new wxButton(this,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
+ statisticsContourBtn->SetEventHandler( this );
+ Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onExtractInformation );
+
+ wxButton *saveResultsBtn = new wxButton(this,-1,_T("Save statistics results"),wxDefaultPosition, wxSize(140,35) );
+ saveResultsBtn->SetEventHandler( this );
+ Connect( saveResultsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfInformationPanel::onSaveResults );
+
+
+ int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
+ //_theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ _mbarrangeSliceInformation = new mBarRange(this,65,65);
+ _mbarrangeSliceInformation->SetMin(0);
+ _mbarrangeSliceInformation->SetStart(0);
+ _mbarrangeSliceInformation-> SetOrientation( true );
+ _mbarrangeSliceInformation-> setActiveStateTo(true);
+ _mbarrangeSliceInformation-> setVisibleLabels( true );
+ _mbarrangeSliceInformation-> setDeviceEndMargin(10);
+ _mbarrangeSliceInformation-> setRepresentedValues( 0 , sizeZ-1 );
+ _mbarrangeSliceInformation-> setDeviceBlitStart(10,10);
+ _mbarrangeSliceInformation-> setIfWithActualDrawed( false );
+ _mbarrangeSliceInformation-> SetStart( 0 );
+ _mbarrangeSliceInformation-> SetEnd( sizeZ-1 );
+
+
+ double range[2];
+ interfMainPanel::getInstance()->GetImageDataRange(range);
+ //this->_theViewPanel->getSceneManager()->GetImageDataRange(range);
+ _mbarrangeRangeInformation = new mBarRange(this,65,65);
+ _mbarrangeRangeInformation->SetMin(0);
+ _mbarrangeRangeInformation->SetStart(0);
+ _mbarrangeRangeInformation-> SetOrientation( true );
+ _mbarrangeRangeInformation-> setActiveStateTo(true);
+ _mbarrangeRangeInformation-> setVisibleLabels( true );
+ _mbarrangeRangeInformation-> setDeviceEndMargin(10);
+ _mbarrangeRangeInformation-> setRepresentedValues( range[0] , range[1] );
+ _mbarrangeRangeInformation-> setDeviceBlitStart(10,10);
+ _mbarrangeRangeInformation-> setIfWithActualDrawed( false );
+ _mbarrangeRangeInformation-> SetStart( range[0] );
+ _mbarrangeRangeInformation-> SetEnd( range[1] );
+
+
+ _staticTextInformation = new wxStaticText(this,-1,_T(" "));
+
+
+// wxButton *XXXXXXXBtn = new wxButton(this,-1,_T("Statistics"),wxDefaultPosition, wxSize(180,35) );
+// XXXXXXXBtn->SetEventHandler( this );
+// Connect( XXXXXXXBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onXXXXX );
+
+
+ _grid = new wxGrid( this,
+ wxID_ANY,
+ wxPoint( 0, 0 ),
+ wxSize( 100, 100 ) );
+
+ int i,gridCol=10,gridRow=sizeZ;
+ _grid->CreateGrid( 0, 0 );
+ _grid->AppendRows(gridRow);
+ _grid->AppendCols(gridCol);
+
+ for (i=0;i<gridRow;i++)
+ {
+ _grid->SetRowLabelValue(i, _T(" ") );
+ }
+// _grid->SetColLabelSize(0);
+
+
+ FillGridWithContoursInformation();
+
+ wxFlexGridSizer * sizerA = new wxFlexGridSizer(10);
+ sizerA->Add( _informationRadiobox , 1, wxALL ,2 );
+ sizerA->Add( _radiolstboxContourGroup , 1, wxALL ,2 );
+
+ wxFlexGridSizer * sizerB = new wxFlexGridSizer(10);
+ sizerB->Add( informationContourLabelsBtn , 1, wxALL ,2 );
+ sizerB->Add( statisticsContourBtn , 1, wxALL ,2 );
+ sizerB->Add( saveResultsBtn , 1, wxALL ,2 );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer->AddGrowableCol(0);
+ sizer->AddGrowableRow(7);
+ sizer->Add( sizerA , 1, wxALL , 0 );
+ sizer->Add( new wxStaticText(this ,-1,_T("Slice Range")) , 1, wxALL , 0 );
+ sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW , 2 );
+ sizer->Add( new wxStaticText(this ,-1,_T("Gray Range")) , 1, wxALL , 0 );
+ sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW , 2 );
+ sizer->Add( sizerB , 1, wxALL , 0 );
+ sizer->Add( _staticTextInformation , 1, wxALL , 0 );
+ sizer->Add( _grid , 1, wxEXPAND , 0 );
+
+
+
+ this->SetSizer( sizer );
+ this->SetSize( wxSize(1500,1500) );
+ //this->SetBackgroundColour( wxColour(100,100,100) );
+ this->SetAutoLayout( true );
+ this->Layout();
+ //return panel;
+}
+interfInformationPanel::~interfInformationPanel(){
+}
+
+void interfInformationPanel::onInformationContourLabels(wxCommandEvent& event){
+ wxBusyCursor wait;
+ FillGridWithContoursInformation();
+}
+void interfInformationPanel::onExtractInformation(wxCommandEvent& event){
+ wxBusyCursor wait;
+ _grid->ClearGrid();
+
+ int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
+ int selection = _informationRadiobox->GetSelection();
+ int minZ = _mbarrangeSliceInformation->GetStart();
+ int maxZ = _mbarrangeSliceInformation->GetEnd();
+
+ interfMainPanel::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ);
+
+
+}
+void interfInformationPanel::onSaveResults(wxCommandEvent& event){
+ wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.txt"), wxSAVE );
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ onExtractInformation( event );
+ std::string directory=(const char *)(dialog.GetDirectory().mb_str());
+ std::string namefile=(const char *)(dialog.GetFilename().mb_str());
+ std::string filename = (const char *)(dialog.GetPath().mb_str() );
+ int typeContourGroup = _radiolstboxContourGroup->GetSelection();
+ interfMainPanel::getInstance()->onSaveResults(directory, namefile, filename, typeContourGroup);
+ }
+}
+
+void interfInformationPanel::FillGridWithContoursInformation(){
+
+ wxString tempString;
+ _grid->ClearGrid();
+ _grid->SetColLabelValue(0, _T("A") );
+ _grid->SetColLabelValue(1, _T("B") );
+ _grid->SetColLabelValue(2, _T("C") );
+ _grid->SetColLabelValue(3, _T("D") );
+ _grid->SetColLabelValue(4, _T("E") );
+ _grid->SetColLabelValue(5, _T("F") );
+ //_instantPanel->getInstant( tempVector );
+
+ int z,sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ();//->getSceneManager()->GetImageDataSizeZ();
+ int ii,sizeLstContourThings;
+ for ( z=0 ; z<sizeZ ; z++)
+ {
+
+ std::vector<std::string> lstContourThings = interfMainPanel::getInstance()->getOutlinesName(z);
+
+ //this->_modelManager->getOutlinesAtInstant( &instant );
+
+ sizeLstContourThings = lstContourThings.size();
+ tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
+ _grid->SetRowLabelValue(z, tempString );
+
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ //ContourThing **contourthing = lstContourThings[ii];
+ //tempString = wxString((*contourthing)->getName().c_str(),wxConvUTF8) ;
+ tempString = wxString(lstContourThings[ii].c_str(),wxConvUTF8) ;
+ _grid->SetCellValue( z, ii, tempString );
+ }
+ }
+}
+
+void interfInformationPanel::setStringInfoPanel(wxString tmpString){
+ _staticTextInformation->SetLabel(tmpString);
+}
+
+void interfInformationPanel::setRowLabelInfoPanel(int z,wxString tempString){
+ _grid->SetRowLabelValue(z, tempString );
+}
+
+int interfInformationPanel::getNumberCols(){
+ return _grid->GetNumberCols();
+}
+
+void interfInformationPanel::appendCols(int numcols){
+ _grid->AppendCols(numcols);
+}
+
+void interfInformationPanel::setCellValue(int z,int tmpIntA,wxString tempString){
+ _grid->SetCellValue( z, tmpIntA , tempString );
+}
+
+void interfInformationPanel::setColLabel(int tmpIntB,wxString tmpTitleString){
+ _grid->SetColLabelValue(tmpIntB, tmpTitleString);
+}
+
+wxString interfInformationPanel::getCellValue(int j,int i){
+ return _grid->GetCellValue( j , i );
+}
\ No newline at end of file
--- /dev/null
+#ifndef __interfToolsPanelH__
+#define __interfToolsPanelH__
+
+#include <wx/wx.h>
+#include "mBarRange.h"
+#include <wx/grid.h>
+
+class interfConfigurationPanel
+ : public wxPanel
+{
+public:
+ interfConfigurationPanel(wxWindow * parent);
+ ~interfConfigurationPanel();
+
+
+
+private:
+
+ void onWidthOfContour(wxScrollEvent& event);
+
+ void onBrigthnessColorWindowLevel(wxScrollEvent& event);
+
+ void OnInterpolation(wxCommandEvent& event);
+
+ wxSlider* _withOfContourLine;
+ wxSlider* _brithtnessWindowLevel;
+ wxSlider* _brithtnessColorLevel;
+ wxCheckBox* _interpolationCheckBox;
+
+};
+
+class interfSpreadPanel
+ : public wxPanel
+{
+public:
+ interfSpreadPanel(wxWindow * parent);
+ ~interfSpreadPanel();
+
+ void appendStringSpread(std::string val);
+ void setStringSpread(std::string stringtemp);
+private:
+
+ wxRadioBox* _spreadMethodRadiobox;
+ wxStaticText* _staticTextSpread;
+ wxTextCtrl* _wxtextctrlSpread;
+
+ void onSpreadReset(wxCommandEvent& event);
+ void onSpreadAdd(wxCommandEvent& event);
+ void onSpreadGo(wxCommandEvent& event);
+
+
+
+};
+
+class interfInformationPanel
+ : public wxPanel
+{
+public:
+ interfInformationPanel(wxWindow * parent);
+ ~interfInformationPanel();
+
+ void setStringInfoPanel(wxString tmpString);
+ void setRowLabelInfoPanel(int z,wxString tempString);
+ void appendCols(int numcols);
+ int getNumberCols();
+ void setCellValue(int z,int tmpIntA,wxString tempString);
+ void setColLabel(int tmpIntB,wxString tmpTitleString);
+ wxString getCellValue(int j,int i);
+private:
+
+ mBarRange* _mbarrangeRangeInformation;
+ mBarRange* _mbarrangeSliceInformation;
+ wxGrid* _grid;
+ wxRadioBox* _informationRadiobox;
+ wxRadioBox* _radiolstboxContourGroup;
+ wxStaticText* _staticTextInformation;
+
+ void onInformationContourLabels(wxCommandEvent& event);
+ void onExtractInformation(wxCommandEvent& event);
+ void onSaveResults(wxCommandEvent& event);
+ void FillGridWithContoursInformation();
+
+
+
+
+};
+
+#endif
+
+
--- /dev/null
+
+//----------------------------------------------------------------------------------------------------------------
+// Class definition include
+//----------------------------------------------------------------------------------------------------------------
+//#include "wxContourEventHandler.h"
+#include "PanelBullEyeOptions.h"
+
+//------------------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------------------
+
+PanelBullEyeOptions::PanelBullEyeOptions (wxWindow * parent, wxSize size) :
+ wxPanel(parent, -1, wxDefaultPosition, size)
+{
+
+ _maxLevels = 5;
+ _maxSections = 10;
+ wxSize sizepanel(190,300);
+ wxPanel *panel = this;
+
+
+ wxString lstOptions[2];
+ lstOptions[0]= wxString("General options",wxConvUTF8);
+ lstOptions[1]= wxString("Detail options",wxConvUTF8);
+ _radioboxBullEyeGenOpt = new wxRadioBox(panel, -1, wxString("General/Detail options",wxConvUTF8), wxDefaultPosition, wxSize(200,45), 2 , lstOptions, 2, wxRA_SPECIFY_COLS);
+ _radioboxBullEyeGenOpt->SetSelection(0);
+
+ _spinctrlBullEyeNumOfCrowns = new wxSpinCtrl( panel , -1,_T("B"),wxDefaultPosition, wxSize(40,20) );
+ _spinctrlBullEyeNumOfCrowns->SetRange(1,_maxLevels);
+ _spinctrlBullEyeNumOfCrowns->SetValue(3);
+
+ _spinctrlBullEyeNumOfSec = new wxSpinCtrl( panel , -1,_T("A"),wxDefaultPosition, wxSize(40,20) );
+ _spinctrlBullEyeNumOfSec->SetRange(1,_maxSections);
+ _spinctrlBullEyeNumOfSec->SetValue(5);
+
+
+ _sliderBullEyeAngle = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ wxFlexGridSizer * sizerGeneralOptions = new wxFlexGridSizer(10);
+
+ wxFlexGridSizer * sizerGeneralOptionsA = new wxFlexGridSizer(1);
+ wxFlexGridSizer * sizerGeneralOptionsB = new wxFlexGridSizer(1);
+ wxFlexGridSizer * sizerGeneralOptionsC = new wxFlexGridSizer(1);
+ sizerGeneralOptionsA -> Add( new wxStaticText(panel,-1,_T("Crowns")) , 1, wxGROW );
+ sizerGeneralOptionsA -> Add( _spinctrlBullEyeNumOfCrowns , 1/*, wxGROW*/ );
+ sizerGeneralOptionsB -> Add( new wxStaticText(panel,-1,_T("Sections")) , 1, wxGROW );
+ sizerGeneralOptionsB -> Add( _spinctrlBullEyeNumOfSec , 1/*, wxGROW*/ );
+ sizerGeneralOptionsC -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
+ sizerGeneralOptionsC -> Add( _sliderBullEyeAngle , 1/*, wxGROW*/ );
+
+ sizerGeneralOptions -> Add( sizerGeneralOptionsA , 1/*, wxGROW*/ );
+ sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerGeneralOptions -> Add( sizerGeneralOptionsB , 1/*, wxGROW*/ );
+ sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerGeneralOptions -> Add( sizerGeneralOptionsC , 1/*, wxGROW*/ );
+
+
+ wxSpinCtrl *tmpSpinSection;
+ wxSlider *tmpSliderRadio;
+ wxSlider *tmpSliderAng;
+
+ wxFlexGridSizer * sizerDetailOptions = new wxFlexGridSizer(6);
+
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T("Crown ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Sections ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Radio %")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
+
+ wxString tmpwxstring;
+ int i;
+ for (i=0;i<_maxLevels;i++){
+ tmpSpinSection = new wxSpinCtrl( panel , -1,_T(""),wxDefaultPosition, wxSize(40,20) );
+ tmpSliderRadio = new wxSlider( panel , -1 ,0,0,100, wxDefaultPosition, wxSize(110,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ tmpSliderAng = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ tmpSpinSection ->SetRange(1,_maxSections);
+
+ tmpwxstring.Printf(_T(" %d. "),i+1);
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,tmpwxstring) , 1, wxGROW );
+ sizerDetailOptions -> Add( tmpSpinSection, 1 );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( tmpSliderRadio, 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( tmpSliderAng, 1, wxGROW );
+
+ tmpSpinSection -> SetValue(5);
+ tmpSliderRadio -> SetValue( 100-(double)((i)*100.0/_maxLevels) );
+ tmpSliderAng -> SetValue(0);
+
+ Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
+ Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
+
+ _lstBullEyeDetailNumOfSec.push_back( tmpSpinSection );
+ _lstBullEyeDetailRadio.push_back( tmpSliderRadio );
+ _lstBullEyeDetailAngle.push_back( tmpSliderAng );
+
+ } //for
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( _radioboxBullEyeGenOpt , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye general options --")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( sizerGeneralOptions , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye detail options --")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( sizerDetailOptions , 1, wxGROW );
+
+ Connect( _radioboxBullEyeGenOpt->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
+ Connect( _spinctrlBullEyeNumOfCrowns->GetId(), wxEVT_COMMAND_TEXT_UPDATED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
+
+ panel->SetSizer( sizer );
+ panel->SetSize( sizepanel );
+ panel->SetAutoLayout( true );
+ panel->Layout();
+
+ RefreshPanel();
+
+}
+
+//------------------------------------------------------------------------------------------------------------
+PanelBullEyeOptions::~PanelBullEyeOptions()
+{
+}
+
+//------------------------------------------------------------------------------------------------------------
+void PanelBullEyeOptions::onRefreshPanel( wxCommandEvent& event )
+{
+ RefreshPanel();
+}
+
+//------------------------------------------------------------------------------------------------------------
+void PanelBullEyeOptions::RefreshPanel()
+{
+ int i;
+ bool ok;
+ if (this->_radioboxBullEyeGenOpt->GetSelection()==0){
+ for (i=0; i<_maxLevels; i++)
+ {
+ _lstBullEyeDetailNumOfSec[i] -> Enable(false);
+ _lstBullEyeDetailRadio[i] -> Enable(false);
+ _lstBullEyeDetailAngle[i] -> Enable(false);
+ } // for
+ } else {
+ int spinSelec = _spinctrlBullEyeNumOfCrowns->GetValue();
+ for (i=0; i<_maxLevels; i++)
+ {
+ ok = (i < spinSelec);
+ _lstBullEyeDetailNumOfSec[i] -> Enable(ok);
+ _lstBullEyeDetailRadio[i] -> Enable(ok);
+ _lstBullEyeDetailAngle[i] -> Enable(ok);
+
+ if (i>0){
+ if (_lstBullEyeDetailRadio[i]->GetValue() > _lstBullEyeDetailRadio[i-1]->GetValue())
+ {
+ _lstBullEyeDetailRadio[i]->SetValue( _lstBullEyeDetailRadio[i-1]->GetValue() );
+ }
+ }// if i>0
+ } // for
+ } // if
+}
+
+//------------------------------------------------------------------------------------------------------------
+int PanelBullEyeOptions::GetNumberOfCrowns()
+{
+ return this->_spinctrlBullEyeNumOfCrowns->GetValue();
+}
+
+//------------------------------------------------------------------------------------------------------------
+int PanelBullEyeOptions::GetNumberOfSections(int nCrown)
+{
+ int result;
+ if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
+ {
+ result = this->_spinctrlBullEyeNumOfSec->GetValue();
+ } else {
+ result = this->_lstBullEyeDetailNumOfSec[nCrown]->GetValue();
+ }
+ return result;
+}
+
+//------------------------------------------------------------------------------------------------------------
+int PanelBullEyeOptions::GetRadioOfCrown(int nCrown)
+{
+ int result;
+ double sizeCrowns;
+ if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
+ {
+ sizeCrowns = (double)( this->_spinctrlBullEyeNumOfCrowns->GetValue() );
+ result = 100.0 * (nCrown+1)/sizeCrowns ;
+ } else {
+ result = this->_lstBullEyeDetailRadio[nCrown]->GetValue();
+ }
+ return result;
+}
+
+//------------------------------------------------------------------------------------------------------------
+double PanelBullEyeOptions::GetAngOfCrownSection(int nCrown,int section)
+{
+ double angle;
+ if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
+ {
+ angle = this->_sliderBullEyeAngle->GetValue();
+ } else {
+ angle = this->_lstBullEyeDetailAngle[nCrown]->GetValue();
+ }
+ double numOfSec = (double)GetNumberOfSections(nCrown);
+ double deltaSec = GetAngDeltaOfCrownSection(nCrown);
+ return angle + section*deltaSec ;
+}
+
+//------------------------------------------------------------------------------------------------------------
+double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown)
+{
+ double numOfSec = (double)GetNumberOfSections(nCrown);
+ return 360.0/numOfSec;
+}
+
--- /dev/null
+#ifndef __PanelBullEyeOptions_h_INCLUDED_H__
+#define __PanelBullEyeOptions_h_INCLUDED_H__
+
+
+// -----------------------------------------------------------------------------------------------------------
+// WX headers inclusion.
+// For compilers that support precompilation, includes <wx/wx.h>.
+// -----------------------------------------------------------------------------------------------------------
+
+#include <wx/wxprec.h>
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
+#include <wx/grid.h>
+
+#include <sstream>
+//------------------------------------------------------------------------------------------------------------
+// Includes
+//------------------------------------------------------------------------------------------------------------
+#include "wxContourMainFrame.h"
+#include <wx/spinctrl.h>
+
+
+
+class PanelBullEyeOptions : public wxPanel {
+public:
+ PanelBullEyeOptions(wxWindow* parent, wxSize size);
+ ~PanelBullEyeOptions ();
+ void onRefreshPanel( wxCommandEvent& event );
+ int GetNumberOfCrowns();
+ int GetNumberOfSections(int nCrown);
+ int GetRadioOfCrown(int nCrown);
+ double GetAngOfCrownSection(int nCrown,int section);
+ double GetAngDeltaOfCrownSection(int nCrown);
+protected:
+
+private:
+ int _maxLevels;
+ int _maxSections;
+ wxRadioBox *_radioboxBullEyeGenOpt;
+ wxSpinCtrl *_spinctrlBullEyeNumOfCrowns;
+ wxSpinCtrl *_spinctrlBullEyeNumOfSec;
+ wxSlider *_sliderBullEyeAngle;
+ std::vector<wxSpinCtrl *> _lstBullEyeDetailNumOfSec;
+ std::vector<wxSlider *> _lstBullEyeDetailRadio;
+ std::vector<wxSlider *> _lstBullEyeDetailAngle;
+
+
+
+
+ void RefreshPanel();
+};
+
+
+#endif // __wxContourEventHandler_HEADER_FILE__
minValue = minV;
maxValue = maxV;
+ _numCheckBox = 0;
showLabels = true;
char a = *elements;
if( a == 67 || a == 99 )// Including C:67 or c:99 as a checkBox (ASCII)
{
- createCheckBoxAndAddToSizer( checkSizer, "", -1, ckecks);
+ /*if(ckecks==0){
+ createCheckBoxAndAddToSizer( checkSizer, "X", -1, ckecks);
+ }else{
+ createCheckBoxAndAddToSizer( checkSizer, "Y", -1, ckecks);
+ }*/
+ createCheckBoxAndAddToSizer( checkSizer, "X", -1, ckecks);
ckecks++;
}
else if ( a == 84 || a==116 )// Including T:84 or t t:116 as textCtrl (ASCII)
}
i++;
}
+ _numCheckBox = ckecks;
sizer->Add(checkSizer, 0, wxGROW |wxALL );
}
+ int wxConceptControl :: getNumCheckBox(){
+ return _numCheckBox;
+ }
+
//------------------------------------------------------------------------------------------------------------
wxCheckBox * wxConceptControl :: createCheckBoxAndAddToSizer(wxSizer *sizer, std::string label, wxWindowID id,int groupID)
{
void reset();
+ int getNumCheckBox();
+
private:
//------------------------------------------------------------------------------------------------------------
// Private methods
bool showLabels;
+ int _numCheckBox;
+
//DECLARE_CLASS(wxConceptControl)
--- /dev/null
+
+
+/* Diagrama de Secuaencia de cambiar un instante
+wxContourEventHandler :: changeInstant()
+ OutlineModelManager :: ->setInstant( _actualInstant );
+ OutlineModelManager :: updateToActualInstant()
+ OutlineModelManager :: getOutlinesAtInstant(Instant * anInstant, bool ifAnnotate)
+ OutlineModelManager :: annotateOutlinesWrap(std::vector<std::string> kNamesVector, std::vector<ContourThing **> theOutlinesVector)
+ wxContourEventHandler :: updateInstantOutlines()
+ OutlineModelManager :: getActualInstantOutlines ()
+ wxVtkBaseView_SceneManager :: addToScene( std::vector< std::string> theKeyNameVector, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
+ wxVtkBaseView_SceneManager :: addToScene( std::string theKeyName, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
+ wxVtkBaseView_SceneManager :: getContourWrap_ViewControlOf
+ MAP find
+ void wxVtkBaseView_SceneManager :: addToScene( std::string theKeyName, ContourWrap_ViewControl * contourWRP, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
+
+*/
+
+
+/*!
+ \mainpage NDimension with wxWidgets and maracas
+
+ \section intro Introduction
+
+ This is the introduction.
+
+
+
+ \dot
+
+
+digraph example_0 {
+ graph [ ratio=fill];
+ node [shape=record, fontname=Helvetica, fontsize=10];
+
+ _wxContourGUIExample [ label="wxContourGUIExample" URL="\ref wxContourGUIExample"];
+ _wxContourEventHandler [ label="wxContourEventHandler" URL="\ref wxContourEventHandler"];
+
+ _OutlineModelManager [ label="OutlineModelManager" URL="\ref OutlineModelManager"];
+ _wxInstantChooserPanel [ label="wxInstantChooserPanel" URL="\ref wxInstantChooserPanel"];
+ _wxContourViewPanel [ label="wxContourViewPanel" URL="\ref wxContourViewPanel"];
+ _wxContour_ButtonsBar [ label="wxContour_ButtonsBar" URL="\ref wxContour_ButtonsBar"];
+ _OutlineModelManager [ label="OutlineModelManager" URL="\ref OutlineModelManager"];
+ _wxVtkBaseView_SceneManager [ label="wxVtkBaseView_SceneManager" URL="\ref wxVtkBaseView_SceneManager"];
+ _SomeEnvironment [ label="SomeEnvironment" URL="\ref SomeEnvironment"];
+
+
+ _wxContourGUIExample -> _wxContourEventHandler [ arrowhead="open", style="dashed" ];
+ _wxContourGUIExample -> _OutlineModelManager [ arrowhead="open", style="dashed" ];
+ _wxContourGUIExample -> _wxInstantChooserPanel [ arrowhead="open", style="dashed" ];
+ _wxContourGUIExample -> _wxContourViewPanel [ arrowhead="open", style="dashed" ];
+ _wxContourGUIExample -> _wxContour_ButtonsBar [ arrowhead="open", style="dashed" ];
+ _wxContourViewPanel -> wxMaracas_N_ViewersWidget [ arrowhead="open", style="dashed" ];
+ _wxContourEventHandler -> _OutlineModelManager [ arrowhead="open", style="dashed" ];
+ _wxContourEventHandler -> _wxVtkBaseView_SceneManager [ arrowhead="open", style="dashed" ];
+ _OutlineModelManager -> _SomeEnvironment [ arrowhead="open", style="dashed" ];
+
+}
+
+\enddot
+
+
+
+*/
+
+
+
+//----------------------------------------------------------------------------------------------------------------
+// Class definition include
+//----------------------------------------------------------------------------------------------------------------
+#include "wxContourEventHandler.h"
+#include <wx/filedlg.h>
+#include <wx/spinctrl.h>
+#include <iostream>
+#include <fstream>
+
+//----------------------------------------------------------------------------------------------------------------
+// Class implementation
+//----------------------------------------------------------------------------------------------------------------
+/** @file wxContourEventHandler.cxx */
+
+
+//------------------------------------------------------------------------------------------------------------
+// Includes
+//------------------------------------------------------------------------------------------------------------
+
+#include "wxContour_ActionCommandsID.h"
+#include "NameWrapper.h"
+#include "ConceptDataWrap.h"
+#include "OutlineGroup.h"
+
+#include <manualContour.h>
+#include "Contour/ContourExtractData.h"
+#include "ImageSourceThing.h"
+#include "PanelBullEyeOptions.h"
+
+
+#include <vtkContourFilter.h>
+#include <vtkCleanPolyData.h>
+#include <vtkPolyDataConnectivityFilter.h>
+#include <vtkStripper.h>
+#include <vtkImageReslice.h>
+#include <vtkMetaImageWriter.h>
+#include <vtkImageMapToWindowLevelColors.h>
+
+
+
+//------------------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------------------
+/*
+PanelBullEyeOptions::PanelBullEyeOptions (wxWindow * parent, wxSize size) :
+ wxPanel(parent, -1, wxDefaultPosition, size)
+{
+
+ _maxLevels = 5;
+ _maxSections = 10;
+ wxSize sizepanel(190,300);
+ wxPanel *panel = this;
+
+
+ wxString lstOptions[2];
+ lstOptions[0]= wxString("General options",wxConvUTF8);
+ lstOptions[1]= wxString("Detail options",wxConvUTF8);
+ _radioboxBullEyeGenOpt = new wxRadioBox(panel, -1, wxString("General/Detail options",wxConvUTF8), wxDefaultPosition, wxSize(200,45), 2 , lstOptions, 2, wxRA_SPECIFY_COLS);
+ _radioboxBullEyeGenOpt->SetSelection(0);
+
+ _spinctrlBullEyeNumOfCrowns = new wxSpinCtrl( panel , -1,_T("B"),wxDefaultPosition, wxSize(40,20) );
+ _spinctrlBullEyeNumOfCrowns->SetRange(1,_maxLevels);
+ _spinctrlBullEyeNumOfCrowns->SetValue(3);
+
+ _spinctrlBullEyeNumOfSec = new wxSpinCtrl( panel , -1,_T("A"),wxDefaultPosition, wxSize(40,20) );
+ _spinctrlBullEyeNumOfSec->SetRange(1,_maxSections);
+ _spinctrlBullEyeNumOfSec->SetValue(5);
+
+
+ _sliderBullEyeAngle = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ wxFlexGridSizer * sizerGeneralOptions = new wxFlexGridSizer(10);
+
+ wxFlexGridSizer * sizerGeneralOptionsA = new wxFlexGridSizer(1);
+ wxFlexGridSizer * sizerGeneralOptionsB = new wxFlexGridSizer(1);
+ wxFlexGridSizer * sizerGeneralOptionsC = new wxFlexGridSizer(1);
+ sizerGeneralOptionsA -> Add( new wxStaticText(panel,-1,_T("Crowns")) , 1, wxGROW );
+ sizerGeneralOptionsA -> Add( _spinctrlBullEyeNumOfCrowns , 1/*, wxGROW );
+ sizerGeneralOptionsB -> Add( new wxStaticText(panel,-1,_T("Sections")) , 1, wxGROW );
+ sizerGeneralOptionsB -> Add( _spinctrlBullEyeNumOfSec , 1/*, wxGROW );
+ sizerGeneralOptionsC -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
+ sizerGeneralOptionsC -> Add( _sliderBullEyeAngle , 1/*, wxGROW );
+
+ sizerGeneralOptions -> Add( sizerGeneralOptionsA , 1/*, wxGROW );
+ sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerGeneralOptions -> Add( sizerGeneralOptionsB , 1/*, wxGROW );
+ sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerGeneralOptions -> Add( sizerGeneralOptionsC , 1/*, wxGROW );
+
+
+ wxSpinCtrl *tmpSpinSection;
+ wxSlider *tmpSliderRadio;
+ wxSlider *tmpSliderAng;
+
+ wxFlexGridSizer * sizerDetailOptions = new wxFlexGridSizer(6);
+
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T("Crown ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Sections ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Radio %")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
+
+ wxString tmpwxstring;
+ int i;
+ for (i=0;i<_maxLevels;i++){
+ tmpSpinSection = new wxSpinCtrl( panel , -1,_T(""),wxDefaultPosition, wxSize(40,20) );
+ tmpSliderRadio = new wxSlider( panel , -1 ,0,0,100, wxDefaultPosition, wxSize(110,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ tmpSliderAng = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ tmpSpinSection ->SetRange(1,_maxSections);
+
+ tmpwxstring.Printf(_T(" %d. "),i+1);
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,tmpwxstring) , 1, wxGROW );
+ sizerDetailOptions -> Add( tmpSpinSection, 1 );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( tmpSliderRadio, 1, wxGROW );
+ sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizerDetailOptions -> Add( tmpSliderAng, 1, wxGROW );
+
+ tmpSpinSection -> SetValue(5);
+ tmpSliderRadio -> SetValue( 100-(double)((i)*100.0/_maxLevels) );
+ tmpSliderAng -> SetValue(0);
+
+ Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
+ Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
+
+ _lstBullEyeDetailNumOfSec.push_back( tmpSpinSection );
+ _lstBullEyeDetailRadio.push_back( tmpSliderRadio );
+ _lstBullEyeDetailAngle.push_back( tmpSliderAng );
+
+ } //for
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( _radioboxBullEyeGenOpt , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye general options --")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( sizerGeneralOptions , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye detail options --")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
+ sizer -> Add( sizerDetailOptions , 1, wxGROW );
+
+ Connect( _radioboxBullEyeGenOpt->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
+ Connect( _spinctrlBullEyeNumOfCrowns->GetId(), wxEVT_COMMAND_TEXT_UPDATED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
+
+ panel->SetSizer( sizer );
+ panel->SetSize( sizepanel );
+ panel->SetAutoLayout( true );
+ panel->Layout();
+
+ RefreshPanel();
+
+}
+
+//------------------------------------------------------------------------------------------------------------
+PanelBullEyeOptions::~PanelBullEyeOptions()
+{
+}
+
+//------------------------------------------------------------------------------------------------------------
+void PanelBullEyeOptions::onRefreshPanel( wxCommandEvent& event )
+{
+ RefreshPanel();
+}
+
+//------------------------------------------------------------------------------------------------------------
+void PanelBullEyeOptions::RefreshPanel()
+{
+ int i;
+ bool ok;
+ if (this->_radioboxBullEyeGenOpt->GetSelection()==0){
+ for (i=0; i<_maxLevels; i++)
+ {
+ _lstBullEyeDetailNumOfSec[i] -> Enable(false);
+ _lstBullEyeDetailRadio[i] -> Enable(false);
+ _lstBullEyeDetailAngle[i] -> Enable(false);
+ } // for
+ } else {
+ int spinSelec = _spinctrlBullEyeNumOfCrowns->GetValue();
+ for (i=0; i<_maxLevels; i++)
+ {
+ ok = (i < spinSelec);
+ _lstBullEyeDetailNumOfSec[i] -> Enable(ok);
+ _lstBullEyeDetailRadio[i] -> Enable(ok);
+ _lstBullEyeDetailAngle[i] -> Enable(ok);
+
+ if (i>0){
+ if (_lstBullEyeDetailRadio[i]->GetValue() > _lstBullEyeDetailRadio[i-1]->GetValue())
+ {
+ _lstBullEyeDetailRadio[i]->SetValue( _lstBullEyeDetailRadio[i-1]->GetValue() );
+ }
+ }// if i>0
+ } // for
+ } // if
+}
+
+//------------------------------------------------------------------------------------------------------------
+int PanelBullEyeOptions::GetNumberOfCrowns()
+{
+ return this->_spinctrlBullEyeNumOfCrowns->GetValue();
+}
+
+//------------------------------------------------------------------------------------------------------------
+int PanelBullEyeOptions::GetNumberOfSections(int nCrown)
+{
+ int result;
+ if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
+ {
+ result = this->_spinctrlBullEyeNumOfSec->GetValue();
+ } else {
+ result = this->_lstBullEyeDetailNumOfSec[nCrown]->GetValue();
+ }
+ return result;
+}
+
+//------------------------------------------------------------------------------------------------------------
+int PanelBullEyeOptions::GetRadioOfCrown(int nCrown)
+{
+ int result;
+ double sizeCrowns;
+ if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
+ {
+ sizeCrowns = (double)( this->_spinctrlBullEyeNumOfCrowns->GetValue() );
+ result = 100.0 * (nCrown+1)/sizeCrowns ;
+ } else {
+ result = this->_lstBullEyeDetailRadio[nCrown]->GetValue();
+ }
+ return result;
+}
+
+//------------------------------------------------------------------------------------------------------------
+double PanelBullEyeOptions::GetAngOfCrownSection(int nCrown,int section)
+{
+ double angle;
+ if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
+ {
+ angle = this->_sliderBullEyeAngle->GetValue();
+ } else {
+ angle = this->_lstBullEyeDetailAngle[nCrown]->GetValue();
+ }
+ double numOfSec = (double)GetNumberOfSections(nCrown);
+ double deltaSec = GetAngDeltaOfCrownSection(nCrown);
+ return angle + section*deltaSec ;
+}
+
+//------------------------------------------------------------------------------------------------------------
+double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown)
+{
+ double numOfSec = (double)GetNumberOfSections(nCrown);
+ return 360.0/numOfSec;
+}
+
+*/
+
+//------------------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------------------
+
+
+ //------------------------------------------------------------------------------------------------------------
+ // Constructors & Destructors
+ //------------------------------------------------------------------------------------------------------------
+
+ wxContourEventHandler ::wxContourEventHandler()
+ :wxEvtHandler()
+ {
+ _creatingContoursActive = false;
+ _theViewPanel = NULL;
+ _modelManager = NULL;
+ _instantPanel = NULL;
+ _buttonsBar = NULL;
+ _gridPanel = NULL;
+ _drawToolsPanel = NULL;
+ _operationsToolsPanel = NULL;
+ _autoFormsPanel = NULL;
+ _standardToolsPanel = NULL;
+ _editionToolsPanel = NULL;
+ _listViewPanel = NULL;
+ _sceneManager = NULL;
+ _actualInstant = NULL;
+ _performingOperation = new PerformingOperation();
+
+ // EED Interface and Spread
+ _spreadFrame = NULL;
+ _segmentationFrame = NULL;
+ _contourPropagation = NULL;
+ _createContourFrame = NULL;
+ _deleteFrame = NULL;
+ _InformationContourFrame = NULL;
+ _interfaceConfigurationFrame = NULL;
+ _TestFrame = NULL;
+ _wxtextctrlTest = NULL;
+ _panelBullEyeOptions = NULL;
+
+ fileNameContourROI = "";
+ _numberOfVariablesStatistics=6+1;
+
+ inundo = 0;
+ inredo = 0;
+ stundoredo = "data/temp";
+#if(WIN32)
+ mkdir(stundoredo.c_str());
+#else
+ mkdir(stundoredo.c_str(),755);
+#endif
+ stundoredo += "/cont";
+ }
+ //------------------------------------------------------------------------------------------------------------
+ wxContourEventHandler :: ~ wxContourEventHandler()
+ {
+ delete _actualInstant;
+ /*delete _theViewPanel;
+ delete _instantPanel;
+ delete _buttonsBar;
+ delete _actualInstant;
+ */
+ delete _sceneManager;
+ delete _performingOperation;
+
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ // Configuration methods
+ //------------------------------------------------------------------------------------------------------------
+
+ bool wxContourEventHandler :: configureEventsHandling()
+ {
+ bool configured = true;
+
+ return configured;
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ // Methods for capturing events
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onProcessMessage( wxCommandEvent& event )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler :: onActionButtonPressed( wxCommandEvent& event )
+ {
+ const char buttonTool = *(char *)event.GetClientData();
+ executeActionCommand( buttonTool );
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onChangedDeep ( wxCommandEvent& event )
+ {
+ double val = _theViewPanel->getCurrentDeep();
+ _instantPanel->setConceptValue( "Axe Depth", (int)val );
+ _theViewPanel->setActualVertical( (int)val );
+ changeInstant();
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onChangeInstant( wxCommandEvent& event )
+ {
+ ConceptDataWrap * dataConcept = NULL;
+ if ( _theViewPanel->GetId() == event.GetId() )
+ {
+ dataConcept = (ConceptDataWrap *)event.GetClientData();
+ int value = dataConcept->getActualValue();
+ _instantPanel->setConceptValue( dataConcept->getName(), value );
+ }
+ else
+ {
+ dataConcept = _instantPanel->getLastConceptData();
+ if( dataConcept->getName().compare( _theViewPanel->getVerticalConceptName() ) == 0)
+ {
+ _theViewPanel->setActualVertical( dataConcept->getActualValue());
+ //_theViewPanel->setVerticalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
+ }
+ else if( dataConcept->getName().compare( _theViewPanel->getHorizontalConceptName() ) == 0|| _instantPanel->getIfConceptCheckedAt( dataConcept->getName(), 0 ) )
+ {
+ _theViewPanel->setHorizontalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
+ }
+ }
+ changeInstant();
+ }
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler :: onCreateMultipleROI( wxCommandEvent& event )
+ {
+ _creatingContoursActive = !_creatingContoursActive;
+ if( _creatingContoursActive )
+ {
+ createContour();
+ }
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onCreateROI( wxCommandEvent& event )
+ {
+ if( _creatingContoursActive )
+ {
+ createContour();
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onStopCreateROI( wxCommandEvent& event )
+ {
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onDeleterROI( wxCommandEvent& event )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onSelectROI( wxCommandEvent& event )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+
+
+ void wxContourEventHandler :: onUnSelectROI( wxCommandEvent& event )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler :: onManualHidedROI( wxCommandEvent& event )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler :: onManualShowedROI( wxCommandEvent& event )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler :: onEditingROI( wxCommandEvent& event )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler :: onMovingROI( wxCommandEvent& event )
+ {
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ // Model management methods
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler::onSpreadReset( wxCommandEvent& event )
+ {
+ _wxtextctrlSpread->SetValue(wxString("",wxConvUTF8));
+ _contourPropagation->resetAppend();
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onSpreadAdd( wxCommandEvent& event )
+ {
+ std::vector<double> vecX;
+ std::vector<double> vecY;
+ std::vector<double> vecZ;
+ _theViewPanel->getSceneManager()->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
+
+ if (vecX.size()!=0){
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ int i,size=vecZ.size();
+ int actualSlice = tempVector[1];
+ for ( i=0 ; i<size ; i++ )
+ {
+ vecZ[i] = actualSlice;
+ } // for
+
+ _contourPropagation->appendContour(&vecX , &vecY , &vecZ);
+ wxString newstring;
+ //newstring.Printf("%s %d -",_wxtextctrlSpread->GetValue(), actualSlice );
+ newstring.append(wxString(_wxtextctrlSpread->GetValue(),wxConvUTF8));
+ newstring.append(wxString(" ",wxConvUTF8));
+ newstring.append(wxString(intToString(actualSlice).c_str(),wxConvUTF8));
+ _wxtextctrlSpread->SetValue(newstring);
+ } // if
+ }
+
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onSpreadGo( wxCommandEvent& event )
+ {
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ wxBusyCursor wait;
+ int typeMethodFindCtrlPoints=_spreadMethodRadiobox->GetSelection();
+ int typeofcontour = 1;
+ manualContourModel *manModelContour;
+ std::vector<double> vecCtrlPointX;
+ std::vector<double> vecCtrlPointY;
+ std::vector<double> vecCtrlPointZ;
+ double minZ,maxZ;
+ int z,j,sizeCtrPt;
+// double idTmp;
+ int idTmp;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+// tempVector[1];
+
+ _contourPropagation->getMaxMinZ(&minZ,&maxZ);
+//JSTG_16-07-08_----------------------------------------------------------------
+ //_contourPropagation->setInterpolationNumber(maxZ-minZ+1);
+ _contourPropagation->setInterpolationNumber(100);
+ _contourPropagation->CalculeSplinePropagation();
+
+ double totalZ = maxZ-minZ+1;
+ double porcent;
+ wxString tmpString;
+//--------------------------------------------------------------------
+ for ( z=(int)minZ ; z<=(int)maxZ ; z++ )
+ {
+ porcent = 100.0* (z-minZ)/totalZ;
+ int numero = (int)(z-minZ+1)/(int)totalZ;
+ std::string stringtemp = " "+intToString(porcent)+"% "+intToString(numero)+" "+intToString(z);
+ tmpString.Append(wxString(stringtemp.c_str(),wxConvUTF8));
+
+ //tmpString.Printf(" %d %c %d/%d %d", (int)porcent , 37 , (int)(z-minZ+1), (int)totalZ,z );
+ _staticTextSpread->SetLabel(tmpString);
+
+ if (_contourPropagation->ifSliceKeyContourExist(z)==false)
+ {
+ manModelContour = factoryManualContourModel( typeofcontour );
+ idTmp = _contourPropagation->FindIdWithZ(z);
+ if (typeMethodFindCtrlPoints==0) // Initial Points
+ {
+ _contourPropagation->GetInitialControlPoints( idTmp , &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ);
+ }
+ if (typeMethodFindCtrlPoints==1) // Automatique Method
+ {
+ _contourPropagation->GetControlPoints( idTmp ,&vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ);
+ }
+ if (typeMethodFindCtrlPoints==2) // sampling
+ {
+ _contourPropagation->GetControlPoints( idTmp , 20.0 ,&vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ);
+ }
+ //--------------------------------------------------------------------
+ sizeCtrPt = vecCtrlPointX.size();
+ for (j=0 ; j<sizeCtrPt ; j++)
+ {
+ //JSTG_16-07-08_----------------------------------------------------------------
+ manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , -900 );
+ //--------------------------------------------------------------------
+ } // for j
+
+ tempVector[1]=z;
+ std::string theName;
+ theName = _modelManager->createOutline( manModelContour, tempVector );
+ bool addedModel = theName.compare("") != 0;
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ this->_theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc,typeofcontour ) ;
+ } // if addedModel
+ }// ifSliceKeyContourExist
+ } // for z
+ _staticTextSpread->SetLabel(wxString(" ",wxConvUTF8));
+ //RefreshInterface();
+
+
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onSpread( )
+ {
+ if (_spreadFrame==NULL)
+ {
+
+ _spreadFrame = new wxFrame (_theViewPanel, -1,_T(" Spread "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
+
+ wxSize sizepanel(250,400);
+ _spreadFrame->SetSize( sizepanel );
+ _spreadFrame->SetEventHandler( this );
+ wxPanel *panel = getSpreadPanel(_spreadFrame);
+ panel->SetSize(sizepanel);
+ /**new wxPanel(_spreadFrame,-1);
+
+ wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxSize(80,35) );
+ wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxSize(80,35));
+
+ wxString lstOptions[3];
+ lstOptions[0]="A";
+ lstOptions[1]="B";
+ lstOptions[2]="C";
+ _spreadMethodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+ _spreadMethodRadiobox->SetSelection(2);
+
+ wxButton *spreadGoBtn = new wxButton(panel,-1,_T("Go"),wxDefaultPosition, wxSize(80,35));
+ _staticTextSpread = new wxStaticText(panel,-1,_T(" "));
+
+ _wxtextctrlSpread = new wxTextCtrl(panel,-1, "",wxDefaultPosition, wxSize(200,150), wxTE_MULTILINE );
+
+ _spreadFrame->SetEventHandler( this );
+ Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadReset );
+ Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadAdd );
+ Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadGo );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( spreadResetBtn , 1, wxGROW );
+ sizer -> Add( spreadAddBtn , 1, wxGROW );
+ sizer -> Add( _spreadMethodRadiobox , 1, wxGROW );
+ sizer -> Add( spreadGoBtn , 1, wxGROW );
+ sizer -> Add( _staticTextSpread , 1, wxGROW );
+ sizer -> Add( _wxtextctrlSpread , 1, wxGROW );
+
+
+ panel->SetSizer( sizer );
+ panel->SetSize( sizepanel );
+ panel->SetAutoLayout( true );
+ panel->Layout();**/
+ _spreadFrame->Show();
+ } else {
+ if (_spreadFrame->IsShown()==true)
+ {
+ _spreadFrame->Show(false);
+ } else {
+ _spreadFrame->Show(true);
+ }
+ }
+ }
+
+ wxPanel* wxContourEventHandler::getSpreadPanel(wxWindow* parent){
+ //wxPanel *panel = new wxPanel(parent,-1);
+
+ _contourPropagation = new ContourPropagation();
+
+ wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString("",wxConvUTF8));
+
+ wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxDefaultSize );
+ wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxDefaultSize);
+
+ wxString lstOptions[3];
+ lstOptions[0]=_T("A");
+ lstOptions[1]=_T("B");
+ lstOptions[2]=_T("C");
+ _spreadMethodRadiobox = new wxRadioBox(panel, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxDefaultSize, 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+ _spreadMethodRadiobox->SetSelection(2);
+
+ wxButton *spreadGoBtn = new wxButton(panel,-1,_T("Go"),wxDefaultPosition, wxDefaultSize);
+ _staticTextSpread = new wxStaticText(panel,-1,_T(" "));
+
+ _wxtextctrlSpread = new wxTextCtrl(panel,-1, _T(""),wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
+
+
+ Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadReset );
+ Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadAdd );
+ Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadGo );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( spreadResetBtn , 1, wxGROW );
+ sizer -> Add( spreadAddBtn , 1, wxGROW );
+ sizer -> Add( _spreadMethodRadiobox , 1, wxGROW );
+ sizer -> Add( spreadGoBtn , 1, wxGROW );
+ sizer -> Add( _staticTextSpread , 1, wxGROW );
+ sizer -> Add( _wxtextctrlSpread , 1, wxGROW );
+
+
+ panel->SetSizer( sizer );
+ //panel->SetSize( wxDefaultSize );
+ panel->SetAutoLayout( true );
+ panel->Layout();
+ return panel;
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onSegmentationAllSlice( wxCommandEvent& event )
+ {
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ wxBusyCursor wait;
+ int x = this->_theViewPanel->GetX();
+ int y = this->_theViewPanel->GetY();
+ int z,minZ,maxZ;
+ double porcent;
+ wxString tmpString;
+ minZ=_mbarrange->GetStart();
+ maxZ=_mbarrange->GetEnd();
+ double totalZ = maxZ-minZ+1;
+ for( z=minZ ; z<=maxZ ; z++ )
+ {
+ porcent = 100.0* (z-minZ)/totalZ;
+ tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
+ _staticTextSegmentation->SetLabel(tmpString);
+ SegmentationOneSlice( x,y,z );
+ }
+ _staticTextSegmentation->SetLabel(_T(" "));
+ RefreshInterface();
+
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onSegmentationOneSlice( wxCommandEvent& event )
+ {
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ wxBusyCursor wait;
+ int x = this->_theViewPanel->GetX();
+ int y = this->_theViewPanel->GetY();
+ int z = this->_theViewPanel->GetZ();
+ SegmentationOneSlice( x,y,z );
+ RefreshInterface();
+
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::SegmentationOneSlice( int x, int y, int z )
+ {
+ int typeofcontour = 1;
+ //--Extracting Contour
+ vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
+// double *range = imagedata->GetScalarRange();
+// double thr = 1;
+ int isovalue = _isovalue->GetValue();
+ int sampling = _sampling->GetValue();
+
+ vtkImageReslice *imageReslice = vtkImageReslice::New();
+//EED
+// double spc[3];
+// imagedata->GetSpacing(spc);
+// x = x*spc[0];
+// y = y*spc[1];
+// z = z*spc[3];
+
+ imageReslice->SetInput( imagedata );
+ imageReslice->SetInformationInput(imagedata);
+ imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
+ imageReslice->SetResliceAxesOrigin(0,0,z);
+ imageReslice->SetOutputDimensionality(2);
+ imageReslice->SetInterpolationModeToLinear();
+
+ imagedata = imageReslice->GetOutput();
+ imagedata->Update();
+ imagedata->UpdateInformation();
+
+ vtkContourFilter* cntVTK = vtkContourFilter::New( );
+ cntVTK->SetInput( imagedata );
+
+ cntVTK->SetNumberOfContours( 1 );
+ //cntVTK->SetValue( 0, vmin );
+// cntVTK->SetValue( 0, (range[1]*thr/100) );
+ cntVTK->SetValue( 1, isovalue );
+ // cntVTK->SetValue( 1, vmax );
+ cntVTK->Update( );
+ cntVTK->UpdateInformation();
+
+ vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
+ cpd->SetInput( cntVTK->GetOutput( ) );
+ cpd->ConvertLinesToPointsOff( );
+ cpd->Update( );
+ cpd->UpdateInformation();
+
+ vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
+ conn->SetExtractionModeToClosestPointRegion( );
+ //conn->SetMaxRecursionDepth( 3000 );
+
+ conn->SetInput( cpd->GetOutput( ) );
+
+ conn->SetClosestPoint( x, y, 0 );
+ conn->Update( );
+ conn->UpdateInformation();
+
+ vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
+ cpd2->SetInput( conn->GetOutput( ) );
+ cpd2->Update();
+ cpd2->UpdateInformation();
+
+ vtkStripper* vtkstripper = vtkStripper::New( );
+ vtkstripper->SetInput( cpd2->GetOutput() );
+ vtkstripper->Update();
+ vtkstripper->UpdateInformation();
+
+
+ vtkPolyData* polyDataResult = vtkstripper->GetOutput();
+
+ polyDataResult->Update( );
+ polyDataResult->UpdateInformation();
+
+/* EED
+ofstream myfile;
+myfile.open ("c:/temp/example.txt");
+myfile << "\n";
+polyDataResult->Print(myfile);
+myfile << "-------------------------------------\n";
+polyDataResult->GetLines()->Print(myfile);
+myfile.close();
+*/
+
+ cntVTK -> Delete();
+ cpd2 -> Delete();
+ cpd -> Delete();
+ conn -> Delete();
+
+
+//--Calculating control points
+
+ std::vector<double> vecX;
+ std::vector<double> vecY;
+ std::vector<double> vecZ;
+
+ std::vector<double> vecCtrlPointX;
+ std::vector<double> vecCtrlPointY;
+ std::vector<double> vecCtrlPointZ;
+
+
+ double *p;
+ int ii,size=polyDataResult->GetNumberOfPoints();
+ int id;
+ for (ii=1;ii<=size;ii++)
+ {
+ id = polyDataResult->GetLines()->GetData()->GetValue(ii);
+ p = polyDataResult->GetPoint(id);
+ double x=p[0];
+ double y=p[1];
+ vecX.push_back( p[0] );
+ vecY.push_back( p[1] );
+ vecZ.push_back( -900 );
+// vecZ.push_back( p[2] );
+ }
+
+
+ ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
+ extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
+
+//PROOFS
+ if (methodRadiobox->GetSelection()==0){
+ extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+ }
+ if (methodRadiobox->GetSelection()==1){
+ extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+ }
+ if (methodRadiobox->GetSelection()==2){
+ extractcontrolpoints2d->SetSamplingControlPoints( sampling );
+ extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+ }
+
+ //--Adding contour to the system
+
+ std::vector<int> actualInstantVector;
+ _instantPanel->getInstant( actualInstantVector );
+ actualInstantVector[1]=z;
+
+ int j,sizeCtrPt = vecCtrlPointX.size();
+ manualContourModel *manModelContour = factoryManualContourModel( typeofcontour );
+ manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
+ if (sizeCtrPt>=3){
+ for (j=0 ; j<sizeCtrPt ; j++)
+ {
+ manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
+ } // for
+ std::string theName;
+ theName = _modelManager->createOutline( manModelContour, actualInstantVector );
+ bool addedModel = theName.compare("") != 0;
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ this->_theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
+ } // if addedModel
+ } // if sizeCtrPt
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onAutomatiqueSegmentation( )
+ {
+ if (_segmentationFrame==NULL)
+ {
+ //JCP 13-10-09
+ /*int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ double range[2];
+ _theViewPanel->getSceneManager()->GetImageDataRange(range);*/
+ //JCP 13-10-09
+
+ wxSize sizePanel( 300, 470);
+ _segmentationFrame = new wxFrame (_theViewPanel, -1,_T(" Segmentation "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
+ _segmentationFrame->SetSize( sizePanel );
+ wxPanel *panel = getSegmentationPanel(_segmentationFrame);
+ /*new wxPanel(_segmentationFrame,-1);
+ wxButton *segmentationOneSliceBtn = new wxButton(panel,-1,_T("Actual slice"), wxDefaultPosition, wxSize(200,35) );
+ wxButton *segmentationAllSliceBtn = new wxButton(panel,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
+ _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ wxString lstOptions[3];
+ lstOptions[0]="A";
+ lstOptions[1]="B";
+ lstOptions[2]="C";
+ methodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+ methodRadiobox->SetSelection(2);
+ _staticTextSegmentation = new wxStaticText(panel,-1,_T(" "));
+
+
+ _mbarrange = new mBarRange(panel,70, 65);
+ _mbarrange->SetMin(0);
+ _mbarrange->SetStart(0);
+
+ _mbarrange-> SetOrientation( true );
+ _mbarrange-> setActiveStateTo(true);
+ _mbarrange-> setVisibleLabels( true );
+ _mbarrange-> setDeviceEndMargin(10);
+ _mbarrange-> setRepresentedValues( 0 , sizeZ );
+ _mbarrange-> setDeviceBlitStart(10,10);
+ _mbarrange-> setIfWithActualDrawed( false );
+ _mbarrange-> SetStart( 0 );
+ _mbarrange-> SetEnd( sizeZ );
+
+
+// _segmentationFrame->SetEventHandler( this );
+ segmentationOneSliceBtn->SetEventHandler( this );
+ segmentationAllSliceBtn->SetEventHandler( this );
+ Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationOneSlice );
+ Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationAllSlice );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(panel,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
+ sizer -> Add( _isovalue , 1, wxGROW );
+ sizer -> Add( methodRadiobox , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("Sampling (%)")) , 1, wxGROW );
+ sizer -> Add( _sampling , 1, wxGROW );
+ sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( _staticTextSegmentation , 1, wxGROW );
+ sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
+ sizer -> Add( _mbarrange , 1, wxGROW );
+
+ panel->SetSizer( sizer );
+ panel->SetSize( sizePanel );
+ panel->SetAutoLayout( true );
+ panel->Layout();*/
+
+ this->_theViewPanel->SetVisibleAxis(true);
+ this->_theViewPanel->Refresh();
+ _segmentationFrame->Show(true);
+//JCP 13-10-09 View the method getSegmentationPanel(), this two methods where moved to getSegmentationPanel
+ //this->_theViewPanel->SetVisibleAxis(true);
+ //this->_theViewPanel->Refresh();
+ } else {
+ if (_segmentationFrame->IsShown()==true)
+ {
+ _segmentationFrame->Show(false);
+ this->_theViewPanel->SetVisibleAxis(false);
+ this->_theViewPanel->Refresh();
+ } else {
+ _segmentationFrame->Show(true);
+ this->_theViewPanel->SetVisibleAxis(true);
+ this->_theViewPanel->Refresh();
+ }
+ }
+ }
+
+ void wxContourEventHandler::showAxis(bool show){
+ this->_theViewPanel->SetVisibleAxis(show);
+ this->_theViewPanel->Refresh();
+ }
+ wxPanel* wxContourEventHandler::getSegmentationPanel(wxWindow* parent){
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ double range[2];
+ _theViewPanel->getSceneManager()->GetImageDataRange(range);
+
+ wxPanel *panel = new wxPanel(parent,-1);
+ wxButton *segmentationOneSliceBtn = new wxButton(panel,-1,_T("Actual slice"), wxDefaultPosition, wxSize(200,35) );
+ wxButton *segmentationAllSliceBtn = new wxButton(panel,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
+ _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ wxString lstOptions[3];
+ lstOptions[0]=_T("A");
+ lstOptions[1]=_T("B");
+ lstOptions[2]=_T("C");
+ methodRadiobox = new wxRadioBox(panel, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+ methodRadiobox->SetSelection(2);
+ _staticTextSegmentation = new wxStaticText(panel,-1,_T(" "));
+
+
+ _mbarrange = new mBarRange(panel,70, 65);
+ _mbarrange->SetMin(0);
+ _mbarrange->SetStart(0);
+
+ _mbarrange-> SetOrientation( true );
+ _mbarrange-> setActiveStateTo(true);
+ _mbarrange-> setVisibleLabels( true );
+ _mbarrange-> setDeviceEndMargin(10);
+ _mbarrange-> setRepresentedValues( 0 , sizeZ );
+ _mbarrange-> setDeviceBlitStart(10,10);
+ _mbarrange-> setIfWithActualDrawed( false );
+ _mbarrange-> SetStart( 0 );
+ _mbarrange-> SetEnd( sizeZ );
+
+
+// _segmentationFrame->SetEventHandler( this );
+ segmentationOneSliceBtn->SetEventHandler( this );
+ segmentationAllSliceBtn->SetEventHandler( this );
+ Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationOneSlice );
+ Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationAllSlice );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(panel,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
+ sizer -> Add( _isovalue , 1, wxGROW );
+ sizer -> Add( methodRadiobox , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("Sampling (%)")) , 1, wxGROW );
+ sizer -> Add( _sampling , 1, wxGROW );
+ sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( _staticTextSegmentation , 1, wxGROW );
+ sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
+ sizer -> Add( _mbarrange , 1, wxGROW );
+
+ panel->SetSizer( sizer );
+// panel->SetSize( sizePanel );
+ panel->SetSize( wxDefaultSize );
+ panel->SetAutoLayout( true );
+ panel->Layout();
+
+ return panel;
+ }
+ void wxContourEventHandler :: onInterfaceTestFrame( )
+ {
+ if (_TestFrame==NULL)
+ {
+ _contourPropagation = new ContourPropagation();
+ _TestFrame = new wxFrame (_theViewPanel, -1,_T(" Test Segmentation "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
+ wxSize sizepanel(200,300);
+ _TestFrame->SetSize( sizepanel );
+ wxPanel *panel = new wxPanel(_TestFrame,-1);
+ wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxSize(80,35) );
+ wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxSize(80,35));
+ wxButton *spreadGoBtn = new wxButton(panel,-1,_T("GoA"),wxDefaultPosition, wxSize(80,35));
+ _wxtextctrlTest = new wxTextCtrl(panel,-1, _T(""),wxDefaultPosition, wxSize(200,150), wxTE_MULTILINE );
+
+ _TestFrame->SetEventHandler( this );
+ Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestReset );
+ Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestAdd );
+ Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestGo );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( spreadResetBtn , 1, wxGROW );
+ sizer -> Add( spreadAddBtn , 1, wxGROW );
+ sizer -> Add( spreadGoBtn , 1, wxGROW );
+ sizer -> Add( _wxtextctrlTest , 1, wxGROW );
+
+ panel->SetSizer( sizer );
+ panel->SetSize( sizepanel );
+ panel->SetAutoLayout( true );
+ panel->Layout();
+ _TestFrame->Show();
+ } else {
+ if (_TestFrame->IsShown()==true)
+ {
+ _TestFrame->Show(false);
+ } else {
+ _TestFrame->Show(true);
+ }
+ }
+ }
+
+ void wxContourEventHandler::onTestReset( wxCommandEvent& event )
+ {
+ _wxtextctrlTest->SetValue(_T(""));
+ _contourPropagation->resetAppend();
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onTestAdd( wxCommandEvent& event )
+ {
+ std::vector<double> vecX;
+ std::vector<double> vecY;
+ std::vector<double> vecZ;
+ _theViewPanel->getSceneManager()->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
+
+ if (vecX.size()!=0){
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ int i,size=vecZ.size();
+ int actualSlice = tempVector[1];
+ for ( i=0 ; i<size ; i++ )
+ {
+ vecZ[i] = actualSlice;
+ } // for
+
+ _contourPropagation->appendContour(&vecX , &vecY , &vecZ);
+ wxString newstring;
+ newstring.append(_wxtextctrlTest->GetValue());
+ newstring.append(_T(" "));
+ newstring.append(wxString(intToString(actualSlice).c_str(),wxConvUTF8));
+ //newstring.Printf(_T("%s %d -"),, );
+ newstring.append(_T(" -"));
+ _wxtextctrlTest->SetValue(newstring);
+ } // if
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onTestGo( wxCommandEvent& event )
+ {
+ std::vector<double> vecX;
+ std::vector<double> vecY;
+ std::vector<double> vecZ;
+ std::vector<int> size;
+
+ std::vector<double> vecCtrlPointX;
+ std::vector<double> vecCtrlPointY;
+ std::vector<double> vecCtrlPointZ;
+
+ //Getting the points of the actual contour
+
+ _contourPropagation->GetKeyContours(&vecX , &vecY , &vecZ, &size);
+ for(int i = 0; i < vecX.size();i++){
+ vecZ[i] = -900;
+ }
+
+ /*std::vector<double> vecX1;
+ std::vector<double> vecY1;
+ std::vector<double> vecZ1;
+ _theViewPanel->getSceneManager()->GetPointsOfActualContour( &vecX1 , &vecY1 , &vecZ1 );
+
+ std::ofstream file1;
+ file1.open( "Temp.txt" );
+ if(file1.is_open())
+ {
+ for(int i = 0; i < vecX.size(); i++){
+ file1<<vecX[i] <<" X1 "<< vecX1[i] <<" Y "<<vecY[i] <<" Y1 "<< vecY1[i] <<" Z "<<vecZ[i] <<" Z1 "<< vecZ1[i]<<std::endl;
+
+ }
+ file1.close();
+ }*/
+
+
+
+ //Setting the points of the contour
+
+ ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
+ extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
+
+ //Getting the control points of the contour by method A
+
+ extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+
+ std::vector<int> actualInstantVector;
+ _instantPanel->getInstant( actualInstantVector );
+ actualInstantVector[1]= this->_theViewPanel->GetZ();
+
+
+
+
+
+ //Adding the Contour to the scene
+
+ manualContourModel *manModelContour = new manualContourModel();
+ int j,sizeCtrPt = vecCtrlPointX.size();
+ if (sizeCtrPt>=3){
+ for (j=0 ; j<sizeCtrPt ; j++)
+ {
+ manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
+ } // for
+ std::string theName;
+ theName = _modelManager->createOutline( manModelContour, actualInstantVector );
+ bool addedModel = theName.compare("") != 0;
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ this->_theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc,1 ) ;
+ } // if addedModel
+ } // if sizeCtrPt
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::FillGridWithContoursInformation()
+ {
+ wxString tempString;
+ _grid->ClearGrid();
+ _grid->SetColLabelValue(0, _T("A") );
+ _grid->SetColLabelValue(1, _T("B") );
+ _grid->SetColLabelValue(2, _T("C") );
+ _grid->SetColLabelValue(3, _T("D") );
+ _grid->SetColLabelValue(4, _T("E") );
+ _grid->SetColLabelValue(5, _T("F") );
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ int z,sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ int ii,sizeLstContourThings;
+ for ( z=0 ; z<sizeZ ; z++)
+ {
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
+
+ sizeLstContourThings = lstContourThings.size();
+ tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
+ _grid->SetRowLabelValue(z, tempString );
+
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ tempString = wxString((*contourthing)->getName().c_str(),wxConvUTF8) ;
+ _grid->SetCellValue( z, ii, tempString );
+ }
+ }
+
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ std::vector<manualContourModel*> wxContourEventHandler::ExploseEachModel( std::vector<manualContourModel*> lstManConMod )
+ {
+ std::vector<manualContourModel*> lstTmp;
+ std::vector<manualContourModel*> lstResult;
+ int j,jSize;
+ int i,iSize=lstManConMod.size();
+ for (i=0;i<iSize;i++)
+ {
+ lstTmp = lstManConMod[i]->ExploseModel();
+ jSize=lstTmp.size();
+ for (j=0;j<jSize;j++)
+ {
+ lstResult.push_back( lstTmp[j] );
+ }
+ }
+ return lstResult;
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onExtractInformation( wxCommandEvent& event )
+ {
+ wxBusyCursor wait;
+ int maxContourGroup = 0;
+
+ _grid->ClearGrid();
+
+ ContourExtractData *contourextractdata = new ContourExtractData();
+ int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
+ contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
+
+ std::vector<manualContourModel*> lstManConMod;
+ std::vector<manualContourModel*> lstManConModTmp;
+ std::vector<manualContourModel*> lstManConModExp;
+ std::vector<double> pLstValue;
+ std::vector<double> pLstValuePosX;
+ std::vector<double> pLstValuePosY;
+ std::vector<double> pLstValuePosZ;
+
+ int resultSize;
+ int resultGrayRangeCount;
+ double resultMin;
+ double resultMax;
+ double resultAverage;
+ double resultStandardeviation;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ int z;
+ int ii,sizeLstContourThings;
+
+
+ int minZ,maxZ;
+ double totalZ;
+ double porcent;
+ wxString tmpString;
+
+
+ if (_informationRadiobox->GetSelection()==0 ) // actual slice
+ {
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ int actualSlice = tempVector[1];
+ minZ = actualSlice;
+ maxZ = actualSlice;
+ }
+ if (_informationRadiobox->GetSelection()==1 ) // slice range
+ {
+ minZ = _mbarrangeSliceInformation->GetStart();
+ maxZ = _mbarrangeSliceInformation->GetEnd();
+ }
+ if (_informationRadiobox->GetSelection()==2 ) // All slices
+ {
+ minZ = 0;
+ maxZ = sizeZ-1;
+ }
+
+ totalZ = maxZ-minZ+1;
+ contourextractdata->SetImage( imagedata);
+
+ // For each slice..
+ for ( z=minZ ; z<=maxZ ; z++ )
+ {
+ porcent = 100.0* (z-minZ)/totalZ;
+ tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
+ _staticTextInformation->SetLabel(tmpString);
+
+ //Extraction data from contours of each slice
+ contourextractdata->SetZtoBeAnalys( z);
+
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
+ sizeLstContourThings = lstContourThings.size();
+
+ lstManConMod.clear();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ lstManConMod.push_back( (*contourthing)->getModel() );
+ }
+ lstManConModExp = ExploseEachModel( lstManConMod );
+
+
+ wxString tempString;
+ tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
+ _grid->SetRowLabelValue(z, tempString );
+//EED004
+ int iContourGroup,sizeContourGroup;
+ if (typeContourGroup==3) // contour separete
+ {
+ sizeContourGroup=lstManConModExp.size();
+ if ( maxContourGroup<sizeContourGroup )
+ {
+ maxContourGroup=sizeContourGroup;
+ }
+ } else { // contour AND OR XOR
+ sizeContourGroup=1;
+ maxContourGroup=1;
+ }
+
+ int tmpIntA;
+
+
+
+ for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
+ lstManConModTmp.clear();
+ if (typeContourGroup==3) // contour separete
+ {
+ lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
+ } else { // contour AND OR XOR
+ lstManConModTmp = lstManConModExp;
+ }
+
+ contourextractdata->SetLstManualContourModel( lstManConModTmp );
+
+ pLstValue.clear();
+ pLstValuePosX.clear();
+ pLstValuePosY.clear();
+ pLstValuePosZ.clear();
+ contourextractdata->GetValuesInsideCrown( &pLstValue,
+ &pLstValuePosX,
+ &pLstValuePosY,
+ &pLstValuePosZ);
+ // Statistics of each slice.
+ contourextractdata->Statistics( &pLstValue,
+ _mbarrangeRangeInformation->GetStart(),
+ _mbarrangeRangeInformation->GetEnd(),
+ &resultGrayRangeCount,
+ &resultSize,
+ &resultMin,
+ &resultMax,
+ &resultAverage,
+ &resultStandardeviation);
+ if (_grid->GetNumberCols()<_numberOfVariablesStatistics*(iContourGroup+1) )
+ {
+ _grid->AppendCols(_numberOfVariablesStatistics);
+ }
+
+ tmpIntA=_numberOfVariablesStatistics*iContourGroup ;
+
+ tempString.Printf(_T("%d"),resultSize);
+ _grid->SetCellValue( z, tmpIntA + 0, tempString );
+ tempString.Printf(_T("%d"),resultGrayRangeCount);
+ _grid->SetCellValue( z, tmpIntA + 1, tempString );
+ tempString.Printf(_T("%f"),resultMin);
+ _grid->SetCellValue( z, tmpIntA + 2, tempString );
+ tempString.Printf(_T("%f"),resultMax);
+ _grid->SetCellValue( z, tmpIntA + 3, tempString );
+ tempString.Printf(_T("%f"),resultAverage);
+ _grid->SetCellValue( z, tmpIntA + 4, tempString );
+ tempString.Printf(_T("%f"),resultStandardeviation);
+ _grid->SetCellValue( z, tmpIntA + 5, tempString );
+
+ } // for iContourGroup
+ } // for z
+
+ int iTitleGroup;
+ wxString tmpTitleString;
+ int tmpIntB;
+ for ( iTitleGroup=0 ; iTitleGroup<maxContourGroup ; iTitleGroup++ )
+ {
+ tmpIntB =_numberOfVariablesStatistics*iTitleGroup;
+ tmpTitleString.Printf(_T("%d-Size Data"),iTitleGroup);
+ _grid->SetColLabelValue( tmpIntB + 0, tmpTitleString );
+ _grid->SetColLabelValue( tmpIntB + 1, _T("Size Range") );
+ _grid->SetColLabelValue( tmpIntB + 2, _T("Min") );
+ _grid->SetColLabelValue( tmpIntB + 3, _T("Max") );
+ _grid->SetColLabelValue( tmpIntB + 4, _T("Average") );
+ _grid->SetColLabelValue( tmpIntB + 5, _T("St.Dev.") );
+ _grid->SetColLabelValue( tmpIntB + 6, _T(" ") );
+ }
+
+ _staticTextInformation->SetLabel( _T("") );
+ delete contourextractdata;
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::SaveValuesXYZ(std::string directory,std::string namefile)
+ {
+ wxBusyCursor wait;
+ ContourExtractData *contourextractdata = new ContourExtractData();
+ int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
+ contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
+
+ std::vector<manualContourModel*> lstManConMod;
+ std::vector<manualContourModel*> lstManConModTmp;
+ std::vector<manualContourModel*> lstManConModExp;
+ std::vector<double> pLstValue;
+ std::vector<double> pLstValuePosX;
+ std::vector<double> pLstValuePosY;
+ std::vector<double> pLstValuePosZ;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ int z;
+ int ii,sizeLstContourThings;
+
+
+ int minZ,maxZ;
+ double totalZ;
+ double porcent;
+ wxString tmpString;
+ minZ = 0;// _mbarrange->GetStart();
+ maxZ = sizeZ;//_mbarrange->GetEnd();
+ totalZ = maxZ-minZ+1;
+
+ contourextractdata->SetImage( imagedata);
+
+ // For each slice..
+ for ( z=0 ; z<sizeZ ; z++)
+ {
+
+ porcent = 100.0* (z-minZ)/totalZ;
+
+ tmpString.Printf(_T("Saving Values"));
+ tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
+ _staticTextInformation->SetLabel(tmpString);
+
+
+ //Extraction data from contours of each slice
+ contourextractdata->SetZtoBeAnalys( z);
+
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
+ sizeLstContourThings = lstContourThings.size();
+
+ lstManConMod.clear();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ lstManConMod.push_back( (*contourthing)->getModel() );
+ }
+ lstManConModExp = ExploseEachModel( lstManConMod );
+
+
+//EED004
+
+ int iContourGroup,sizeContourGroup;
+ if (typeContourGroup==3) // contour separete
+ {
+ sizeContourGroup=lstManConModExp.size();
+ } else { // contour AND OR XOR
+ sizeContourGroup=1;
+ }
+
+ for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
+ lstManConModTmp.clear();
+ if (typeContourGroup==3) // contour separete
+ {
+ lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
+ } else { // contour AND OR XOR
+ lstManConModTmp = lstManConModExp;
+ }
+
+ contourextractdata->SetLstManualContourModel( lstManConModTmp );
+
+ pLstValue.clear();
+ pLstValuePosX.clear();
+ pLstValuePosY.clear();
+ pLstValuePosZ.clear();
+ contourextractdata->GetValuesInsideCrown( &pLstValue,
+ &pLstValuePosX,
+ &pLstValuePosY,
+ &pLstValuePosZ);
+
+ wxString filename;
+ filename.Printf(_T("%s"),directory.c_str());
+ filename.Printf(_T("\\"));
+ filename.Printf(_T("%s"),namefile.c_str());
+ filename.Printf(_T("-slice"));
+ filename.Printf(_T("%d"),z);
+ filename.Printf(_T("-cont"));
+ filename.Printf(_T("%d"),iContourGroup);
+ filename.Printf(_T(".txt"));
+ FILE *pFile=fopen((const char *)filename.mb_str(),"w+");
+ fprintf(pFile,"value \t x \t y \t z\n" );
+ int iLstValue,sizeLstValue=pLstValue.size();
+ for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
+ {
+ fprintf(pFile,"%f\t %f\t %f\t %f\n", (float)pLstValue[iLstValue] , (float)pLstValuePosX[iLstValue], (float)pLstValuePosY[iLstValue], (float)z );
+ }
+ fclose(pFile);
+ } // for iContourGroup
+ } // for z
+ _staticTextInformation->SetLabel( _T("") );
+ delete contourextractdata;
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::SaveImageResult(std::string directory,std::string namefile)
+ {
+ wxBusyCursor wait;
+ ContourExtractData *contourextractdata = new ContourExtractData( true );
+ int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
+ if (typeContourGroup==3)
+ {
+ typeContourGroup=1;
+ }
+ contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
+
+ std::vector<manualContourModel*> lstManConMod;
+ std::vector<manualContourModel*> lstManConModTmp;
+ std::vector<manualContourModel*> lstManConModExp;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ int z;
+ int ii,sizeLstContourThings;
+
+
+ int minZ,maxZ;
+ double totalZ;
+ double porcent;
+
+ wxString tmpString;
+
+ minZ = 0;// _mbarrange->GetStart();
+ maxZ = sizeZ;//_mbarrange->GetEnd();
+ totalZ = maxZ-minZ+1;
+
+ contourextractdata->SetImage( imagedata);
+
+ // For each slice..
+ for ( z=0 ; z<sizeZ ; z++)
+ {
+
+ porcent = 100.0* (z-minZ)/totalZ;
+ tmpString.Printf(_T("Saving Values"));
+ tmpString.Printf(_T("%d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
+ _staticTextInformation->SetLabel(tmpString);
+
+ //Extraction data from contours of each slice
+ contourextractdata->SetZtoBeAnalys( z);
+
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
+ sizeLstContourThings = lstContourThings.size();
+
+ lstManConMod.clear();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ lstManConMod.push_back( (*contourthing)->getModel() );
+ }
+ lstManConModExp = ExploseEachModel( lstManConMod );
+
+
+ int iContourGroup,sizeContourGroup;
+ if (typeContourGroup==3) // contour separete
+ {
+ sizeContourGroup=lstManConModExp.size();
+ } else { // contour AND OR XOR
+ sizeContourGroup=1;
+ }
+
+ for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
+ lstManConModTmp.clear();
+ if (typeContourGroup==3) // contour separete
+ {
+ lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
+ } else { // contour AND OR XOR
+ lstManConModTmp = lstManConModExp;
+ }
+
+ contourextractdata->SetLstManualContourModel( lstManConModTmp );
+
+
+// for (ii=0 ; ii<sizeLstContourThings ; ii++)
+// {
+// ContourThing **contourthing = lstContourThings[ii];
+// lstManConMod.push_back( (*contourthing)->getModel() );
+// }
+// contourextractdata->SetLstManualContourModel( lstManConMod );
+
+ contourextractdata->CalculateImageResult(); // with actual Z
+
+ } // for iContourGroup
+ } // for z
+
+
+ wxString filename;
+ //filename.Printf(_T("%s\\%s-Value.mhd",directory.c_str(),namefile.c_str(),z);
+ filename.Printf(_T("%s"),directory.c_str());
+ filename.Printf(_T("\\"));
+ filename.Printf(_T("%s"),namefile.c_str());
+ filename.Printf(_T("-Value.mhd"));
+
+// Image Value
+ vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
+ writerValueImage->SetInput( contourextractdata->GetVtkImageValueResult() );
+ writerValueImage->SetFileName( (const char *)filename.mb_str() );
+ writerValueImage->SetFileDimensionality( 3 );
+ writerValueImage->Write( );
+
+// Image Mask
+ // filename.Printf("%s\\%s-Mask.mhd",directory.c_str(),namefile.c_str(),z);
+ filename.Printf(_T("%s"),directory.c_str());
+ filename.Printf(_T("\\"));
+ filename.Printf(_T("%s"),namefile.c_str());
+ filename.Printf(_T("-Mask.mhd"));
+ vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
+ writerMaskImage->SetInput( contourextractdata->GetVtkImageMaskResult() );
+ writerMaskImage->SetFileName( (const char *)filename.mb_str() );
+ writerMaskImage->SetFileDimensionality( 3 );
+ writerMaskImage->Write( );
+
+ _staticTextInformation->SetLabel( _T("") );
+ delete contourextractdata;
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onInformationContourLabels( wxCommandEvent& event )
+ {
+ wxBusyCursor wait;
+ FillGridWithContoursInformation();
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onSaveResults( wxCommandEvent& event )
+ {
+ wxFileDialog dialog(_InformationContourFrame, _T("Choose a file"), _T(""), _T(""), _T("*.txt"), wxSAVE );
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ onExtractInformation( event );
+ std::string directory=(const char *)(dialog.GetDirectory().mb_str());
+ std::string namefile=(const char *)(dialog.GetFilename().mb_str());
+
+ SaveValuesXYZ( directory , namefile );
+ SaveImageResult( directory , namefile );
+
+ std::string filename = (const char *)(dialog.GetPath().mb_str() );
+ FILE *pFile=fopen(filename.c_str(),"w+");
+
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+
+ wxString tmpString;
+ int i,j,maxX,maxY=sizeZ;
+ maxX=this->_grid->GetNumberCols();
+
+ int iTitle,sizeTitle = (maxX / _numberOfVariablesStatistics);
+ for ( iTitle=0; iTitle<sizeTitle ; iTitle++)
+ {
+ fprintf(pFile,"-- \t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle,tmpString.c_str() );
+ }
+ fprintf(pFile,"\n" );
+
+
+
+ for ( j=0; j<maxY ; j++)
+ {
+ fprintf(pFile,"%d\t" , j );
+ for (i=0 ; i<maxX ; i++){
+ tmpString = _grid->GetCellValue( j , i );
+ fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
+ } // for i
+ fprintf(pFile,"\n" );
+ } // for j
+
+ fclose(pFile);
+ } // if ShowModal
+
+
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onInformationContourFrame()
+ {
+ if (_InformationContourFrame==NULL)
+ {
+ _InformationContourFrame = new wxFrame (_theViewPanel, -1,_T(" Information "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
+ _InformationContourFrame->SetSize( wxSize(500,450) );
+ wxSize sizepanel(200,300);
+ wxPanel *panel = getInformationPanel(_InformationContourFrame);
+//JCP 13-10-09 Grouping the panel in a method
+ /*new wxPanel(_InformationContourFrame,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
+
+ wxString lstOptions[4];
+ lstOptions[0]=_T("Actual Slice");
+ lstOptions[1]=_T("Range Slices");
+ lstOptions[2]=_T("All Slices");
+ _informationRadiobox = new wxRadioBox(panel, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+
+ wxString lstOptContOperation[5];
+ lstOptContOperation[0]=_T("AND");
+ lstOptContOperation[1]=_T("OR");
+ lstOptContOperation[2]=_T("XOR");
+ lstOptContOperation[3]=_T("ALL");
+ _radiolstboxContourGroup = new wxRadioBox(panel, -1, _T("Contour group"), wxDefaultPosition, wxSize(270,45), 4 , lstOptContOperation, 4, wxRA_SPECIFY_COLS);
+
+ wxButton *informationContourLabelsBtn = new wxButton(panel,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
+ informationContourLabelsBtn->SetEventHandler( this );
+ Connect( informationContourLabelsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onInformationContourLabels );
+
+ wxButton *statisticsContourBtn = new wxButton(panel,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
+ statisticsContourBtn->SetEventHandler( this );
+ Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onExtractInformation );
+
+ wxButton *saveResultsBtn = new wxButton(panel,-1,_T("Save statistics results"),wxDefaultPosition, wxSize(140,35) );
+ saveResultsBtn->SetEventHandler( this );
+ Connect( saveResultsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSaveResults );
+
+
+ int sizeZ = this->_theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ _mbarrangeSliceInformation = new mBarRange(panel,65,65);
+ _mbarrangeSliceInformation->SetMin(0);
+ _mbarrangeSliceInformation->SetStart(0);
+ _mbarrangeSliceInformation-> SetOrientation( true );
+ _mbarrangeSliceInformation-> setActiveStateTo(true);
+ _mbarrangeSliceInformation-> setVisibleLabels( true );
+ _mbarrangeSliceInformation-> setDeviceEndMargin(10);
+ _mbarrangeSliceInformation-> setRepresentedValues( 0 , sizeZ-1 );
+ _mbarrangeSliceInformation-> setDeviceBlitStart(10,10);
+ _mbarrangeSliceInformation-> setIfWithActualDrawed( false );
+ _mbarrangeSliceInformation-> SetStart( 0 );
+ _mbarrangeSliceInformation-> SetEnd( sizeZ-1 );
+
+
+ double range[2];
+ this->_theViewPanel->getSceneManager()->GetImageDataRange(range);
+ _mbarrangeRangeInformation = new mBarRange(panel,65,65);
+ _mbarrangeRangeInformation->SetMin(0);
+ _mbarrangeRangeInformation->SetStart(0);
+ _mbarrangeRangeInformation-> SetOrientation( true );
+ _mbarrangeRangeInformation-> setActiveStateTo(true);
+ _mbarrangeRangeInformation-> setVisibleLabels( true );
+ _mbarrangeRangeInformation-> setDeviceEndMargin(10);
+ _mbarrangeRangeInformation-> setRepresentedValues( range[0] , range[1] );
+ _mbarrangeRangeInformation-> setDeviceBlitStart(10,10);
+ _mbarrangeRangeInformation-> setIfWithActualDrawed( false );
+ _mbarrangeRangeInformation-> SetStart( range[0] );
+ _mbarrangeRangeInformation-> SetEnd( range[1] );
+
+
+ _staticTextInformation = new wxStaticText(panel,-1,_T(" "));
+
+
+// wxButton *XXXXXXXBtn = new wxButton(panel,-1,_T("Statistics"),wxDefaultPosition, wxSize(180,35) );
+// XXXXXXXBtn->SetEventHandler( this );
+// Connect( XXXXXXXBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onXXXXX );
+
+
+ _grid = new wxGrid( panel,
+ wxID_ANY,
+ wxPoint( 0, 0 ),
+ wxSize( 100, 100 ) );
+
+ int i,gridCol=10,gridRow=sizeZ;
+ _grid->CreateGrid( 0, 0 );
+ _grid->AppendRows(gridRow);
+ _grid->AppendCols(gridCol);
+
+ for (i=0;i<gridRow;i++)
+ {
+ _grid->SetRowLabelValue(i, _T(" ") );
+ }
+// _grid->SetColLabelSize(0);
+
+
+ FillGridWithContoursInformation();
+
+ wxFlexGridSizer * sizerA = new wxFlexGridSizer(10);
+ sizerA->Add( _informationRadiobox , 1, wxALL ,2 );
+ sizerA->Add( _radiolstboxContourGroup , 1, wxALL ,2 );
+
+ wxFlexGridSizer * sizerB = new wxFlexGridSizer(10);
+ sizerB->Add( informationContourLabelsBtn , 1, wxALL ,2 );
+ sizerB->Add( statisticsContourBtn , 1, wxALL ,2 );
+ sizerB->Add( saveResultsBtn , 1, wxALL ,2 );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer->AddGrowableCol(0);
+ sizer->AddGrowableRow(7);
+ sizer->Add( sizerA , 1, wxALL , 0 );
+ sizer->Add( new wxStaticText(panel ,-1,_T("Slice Range")) , 1, wxALL , 0 );
+ sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW , 2 );
+ sizer->Add( new wxStaticText(panel ,-1,_T("Gray Range")) , 1, wxALL , 0 );
+ sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW , 2 );
+ sizer->Add( sizerB , 1, wxALL , 0 );
+ sizer->Add( _staticTextInformation , 1, wxALL , 0 );
+ sizer->Add( _grid , 1, wxEXPAND , 0 );
+
+
+
+ panel->SetSizer( sizer );
+ panel->SetSize( wxSize(1500,1500) );
+ //panel->SetBackgroundColour( wxColour(100,100,100) );
+ panel->SetAutoLayout( true );
+ panel->Layout();*/
+
+ wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
+
+// sizerPanel->AddGrowableCol(0);
+// sizerPanel->AddGrowableRow(0);
+
+//JCP 14-10-09
+ //sizerPanel -> Add( sizer , 1, wxEXPAND ,0);
+ sizerPanel -> Add( panel->GetSizer() , 1, wxEXPAND ,0);
+//JCP 14-10-09
+
+
+
+ _InformationContourFrame->SetSizer( sizerPanel );
+ _InformationContourFrame->SetAutoLayout( true );
+ _InformationContourFrame->Layout();
+
+ _InformationContourFrame->Show();
+ } else {
+ if (_InformationContourFrame->IsShown()==true)
+ {
+ _InformationContourFrame->Show(false);
+ } else {
+ FillGridWithContoursInformation();
+ _InformationContourFrame->Show(true);
+ }
+ }
+ }
+
+ wxPanel* wxContourEventHandler::getInformationPanel(wxWindow* parent){
+ wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
+
+ wxString lstOptions[4];
+ lstOptions[0]=_T("Actual Slice");
+ lstOptions[1]=_T("Range Slices");
+ lstOptions[2]=_T("All Slices");
+ _informationRadiobox = new wxRadioBox(panel, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+
+ wxString lstOptContOperation[5];
+ lstOptContOperation[0]=_T("AND");
+ lstOptContOperation[1]=_T("OR");
+ lstOptContOperation[2]=_T("XOR");
+ lstOptContOperation[3]=_T("ALL");
+ _radiolstboxContourGroup = new wxRadioBox(panel, -1, _T("Contour group"), wxDefaultPosition, wxSize(270,45), 4 , lstOptContOperation, 4, wxRA_SPECIFY_COLS);
+
+ wxButton *informationContourLabelsBtn = new wxButton(panel,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
+ informationContourLabelsBtn->SetEventHandler( this );
+ Connect( informationContourLabelsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onInformationContourLabels );
+
+ wxButton *statisticsContourBtn = new wxButton(panel,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
+ statisticsContourBtn->SetEventHandler( this );
+ Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onExtractInformation );
+
+ wxButton *saveResultsBtn = new wxButton(panel,-1,_T("Save statistics results"),wxDefaultPosition, wxSize(140,35) );
+ saveResultsBtn->SetEventHandler( this );
+ Connect( saveResultsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSaveResults );
+
+
+ int sizeZ = this->_theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ _mbarrangeSliceInformation = new mBarRange(panel,65,65);
+ _mbarrangeSliceInformation->SetMin(0);
+ _mbarrangeSliceInformation->SetStart(0);
+ _mbarrangeSliceInformation-> SetOrientation( true );
+ _mbarrangeSliceInformation-> setActiveStateTo(true);
+ _mbarrangeSliceInformation-> setVisibleLabels( true );
+ _mbarrangeSliceInformation-> setDeviceEndMargin(10);
+ _mbarrangeSliceInformation-> setRepresentedValues( 0 , sizeZ-1 );
+ _mbarrangeSliceInformation-> setDeviceBlitStart(10,10);
+ _mbarrangeSliceInformation-> setIfWithActualDrawed( false );
+ _mbarrangeSliceInformation-> SetStart( 0 );
+ _mbarrangeSliceInformation-> SetEnd( sizeZ-1 );
+
+
+ double range[2];
+ this->_theViewPanel->getSceneManager()->GetImageDataRange(range);
+ _mbarrangeRangeInformation = new mBarRange(panel,65,65);
+ _mbarrangeRangeInformation->SetMin(0);
+ _mbarrangeRangeInformation->SetStart(0);
+ _mbarrangeRangeInformation-> SetOrientation( true );
+ _mbarrangeRangeInformation-> setActiveStateTo(true);
+ _mbarrangeRangeInformation-> setVisibleLabels( true );
+ _mbarrangeRangeInformation-> setDeviceEndMargin(10);
+ _mbarrangeRangeInformation-> setRepresentedValues( range[0] , range[1] );
+ _mbarrangeRangeInformation-> setDeviceBlitStart(10,10);
+ _mbarrangeRangeInformation-> setIfWithActualDrawed( false );
+ _mbarrangeRangeInformation-> SetStart( range[0] );
+ _mbarrangeRangeInformation-> SetEnd( range[1] );
+
+
+ _staticTextInformation = new wxStaticText(panel,-1,_T(" "));
+
+
+// wxButton *XXXXXXXBtn = new wxButton(panel,-1,_T("Statistics"),wxDefaultPosition, wxSize(180,35) );
+// XXXXXXXBtn->SetEventHandler( this );
+// Connect( XXXXXXXBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onXXXXX );
+
+
+ _grid = new wxGrid( panel,
+ wxID_ANY,
+ wxPoint( 0, 0 ),
+ wxSize( 100, 100 ) );
+
+ int i,gridCol=10,gridRow=sizeZ;
+ _grid->CreateGrid( 0, 0 );
+ _grid->AppendRows(gridRow);
+ _grid->AppendCols(gridCol);
+
+ for (i=0;i<gridRow;i++)
+ {
+ _grid->SetRowLabelValue(i, _T(" ") );
+ }
+// _grid->SetColLabelSize(0);
+
+
+ FillGridWithContoursInformation();
+
+ wxFlexGridSizer * sizerA = new wxFlexGridSizer(10);
+ sizerA->Add( _informationRadiobox , 1, wxALL ,2 );
+ sizerA->Add( _radiolstboxContourGroup , 1, wxALL ,2 );
+
+ wxFlexGridSizer * sizerB = new wxFlexGridSizer(10);
+ sizerB->Add( informationContourLabelsBtn , 1, wxALL ,2 );
+ sizerB->Add( statisticsContourBtn , 1, wxALL ,2 );
+ sizerB->Add( saveResultsBtn , 1, wxALL ,2 );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer->AddGrowableCol(0);
+ sizer->AddGrowableRow(7);
+ sizer->Add( sizerA , 1, wxALL , 0 );
+ sizer->Add( new wxStaticText(panel ,-1,_T("Slice Range")) , 1, wxALL , 0 );
+ sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW , 2 );
+ sizer->Add( new wxStaticText(panel ,-1,_T("Gray Range")) , 1, wxALL , 0 );
+ sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW , 2 );
+ sizer->Add( sizerB , 1, wxALL , 0 );
+ sizer->Add( _staticTextInformation , 1, wxALL , 0 );
+ sizer->Add( _grid , 1, wxEXPAND , 0 );
+
+
+
+ panel->SetSizer( sizer );
+ panel->SetSize( wxSize(1500,1500) );
+ //panel->SetBackgroundColour( wxColour(100,100,100) );
+ panel->SetAutoLayout( true );
+ panel->Layout();
+ return panel;
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onSpreadInDepth( std::vector<std::string> & keyNamesVector )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onOutline_Union_Of( std::vector<std::string> & keyNamesVector )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onOutline_Intersection_Of( std::vector<std::string> & keyNamesVector )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onOutline_Combination_Of( std::vector<std::string> & keyNamesVector )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onOutline_Fragmentation_Of( std::vector<std::string> & keyNamesVector )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onOutline_Agrupation_Of( std::vector<std::string> & keyNamesVector )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onCopyOutlines( std::vector<std::string> & keyNamesVector )
+ {
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ _performingOperation->reset();
+ _performingOperation->setStartCommand( (char)wxContour_ActionCommandsID::COPY_TOOL );
+ _performingOperation->setStartOperationInstantVector( tempVector );
+ _performingOperation->setKeyNamesOperationElems( keyNamesVector );
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onPasteOutlines( )
+ {
+ char theStartCommand = _performingOperation->getStartCommand();
+ if ( theStartCommand == wxContour_ActionCommandsID::COPY_TOOL )
+ {
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ _performingOperation->setEndOperationInstantVector ( tempVector );
+ std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
+ int i,size = elems.size();
+ for( i=0; i<size; i++ )
+ {
+ createCopyContourOf( elems[i], tempVector, i>0 );
+ }
+
+
+ }
+ int fin = 0;
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onShowOutlines( std::vector<std::string> & keyNamesVector )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onHideOutlines( std::vector<std::string> & keyNamesVector )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onSelectOutlines( std::vector<std::string> & keyNamesVector )
+ {
+ //if( keyNamesVector.empty() )
+ {
+ _theViewPanel->getSceneManager()->drawSelectionROI( );
+ }
+ /*else
+ {
+ int ok = keyNamesVector.size();
+ _theViewPanel->getSceneManager()->selectObjects( keyNamesVector );
+ std::string name = keyNamesVector[0];
+ }*/
+ /*
+ _theViewPanel->getSceneManager()->drawSelectionROI( );
+ std::vector<std::string> currentSelection = _theViewPanel->getSceneManager()->getSelectedObjects();
+ int ok = currentSelection.size();
+ _theViewPanel->getSceneManager()->selectObjects( currentSelection );*/
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onEditOutlines( std::vector<std::string> & keyNamesVector )
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: deleteContour( std::string theKeyName )
+ {
+ manualContourModel * cModel;
+ manualViewBaseContour * cViewer;
+ manualContourBaseControler * cControler;
+
+ ContourWrap_ViewControl *conwrapviewControl = _theViewPanel->getSceneManager()->getContourWrap_ViewControlOf( theKeyName );
+ cControler = conwrapviewControl->getControler();
+ int ispartofstaticlst= _modelManager->IsPartOfStaticList(theKeyName);
+ if ((cControler!=NULL) && (cControler->IsEditable()==false) && (ispartofstaticlst==-1) )
+ {
+ _theViewPanel->getSceneManager()->removeFromScene( theKeyName );
+ cModel = _modelManager->getOutlineByKeyName(theKeyName)->getModel();
+ _modelManager->removeOutline( theKeyName );
+ cViewer = conwrapviewControl->getViewer();
+ _theViewPanel->getSceneManager()->removeWrap( theKeyName );
+//EED Borrame
+//FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
+//fprintf(ff,"EED wxContourEventHandler::deleteContours() \n" );
+//fprintf(ff," %s %p\n",keyNamesVector[i].c_str(), cControler );
+//fclose(ff);
+ delete cModel;
+ delete cViewer;
+ delete cControler;
+ } // if editable
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: deleteContours( std::vector<std::string> keyNamesVector )
+ {
+ int i,size=keyNamesVector.size();
+ for (i=0;i<size;i++)
+ {
+ deleteContour( keyNamesVector[i] );
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: deleteAllContours( )
+ {
+ wxBusyCursor wait;
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+//JCP --08-09-2008 When using a diferent interface the _mbarrangeDeleteAll might not be initialize
+// the values in GetStart and GetEnd will then not be initialize also.
+// We use instead the values given when initializing the _deletepanel.
+
+ //int minZ = _mbarrangeDeleteAll->GetStart();
+ //int maxZ = _mbarrangeDeleteAll->GetEnd();
+ int minZ, maxZ;
+
+ minZ = 0;
+ maxZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+
+//JCP --08-09-2008
+
+ _theViewPanel->getSceneManager()->removeSceneContours( );
+ _modelManager->removeAllOutlines();
+ _theViewPanel->getSceneManager()->removeAllOutlines();
+//JCP --08-09-2008
+ /*
+ if ( (minZ==0) && (maxZ==_mbarrangeDeleteAll->GetMax() ))
+ {
+ _theViewPanel->getSceneManager()->removeSceneContours( );
+ _modelManager->removeAllOutlines();
+ _theViewPanel->getSceneManager()->removeAllOutlines();
+
+ } else {
+ for ( z=minZ ; z<=maxZ ; z++)
+ {
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
+
+ sizeLstContourThings = lstContourThings.size();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ deleteContour( (*contourthing)->getName() );
+ } //for ii
+ }// for z
+ } // if
+ JCP --08-09-2008 */
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::openContours( FILE *pFile, bool staticContour )
+ {
+ char tmp[255];
+ fscanf(pFile,"%s",tmp); // NumberOfContours
+ fscanf(pFile,"%s",tmp); // ##
+ int numberOfContours = atoi(tmp);
+
+ std::vector<int> instantVector;
+ int typeContourModel;
+ manualContourModel *manModelContour;
+ int typeView;
+
+ int i;
+ for (i=0;i<numberOfContours;i++)
+ {
+ instantVector.clear();
+ fscanf(pFile,"%s",tmp); // Instant
+
+ fscanf(pFile,"%s",tmp); // 1
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 2
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 3
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 4
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 5
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 6
+ instantVector.push_back( atoi(tmp) );
+
+
+ fscanf(pFile,"%s",tmp); // TypeContourModel
+ fscanf(pFile,"%s",tmp); // ##
+ typeContourModel = atoi(tmp);
+
+ manModelContour = factoryManualContourModel(typeContourModel);
+ manModelContour->Open(pFile);
+
+ fscanf(pFile,"%s",tmp); // TypeView
+ fscanf(pFile,"%s",tmp); // ##
+ typeView = atoi(tmp);
+
+
+// if (typeView==1)
+// {
+// }
+
+
+ std::string theName;
+ theName = _modelManager->createOutline( manModelContour, instantVector );
+ bool addedModel = theName.compare("") != 0;
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ this->_theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
+ }
+
+ if (staticContour==true)
+ {
+ Instant instant(&instantVector);
+ changeContourOfManager( theName , &instant );
+ }
+
+ }// for numberOfContours
+
+
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::openFileWithContours()
+ {
+ char tmp[255];
+ wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN );
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
+ FILE *pFile=fopen(fileNameContourROI.c_str(),"r+");
+
+ fscanf(pFile,"%s",tmp); // --CreaContour--
+
+ fscanf(pFile,"%s",tmp); // Version
+ fscanf(pFile,"%s",tmp); // 1.0.1
+ std::string version(tmp);
+
+ openContours(pFile,false);
+ if (version!="1.0.0"){
+ openContours(pFile,true);
+ }
+// _theViewPanel->getSceneManager()->openFileWithContours(ff);
+
+ fclose(pFile);
+ }
+ _theViewPanel->getSceneManager()->removeSceneContours();
+ changeInstant();
+ //updateInstantOutlines();
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::saveFileWithContours( std::string filename )
+ {
+ FILE *pFile=fopen(filename.c_str(),"w+");
+ std::vector< std::string > lstNameThings;
+ int i,sizeLstNameThings;
+
+ fprintf(pFile,"--CreaContour--\n");
+ fprintf(pFile,"Version %s\n", "1.0.1" );
+
+ // Normal Contours
+ lstNameThings = _modelManager->GetLstNameThings();
+ sizeLstNameThings = lstNameThings.size();
+ fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
+ for (i=0 ; i<sizeLstNameThings ; i++)
+ {
+ _modelManager->SaveThingName( pFile, lstNameThings[i] );
+ _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
+ }// for i
+
+ //-- Contours Statics
+ lstNameThings = _modelManager->GetLstNameThingsStatic();
+ sizeLstNameThings = lstNameThings.size();
+ fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
+ for (i=0 ; i<sizeLstNameThings ; i++)
+ {
+ _modelManager->SaveThingName( pFile, lstNameThings[i] );
+ _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
+ }// for i
+ fclose(pFile);
+ }
+
+
+ //----------------------------------------------------------
+
+ void wxContourEventHandler::saveFileWithContours()
+ {
+ wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE );
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
+ saveFileWithContours( fileNameContourROI );
+ } // if ShowModal
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: saveFileWithContoursAutomatique()
+ {
+ if (fileNameContourROI=="")
+ {
+ saveFileWithContours();
+ } else {
+ saveFileWithContours(fileNameContourROI);
+ }
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append )
+ {
+ std::string cloneName = _modelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
+ manualContourModel * manualModel = _modelManager->getOutlineByKeyName( cloneName )->getModel();
+ _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ manualContourModel * wxContourEventHandler::factoryManualContourModel(int typeContour)
+ {
+ manualContourModel *manModelContour=NULL;
+
+ // spline
+ if (typeContour==0)
+ {
+ manModelContour = new manualContourModel();
+ }
+
+ // spline
+ if (typeContour==1)
+ {
+ manModelContour = new manualContourModel();
+ }
+
+ // rectangle
+ if (typeContour==2)
+ {
+ manModelContour = new manualContourModelRoi();
+ }
+
+ // circle
+ if (typeContour==3)
+ {
+ manModelContour = new manualContourModelCircle();
+ }
+
+ // BullEye / star
+ if (typeContour==4)
+ {
+ manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
+ manModelContour = manModelContourBullEye;
+ if (_panelBullEyeOptions!=NULL){
+ int iCrown,sizeCrowns,iSector,sizeSectors;
+ double radioA,radioB,ang,angDelta ;
+ sizeCrowns = _panelBullEyeOptions->GetNumberOfCrowns();
+ for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
+ {
+ sizeSectors = _panelBullEyeOptions->GetNumberOfSections(iCrown);
+ radioB = _panelBullEyeOptions->GetRadioOfCrown(iCrown);
+ if (iCrown==sizeCrowns-1)
+ {
+ radioA = 0;
+ } else {
+ radioA = _panelBullEyeOptions->GetRadioOfCrown(iCrown+1);
+ }
+ radioA=radioA/100.0;
+ radioB=radioB/100.0;
+ for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
+ {
+ ang = _panelBullEyeOptions->GetAngOfCrownSection(iCrown,iSector);
+ angDelta= _panelBullEyeOptions->GetAngDeltaOfCrownSection(iCrown);
+ manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
+ } // for iSector
+ } // for iCrown
+ } // if _panelBullEyeOptions
+ }// if typeContour==4
+
+ return manModelContour;
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: createContour( int typeContour )
+ {
+ //Creating the manualContourModel and including in the model
+ manualContourModel * manModelContour = factoryManualContourModel(typeContour);
+ std::vector<int> instantVector;
+ _instantPanel->getInstant( instantVector );
+ std::string theName;
+ theName= _modelManager->createOutline( manModelContour, instantVector );
+ bool addedModel = theName.compare("") != 0;//??
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ this->_theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeContour) ;
+ }
+
+//EED Borrame
+//FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
+//fprintf(ff,"EED wxContourEventHandler::createContour() \n" );
+//fprintf(ff," %s\n %p ",theName.c_str() , );
+//fclose(ff);
+
+
+ }
+ manualContourModel * wxContourEventHandler::factoryManualContourModel(PanelBullEyeOptions* panel){
+
+ manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
+ manualContourModel *manModelContour=NULL;
+ manModelContour = manModelContourBullEye;
+ if (panel!=NULL){
+ int iCrown,sizeCrowns,iSector,sizeSectors;
+ double radioA,radioB,ang,angDelta ;
+ sizeCrowns = panel->GetNumberOfCrowns();
+ for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
+ {
+ sizeSectors = panel->GetNumberOfSections(iCrown);
+ radioB = panel->GetRadioOfCrown(iCrown);
+ if (iCrown==sizeCrowns-1)
+ {
+ radioA = 0;
+ } else {
+ radioA = panel->GetRadioOfCrown(iCrown+1);
+ }
+ radioA=radioA/100.0;
+ radioB=radioB/100.0;
+ for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
+ {
+ ang = panel->GetAngOfCrownSection(iCrown,iSector);
+ angDelta= panel->GetAngDeltaOfCrownSection(iCrown);
+ manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
+ } // for iSector
+ } // for iCrown
+ } // if _panelBullEyeOptions
+
+ return manModelContour;
+ }
+
+ void wxContourEventHandler :: createContourBullsEye(PanelBullEyeOptions* panel )
+ {
+ //Creating the manualContourModel and including in the model
+ manualContourModel * manModelContour = factoryManualContourModel(panel );
+ std::vector<int> instantVector;
+ _instantPanel->getInstant( instantVector );
+ std::string theName;
+ theName= _modelManager->createOutline( manModelContour, instantVector );
+ bool addedModel = theName.compare("") != 0;
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ this->_theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , 4) ;
+ }
+
+//EED Borrame
+//FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
+//fprintf(ff,"EED wxContourEventHandler::createContour() \n" );
+//fprintf(ff," %s\n %p ",theName.c_str() , );
+//fclose(ff);
+
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ // Attributes getters and setters
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler :: setModelManager( OutlineModelManager * theModelManager )
+ {
+ _modelManager = theModelManager;
+ _workSpace = _modelManager->getContourWorkspace();
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: setViewPanel( wxContourViewPanel * theViewPanel )
+ {
+ _theViewPanel = theViewPanel;
+ //_theViewPanel->setWxEventHandler( this );
+
+ /*double spc[3];
+ this->_theViewPanel->getSpacing(spc);
+ _sceneManager = new wxVtkBaseView_SceneManager ( this->_theViewPanel->getWxVtkBaseView(), this, spc );
+
+ Connect( _theViewPanel->GetId(), wxINSTANT_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangeInstant );
+ Connect( wxID_ANY, wxEVT_START_CREATE_MULT_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onCreateMultipleROI );
+ Connect( wxID_ANY, wxEVT_START_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onCreateROI );
+ Connect( wxID_ANY, wxEVT_STOP_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onStopCreateROI );
+ Connect( wxID_ANY, wxEVT_CHANGED_DEEP, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangedDeep );
+ Connect( wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler :: onActionButtonPressed ); */
+
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel )
+ {
+ _instantPanel = theInstantChooserPanel;
+ //_instantPanel->setWxEventHandler( this );
+
+ //Connect( _instantPanel->GetId(), wxINSTANT_CHOOSER_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangeInstant );
+
+ std::vector<int> vect;
+ _instantPanel->getInstant( vect );
+ _actualInstant = new Instant( &vect );
+
+ if( _modelManager!=NULL )
+ {
+ std::vector<std::string> conceptNameVect;
+ std::vector<int> conceptSizeVect;
+ _modelManager-> getConceptsInformation(conceptNameVect, conceptSizeVect);
+ int i=0;
+ int max = conceptNameVect.size();
+ for( ; i<max; i++)
+ {
+ if( conceptNameVect[i].compare("Axe Depth") == 0 )
+ {
+ _instantPanel->addConcept( conceptNameVect[i], 0, conceptSizeVect[i], 1);
+ } else {
+ _instantPanel->addConcept( conceptNameVect[i], 1, conceptSizeVect[i], 1);
+ } // if
+ } // for
+ } else {
+ //Should be configured later, or abort program, because Model -NEEDS- to be added before chooserPanel
+ }
+ if( _theViewPanel!=NULL )
+ {
+ double val = _theViewPanel->getCurrentDeep();
+ _instantPanel->setConceptValue( "Axe Depth", (int)val );
+ //JCP _instantPanel->setConceptValue("time", num de imagenes);
+ ConceptDataWrap * data = _instantPanel->getConceptDataOf( "Axe Depth" );
+ changeInstant();
+ _theViewPanel->setVerticalConcept( "Axe Depth", data->getMinValue(), data->getMaxValue(), data->getMinShowedValue(), data->getMaxShowedValue(), data->getActualValue() );
+ } else {
+ //Should be configured later, or abort program, because ViewPanel -NEEDS- to be added before chooserPanel
+ }// if
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: setButtonsBar( wxContour_ButtonsBar * theButtonsBar )
+ {
+ _buttonsBar = theButtonsBar;
+ _buttonsBar->setWxEventHandler( this );
+ Connect( _buttonsBar->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler:: onActionButtonPressed );
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: setGrid( wxContour_Grid * theGridPanel )
+ {
+ _gridPanel = theGridPanel;
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: setDrawToolsPanel( wxContour_DrawToolsPanel * theDrawToolsPanel )
+ {
+ _drawToolsPanel = theDrawToolsPanel;
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: setOperationsToolsPanel( wxContour_OperationsToolsPanel * theOperationsToolsPanel )
+ {
+ _operationsToolsPanel = theOperationsToolsPanel;
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: setAutomaticFormsPanel( wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel )
+ {
+ _autoFormsPanel = theAutoFormsPanel;
+ }
+
+ void wxContourEventHandler :: setStandardToolsPanel( wxContour_StandardToolsPanel * theStandardToolsPanel )
+ {
+ _standardToolsPanel= theStandardToolsPanel;
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: setEditionToolsPanel( wxContour_EdtionToolsPanel * theEditionToolsPanel )
+ {
+ _editionToolsPanel = theEditionToolsPanel;
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: setListViewPanel( wxContour_ListViewPanel * theListViewPanel )
+ {
+ _listViewPanel = theListViewPanel;
+ }
+ //------------------------------------------------------------------------------------------------------------
+ // Other functional methods
+ //------------------------------------------------------------------------------------------------------------
+
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onDeleteContour( wxCommandEvent& event )
+ {
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+
+ int i,size=_theViewPanel->getSceneManager()->getSelectedObjects().size();
+ for(i=0;i<size;i++)
+ {
+ std::string keyName = _theViewPanel->getSceneManager()->getSelectedObjects()[i];
+ int ispartofstaticlist = this->_modelManager->IsPartOfStaticList( keyName );
+ if ( ispartofstaticlist>=0 )
+ {
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ Instant instant(&tempVector);
+ this->_modelManager->ChangeContourOfList(keyName, &instant);
+ }
+ }
+
+ std::vector<std::string> lstKeyName;
+ std::vector<std::string> lstKeyNameActualSlice;
+ std::vector<std::string> lstKeyNameToBeErase;
+
+ lstKeyNameToBeErase = _theViewPanel->getSceneManager()->getSelectedObjects();
+ lstKeyNameActualSlice = _theViewPanel->getSceneManager()->GetlstContoursNameActualSlice();
+ int k,kSize=lstKeyNameToBeErase.size();
+ int j,jSize=lstKeyNameActualSlice.size();
+ bool ok;
+ for (k=0;k<kSize; k++)
+ {
+ ok=false;
+ for (j=0;j<jSize; j++)
+ {
+ if (lstKeyNameToBeErase[k]==lstKeyNameActualSlice[j])
+ {
+ ok=true;
+ }
+ } // for j
+ if (ok==true)
+ {
+ lstKeyName.push_back( lstKeyNameToBeErase[k] );
+ } // if ok
+ } // for k
+
+ deleteContours( lstKeyName );
+
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onDeleteContoursActSlice( wxCommandEvent& event )
+ {
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ deleteContours( (std::vector<std::string>)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() );
+
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler::onDeleteAllContours( wxCommandEvent& event )
+ {
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ deleteAllContours( );
+
+
+ }
+
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onDeleteFrame( )
+ {
+ if (_deleteFrame==NULL)
+ {
+ _deleteFrame = new wxFrame (_theViewPanel, -1,_T(" Delete Contour "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
+ int width=300;
+ wxSize sizepanel(width,230);
+ _deleteFrame->SetSize( sizepanel );
+ wxPanel *panel = new wxPanel(_deleteFrame,-1);
+ wxButton *deleteContourBtn = new wxButton(panel,-1,_T("Delete contour selected"),wxDefaultPosition, wxSize(width-10,35) );
+ wxButton *deleteContoursActSliceBtn = new wxButton(panel,-1,_T("Delete contours of actual slice"),wxDefaultPosition, wxSize(width-10,35));
+ wxButton *deleteAllContoursBtn = new wxButton(panel,-1,_T("Delete all contours"),wxDefaultPosition, wxSize(width-10,35));
+
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ _mbarrangeDeleteAll = new mBarRange(panel,70, 65);
+ _mbarrangeDeleteAll->SetMin(0);
+ _mbarrangeDeleteAll->SetStart(0);
+
+ _mbarrangeDeleteAll-> SetOrientation( true );
+ _mbarrangeDeleteAll-> setActiveStateTo(true);
+ _mbarrangeDeleteAll-> setVisibleLabels( true );
+ _mbarrangeDeleteAll-> setDeviceEndMargin(10);
+ _mbarrangeDeleteAll-> setRepresentedValues( 0 , sizeZ );
+ _mbarrangeDeleteAll-> setDeviceBlitStart(10,10);
+ _mbarrangeDeleteAll-> setIfWithActualDrawed( false );
+ _mbarrangeDeleteAll-> SetStart( 0 );
+ _mbarrangeDeleteAll-> SetEnd( sizeZ );
+
+
+ _deleteFrame->SetEventHandler( this );
+ Connect( deleteContourBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onDeleteContour );
+ Connect( deleteContoursActSliceBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onDeleteContoursActSlice );
+ Connect( deleteAllContoursBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onDeleteAllContours );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( deleteContourBtn , 1, wxGROW );
+ sizer -> Add( deleteContoursActSliceBtn , 1, wxGROW );
+ sizer -> Add( deleteAllContoursBtn , 1, wxGROW );
+ sizer -> Add( _mbarrangeDeleteAll , 1, wxGROW );
+
+ panel->SetSizer( sizer );
+ panel->SetSize( sizepanel );
+ panel->SetAutoLayout( true );
+ panel->Layout();
+ _deleteFrame->Show(true);
+ } else {
+ if (_deleteFrame->IsShown()==true)
+ {
+ _deleteFrame->Show(false);
+ } else {
+ _deleteFrame->Show(true);
+ }
+ }
+ }
+
+
+//------------------------------------------------------------------------------------------------------------
+void wxContourEventHandler::onCreateContourSpline( wxCommandEvent& event )
+{
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ createContour( 1 );
+
+
+
+}
+
+//------------------------------------------------------------------------------------------------------------
+void wxContourEventHandler::onCreateContourRectangle( wxCommandEvent& event )
+{
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ createContour( 2 );
+
+
+}
+
+//------------------------------------------------------------------------------------------------------------
+void wxContourEventHandler::onCreateContourCircle( wxCommandEvent& event )
+{
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ createContour( 3 );
+
+
+}
+//------------------------------------------------------------------------------------------------------------
+void wxContourEventHandler::onCreateContourBullEye( wxCommandEvent& event )
+{
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ createContour( 4 );
+
+}
+
+
+
+//------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onCreateContourFrame( )
+ {
+ if (_createContourFrame==NULL)
+ {
+ _createContourFrame = new wxFrame (_theViewPanel, -1,_T(" New Contour "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
+ wxSize sizepanel(490,600);
+ _createContourFrame->SetSize( sizepanel );
+ wxPanel *panel = new wxPanel(_createContourFrame,-1);
+ wxButton *newContourSplineBtn = new wxButton(panel,-1,_T("Interpolation B-spline (close)"),wxDefaultPosition, wxSize(180,35) );
+ newContourSplineBtn->SetToolTip(_T("CTRL-N"));
+ wxButton *newContourRectangleBtn = new wxButton(panel,-1,_T("Rectangle"),wxDefaultPosition, wxSize(180,35));
+ wxButton *newContourCircleBtn = new wxButton(panel,-1,_T("Circle"),wxDefaultPosition, wxSize(180,35));
+ wxButton *newContourStarBtn = new wxButton(panel,-1,_T("Bull eye"),wxDefaultPosition, wxSize(180,35));
+
+ _panelBullEyeOptions = new PanelBullEyeOptions(panel, wxSize(100,200));
+
+ _createContourFrame->SetEventHandler( this );
+ Connect( newContourSplineBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourSpline );
+ Connect( newContourRectangleBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourRectangle );
+ Connect( newContourCircleBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourCircle );
+ Connect( newContourStarBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourBullEye );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( newContourSplineBtn , 1, wxGROW );
+ sizer -> Add( newContourRectangleBtn , 1, wxGROW );
+ sizer -> Add( newContourCircleBtn , 1, wxGROW );
+ sizer -> Add( newContourStarBtn , 1, wxGROW );
+ sizer -> Add( _panelBullEyeOptions , 1, wxGROW );
+
+ panel->SetSizer( sizer );
+ panel->SetSize( sizepanel );
+ panel->SetAutoLayout( true );
+ panel->Layout();
+ _createContourFrame->Show(true);
+ } else {
+ if (_createContourFrame->IsShown()==true)
+ {
+ _createContourFrame->Show(false);
+ } else {
+ _createContourFrame->Show(true);
+ }
+ }
+ }
+
+
+//------------------------------------------------------------------------
+void wxContourEventHandler::RefreshInterface()
+{
+ changeInstant();
+ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
+ wxvtk2dbaseview->Refresh();
+}
+
+//------------------------------------------------------------------------
+void wxContourEventHandler::onWidthOfContour(wxScrollEvent& event){
+ _theViewPanel->getSceneManager()->removeSceneContours();
+ double width = (double)_withOfContourLine->GetValue() / 2.0;
+ _theViewPanel->getSceneManager()->SetWidthContour( width );
+
+ RefreshInterface();
+}
+
+//------------------------------------------------------------------------
+
+void wxContourEventHandler::onBrigthnessColorWindowLevel(wxScrollEvent& event){
+ int colorwindow = _brithtnessColorLevel->GetValue();
+ int windowlevel = _brithtnessWindowLevel->GetValue();
+ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
+ vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
+ imageviewer->SetColorWindow(colorwindow);
+ imageviewer->SetColorLevel(windowlevel);
+// wxvtk2dbaseview->Refresh();
+ RefreshInterface();
+}
+
+void wxContourEventHandler::OnInterpolation(wxCommandEvent& event)
+{
+ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
+ vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
+ if (_interpolationCheckBox->GetValue()==true)
+ {
+ imageviewer->GetImageActor()->InterpolateOn();
+ } else {
+ imageviewer->GetImageActor()->InterpolateOff();
+ }
+ RefreshInterface();
+}
+
+
+//------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onInterfaceConfigurationFrame( )
+ {
+ if (_interfaceConfigurationFrame==NULL)
+ {
+ _interfaceConfigurationFrame = new wxFrame (_theViewPanel, -1,_T(" Interface Configuration "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
+ wxSize sizepanel(190,400);
+ _interfaceConfigurationFrame->SetSize( sizepanel );
+ _interfaceConfigurationFrame->SetEventHandler( this );
+ wxPanel* panel = getConfigurationPanel(_interfaceConfigurationFrame);
+ panel->SetSize(sizepanel);
+ _interfaceConfigurationFrame->Show(true);
+ } else {
+ if (_interfaceConfigurationFrame->IsShown()==true)
+ {
+ _interfaceConfigurationFrame->Show(false);
+ } else {
+ _interfaceConfigurationFrame->Show(true);
+ }
+ }
+ }
+
+
+ //**JCP 13-10-08
+
+ wxPanel* wxContourEventHandler :: getConfigurationPanel(wxWindow* parent){
+
+ /*wxPanel *panel = new wxPanel(parent,-1);
+ _withOfContourLine = new wxSlider(panel, -1, 1 , 1, 10, wxDefaultPosition, wxSize(180,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ double range[2];
+ this->_theViewPanel->getSceneManager()->GetImageDataRange(range);
+
+ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
+ vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
+ int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
+ int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
+
+ _brithtnessWindowLevel = new wxSlider(panel, -1, windowlevel , 1, range[1], wxDefaultPosition, wxSize(180,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ _brithtnessColorLevel = new wxSlider(panel, -1, colorwindow , 1, range[1], wxDefaultPosition, wxSize(180,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ _interpolationCheckBox = new wxCheckBox(panel, -1, _T("Image interpolation") );
+ _interpolationCheckBox->SetValue(true);
+
+ _interfaceConfigurationFrame->SetEventHandler( this );
+
+ Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
+ Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
+
+ Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
+ Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
+ Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
+ Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
+ Connect( _interpolationCheckBox->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::OnInterpolation );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(panel,-1,_T("Contour width")) , 1, wxGROW );
+ sizer -> Add( _withOfContourLine , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("Brightness of the image")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("--Window level--")) , 1, wxGROW );
+ sizer -> Add( _brithtnessWindowLevel , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("--Color level--")) , 1, wxGROW );
+ sizer -> Add( _brithtnessColorLevel, 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( _interpolationCheckBox , 1, wxGROW );
+
+ panel->SetSizer( sizer );
+ //JCP 13-10-08
+ //panel->SetSize( sizepanel );
+ //13-10-08
+ panel->SetAutoLayout( true );
+ panel->Layout();
+
+ return panel;*/
+
+ wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString(_T("")));
+ _withOfContourLine = new wxSlider(panel, -1, 1 , 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ double range[2];
+ this->_theViewPanel->getSceneManager()->GetImageDataRange(range);
+
+ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
+ vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
+ int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
+ int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
+
+ _brithtnessWindowLevel = new wxSlider(panel, -1, windowlevel , 1, range[1], wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ _brithtnessColorLevel = new wxSlider(panel, -1, colorwindow , 1, range[1], wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+ _interpolationCheckBox = new wxCheckBox(panel, -1, _T("Image interpolation") );
+ _interpolationCheckBox->SetValue(true);
+
+ Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
+ Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
+
+ Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
+ Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
+ Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
+ Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
+ Connect( _interpolationCheckBox->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::OnInterpolation );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(panel,-1,_T("Contour width")) , 1, wxGROW );
+ sizer -> Add( _withOfContourLine , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("Brightness of the image")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("--Window level--")) , 1, wxGROW );
+ sizer -> Add( _brithtnessWindowLevel , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("--Color level--")) , 1, wxGROW );
+ sizer -> Add( _brithtnessColorLevel, 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( _interpolationCheckBox , 1, wxGROW );
+
+ panel->SetSizer( sizer );
+ //JCP 13-10-08
+ //panel->SetSize( sizepanel );
+ //13-10-08
+ panel->SetAutoLayout( true );
+ panel->Layout();
+
+ return panel;
+ }
+
+//**JCP 13-10-08
+
+
+
+//------------------------------------------------------------------
+ void wxContourEventHandler :: changeContourOfManager(std::string keyName, Instant *instant)
+ {
+ this->_modelManager->ChangeContourOfList(keyName, instant);
+ }
+
+//------------------------------------------------------------------
+ void wxContourEventHandler :: changeContoursOfManager( std::vector<std::string> & keyNamesVector )
+ {
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ Instant instant(&tempVector);
+
+ int i , size=keyNamesVector.size();
+ for ( i=0 ; i<size ; i++ )
+ {
+ changeContourOfManager(keyNamesVector[i], &instant);
+ } // i
+
+
+ }
+
+
+//------------------------------------------------------------------
+ void wxContourEventHandler :: executeActionCommand( const char toolCommand )
+ {
+ std::vector<std::string> currentSelection = _theViewPanel->getSceneManager()->getSelectedObjects();
+ int elementsSelected = currentSelection.size();
+ if( toolCommand == (wxContour_ActionCommandsID::CREATE_TOOL) )
+ {
+ onCreateContourFrame();
+ }
+ if( toolCommand == (wxContour_ActionCommandsID::CREATE_CONTOUR_KEY) )
+ {
+ createContour();
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::DELETE_TOOL )
+ {
+ onDeleteFrame( );
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::DELETE_KEY )
+ {
+ deleteContours( currentSelection );
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::SAVE_TOOL )
+ {
+ saveFileWithContours( );
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::SAVE_KEY )
+ {
+ saveFileWithContoursAutomatique( );
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::OPEN_TOOL )
+ {
+ openFileWithContours( );
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::CHANGE_TOOL )
+ {
+ if ( elementsSelected >= 1 )
+ {
+ changeContoursOfManager( currentSelection );
+ }
+
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::HIDE_TOOL )
+ {
+ if ( elementsSelected >= 1 )
+ {
+ onHideOutlines( currentSelection );
+ }
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::SHOW_TOOL )
+ {
+ if ( elementsSelected >= 1 )
+ {
+ onShowOutlines( currentSelection );
+ }
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::COPY_TOOL )
+ {
+ if ( elementsSelected >= 1 )
+ {
+ onCopyOutlines( currentSelection );
+ }
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::PASTE_TOOL )
+ {
+ onPasteOutlines( );
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::SPREAD_TOOL )
+ {
+ onSpread();
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::AUTOMATIQUESEGMENTATION_TOOL )
+ {
+ onAutomatiqueSegmentation( );
+ }
+
+ else if( toolCommand == wxContour_ActionCommandsID::SELECT_TOOL )
+ {
+ onSelectOutlines( currentSelection );
+
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::EDIT_TOOL )
+ {
+ if ( elementsSelected >= 1 )
+ {
+ onEditOutlines( currentSelection );
+ }
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::UNDO_TOOL )
+ {
+ onUNDO();
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::REDO_TOOL )
+ {
+ onREDO();
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::INFORMATIONCONTOUR_TOOL )
+ {
+ onInformationContourFrame();
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::INTERFACECONFIGURATION_TOOL )
+ {
+ onInterfaceConfigurationFrame();
+ }
+ else if( toolCommand == wxContour_ActionCommandsID::TEST_TOOL )
+ {
+ onInterfaceTestFrame();
+ }
+
+
+ }
+
+
+ //------------------------------------------------------------------------------------------------------------
+ // Getting information methods
+ //------------------------------------------------------------------------------------------------------------
+
+
+
+ //------------------------------------------------------------------------------------------------------------
+ // Private methods
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler :: updateInstantOutlines()
+ {
+ std::vector<NameWrapper *> namesWrapping = _modelManager->getActualInstantOutlines();
+ int size = namesWrapping.size();
+ _theViewPanel->getSceneManager()->removeSceneContours();
+ for( int i=0; i<size; i++)
+ {
+ _theViewPanel->getSceneManager()->addToScene(namesWrapping[i]->getKeyName(), true, true, true, false, false );
+ }
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: updateInstantImageData()
+ {
+ wxContourMainFrame * instance = wxContourMainFrame::getInstance();
+ if(instance != NULL){
+ int val;
+ std::string conceptname;
+ val = _instantPanel->getConceptValue(conceptname);
+
+ if(conceptname.compare("time")==0){
+ std::vector<vtkImageData*> imgvect = instance->getVectImages();
+ for(int i = 0; i < imgvect.size(); i++){
+ //_instantPanel->getI
+ }
+ //ImageSourceThing* imgsoth = new ImageSourceThing();
+ //_modelManager->addImageSource(
+ }
+ }
+ }
+ //------------------------------------------------------------------------------------------------------------
+
+ void wxContourEventHandler :: updateInstantAxes()
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: changeInstant()
+ {
+ std::vector<int> instantVect;
+ _instantPanel->getInstant( instantVect );
+ Instant * theInstant = new Instant ( &instantVect );
+ //if( !theInstant->isEquals( _actualInstant ))
+ {
+ //Setting the actual instant
+ _actualInstant = theInstant;
+ _modelManager->setInstant( _actualInstant );
+
+ updateInstantOutlines();
+ updateInstantImageData();
+ updateInstantAxes();
+
+
+ //Searching the elements at the specified instant
+
+ /*
+ std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
+ iter = contours_ViewControl->find("Outline 0");
+ (iter->second)->getViewer()->RemoveCompleteContourActor();*/
+ }
+ }
+
+ void wxContourEventHandler :: saveState(){
+
+
+ inredo = 0;
+
+ //char str[9000];
+ //itoa(inundo, str, 10);
+ std::string str = intToString(inundo);
+
+
+ std::string temp = stundoredo + str + ".roi";
+ saveFileWithContours(temp);
+
+ inundo++;
+ }
+
+ void wxContourEventHandler ::loadState(std::string filename){
+
+ char tmp[255];
+ FILE *pFile=fopen(filename.c_str(),"r+");
+
+ fscanf(pFile,"%s",tmp); // --CreaContour--
+
+ fscanf(pFile,"%s",tmp); // Version
+ fscanf(pFile,"%s",tmp); // 1.0.1
+ std::string version(tmp);
+
+ deleteAllContours();
+
+ openContours(pFile,false);
+ if (version!="1.0.0"){
+ openContours(pFile,true);
+ }
+
+ fclose(pFile);
+
+ //_theViewPanel->getSceneManager()->removeSceneContours();
+ //changeInstant();
+
+ }
+void wxContourEventHandler :: onREDO()
+ {
+ if(inredo > 0){
+ inredo--;
+ inundo++;
+
+ //char str[9000];
+ //itoa(inundo, str, 10);
+ std::string str = intToString(inundo);
+
+
+ std::string temp = stundoredo + str + ".roi";
+
+ loadState(temp);
+
+
+ }
+
+ }
+ //------------------------------------------------------------------------------------------------------------
+ void wxContourEventHandler :: onUNDO()
+ {
+ if(inundo>0){
+ if(inredo==0){
+
+ //char str[9000];
+ //itoa(inundo, str, 10);
+ std::string str = intToString(inundo);
+
+ std::string temp = stundoredo + str + ".roi";
+ saveFileWithContours(temp);
+
+ }
+ inredo++;
+ inundo--;
+
+ //char str[9000];
+ //itoa(inundo, str, 10);
+ std::string str = intToString(inundo);
+
+
+ std::string temp = stundoredo + str + ".roi";
+
+ loadState(temp);
+ }
+ }
+//JCP 21 - 10 - 09
+ void wxContourEventHandler :: getValuesXYZ(double **vectx, double **vecty, double **vectz, std::vector<int>* size){
+
+
+ wxBusyCursor wait;
+ ContourExtractData *contourextractdata = new ContourExtractData();
+ int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
+ contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
+
+ std::vector<manualContourModel*> lstManConMod;
+ std::vector<manualContourModel*> lstManConModTmp;
+ std::vector<manualContourModel*> lstManConModExp;
+ std::vector<double> pLstValue;
+ std::vector<double> pLstValuePosX;
+ std::vector<double> pLstValuePosY;
+ std::vector<double> pLstValuePosZ;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ int z;
+ int ii,sizeLstContourThings;
+
+
+ int minZ,maxZ;
+ double totalZ;
+ double porcent;
+ wxString tmpString;
+ minZ = 0;// _mbarrange->GetStart();
+ maxZ = sizeZ;//_mbarrange->GetEnd();
+ totalZ = maxZ-minZ+1;
+
+ contourextractdata->SetImage( imagedata);
+
+ // For each slice..
+ vectx = new double *[sizeZ];
+ vecty = new double *[sizeZ];
+ vectz = new double *[sizeZ];
+ for ( z=0 ; z<sizeZ ; z++)
+ {
+
+ porcent = 100.0* (z-minZ)/totalZ;
+
+ //Extraction data from contours of each slice
+ contourextractdata->SetZtoBeAnalys( z);
+
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
+ sizeLstContourThings = lstContourThings.size();
+
+ lstManConMod.clear();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ lstManConMod.push_back( (*contourthing)->getModel() );
+ }
+ lstManConModExp = ExploseEachModel( lstManConMod );
+
+
+//EED004
+
+ int iContourGroup,sizeContourGroup;
+ if (typeContourGroup==3) // contour separete
+ {
+ sizeContourGroup=lstManConModExp.size();
+ } else { // contour AND OR XOR
+ sizeContourGroup=1;
+ }
+
+ for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
+ lstManConModTmp.clear();
+ if (typeContourGroup==3) // contour separete
+ {
+ lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
+ } else { // contour AND OR XOR
+ lstManConModTmp = lstManConModExp;
+ }
+
+ contourextractdata->SetLstManualContourModel( lstManConModTmp );
+
+ pLstValue.clear();
+ pLstValuePosX.clear();
+ pLstValuePosY.clear();
+ pLstValuePosZ.clear();
+ contourextractdata->GetValuesInsideCrown( &pLstValue,
+ &pLstValuePosX,
+ &pLstValuePosY,
+ &pLstValuePosZ);
+
+
+ int iLstValue,sizeLstValue=pLstValue.size();
+
+ //We initialize the pointers
+ size->push_back(sizeLstValue);
+ vectx[sizeZ] = new double[sizeLstValue];
+ vecty[sizeZ] = new double[sizeLstValue];
+ vectz[sizeZ] = new double[sizeLstValue];
+
+ for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
+ {
+
+ vectx[sizeZ][iLstValue] = pLstValuePosX[iLstValue];
+ vecty[sizeZ][iLstValue] = pLstValuePosY[iLstValue];
+ vectz[sizeZ][iLstValue] = pLstValuePosZ[iLstValue];
+
+ }
+ //The size of the contour is saved
+
+
+
+ //fclose(pFile);
+ } // for iContourGroup
+ } // for z
+ //_staticTextInformation->SetLabel( _T("") );
+ delete contourextractdata;
+
+ }
+
+
+ void wxContourEventHandler :: getMaskValue(vtkImageData* mask, vtkImageData* value){
+
+
+ wxBusyCursor wait;
+ ContourExtractData *contourextractdata = new ContourExtractData( true );
+ int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
+ if (typeContourGroup==3)
+ {
+ typeContourGroup=1;
+ }
+ contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
+
+ std::vector<manualContourModel*> lstManConMod;
+ std::vector<manualContourModel*> lstManConModTmp;
+ std::vector<manualContourModel*> lstManConModExp;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ int z;
+ int ii,sizeLstContourThings;
+
+
+ int minZ,maxZ;
+ double totalZ;
+ double porcent;
+
+ wxString tmpString;
+
+ minZ = 0;// _mbarrange->GetStart();
+ maxZ = sizeZ;//_mbarrange->GetEnd();
+ totalZ = maxZ-minZ+1;
+
+ contourextractdata->SetImage( imagedata);
+
+ // For each slice..
+ for ( z=0 ; z<sizeZ ; z++)
+ {
+
+ porcent = 100.0* (z-minZ)/totalZ;
+ tmpString.Printf(_T("Saving Values"));
+ tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
+ _staticTextInformation->SetLabel(tmpString);
+
+ //Extraction data from contours of each slice
+ contourextractdata->SetZtoBeAnalys( z);
+
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
+ sizeLstContourThings = lstContourThings.size();
+
+ lstManConMod.clear();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ lstManConMod.push_back( (*contourthing)->getModel() );
+ }
+ lstManConModExp = ExploseEachModel( lstManConMod );
+
+
+ int iContourGroup,sizeContourGroup;
+ if (typeContourGroup==3) // contour separete
+ {
+ sizeContourGroup=lstManConModExp.size();
+ } else { // contour AND OR XOR
+ sizeContourGroup=1;
+ }
+
+ for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
+ lstManConModTmp.clear();
+ if (typeContourGroup==3) // contour separete
+ {
+ lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
+ } else { // contour AND OR XOR
+ lstManConModTmp = lstManConModExp;
+ }
+
+ contourextractdata->SetLstManualContourModel( lstManConModTmp );
+
+
+ contourextractdata->CalculateImageResult(); // with actual Z
+
+ } // for iContourGroup
+ } // for z
+
+
+
+// Image Value
+ value = contourextractdata->GetVtkImageValueResult();
+
+// Image Mask
+ mask = contourextractdata->GetVtkImageMaskResult();
+
+ delete contourextractdata;
+
+
+ }
+ wxPanel* wxContourEventHandler::getSegmentationPanelITK(wxWindow* parent){
+
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ double range[2];
+ _theViewPanel->getSceneManager()->GetImageDataRange(range);
+
+ wxPanel *panel = new wxPanel(parent,-1);
+ wxButton *segmentationOneSliceBtn = new wxButton(panel,-1,_T("Actual slice"), wxDefaultPosition, wxSize(200,35) );
+ wxButton *segmentationAllSliceBtn = new wxButton(panel,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
+ _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ wxString lstOptions[3];
+ lstOptions[0]=_T("A");
+ lstOptions[1]=_T("B");
+ lstOptions[2]=_T("C");
+ methodRadiobox = new wxRadioBox(panel, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
+ methodRadiobox->SetSelection(2);
+ _staticTextSegmentation = new wxStaticText(panel,-1,_T(" "));
+
+
+ _mbarrange = new mBarRange(panel,70, 65);
+ _mbarrange->SetMin(0);
+ _mbarrange->SetStart(0);
+
+ _mbarrange-> SetOrientation( true );
+ _mbarrange-> setActiveStateTo(true);
+ _mbarrange-> setVisibleLabels( true );
+ _mbarrange-> setDeviceEndMargin(10);
+ _mbarrange-> setRepresentedValues( 0 , sizeZ );
+ _mbarrange-> setDeviceBlitStart(10,10);
+ _mbarrange-> setIfWithActualDrawed( false );
+ _mbarrange-> SetStart( 0 );
+ _mbarrange-> SetEnd( sizeZ );
+
+
+// _segmentationFrame->SetEventHandler( this );
+ segmentationOneSliceBtn->SetEventHandler( this );
+ segmentationAllSliceBtn->SetEventHandler( this );
+ Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationOneSliceITK );
+ Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationAllSliceITK );
+
+ wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
+ sizer -> Add( new wxStaticText(panel,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
+ sizer -> Add( _isovalue , 1, wxGROW );
+ sizer -> Add( methodRadiobox , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T("Sampling (%)")) , 1, wxGROW );
+ sizer -> Add( _sampling , 1, wxGROW );
+ sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
+ sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( _staticTextSegmentation , 1, wxGROW );
+ sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
+ sizer -> Add( _mbarrange , 1, wxGROW );
+
+ panel->SetSizer( sizer );
+// panel->SetSize( sizePanel );
+ panel->SetSize( wxDefaultSize );
+ panel->SetAutoLayout( true );
+ panel->Layout();
+
+ return panel;
+
+ }
+
+ void wxContourEventHandler::onSegmentationAllSliceITK( wxCommandEvent& event ){
+ //TODO implementar el método para todos los slices ver ayuda en onSegmentationAllSlice
+ }
+ void wxContourEventHandler::onSegmentationOneSliceITK( wxCommandEvent& event ){
+ //TODO implementar el método de segmentación en ITK ver ayuda en onSegmentationOneSlice y el método
+ // SegmentationOneSlice(x, y, z) que es la implementación del método en VTK
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ wxBusyCursor wait;
+ int x = this->_theViewPanel->GetX();
+ int y = this->_theViewPanel->GetY();
+ int z = this->_theViewPanel->GetZ();
+ //SegmentationOneSlice( x,y,z );
+ RefreshInterface();
+ }
+ void wxContourEventHandler::onSnakePressed(wxWindow* parent){
+
+ std::vector<double> vecX;
+ std::vector<double> vecY;
+ std::vector<double> vecZ;
+ _theViewPanel->getSceneManager()->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
+
+ if (vecX.size()!=0){
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ int i,size=vecZ.size();
+ int actualSlice = tempVector[1];
+ for ( i=0 ; i<size ; i++ )
+ {
+ vecZ[i] = actualSlice;
+ } // for
+
+ wxDialog* dialog = new wxDialog(parent, -1, wxString(_T("Snake")));
+ wxPanel* panel = new wxPanel(dialog,-1);
+ wxStaticText* sttext = new wxStaticText(panel, -1, wxString(_T("Panel para snake")));
+ dialog->ShowModal();
+ } // if
+
+ }
+
+ void wxContourEventHandler::checkInformationPanel(){
+ if (_InformationContourFrame==NULL){
+ onInformationContourFrame();
+ _InformationContourFrame->Show(false);
+ }
+ }
+
+ std::string wxContourEventHandler::intToString(int num){
+ std::string result;
+ if(num == 0){
+ result = "0";
+ }else{
+ int k=num;
+ while (k > 0){
+ char temp = k % 10 + 48;
+ k = k / 10;
+ result = temp + result;
+ }
+ }
+ return result;
+ }
+//JCP 21 - 10 - 09
+
+
--- /dev/null
+#ifndef __wxContourEventHandler_h_INCLUDED_H__
+#define __wxContourEventHandler_h_INCLUDED_H__
+
+
+// -----------------------------------------------------------------------------------------------------------
+// WX headers inclusion.
+// For compilers that support precompilation, includes <wx/wx.h>.
+// -----------------------------------------------------------------------------------------------------------
+
+#include <wx/wxprec.h>
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
+#include <wx/grid.h>
+
+#include <sstream>
+//------------------------------------------------------------------------------------------------------------
+// Includes
+//------------------------------------------------------------------------------------------------------------
+#include <wxContourViewPanel.h>
+#include "wxContourMainFrame.h"
+#include <vtkImageData.h>
+#include "OutlineModelManager.h"
+#include "ContourWorkspace.h"
+#include "wxInstantChooserPanel.h"
+#include "wxContour_ButtonsBar.h"
+#include "wxContour_Grid.h"
+#include "wxContour_DrawToolsPanel.h"
+#include "wxContour_OperationsToolsPanel.h"
+#include "wxContour_AutomaticFormsToolsPanel.h"
+#include "wxContour_StandardToolsPanel.h"
+#include "wxContour_EdtionToolsPanel.h"
+#include "wxContour_ListViewPanel.h"
+#include "wxContour_ActionCommandsID.h"
+
+#include "PerformingOperation.h"
+
+#include "ContourThing.h"
+#include "AxeThing.h"
+#include "ImageSourceThing.h"
+#include "ImageSectionThing.h"
+#include "InstantMembersNameList.h"
+#include "OutlineGroup.h"
+#include "SomeEnvironment.h"
+#include "ContourWorkspace.h"
+#include "ContourWrap_ViewControl.h"
+#include "Instant.h"
+
+#include "wxVtkBaseView_SceneManager.h"
+
+
+#include "Contour/ContourPropagation.h"
+#include "mBarRange.h"
+
+#include "PanelBullEyeOptions.h"
+
+/** file wxContourEventHandler.h */
+
+
+/*
+class PanelBullEyeOptions : public wxPanel {
+public:
+ PanelBullEyeOptions(wxWindow* parent, wxSize size);
+ ~PanelBullEyeOptions ();
+ void onRefreshPanel( wxCommandEvent& event );
+ int GetNumberOfCrowns();
+ int GetNumberOfSections(int nCrown);
+ int GetRadioOfCrown(int nCrown);
+ double GetAngOfCrownSection(int nCrown,int section);
+ double GetAngDeltaOfCrownSection(int nCrown);
+protected:
+
+private:
+ int _maxLevels;
+ int _maxSections;
+ wxRadioBox *_radioboxBullEyeGenOpt;
+ wxSpinCtrl *_spinctrlBullEyeNumOfCrowns;
+ wxSpinCtrl *_spinctrlBullEyeNumOfSec;
+ wxSlider *_sliderBullEyeAngle;
+ std::vector<wxSpinCtrl *> _lstBullEyeDetailNumOfSec;
+ std::vector<wxSlider *> _lstBullEyeDetailRadio;
+ std::vector<wxSlider *> _lstBullEyeDetailAngle;
+
+
+
+
+ void RefreshPanel();
+};*/
+
+
+
+
+//------------------------------------------------------------------------------------------------------------
+// Class definition
+//------------------------------------------------------------------------------------------------------------
+class wxContourEventHandler : public wxEvtHandler {
+
+ public:
+
+ //------------------------------------------------------------------------------------------------------------
+ // Constructors & Destructors
+ //------------------------------------------------------------------------------------------------------------
+ wxContourEventHandler();
+ ~wxContourEventHandler();
+
+ //------------------------------------------------------------------------------------------------------------
+ // Configuration methods
+ //------------------------------------------------------------------------------------------------------------
+ bool configureEventsHandling();
+
+ //------------------------------------------------------------------------------------------------------------
+ // Methods for capturing events
+ //------------------------------------------------------------------------------------------------------------
+ void onProcessMessage( wxCommandEvent& event );
+ void onActionButtonPressed( wxCommandEvent& event );
+ void onChangedDeep ( wxCommandEvent& event );
+ void onChangeInstant( wxCommandEvent& event );
+ void onCreateMultipleROI( wxCommandEvent& event );
+ void onSelectMultipleROI( wxCommandEvent& event );
+ void onCreateROI( wxCommandEvent& event );
+ void onStopCreateROI( wxCommandEvent& event );
+ void onDeleterROI( wxCommandEvent& event );
+ void onSelectROI( wxCommandEvent& event );
+ void onUnSelectROI( wxCommandEvent& event );
+ void onManualHidedROI( wxCommandEvent& event );
+ void onManualShowedROI( wxCommandEvent& event );
+ void onEditingROI( wxCommandEvent& event );
+ void onMovingROI( wxCommandEvent& event );
+
+ //------------------------------------------------------------------------------------------------------------
+ // Model management methods
+ //------------------------------------------------------------------------------------------------------------
+
+ void createCopyContourOf( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append = false );
+ void createContour( int typeContour=1 );
+ void deleteContour( std::string theKeyName );
+ void deleteContours( std::vector<std::string> keyNamesVector );
+ void deleteAllContours( );
+ void openContours( FILE *pFile, bool staticContour );
+ void openFileWithContours();
+ void saveFileWithContours();
+ void saveFileWithContours( std::string filename );
+ void saveFileWithContoursAutomatique();
+ void onSpread( );
+ void onSpreadInDepth( std::vector<std::string> & keyNamesVector );
+ void onAutomatiqueSegmentation( );
+ void onOutline_Union_Of( std::vector<std::string> & keyNamesVector );
+ void onOutline_Intersection_Of( std::vector<std::string> & keyNamesVector );
+ void onOutline_Combination_Of( std::vector<std::string> & keyNamesVector );
+ void onOutline_Fragmentation_Of( std::vector<std::string> & keyNamesVector );
+ void onOutline_Agrupation_Of( std::vector<std::string> & keyNamesVector );
+ void onCopyOutlines( std::vector<std::string> & keyNamesVector );
+ void onPasteOutlines( );
+ void onShowOutlines( std::vector<std::string> & keyNamesVector );
+ void onHideOutlines( std::vector<std::string> & keyNamesVector );
+ void onSelectOutlines( std::vector<std::string> & keyNamesVector );
+ void onEditOutlines( std::vector<std::string> & keyNamesVector );
+ void onREDO();
+ void onUNDO();
+ void changeContourOfManager(std::string keyName, Instant *instant);
+ void changeContoursOfManager(std::vector<std::string> & keyNamesVector);
+
+
+ //------------------------------------------------------------------------------------------------------------
+ // Attributes getters and setters
+ //------------------------------------------------------------------------------------------------------------
+ void setModelManager( OutlineModelManager * theModelManager );
+ void setViewPanel( wxContourViewPanel* theViewPanel );
+ void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
+ void setButtonsBar( wxContour_ButtonsBar * theButtonsBar );
+ void setGrid( wxContour_Grid * theGridPanel );
+ void setDrawToolsPanel( wxContour_DrawToolsPanel * theDrawToolsPanel );
+ void setOperationsToolsPanel( wxContour_OperationsToolsPanel * theDrawToolsPanel );
+ void setAutomaticFormsPanel( wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel );
+ void setStandardToolsPanel( wxContour_StandardToolsPanel * theStandardToolsPanel );
+ void setEditionToolsPanel( wxContour_EdtionToolsPanel * theEditionToolsPanel );
+ void setListViewPanel( wxContour_ListViewPanel * theListViewPanel );
+
+ //------------------------------------------------------------------------------------------------------------
+ // Other functional methods
+ //------------------------------------------------------------------------------------------------------------
+ void executeActionCommand( const char toolCommand );
+
+ //------------------------------------------------------------------------------------------------------------
+ // Getting information methods
+ //------------------------------------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------
+ // Responding Spread Tools
+ //------------------------------------------------------------------------------------------------------------
+ void onSpreadReset( wxCommandEvent& event );
+ void onSpreadAdd( wxCommandEvent& event );
+ void onSpreadGo( wxCommandEvent& event );
+
+ void onSegmentationAllSlice( wxCommandEvent& event );
+ void onSegmentationOneSlice( wxCommandEvent& event );
+ void SegmentationOneSlice( int x, int y, int z );
+
+
+ void onTest( wxCommandEvent& event );
+ void onTestReset( wxCommandEvent& event );
+ void onTestAdd( wxCommandEvent& event );
+ void onTestGo( wxCommandEvent& event );
+
+
+ void onCreateContourSpline( wxCommandEvent& event );
+ void onCreateContourRectangle( wxCommandEvent& event );
+ void onCreateContourCircle( wxCommandEvent& event );
+ void onCreateContourBullEye( wxCommandEvent& event );
+ void onCreateContourFrame( );
+ void onDeleteFrame( );
+ void onDeleteContour( wxCommandEvent& event );
+ void onDeleteContoursActSlice( wxCommandEvent& event );
+ void onDeleteAllContours( wxCommandEvent& event );
+ void onInformationContourFrame();
+ void onInformationContourLabels( wxCommandEvent& event );
+ void onExtractInformation( wxCommandEvent& event );
+ void onSaveResults( wxCommandEvent& event );
+ void onInterfaceConfigurationFrame();
+ void onWidthOfContour(wxScrollEvent& event);
+ void onBrigthnessColorWindowLevel(wxScrollEvent& event);
+ void OnInterpolation(wxCommandEvent& event);
+
+ void onInterfaceTestFrame();
+
+ void SaveValuesXYZ(std::string directory,std::string namefile);
+ void SaveImageResult(std::string directory,std::string namefile);
+
+/**
+** JCP 13-10-08 This methods group the diferent kind of panels
+**/
+ wxPanel* getInformationPanel(wxWindow* parent);
+ wxPanel* getConfigurationPanel(wxWindow* parent);
+ wxPanel* getSegmentationPanel(wxWindow* parent);
+ wxPanel* getSegmentationPanelITK(wxWindow* parent);
+ wxPanel* getSpreadPanel(wxWindow* parent);
+ void onSegmentationAllSliceITK( wxCommandEvent& event );
+ void onSegmentationOneSliceITK( wxCommandEvent& event );
+ void onSnakePressed(wxWindow* parent);
+
+ void showAxis(bool show);
+//JCP 13-10-09 Fill grid as public
+ void FillGridWithContoursInformation();
+//JCP 13-10-09
+//JCP 16-10-09
+ void createContourBullsEye(PanelBullEyeOptions* panel );
+
+ //void getValuesXYZ(std::vector<double *>* vectx, std::vector<double*>* vecty, std::vector<double*>* vectz, std::vector<int>* size);
+//JCP 22-10-09
+ /**
+ ** This method gets the information of the contours in each slice
+ **/
+ void getValuesXYZ(double ** vectx, double ** vecty, double ** vectz, std::vector<int>* size);
+ /**
+ ** This method gets the mask and value images generated by the contours
+ **/
+ void getMaskValue(vtkImageData* mask, vtkImageData* value);
+ /**This Method checks for the information panel, it initalizes all the values
+ ** in the controls so they can be retreived
+ **/
+ void checkInformationPanel();
+//JCP 22-10-09
+
+//JCP 16-10-09
+
+
+private:
+ //------------------------------------------------------------------------------------------------------------
+ // Private methods
+ //------------------------------------------------------------------------------------------------------------
+ void updateInstantOutlines();
+ void updateInstantImageData();
+ void updateInstantAxes();
+ void changeInstant();
+ void RefreshInterface();
+
+ // EED
+//JCP 13-10-09 must be a public method
+ //void FillGridWithContoursInformation();
+//JCP 13-10-09
+ manualContourModel * factoryManualContourModel(int typeContour);
+ manualContourModel * factoryManualContourModel(PanelBullEyeOptions* panel);
+ std::vector<manualContourModel*> ExploseEachModel( std::vector<manualContourModel*> lstManConMod );
+
+ //------------------------------------------------------------------------------------------------------------
+ // Attributtes
+ //------------------------------------------------------------------------------------------------------------
+
+ wxContourViewPanel* _theViewPanel;
+ OutlineModelManager * _modelManager;
+ ContourWorkspace * _workSpace;
+ wxInstantChooserPanel * _instantPanel;
+ wxContour_ButtonsBar * _buttonsBar;
+
+ wxVtkBaseView_SceneManager * _sceneManager;
+
+ Instant * _actualInstant;
+ wxContour_Grid * _gridPanel;
+ wxContour_DrawToolsPanel * _drawToolsPanel;
+ wxContour_OperationsToolsPanel * _operationsToolsPanel;
+ wxContour_AutomaticFormsToolsPanel * _autoFormsPanel;
+ wxContour_StandardToolsPanel * _standardToolsPanel;
+ wxContour_EdtionToolsPanel * _editionToolsPanel;
+ wxContour_ListViewPanel * _listViewPanel;
+
+ /*DECLARE_CLASS(wxContourMainFrame)
+ // any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()*/
+ bool _creatingContoursActive;
+ PerformingOperation * _performingOperation;
+
+ // Interface EED
+ wxFrame *_spreadFrame;
+ wxFrame *_segmentationFrame;
+ wxFrame *_createContourFrame;
+ wxFrame *_deleteFrame;
+ wxFrame *_InformationContourFrame;
+ wxFrame *_interfaceConfigurationFrame;
+ wxFrame *_TestFrame;
+ wxTextCtrl * _wxtextctrlTest;
+
+ std::string fileNameContourROI;
+
+ wxRadioBox *methodRadiobox;
+ ContourPropagation *_contourPropagation;
+ wxSlider *_isovalue;
+ wxSlider *_sampling;
+ wxStaticText *_staticTextSegmentation;
+ mBarRange *_mbarrange;
+ wxTextCtrl *_wxtextctrlSpread;
+ wxRadioBox *_informationRadiobox;
+ wxListCtrl *_wxlistctrl;
+ wxGrid *_grid;
+ wxStaticText *_staticTextInformation;
+ mBarRange *_mbarrangeSliceInformation;
+ mBarRange *_mbarrangeRangeInformation;
+ wxSlider *_withOfContourLine;
+ wxSlider *_brithtnessWindowLevel;
+ wxSlider *_brithtnessColorLevel;
+ mBarRange *_mbarrangeDeleteAll;
+ wxCheckBox *_interpolationCheckBox;
+ wxRadioBox *_spreadMethodRadiobox;
+ wxRadioBox *_radiolstboxContourGroup;
+ wxStaticText *_staticTextSpread;
+ PanelBullEyeOptions *_panelBullEyeOptions;
+ int _numberOfVariablesStatistics;
+
+ int inundo;
+ int inredo;
+ std::string stundoredo;
+
+ void saveState();
+ void loadState(std::string filename);
+
+ std::string intToString(int num);
+};
+#endif // __wxContourEventHandler_HEADER_FILE__
//----------------------------------------------------------------------------------------------------------------
#include "wxContourMainFrame.h"
+
+
//----------------------------------------------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------------------------------------------
#include "ConceptDataWrap.h"
#include <manualContour.h>
-#include "ImageSourceThing.h"
-#include "vtkImageData.h"
-#include "wxContour_ActionCommandsID.h"
+//#include "ImageSourceThing.h"
+//#include "wxContour_ActionCommandsID.h"
+//#include "OutlineModelBuilder.h"
+//#include "wxContourEventHandler.h"
//----------------------------------------------------------------------------------------------------------------
// Class implementation
//------------------------------------------------------------------------------------------------------------
// Constructors & Destructors
//------------------------------------------------------------------------------------------------------------
+
+wxContourMainFrame* wxContourMainFrame:: instance = NULL;
+char wxContourMainFrame::COPY = 'C';
wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style)
//: wxPanel(parent, id, title, pos, size, style)
m_mgr.SetManagedWindow(this);
_creatingContoursActive = false;
_theViewPanel = NULL;
- _modelManager = NULL;
+// _modelManager = NULL;
+ _instantPanel = NULL;
+ _buttonsBar = NULL;
+ _gridPanel = NULL;
+ _drawToolsPanel = NULL;
+ _operationsToolsPanel = NULL;
+ _autoFormsPanel = NULL;
+ _standardToolsPanel = NULL;
+ _editionToolsPanel = NULL;
+ _listViewPanel = NULL;
+ _sceneManager = NULL;
+ //_actualInstant = NULL;
+ _numberOfVariablesStatistics = 6+1;
+
+ // set up default notebook style
+ m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
+ m_notebook_theme = 0;
+ //wxContour_ActionCommandsID a;
+
+ }
+
+wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style)
+ : wxPanel(parent, id, pos, size, style)
+ {
+ m_mgr.SetManagedWindow(this);
+ _creatingContoursActive = false;
+ _theViewPanel = NULL;
+// _modelManager = NULL;
_instantPanel = NULL;
_buttonsBar = NULL;
_gridPanel = NULL;
_editionToolsPanel = NULL;
_listViewPanel = NULL;
_sceneManager = NULL;
- _actualInstant = NULL;
+ //_actualInstant = NULL;
// set up default notebook style
m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
m_notebook_theme = 0;
- wxContour_ActionCommandsID a;
+ //wxContour_ActionCommandsID a;
+ _numberOfVariablesStatistics = 6+1;
+
+
+ _performingOperation = new PerformingOperation();
+//JCP 17 - 10 - 2008
+
+ inredo = 0;
+ inundo = 0;
+
+ kernelManager = new KernelManagerContour(images);
+ //kernelManager->setVectImages(images);
+ //kernelManager->initializeEnvironment();
+
+ //vtkImageData* selectedimage = kernelManager->getVectImages()[0];
+
+//-------------------------------------------------------------
+
+ /*frame = new wxContourMainFrame(_builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv(),NULL, wxID_ANY, wxT("ROI Application Sample"), wxPoint(50,50), wxSize(800, 600));
+ frame->Show(TRUE);*/
+
+ //Creating the evtHandler of the panels
+ //wxContourEventHandler * eventHandler = new wxContourEventHandler();
+
+ //Creating the window that will show the panels
+
+ //Getting the parent for the panels ( using aui )
+ wxAuiNotebook * notebook = this->createNotebook();
+
+ //JCP 17 - 11 - 08
+ //wxInstantChooserPanel * instantPanel = new wxInstantChooserPanel( notebook, "Instant Chooser", true);
+ //JCP 17 - 11 - 08
+ std::vector<std::string> conceptNameVect;
+ std::vector<int> conceptSizeVect;
+
+
+
+ _instantPanel = new wxInstantChooserPanel( notebook, "Instant Chooser", true, false, "c" );
+ _theViewPanel = new wxContourViewPanel( kernelManager->getSourceImage(), notebook );
+
+
+
+ kernelManager->getConceptsInformation(conceptNameVect, conceptSizeVect);
+ _instantPanel->addConcepts(conceptNameVect, conceptSizeVect);
+
+
+ double val = _theViewPanel->getCurrentDeep();
+ _instantPanel->setConceptValue( "Axe Depth", (int)val );
+ //JCP _instantPanel->setConceptValue("time", num de imagenes);
+ ConceptDataWrap * data = _instantPanel->getConceptDataOf( "Axe Depth" );
+ //*******************changeInstant();
+ _theViewPanel->setVerticalConcept( "Axe Depth", data->getMinValue(), data->getMaxValue(), data->getMinShowedValue(), data->getMaxShowedValue(), data->getActualValue() );
+
+ //eventHandler->setModelManager( kernelManager->getOutlineModelManager() );
+ //eventHandler->setViewPanel( _theViewPanel );
+ //_theViewPanel->initializeScenceManager();
+ //eventHandler->setInstantChooserPanel( _instantPanel );
+
+ //bool successConfiuration = eventHandler->configureEventsHandling();
+
+ //successConfiuration &= this->configurePanels( notebook );
+ this->configurePanels( notebook );
+
+ interfMainPanel* pannew = interfMainPanel::getInstance(parent);//, eventHandler);
+
+//JCP 17 -10 - 2008
+
+
+ }
+
+
+ wxContourMainFrame* wxContourMainFrame :: getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style ){
+ if(instance == NULL){
+ instance = new wxContourMainFrame(parent, id, title, pos, size, images, style);
+ }
+ return instance;
+ }
+
+ std::vector<vtkImageData*> wxContourMainFrame ::getVectImages(){
+ return kernelManager->getVectImages();
+ }
+ wxContourMainFrame* wxContourMainFrame :: getInstance(){
+ return instance;
+
}
wxContourMainFrame :: ~wxContourMainFrame()
//------------------------------------------------------------------------------------------------------------
- void wxContourMainFrame :: setViewPanel( wxContourViewPanel * theViewPanel )
- {
- _theViewPanel = theViewPanel;
- }
-
+
void wxContourMainFrame :: setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel )
{
_instantPanel = theInstantChooserPanel;
_listViewPanel = theListViewPanel;
}
+
+
+void wxContourMainFrame::onCreateContourSpline( ){
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ createContour( 1 );
+
+}
+void wxContourMainFrame::onCreateContourRectangle( ){
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ createContour( 2 );
+}
+void wxContourMainFrame::onCreateContourCircle( ){
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ createContour( 3 );
+}
+//------------------------------------------------------------------------------------------------------------
+
+void wxContourMainFrame :: onCreateContourBullEye(wxPanel* panel )
+{
+ //Creating the manualContourModel and including in the model
+ manualContourModel * manModelContour = factoryManualContourModel(panel );
+
+ std::vector<int> instantVector;
+ _instantPanel->getInstant( instantVector );
+ std::string theName = kernelManager->createOutline(manModelContour, instantVector);
+
+ /*std::vector<int> instantVector;
+ _instantPanel->getInstant( instantVector );
+ std::string theName;
+ theName= _modelManager->createOutline( manModelContour, instantVector );*/
+ bool addedModel = theName.compare("") != 0;//??
+
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ _theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , 4) ;
+ }
+}
+void wxContourMainFrame :: createContour( int typeContour )
+{
+ //Creating the manualContourModel and including in the model
+ manualContourModel * manModelContour = kernelManager->factoryManualContourModel(typeContour);
+
+
+ std::vector<int> instantVector;
+ _instantPanel->getInstant( instantVector );
+ std::string theName = kernelManager->createOutline(manModelContour, instantVector);
+
+ /*std::vector<int> instantVector;
+ _instantPanel->getInstant( instantVector );
+ std::string theName;
+ theName= _modelManager->createOutline( manModelContour, instantVector );*/
+ bool addedModel = theName.compare("") != 0;//??
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ _theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeContour) ;
+ }
+
+}
+manualContourModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel){
+
+ manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
+ manualContourModel *manModelContour=NULL;
+ manModelContour = manModelContourBullEye;
+ if (panel!=NULL){
+ int iCrown,sizeCrowns,iSector,sizeSectors;
+ double radioA,radioB,ang,angDelta ;
+ sizeCrowns = ((PanelBullEyeOptions*)panel)->GetNumberOfCrowns();
+ for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
+ {
+ sizeSectors = ((PanelBullEyeOptions*)panel)->GetNumberOfSections(iCrown);
+ radioB = ((PanelBullEyeOptions*)panel)->GetRadioOfCrown(iCrown);
+ if (iCrown==sizeCrowns-1)
+ {
+ radioA = 0;
+ } else {
+ radioA = ((PanelBullEyeOptions*)panel)->GetRadioOfCrown(iCrown+1);
+ }
+ radioA=radioA/100.0;
+ radioB=radioB/100.0;
+ for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
+ {
+ ang = ((PanelBullEyeOptions*)panel)->GetAngOfCrownSection(iCrown,iSector);
+ angDelta= ((PanelBullEyeOptions*)panel)->GetAngDeltaOfCrownSection(iCrown);
+ manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
+ } // for iSector
+ } // for iCrown
+ } // if _panelBullEyeOptions
+
+ return manModelContour;
+}
+void wxContourMainFrame :: saveState(){
+
+ std::string temp = kernelManager->saveState();
+ saveFileWithContours(temp);
+}
+
+void wxContourMainFrame::onDeleteContour(){
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ std::vector<std::string> lstKeyNameToBeErase;
+ lstKeyNameToBeErase = _theViewPanel->getSceneManager()->getSelectedObjects();
+ deleteContours( lstKeyNameToBeErase );
+/*JCP 19 - 11 - 08
+ int i,size=_sceneManager->getSelectedObjects().size();
+ for(i=0;i<size;i++)
+ {
+ std::string keyName = _sceneManager->getSelectedObjects()[i];
+ int ispartofstaticlist = this->_modelManager->IsPartOfStaticList( keyName );
+ if ( ispartofstaticlist>=0 )
+ {
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ Instant instant(&tempVector);
+ this->_modelManager->ChangeContourOfList(keyName, &instant);
+ }
+ }
+
+ std::vector<std::string> lstKeyName;
+ std::vector<std::string> lstKeyNameActualSlice;
+ std::vector<std::string> lstKeyNameToBeErase;
+
+ lstKeyNameToBeErase = _sceneManager->getSelectedObjects();
+ lstKeyNameActualSlice = _sceneManager->GetlstContoursNameActualSlice();
+ int k,kSize=lstKeyNameToBeErase.size();
+ int j,jSize=lstKeyNameActualSlice.size();
+ bool ok;
+ for (k=0;k<kSize; k++)
+ {
+ ok=false;
+ for (j=0;j<jSize; j++)
+ {
+ if (lstKeyNameToBeErase[k]==lstKeyNameActualSlice[j])
+ {
+ ok=true;
+ }
+ } // for j
+ if (ok==true)
+ {
+ lstKeyName.push_back( lstKeyNameToBeErase[k] );
+ } // if ok
+ } // for k
+
+ deleteContours( lstKeyName );
+JCP 19 - 11 - 08*/
+}
+
+void wxContourMainFrame :: deleteContours( std::vector<std::string> keyNamesVector )
+{
+ int i,size=keyNamesVector.size();
+ for (i=0;i<size;i++)
+ {
+ deleteContour( keyNamesVector[i] );
+ }
+}
+
+void wxContourMainFrame :: deleteContour( std::string theKeyName ){
+ /*manualContourModel * cModel;
+ manualViewBaseContour * cViewer;
+ manualContourBaseControler * cControler;
+
+ ContourWrap_ViewControl *conwrapviewControl = _theViewPanel->getSceneManager()->getContourWrap_ViewControlOf( theKeyName );
+ cControler = conwrapviewControl->getControler();*/
+
+ //JCP 21 - 11 - 2008
+ bool isedit = _theViewPanel->isEditableCControler(theKeyName);
+ bool ispartofstaticlst = kernelManager->IsPartOfStaticList(theKeyName);
+
+ if (isedit && ispartofstaticlst)
+ {
+ _theViewPanel->removeFromScene(theKeyName);
+
+ kernelManager->deleteCModel(theKeyName);
+ //_theViewPanel->getSceneManager()->removeFromScene( theKeyName );
+ //cViewer = conwrapviewControl->getViewer();
+ //_theViewPanel->getSceneManager()->removeWrap( theKeyName );
+ //cControler* conwrapviewControl->getControler();
+//EED Borrame
+//FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
+//fprintf(ff,"EED wxContourEventHandler::deleteContours() \n" );
+//fprintf(ff," %s %p\n",keyNamesVector[i].c_str(), cControler );
+//fclose(ff);
+ // delete cModel;
+ // delete cViewer;
+ // delete cControler;
+ } // if editable
+//JCP 21 - 11 - 08
+}
+
+void wxContourMainFrame::onDeleteContoursActSlice(){
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ deleteContours( (std::vector<std::string>)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() );
+}
+void wxContourMainFrame::onDeleteAllContours(){
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ deleteAllContours();
+}
+void wxContourMainFrame::deleteAllContours(){
+ //JCP 20-10-08 Undo redo implementation
+
+ wxBusyCursor wait;
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+//JCP --08-09-2008 When using a diferent interface the _mbarrangeDeleteAll might not be initialize
+// the values in GetStart and GetEnd will then not be initialize also.
+// We use instead the values given when initializing the _deletepanel.
+
+ //int minZ = _mbarrangeDeleteAll->GetStart();
+ //int maxZ = _mbarrangeDeleteAll->GetEnd();
+ int minZ, maxZ;
+
+ minZ = 0;
+ maxZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+
+//JCP --08-09-2008
+
+ _theViewPanel->getSceneManager()->removeSceneContours( );
+ _theViewPanel->getSceneManager()->removeAllOutlines();
+ kernelManager->removeAllOutlines();
+//JCP --08-09-2008
+ /*
+ if ( (minZ==0) && (maxZ==_mbarrangeDeleteAll->GetMax() ))
+ {
+ _theViewPanel->getSceneManager()->removeSceneContours( );
+ _modelManager->removeAllOutlines();
+ _theViewPanel->getSceneManager()->removeAllOutlines();
+
+ } else {
+ for ( z=minZ ; z<=maxZ ; z++)
+ {
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
+
+ sizeLstContourThings = lstContourThings.size();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ deleteContour( (*contourthing)->getName() );
+ } //for ii
+ }// for z
+ } // if
+JCP --08-09-2008 */
+}
+
+void wxContourMainFrame::setConceptValue( std::string name, int value ){
+ _instantPanel->setConceptValue(name, value);
+}
+
+ConceptDataWrap* wxContourMainFrame::getLastConceptData(){
+ return _instantPanel->getLastConceptData();
+}
+bool wxContourMainFrame::getIfConceptCheckedAt( std::string name, int pos ){
+ return _instantPanel->getIfConceptCheckedAt( name, pos );
+}
+
+void wxContourMainFrame::changeInstant(){
+ std::vector<int> instantVect;
+ _instantPanel->getInstant( instantVect );
+// Instant * theInstant = new Instant ( &instantVect );
+
+ //Setting the actual instant
+ //_actualInstant = theInstant;
+
+ kernelManager->setInstant(instantVect);
+ //_modelManager->setInstant( _actualInstant );
+
+ updateInstantOutlines();
+ updateInstantImageData();
+ updateInstantAxes();
+
+
+}
+void wxContourMainFrame :: updateInstantOutlines(){
+
+ _theViewPanel->removeSceneContours();
+ _theViewPanel->addNameWrapperToScene();
+
+ //for( int i=0; i<size; i++)
+ //{
+ // _theViewPanel->getSceneManager()->addToScene(namesWrapping[i]->getKeyName(), true, true, true, false, false );
+ //}
+}
+
+int wxContourMainFrame::getNamesWrappingSize(){
+ return kernelManager->getNamesWrappingSize();
+}
+std::string wxContourMainFrame::getNameWrapping(int i){
+ return kernelManager->getNameWrapping(i);
+}
+
+void wxContourMainFrame::updateInstantImageData(){
+ std::vector<int> inst;
+ _instantPanel->getInstant(inst);
+
+ vtkImageData* img = kernelManager->getImageAtInstant(inst);
+ if(img!=NULL){
+ _theViewPanel->changeImage(img);
+ }
+}
+void wxContourMainFrame::updateInstantAxes(){
+}
+
+void wxContourMainFrame::onChangeDeep(int val){
+ _instantPanel->setConceptValue( "Axe Depth", (int)val );
+ changeInstant();
+}
+
+
+void wxContourMainFrame::onCopy(){
+ std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ _performingOperation->reset();
+ _performingOperation->setStartCommand( COPY );
+ _performingOperation->setStartOperationInstantVector( tempVector );
+ _performingOperation->setKeyNamesOperationElems( currentSelection );
+}
+void wxContourMainFrame::onPaste(){
+
+
+ char theStartCommand = _performingOperation->getStartCommand();
+ if ( theStartCommand == COPY )
+ {
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ _performingOperation->setEndOperationInstantVector ( tempVector );
+ std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
+ int i,size = elems.size();
+ for( i=0; i<size; i++ )
+ {
+ createCopyContourOf( elems[i], tempVector, i>0 );
+ }
+ }
+}
+void wxContourMainFrame::onUndo(){
+ std::string filename;
+ if(kernelManager->onUndoSaveFile(filename)){
+ saveFileWithContours(filename);
+ }
+ if(kernelManager->onUndo(filename)){
+ loadState(filename);
+ }
+}
+void wxContourMainFrame::onRedo(){
+ std::string filename;
+ if(kernelManager->onRedo(filename)){
+ loadState(filename);
+ }
+
+}
+void wxContourMainFrame :: createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append ){
+ std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
+ manualContourModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel();
+ _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
+}
+
+void wxContourMainFrame ::loadState(std::string filename){
+ char tmp[255];
+ FILE *pFile=fopen(filename.c_str(),"r+");
+
+ fscanf(pFile,"%s",tmp); // --CreaContour--
+
+ fscanf(pFile,"%s",tmp); // Version
+ fscanf(pFile,"%s",tmp); // 1.0.1
+ std::string version(tmp);
+
+ deleteAllContours();
+
+ openContours(pFile,false);
+ if (version!="1.0.0"){
+ openContours(pFile,true);
+ }
+
+ fclose(pFile);
+
+ //_theViewPanel->getSceneManager()->removeSceneContours();
+ //changeInstant();
+
+}
+
+void wxContourMainFrame::onLoad(){
+ char tmp[255];
+ wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN );
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
+ FILE *pFile=fopen(fileNameContourROI.c_str(),"r+");
+
+ fscanf(pFile,"%s",tmp); // --CreaContour--
+
+ fscanf(pFile,"%s",tmp); // Version
+ fscanf(pFile,"%s",tmp); // 1.0.1
+ std::string version(tmp);
+
+ openContours(pFile,false);
+ if (version!="1.0.0"){
+ openContours(pFile,true);
+ }
+// _theViewPanel->getSceneManager()->openFileWithContours(ff);
+
+ fclose(pFile);
+ }
+ _theViewPanel->getSceneManager()->removeSceneContours();
+ changeInstant();
+}
+void wxContourMainFrame::onSave(){
+ wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE );
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
+ saveFileWithContours( fileNameContourROI );
+ }
+}
+void wxContourMainFrame::saveFileWithContours( std::string filename ){
+
+ FILE *pFile=fopen(filename.c_str(),"w+");
+ std::vector< std::string > lstNameThings;
+ int i,sizeLstNameThings;
+
+ fprintf(pFile,"--CreaContour--\n");
+ fprintf(pFile,"Version %s\n", "1.0.1" );
+
+ // Normal Contours
+ lstNameThings = kernelManager->GetLstNameThings();
+ sizeLstNameThings = lstNameThings.size();
+ fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
+ for (i=0 ; i<sizeLstNameThings ; i++)
+ {
+ kernelManager->SaveThingName( pFile, lstNameThings[i] );
+ _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
+ }// for i
+
+ //-- Contours Statics
+ lstNameThings = kernelManager->GetLstNameThingsStatic();
+ sizeLstNameThings = lstNameThings.size();
+ fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
+ for (i=0 ; i<sizeLstNameThings ; i++)
+ {
+ kernelManager->SaveThingName( pFile, lstNameThings[i] );
+ _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
+ }// for i
+ fclose(pFile);
+}
+
+void wxContourMainFrame::openContours( FILE *pFile, bool staticContour ){
+ char tmp[255];
+ fscanf(pFile,"%s",tmp); // NumberOfContours
+ fscanf(pFile,"%s",tmp); // ##
+ int numberOfContours = atoi(tmp);
+
+ std::vector<int> instantVector;
+ int typeContourModel;
+ manualContourModel *manModelContour;
+ int typeView;
+
+ int i;
+ for (i=0;i<numberOfContours;i++)
+ {
+ instantVector.clear();
+ fscanf(pFile,"%s",tmp); // Instant
+
+ fscanf(pFile,"%s",tmp); // 1
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 2
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 3
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 4
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 5
+ instantVector.push_back( atoi(tmp) );
+ fscanf(pFile,"%s",tmp); // 6
+ instantVector.push_back( atoi(tmp) );
+
+
+ fscanf(pFile,"%s",tmp); // TypeContourModel
+ fscanf(pFile,"%s",tmp); // ##
+ typeContourModel = atoi(tmp);
+
+ manModelContour = kernelManager->factoryManualContourModel(typeContourModel);
+ manModelContour->Open(pFile);
+
+ fscanf(pFile,"%s",tmp); // TypeView
+ fscanf(pFile,"%s",tmp); // ##
+ typeView = atoi(tmp);
+
+
+// if (typeView==1)
+// {
+// }
+
+
+ std::string theName;
+ theName = kernelManager->createOutline( manModelContour, instantVector );
+ bool addedModel = theName.compare("") != 0;
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ _theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
+ }
+
+ if (staticContour==true)
+ {
+ Instant instant(&instantVector);
+ kernelManager->changeContourOfManager( theName , &instant );
+ }
+
+ }// for numberOfContours
+
+}
+
+void wxContourMainFrame::RefreshInterface(){
+ changeInstant();
+ _theViewPanel->RefreshInterface();
+ //wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
+ //wxvtk2dbaseview->Refresh();
+}
+
+vtkImageData* wxContourMainFrame::getImageData(){
+ return _theViewPanel->getImageData();
+}
+
+void wxContourMainFrame::onSegmentationOneSlice(int isovalue,int sampling,int method){
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ wxBusyCursor wait;
+ int x = _theViewPanel->GetX();
+ int y = _theViewPanel->GetY();
+ int z = _theViewPanel->GetZ();
+ SegmentationOneSlice( x,y,z,isovalue, sampling, method );
+ RefreshInterface();
+}
+
+void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method )
+{
+ int typeofcontour = 1;
+ //--Extracting Contour
+ //vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
+ vtkImageData *imagedata = getImageData();
+// double *range = imagedata->GetScalarRange();
+// double thr = 1;
+
+ vtkImageReslice *imageReslice = vtkImageReslice::New();
+//EED
+// double spc[3];
+// imagedata->GetSpacing(spc);
+// x = x*spc[0];
+// y = y*spc[1];
+// z = z*spc[3];
+
+ imageReslice->SetInput( imagedata );
+ imageReslice->SetInformationInput(imagedata);
+ imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
+ imageReslice->SetResliceAxesOrigin(0,0,z);
+ imageReslice->SetOutputDimensionality(2);
+ imageReslice->SetInterpolationModeToLinear();
+
+ imagedata = imageReslice->GetOutput();
+ imagedata->Update();
+ imagedata->UpdateInformation();
+
+ vtkContourFilter* cntVTK = vtkContourFilter::New( );
+ cntVTK->SetInput( imagedata );
+
+ cntVTK->SetNumberOfContours( 1 );
+ //cntVTK->SetValue( 0, vmin );
+// cntVTK->SetValue( 0, (range[1]*thr/100) );
+ cntVTK->SetValue( 1, isovalue );
+// cntVTK->SetValue( 1, vmax );
+ cntVTK->Update( );
+ cntVTK->UpdateInformation();
+
+ vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
+ cpd->SetInput( cntVTK->GetOutput( ) );
+ cpd->ConvertLinesToPointsOff( );
+ cpd->Update( );
+ cpd->UpdateInformation();
+
+ vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
+ conn->SetExtractionModeToClosestPointRegion( );
+ //conn->SetMaxRecursionDepth( 3000 );
+
+ conn->SetInput( cpd->GetOutput( ) );
+
+ conn->SetClosestPoint( x, y, 0 );
+ conn->Update( );
+ conn->UpdateInformation();
+
+ vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
+ cpd2->SetInput( conn->GetOutput( ) );
+ cpd2->Update();
+ cpd2->UpdateInformation();
+
+ vtkStripper* vtkstripper = vtkStripper::New( );
+ vtkstripper->SetInput( cpd2->GetOutput() );
+ vtkstripper->Update();
+ vtkstripper->UpdateInformation();
+
+
+ vtkPolyData* polyDataResult = vtkstripper->GetOutput();
+
+ polyDataResult->Update( );
+ polyDataResult->UpdateInformation();
+
+/* EED
+ofstream myfile;
+myfile.open ("c:/temp/example.txt");
+myfile << "\n";
+polyDataResult->Print(myfile);
+myfile << "-------------------------------------\n";
+polyDataResult->GetLines()->Print(myfile);
+myfile.close();
+*/
+
+ cntVTK -> Delete();
+ cpd2 -> Delete();
+ cpd -> Delete();
+ conn -> Delete();
+
+
+//--Calculating control points
+
+ std::vector<double> vecX;
+ std::vector<double> vecY;
+ std::vector<double> vecZ;
+
+ std::vector<double> vecCtrlPointX;
+ std::vector<double> vecCtrlPointY;
+ std::vector<double> vecCtrlPointZ;
+
+
+ double *p;
+ int ii,size=polyDataResult->GetNumberOfPoints();
+ int id;
+ for (ii=1;ii<=size;ii++)
+ {
+ id = polyDataResult->GetLines()->GetData()->GetValue(ii);
+ p = polyDataResult->GetPoint(id);
+ double x=p[0];
+ double y=p[1];
+ vecX.push_back( p[0] );
+ vecY.push_back( p[1] );
+ vecZ.push_back( -900 );
+// vecZ.push_back( p[2] );
+ }
+
+
+ ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
+ extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
+
+//PROOFS
+ /*if (methodRadiobox->GetSelection()==0){
+ extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+ }
+ if (methodRadiobox->GetSelection()==1){
+ extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+ }
+ if (methodRadiobox->GetSelection()==2){
+ extractcontrolpoints2d->SetSamplingControlPoints( sampling );
+ extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+ }*/
+
+ if (method==0){
+ extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+ }
+ else if (method==1){
+ extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+ }
+ else if (method==2){
+ extractcontrolpoints2d->SetSamplingControlPoints( sampling );
+ extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
+ }
+
+ //--Adding contour to the system
+
+ std::vector<int> actualInstantVector;
+ _instantPanel->getInstant( actualInstantVector );
+ actualInstantVector[1]=z;
+
+ int j,sizeCtrPt = vecCtrlPointX.size();
+ manualContourModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour );
+ manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
+ if (sizeCtrPt>=3){
+ for (j=0 ; j<sizeCtrPt ; j++)
+ {
+ manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
+ } // for
+ std::string theName;
+ //theName = _modelManager->createOutline( manModelContour, actualInstantVector );
+ theName = kernelManager->createOutline( manModelContour, actualInstantVector );
+ bool addedModel = theName.compare("") != 0;
+ if( addedModel )
+ {
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ _theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
+ //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
+ } // if addedModel
+ } // if sizeCtrPt
+}
+
+int wxContourMainFrame::GetImageDataSizeZ(){
+ return _theViewPanel->GetImageDataSizeZ();
+}
+
+void wxContourMainFrame::GetImageDataRange(double *range){
+ _theViewPanel->GetImageDataRange(range);
+}
+
+void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method){
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ wxBusyCursor wait;
+ int x = _theViewPanel->GetX();
+ int y = _theViewPanel->GetY();
+ int z;
+ double porcent;
+ wxString tmpString;
+ double totalZ = maxZ-minZ+1;
+ for( z=minZ ; z<=maxZ ; z++ )
+ {
+ porcent = 100.0* (z-minZ)/totalZ;
+ tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
+ interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString);
+ //_staticTextSegmentation->SetLabel(tmpString);
+ SegmentationOneSlice( x,y,z,isovalue, sampling,method );
+ }
+ interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T(" "));
+ RefreshInterface();
+}
+
+void wxContourMainFrame::showAxis(bool show){
+ _theViewPanel->SetVisibleAxis(show);
+ _theViewPanel->Refresh();
+}
+
+
+void wxContourMainFrame::onRigidPressed(){
+ std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
+ int elementsSelected = currentSelection.size();
+
+ if ( elementsSelected >= 1 ){
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ Instant instant(&tempVector);
+
+ int i , size=currentSelection.size();
+ for ( i=0 ; i<size ; i++ )
+ {
+ kernelManager->changeContourOfManager(currentSelection[i], &instant);
+ } // i
+ }
+}
+
+void wxContourMainFrame::onWidthOfContour(double width){
+
+ _theViewPanel->removeSceneContours();
+ _theViewPanel->SetWidthContour(width);
+
+ //_theViewPanel->getSceneManager()->SetWidthContour( width );
+
+ RefreshInterface();
+}
+int wxContourMainFrame::getColorWindow(){
+ return _theViewPanel->getColorWindow();
+}
+int wxContourMainFrame::getWindowLevel(){
+ return _theViewPanel->getWindowLevel();
+}
+
+void wxContourMainFrame::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel){
+ _theViewPanel->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
+
+
+ RefreshInterface();
+}
+
+void wxContourMainFrame::onInterpolation(bool interpolate){
+ _theViewPanel->onInterpolation(interpolate);
+ RefreshInterface();
+}
+
+void wxContourMainFrame::onChangeInstant(std::string name,int actual){
+ _instantPanel->setConceptValue( name, actual );
+}
+
+void wxContourMainFrame::resetAppend(){
+ kernelManager->resetAppend();
+
+}
+
+void wxContourMainFrame::onSpreadAdd(){
+ std::vector<double> vecX;
+ std::vector<double> vecY;
+ std::vector<double> vecZ;
+ _theViewPanel->GetPointsOfActualContour(&vecX , &vecY , &vecZ );
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ std::string val = kernelManager->onSpreadAdd(&vecX , &vecY , &vecZ, tempVector);
+
+ interfMainPanel::getInstance()->appendStringSpread(val);
+
+}
+
+void wxContourMainFrame::onSpreadGo(int type){
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+
+ wxBusyCursor wait;
+ std::vector<double> vecCtrlPointX;
+ std::vector<double> vecCtrlPointY;
+ std::vector<double> vecCtrlPointZ;
+ double minZ,maxZ;
+ int z;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+// tempVector[1];
+
+ kernelManager->getMaxMinZ(&minZ,&maxZ);
+//JSTG_16-07-08_----------------------------------------------------------------
+ //_contourPropagation->setInterpolationNumber(maxZ-minZ+1);
+ kernelManager->CalculeSplinePropagation();
+
+ double totalZ = maxZ-minZ+1;
+ double porcent;
+ wxString tmpString;
+//--------------------------------------------------------------------
+ for ( z=(int)minZ ; z<=(int)maxZ ; z++ )
+ {
+ porcent = 100.0* (z-minZ)/totalZ;
+ int numero = (int)(z-minZ+1)/(int)totalZ;
+ std::string stringtemp = " "+kernelManager->intToString(porcent)+"% "+kernelManager->intToString(numero)+" "+kernelManager->intToString(z);
+
+ interfMainPanel::getInstance()->setStringSpread(stringtemp);
+
+ int typeofcontour = 1;
+ std::string theName;
+ manualContourModel* manModelContour = kernelManager->GetPoints(z, type, &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ, theName,typeofcontour, tempVector);
+
+ if( manModelContour!=NULL ){
+ double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
+ this->_theViewPanel->getSpacing(spc);
+ //Adding the manualContourControler to interface objects structure
+ //Adding the manualViewContour to interface objects structure
+ //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
+ _theViewPanel->configureViewControlTo( theName, manModelContour,spc,typeofcontour ) ;
+ } // if addedModel
+ }
+ if(z > maxZ){
+ porcent = 100.0;
+ int numero = (int)(z-minZ+1)/(int)totalZ;
+ std::string stringtemp = " "+kernelManager->intToString(porcent)+"% "+kernelManager->intToString(numero)+" "+kernelManager->intToString(z);
+
+ interfMainPanel::getInstance()->setStringSpread(stringtemp);
+ }// for z
+ //RefreshInterface();
+}
+
+void wxContourMainFrame::getInstantVector(std::vector<int>& tempVector){
+
+}
+
+std::vector<std::string> wxContourMainFrame::getOutlinesName(int slide){
+ std::vector<int> tempVector;
+ _instantPanel->getInstant(tempVector);
+ //Asignation of slide number should be different ex by name
+ tempVector[1]=slide;
+ return kernelManager->getOutlinesNameAtInstant(tempVector);
+}
+
+void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ){
+ int maxContourGroup = 0;
+
+ ContourExtractData *contourextractdata = new ContourExtractData();
+
+ contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
+
+ std::vector<manualContourModel*> lstManConMod;
+ std::vector<manualContourModel*> lstManConModTmp;
+ std::vector<manualContourModel*> lstManConModExp;
+ std::vector<double> pLstValue;
+ std::vector<double> pLstValuePosX;
+ std::vector<double> pLstValuePosY;
+ std::vector<double> pLstValuePosZ;
+
+ int resultSize;
+ int resultGrayRangeCount;
+ double resultMin;
+ double resultMax;
+ double resultAverage;
+ double resultStandardeviation;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ vtkImageData *imagedata = _theViewPanel->getImageData();
+ int sizeZ = _theViewPanel->GetImageDataSizeZ();
+ int z;
+ int ii,sizeLstContourThings;
+
+
+ int minZ,maxZ;
+ double totalZ;
+ double porcent;
+ wxString tmpString;
+
+
+
+ if (selection==0 ) // actual slice
+ {
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+ int actualSlice = tempVector[1];
+ minZ = actualSlice;
+ maxZ = actualSlice;
+ }
+ else if (selection==2 ) // All slices
+ {
+ minZ = 0;
+ maxZ = sizeZ-1;
+ }
+ else if (selection==1 ) // slice range
+ {
+ minZ = minimumZ;
+ maxZ = maximumZ;
+ }
+
+
+ totalZ = maxZ-minZ+1;
+ contourextractdata->SetImage( imagedata);
+
+// For each slice..
+ for ( z=minZ ; z<=maxZ ; z++ )
+ {
+
+ porcent = 100.0* (z-minZ)/totalZ;
+ tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
+
+ interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
+ //_staticTextInformation->SetLabel(tmpString);
+
+ //Extraction data from contours of each slice
+ contourextractdata->SetZtoBeAnalys( z);
+
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
+ sizeLstContourThings = lstContourThings.size();
+
+ lstManConMod.clear();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ lstManConMod.push_back( (*contourthing)->getModel() );
+ }
+ lstManConModExp = kernelManager->ExploseEachModel( lstManConMod );
+
+
+ wxString tempString;
+ tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
+ interfMainPanel::getInstance()->setRowLabelInfoPanel(z, tempString);
+ //_grid->SetRowLabelValue(z, tempString );
+//EED004
+ int iContourGroup,sizeContourGroup;
+ if (typeContourGroup==3) // contour separete
+ {
+ sizeContourGroup=lstManConModExp.size();
+ if ( maxContourGroup<sizeContourGroup )
+ {
+ maxContourGroup=sizeContourGroup;
+ }
+ } else { // contour AND OR XOR
+ sizeContourGroup=1;
+ maxContourGroup=1;
+ }
+
+ int tmpIntA;
+
+
+
+ for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
+ lstManConModTmp.clear();
+ if (typeContourGroup==3) // contour separete
+ {
+ lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
+ } else { // contour AND OR XOR
+ lstManConModTmp = lstManConModExp;
+ }
+
+ contourextractdata->SetLstManualContourModel( lstManConModTmp );
+
+ pLstValue.clear();
+ pLstValuePosX.clear();
+ pLstValuePosY.clear();
+ pLstValuePosZ.clear();
+ contourextractdata->GetValuesInsideCrown( &pLstValue,
+ &pLstValuePosX,
+ &pLstValuePosY,
+ &pLstValuePosZ);
+ // Statistics of each slice.
+ contourextractdata->Statistics( &pLstValue,
+ minimumZ,
+ maximumZ,
+ &resultGrayRangeCount,
+ &resultSize,
+ &resultMin,
+ &resultMax,
+ &resultAverage,
+ &resultStandardeviation);
+
+ if (interfMainPanel::getInstance()->getNumberColsInformationPanel()<_numberOfVariablesStatistics*(iContourGroup+1) )
+ {
+ interfMainPanel::getInstance()->appendColsInformationPanel(_numberOfVariablesStatistics);
+ }
+
+ tmpIntA=_numberOfVariablesStatistics*iContourGroup ;
+
+ tempString.Printf(_T("%d"),resultSize);
+ interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA, tempString);
+
+ tempString.Printf(_T("%d"),resultGrayRangeCount);
+ interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+1, tempString);
+
+ tempString.Printf(_T("%f"),resultMin);
+ interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+2, tempString);
+
+ tempString.Printf(_T("%f"),resultMax);
+ interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+3, tempString);
+
+ tempString.Printf(_T("%f"),resultAverage);
+ interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+4, tempString);
+
+ tempString.Printf(_T("%f"),resultStandardeviation);
+ interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+5, tempString);
+
+
+ } // for iContourGroup
+ } // for z
+
+ int iTitleGroup;
+ wxString tmpTitleString;
+ int tmpIntB;
+ for ( iTitleGroup=0 ; iTitleGroup<maxContourGroup ; iTitleGroup++ )
+ {
+ tmpIntB =_numberOfVariablesStatistics*iTitleGroup;
+ tmpTitleString.Printf(_T("%d-Size Data"),iTitleGroup);
+ interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString);
+
+ interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString );
+ interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 1, _T("Size Range") );
+ interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 2, _T("Min") );
+ interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 3, _T("Max") );
+ interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 4, _T("Average") );
+ interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 5, _T("St.Dev.") );
+ interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 6, _T(" ") );
+ }
+
+ interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
+ delete contourextractdata;
+}
+
+void wxContourMainFrame::onSaveResults(std::string directory,std::string namefile, std::string filename, int typeContourGroup){
+ SaveValuesXYZ( directory , namefile, typeContourGroup );
+ SaveImageResult( directory , namefile, typeContourGroup);
+
+
+ FILE *pFile=fopen(filename.c_str(),"w+");
+
+ int sizeZ = _theViewPanel->GetImageDataSizeZ();
+
+ wxString tmpString;
+ int i,j,maxX,maxY=sizeZ;
+ maxX= interfMainPanel::getInstance()->getNumberColsInformationPanel();//this->_grid->GetNumberCols();
+
+ int iTitle,sizeTitle = (maxX / _numberOfVariablesStatistics);
+ for ( iTitle=0; iTitle<sizeTitle ; iTitle++)
+ {
+ fprintf(pFile,"-- \t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle,tmpString.c_str() );
+ }
+ fprintf(pFile,"\n" );
+
+
+
+ for ( j=0; j<maxY ; j++)
+ {
+ fprintf(pFile,"%d\t" , j );
+ for (i=0 ; i<maxX ; i++){
+ tmpString = interfMainPanel::getInstance()->getCellValue(j, i);//_grid->GetCellValue( j , i );
+ fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
+ } // for i
+ fprintf(pFile,"\n" );
+ } // for j
+
+ fclose(pFile);
+}
+
+void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefile,int typeContourGroup)
+{
+ wxBusyCursor wait;
+ ContourExtractData *contourextractdata = new ContourExtractData();
+ //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
+ contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
+
+ std::vector<manualContourModel*> lstManConMod;
+ std::vector<manualContourModel*> lstManConModTmp;
+ std::vector<manualContourModel*> lstManConModExp;
+ std::vector<double> pLstValue;
+ std::vector<double> pLstValuePosX;
+ std::vector<double> pLstValuePosY;
+ std::vector<double> pLstValuePosZ;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
+ int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
+ int z;
+ int ii,sizeLstContourThings;
+
+
+ int minZ,maxZ;
+ double totalZ;
+ double porcent;
+ wxString tmpString;
+ minZ = 0;// _mbarrange->GetStart();
+ maxZ = sizeZ;//_mbarrange->GetEnd();
+ totalZ = maxZ-minZ+1;
+
+ contourextractdata->SetImage( imagedata);
+
+// For each slice..
+ for ( z=0 ; z<sizeZ ; z++)
+ {
+
+ porcent = 100.0* (z-minZ)/totalZ;
+
+ tmpString.Printf(_T("Saving Values"));
+ tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
+ interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
+ //_staticTextInformation->SetLabel(tmpString);
+
+
+ //Extraction data from contours of each slice
+ contourextractdata->SetZtoBeAnalys( z);
+
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant(&instant);//this->_modelManager->getOutlinesAtInstant( &instant );
+ sizeLstContourThings = lstContourThings.size();
+
+ lstManConMod.clear();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ lstManConMod.push_back( (*contourthing)->getModel() );
+ }
+ lstManConModExp = kernelManager->ExploseEachModel( lstManConMod );
+
+
+//EED004
+
+ int iContourGroup,sizeContourGroup;
+ if (typeContourGroup==3) // contour separete
+ {
+ sizeContourGroup=lstManConModExp.size();
+ } else { // contour AND OR XOR
+ sizeContourGroup=1;
+ }
+
+ for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
+ lstManConModTmp.clear();
+ if (typeContourGroup==3) // contour separete
+ {
+ lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
+ } else { // contour AND OR XOR
+ lstManConModTmp = lstManConModExp;
+ }
+
+ contourextractdata->SetLstManualContourModel( lstManConModTmp );
+
+ pLstValue.clear();
+ pLstValuePosX.clear();
+ pLstValuePosY.clear();
+ pLstValuePosZ.clear();
+ contourextractdata->GetValuesInsideCrown( &pLstValue,
+ &pLstValuePosX,
+ &pLstValuePosY,
+ &pLstValuePosZ);
+
+ std::string temp = directory + "/" + namefile + "-slice";
+ temp = temp + kernelManager->intToString(z) + "-cont" + kernelManager->intToString(iContourGroup);
+ temp = temp + ".txt";
+
+ wxString filename;
+ /*filename.Printf(_T("%s"),directory.c_str());
+ filename.append(_T("\\"));
+ filename.append(_T("%s"),namefile.c_str());
+ filename.append(_T("-slice"));
+ filename.append(_T("%d"),z);
+ filename.append(_T("-cont"));
+ filename.append(_T("%d"),iContourGroup);
+ filename.append(_T(".txt"));*/
+ filename.Printf(temp.c_str());
+ FILE *pFile=fopen((const char *)filename.mb_str(),"w+");
+ fprintf(pFile,"value \t x \t y \t z\n" );
+ int iLstValue,sizeLstValue=pLstValue.size();
+ for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
+ {
+ fprintf(pFile,"%f\t %f\t %f\t %f\n", (float)pLstValue[iLstValue] , (float)pLstValuePosX[iLstValue], (float)pLstValuePosY[iLstValue], (float)z );
+ }
+ fclose(pFile);
+ } // for iContourGroup
+ } // for z
+ interfMainPanel::getInstance()->setStringInfoPanel(_T(""));
+ //_staticTextInformation->SetLabel( _T("") );
+ delete contourextractdata;
+}
+
+void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, int typeContourGroup)
+{
+ wxBusyCursor wait;
+ ContourExtractData *contourextractdata = new ContourExtractData( true );
+ //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
+ if (typeContourGroup==3)
+ {
+ typeContourGroup=1;
+ }
+ contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
+
+ std::vector<manualContourModel*> lstManConMod;
+ std::vector<manualContourModel*> lstManConModTmp;
+ std::vector<manualContourModel*> lstManConModExp;
+
+ std::vector<int> tempVector;
+ _instantPanel->getInstant( tempVector );
+
+ vtkImageData *imagedata = _theViewPanel->getImageData();
+ int sizeZ = _theViewPanel->GetImageDataSizeZ();
+ int z;
+ int ii,sizeLstContourThings;
+
+
+ int minZ,maxZ;
+ double totalZ;
+ double porcent;
+
+ wxString tmpString;
+
+ minZ = 0;// _mbarrange->GetStart();
+ maxZ = sizeZ;//_mbarrange->GetEnd();
+ totalZ = maxZ-minZ+1;
+
+ contourextractdata->SetImage( imagedata);
+
+// For each slice..
+ for ( z=0 ; z<sizeZ ; z++)
+ {
+
+ porcent = 100.0* (z-minZ)/totalZ;
+ tmpString.Printf(_T("Saving Values"));
+ tmpString.Printf(_T("%d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
+ interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
+
+ //Extraction data from contours of each slice
+ contourextractdata->SetZtoBeAnalys( z);
+
+ tempVector[1]=z;
+ Instant instant(&tempVector);
+ std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
+ sizeLstContourThings = lstContourThings.size();
+
+ lstManConMod.clear();
+ for (ii=0 ; ii<sizeLstContourThings ; ii++)
+ {
+ ContourThing **contourthing = lstContourThings[ii];
+ lstManConMod.push_back( (*contourthing)->getModel() );
+ }
+ lstManConModExp = kernelManager->ExploseEachModel( lstManConMod );
+
+
+ int iContourGroup,sizeContourGroup;
+ if (typeContourGroup==3) // contour separete
+ {
+ sizeContourGroup=lstManConModExp.size();
+ } else { // contour AND OR XOR
+ sizeContourGroup=1;
+ }
+
+ for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
+ lstManConModTmp.clear();
+ if (typeContourGroup==3) // contour separete
+ {
+ lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
+ } else { // contour AND OR XOR
+ lstManConModTmp = lstManConModExp;
+ }
+
+ contourextractdata->SetLstManualContourModel( lstManConModTmp );
+
+
+// for (ii=0 ; ii<sizeLstContourThings ; ii++)
+// {
+// ContourThing **contourthing = lstContourThings[ii];
+// lstManConMod.push_back( (*contourthing)->getModel() );
+// }
+// contourextractdata->SetLstManualContourModel( lstManConMod );
+
+ contourextractdata->CalculateImageResult(); // with actual Z
+
+ } // for iContourGroup
+ } // for z
+
+ std::string temp = directory + "/" + namefile + "-Value.mhd";
+
+ wxString filename;
+ filename.Printf(_T(temp.c_str()));
+ //filename.Printf(_T("%s\\%s-Value.mhd",directory.c_str(),namefile.c_str(),z);
+ /*filename.Printf(_T("%s"),directory.c_str());
+ filename.append(_T("\\"));
+ filename.append(_T("%s"),namefile.c_str());
+ filename.append(_T("-Value.mhd"));*/
+
+// Image Value
+ vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
+ writerValueImage->SetInput( contourextractdata->GetVtkImageValueResult() );
+ writerValueImage->SetFileName( (const char *)filename.mb_str() );
+ writerValueImage->SetFileDimensionality( 3 );
+ writerValueImage->Write( );
+
+// Image Mask
+ // filename.Printf("%s\\%s-Mask.mhd",directory.c_str(),namefile.c_str(),z);
+ temp = directory + "/" + namefile + "-Mask.mhd";
+
+ filename.Printf(_T(temp.c_str()));
+
+ /*filename.Printf(_T("%s"),directory.c_str());
+ filename.append(_T("\\"));
+ filename.append(_T("%s"),namefile.c_str());
+ filename.append(_T("-Mask.mhd"));*/
+
+ vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
+ writerMaskImage->SetInput( contourextractdata->GetVtkImageMaskResult() );
+ writerMaskImage->SetFileName( (const char *)filename.mb_str() );
+ writerMaskImage->SetFileDimensionality( 3 );
+ writerMaskImage->Write( );
+
+ interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
+ delete contourextractdata;
+}
+
+void wxContourMainFrame::onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow){
+ if( name.compare( _theViewPanel->getVerticalConceptName() ) == 0){
+ _theViewPanel->setActualVertical( value);
+ }
+ else if( name.compare( _theViewPanel->getHorizontalConceptName() ) == 0|| _instantPanel->getIfConceptCheckedAt( name, 0 ) ) {
+ _theViewPanel->setHorizontalConcept( name, minshow, maxshow, minshow, maxshow, value);
+ }
+
+ changeInstant();
+}
//------------------------------------------------------------------------------------------------------------
#include "wx/aui/aui.h"
-#include "ContourThing.h"
-#include "AxeThing.h"
-#include "ImageSourceThing.h"
-#include "ImageSectionThing.h"
-#include "InstantMembersNameList.h"
-#include "OutlineGroup.h"
+#include "interfMainPanel.h"
+
+#include "wxVtkBaseView_SceneManager.h"
+#include "wxInstantChooserPanel.h"
+#include "wxContourViewPanel.h"
+
+#include "KernelManagerContour.h"
+
+#include "ContourWorkspace.h"
+#include "contour/contourextractdata.h"
+
+
+
+
+#include "PerformingOperation.h"
+
+
+
+//#include "ContourThing.h"
+//#include "AxeThing.h"
+//#include "ImageSourceThing.h"
+//#include "ImageSectionThing.h"
+//#include "InstantMembersNameList.h"
+//#include "OutlineGroup.h"
#include "SomeEnvironment.h"
#include "ContourWorkspace.h"
#include "ContourWrap_ViewControl.h"
#include "Instant.h"
+#include "PerformingOperation.h"
+
+#include "ContourThing.h"
+
+//#include "OutlineModelManager.h"
-#include "OutlineModelManager.h"
-#include "wxInstantChooserPanel.h"
#include "wxContour_ButtonsBar.h"
#include "wxContour_ControlPanel.h"
-#include "wxContourViewPanel.h"
+
#include "wxContour_Grid.h"
#include "wxContour_DrawToolsPanel.h"
#include "wxContour_OperationsToolsPanel.h"
#include "wxContour_EdtionToolsPanel.h"
#include "wxContour_ListViewPanel.h"
-#include "wxVtkBaseView_SceneManager.h"
+
+
+
+#include "vtkContourFilter.h"
+#include "vtkPolyDataConnectivityFilter.h"
+#include "vtkCleanPolyData.h"
+#include "vtkImageReslice.h"
+#include "vtkMetaImageWriter.h"
+#include "vtkImageData.h"
+#include "vtkMetaImageReader.h"
//------------------------------------------------------------------------------------------------------------
// Events declaration
wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
+ wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
~wxContourMainFrame();
void createInstantChooserPanel(wxWindow * parent);
void createViewPanel(wxWindow * parent);
-
- void setViewPanel( wxContourViewPanel * theViewPanel );
void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
//------------------------------------------------------------------------------------------------------------
// Attributes getters and setters
//------------------------------------------------------------------------------------------------------------
-
+ static wxContourMainFrame* getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
+ static wxContourMainFrame* getInstance();
//------------------------------------------------------------------------------------------------------------
// Other functional methods
//------------------------------------------------------------------------------------------------------------
+ /*
+ ** This method returns the vector of images selected by the user
+ ** return value std::vector<vtkImageData*>
+ */
+ std::vector<vtkImageData*> getVectImages();
+
+ /**
+ ** This methods connect the event in the class interfMainPanel with the world of the appli
+ **/
+ void onCreateContourSpline( );
+ void onCreateContourRectangle( );
+ void onCreateContourCircle( );
+ void onCreateContourBullEye(wxPanel* pan);
+ /////////////////////////////////
+ void onDeleteContour();
+ void deleteContours( std::vector<std::string> keyNamesVector );
+ void deleteContour( std::string theKeyName );
+ void onDeleteContoursActSlice();
+ void onDeleteAllContours();
+ void deleteAllContours();
+ void setConceptValue( std::string name, int value );
+ ConceptDataWrap* getLastConceptData();
+ bool getIfConceptCheckedAt( std::string name, int pos );
+
+ void changeInstant();
+
+ int getNamesWrappingSize();
+
+ std::string getNameWrapping(int i);
+
+
+ void updateInstantOutlines();
+ void updateInstantImageData();
+ void updateInstantAxes();
+
+ void onChangeDeep(int val);
+
+///////////////////////////
+ void onCopy();
+ void onPaste();
+ void onUndo();
+ void onRedo();
+ void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
+///////////////////////7
+ void onLoad();
+ void onSave();
+
+ void openContours( FILE *pFile, bool staticContour );
+
+ void RefreshInterface();
+
+ vtkImageData* getImageData();
+
+ void onSegmentationOneSlice(int isovalue,int sampling,int method);
+
+ void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
+
+ int GetImageDataSizeZ();
+
+ void GetImageDataRange(double *range);
+
+ void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
+
+ void showAxis(bool show);
+
+ void onRigidPressed();
+
+ void onWidthOfContour(double width);
+
+ int getColorWindow();
+ int getWindowLevel();
+
+ void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
+
+ void onInterpolation(bool interpolate);
+
+ void onChangeInstant(std::string name,int actual);
+
+ void resetAppend();
+
+ void onSpreadAdd();
+
+ void onSpreadGo(int type);
+
+ void getInstantVector(std::vector<int>& tempVector);
+
+ std::vector<std::string> getOutlinesName(int slide);
+
+ void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ);
+
+ void onSaveResults(std::string directory,std::string namefile, std::string filename, int typeContourGroup);
+
+ void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
+
+ void SaveImageResult(std::string directory,std::string namefile, int typeContourGroup);
+
+ void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
private:
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
// Attributtes
//------------------------------------------------------------------------------------------------------------
+ static wxContourMainFrame* instance;
+
+ KernelManagerContour* kernelManager;
+
+ wxContourViewPanel* _theViewPanel;
+
wxAuiManager m_mgr;
/*
*/
long m_notebook_style;
long m_notebook_theme;
+ int _numberOfVariablesStatistics;
- wxContourViewPanel * _theViewPanel;
-
- OutlineModelManager * _modelManager;
+ //OutlineModelManager * _modelManager;
wxInstantChooserPanel * _instantPanel;
wxVtkBaseView_SceneManager * _sceneManager;
- Instant * _actualInstant;
+ //Instant * _actualInstant;
+
+
/*DECLARE_CLASS(wxContourMainFrame)
// any class wishing to process wxWindows events must use this macro
DECLARE_EVENT_TABLE()*/
bool _creatingContoursActive;
+////////JCP 21 - 11 - 08
+ void createContour( int typeContour );
+
+ //manualContourModel * factoryManualContourModel(int typeContour);
+
+ manualContourModel * factoryManualContourModel(wxPanel* panel);
+
+
+
+ void saveState();
+ void loadState(std::string filename);
+
+ void saveFileWithContours( std::string filename );
+
+ int inredo;
+ int inundo;
+ std::string stundoredo;
+
+
+
+ //wxContourViewPanel* _viewPan;
+ PerformingOperation* _performingOperation;
+
+ static char COPY;
};
//----------------------------------------------------------------------------------------------------------------
#include "wxContourViewPanel.h"
-
+#include "wxContourMainFrame.h"
//----------------------------------------------------------------------------------------------------------------
// Other includes
//----------------------------------------------------------------------------------------------------------------
#include "ConceptDataWrap.h"
+//this should be eliminated at some point
+//#include "wxContourEventHandler.h"
//----------------------------------------------------------------------------------------------------------------
// Class implementation
//----------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
// Constructors & Destructors
//------------------------------------------------------------------------------------------------------------
-
- wxContourViewPanel :: wxContourViewPanel ( vtkImageData * theShowingImage, wxWindow *parent, const wxPoint& pos, const wxSize& size,long style, int vertStart, int vertEnd, int horzStart, int horzEnd )
- //:wxScrolledWindow(parent, -1, pos, size, style)
- :wxPanel(parent, -1, pos, size, style)
/*{
showingVID = theShowingImage;
SetBackgroundColour(wxColour(255,0,0));
}*/
+ //:wxScrolledWindow(parent, -1, pos, size, style)
+ wxContourViewPanel :: wxContourViewPanel ( vtkImageData * theShowingImage, wxWindow *parent, const wxPoint& pos, const wxSize& size,long style, int vertStart, int vertEnd, int horzStart, int horzEnd )
+ :wxPanel(parent, -1, pos, size, style)
{
theShowingImage->GetSpacing(last_spacing);
createHorizontalBar(1,80);
createVerticalBar(1,200);
createViewPanel();
+ _eventHandler = NULL;
wxFlexGridSizer * panelSizer = new wxFlexGridSizer(1, 4, gapV, gapH);
panelSizer -> AddGrowableCol(2);
//theViewPanel->GetWindow(1)->SetSize(800,600);
//outSizer->Fit( this );
+
+ initializeScenceManager();
+
}
}
+ void wxContourViewPanel::initializeScenceManager(){
+
+ //_theViewPanel = theViewPanel;
+ //_theViewPanel->setWxEventHandler( this );
+
+ double spc[3];
+ this->getSpacing(spc);
+ _sceneManager = new wxVtkBaseView_SceneManager ( this->getWxVtkBaseView(), this, spc );
+
+ Connect( this->GetId(), wxINSTANT_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onChangeInstant );
+ Connect( wxID_ANY, wxEVT_START_CREATE_MULT_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onCreateMultipleROI );
+ Connect( wxID_ANY, wxEVT_START_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onCreateROI );
+ Connect( wxID_ANY, wxEVT_STOP_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStopCreateROI );
+ Connect( wxID_ANY, wxEVT_CHANGED_DEEP, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onChangedDeep );
+ Connect( wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourViewPanel :: onActionButtonPressed );
+
+ }
+
+ wxVtkBaseView_SceneManager* wxContourViewPanel::getSceneManager(){
+ return _sceneManager;
+ }
+
//------------------------------------------------------------------------------------------------------------
// Creational and initialization methods
//------------------------------------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------------------------------------
+ void wxContourViewPanel::changeImage(vtkImageData* img){
+
+ theViewPanel->SetImage(img);
+
+ }
wxVtkMPR2DView * wxContourViewPanel::GetwxVtkMPR2DView()
{
return (wxVtkMPR2DView *) (theViewPanel->GetwxVtkBaseView(1));
*/
void wxContourViewPanel :: onActualChange_Bar_Horizontal(wxCommandEvent& event)
{
- int nxActual_h = getActualHorizontal();
+
+ int actual = getActualHorizontal();
- if (_eventHandler!=NULL)
- {
+ wxContourMainFrame::getInstance()->onChangeInstant(_horizontalConceptName, actual);
+
+ //JCP 26 - 11 - 08
+ //int nxActual_h = getActualHorizontal();
+
+
+ //if (_eventHandler!=NULL)
+ //{
//-------------------------------------------------
// Sending the event of wxINSTANT_CHANGE
//-------------------------------------------------
- wxCommandEvent newevent(wxINSTANT_CHANGE,GetId());
+ // wxCommandEvent newevent(wxINSTANT_CHANGE,GetId());
- ConceptDataWrap * cWrap = new ConceptDataWrap( _horizontalConceptName );
- cWrap->setActualValue( nxActual_h );
+ // ConceptDataWrap * cWrap = new ConceptDataWrap( _horizontalConceptName );
+ // cWrap->setActualValue( nxActual_h );
- newevent.SetClientData( (void *)cWrap );
- _eventHandler->ProcessEvent(newevent);
- }
+ // newevent.SetClientData( (void *)cWrap );
+ // _eventHandler->ProcessEvent(newevent);
+
+ //}
+ //JCP 26 - 11 - 08
}
/**
* Handles the event wxEVT_TSBAR_START from the horizontal bar
*/
void wxContourViewPanel :: onActualChange_Bar_Vertical(wxCommandEvent& event)
{
+ int actual = getActualVertical();
+ wxContourMainFrame::getInstance()->onChangeInstant(_verticalConceptName, actual);
+ //JCP 26 - 11 - 08
+ /*
int nxActual_v = getActualVertical();
if (_eventHandler!=NULL)
newevent.SetClientData( (void *)cWrap );
_eventHandler->ProcessEvent(newevent);
- }
+ }*/
+ //JCP 26 - 11 - 08
}
/**
* Handles the event wxEVT_TSBAR_START from the vertical bar
*/
int wxContourViewPanel :: getActualVertical()
{
- return _verticalBar->GetEnd();
+ return _verticalBar->GetActual();//GetEnd();
}
/**
//EED 08/04/2008
// return theViewPanel->GetZ(1);
return theViewPanel->GetZ();
+ //return GetZ();
}
+ bool wxContourViewPanel::isEditableCControler(std::string theKeyName){
+ return _sceneManager->isEditableCControler(theKeyName);
+ }
+
+ void wxContourViewPanel::removeFromScene(std::string theKeyName){
+
+ _sceneManager->deleteCViewerCControler(theKeyName);
+
+
+ }
+
+ void wxContourViewPanel::onChangeInstant(wxCommandEvent& event){
+ ConceptDataWrap * dataConcept = NULL;
+ if ( GetId() == event.GetId() )
+ {
+ dataConcept = (ConceptDataWrap *)event.GetClientData();
+ int value = dataConcept->getActualValue();
+ //_instantPanel->setConceptValue( dataConcept->getName(), value );
+ wxContourMainFrame::getInstance()->setConceptValue( dataConcept->getName(), value );
+ }
+ else
+ {
+ dataConcept = wxContourMainFrame::getInstance()->getLastConceptData();
+ if( dataConcept->getName().compare( getVerticalConceptName() ) == 0)
+ {
+ setActualVertical( dataConcept->getActualValue());
+ //_theViewPanel->setVerticalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
+ }
+ else if( dataConcept->getName().compare( getHorizontalConceptName() ) == 0|| wxContourMainFrame::getInstance()->getIfConceptCheckedAt( dataConcept->getName(), 0 ) )
+ {
+ setHorizontalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
+ }
+ }
+ wxContourMainFrame::getInstance()->changeInstant();
+ }
+ void wxContourViewPanel::onCreateMultipleROI (wxCommandEvent& event){
+ }
+ void wxContourViewPanel::onCreateROI (wxCommandEvent& event){
+ }
+ void wxContourViewPanel::onStopCreateROI (wxCommandEvent& event){
+ }
+ void wxContourViewPanel::onChangedDeep (wxCommandEvent& event){
+ double val = getCurrentDeep();
+ setActualVertical( (int)val );
+ wxContourMainFrame::getInstance()->onChangeDeep((int)val);
+ //_instantPanel->setConceptValue( "Axe Depth", (int)val );
+
+// changeInstant();
+ }
+ void wxContourViewPanel::onActionButtonPressed(wxCommandEvent& event){
+ }
+
+ void wxContourViewPanel::removeSceneContours(){
+ _sceneManager->removeSceneContours();
+ }
+
+ void wxContourViewPanel::addNameWrapperToScene(){
+ int size = wxContourMainFrame::getInstance()->getNamesWrappingSize();
+ for(int i = 0; i < size;i++){
+ std::string name = wxContourMainFrame::getInstance()->getNameWrapping(i);
+ _sceneManager->addToScene(name, true, true, true, false, false );
+ }
+ }
+
+ std::vector<std::string> wxContourViewPanel::getSelectedObjects(){
+ return _sceneManager->getSelectedObjects();
+ }
+
+ void wxContourViewPanel::RefreshInterface(){
+ getWxVtkBaseView()->Refresh();
+ }
+ vtkImageData* wxContourViewPanel::getImageData(){
+ return _sceneManager->GetImageData();
+ }
+
+ void wxContourViewPanel::configureViewControlTo(std::string theName,manualContourModel* manModelContour,double* spc,int typeofcontour){
+ _sceneManager->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
+ }
+
+ int wxContourViewPanel::GetImageDataSizeZ(){
+ return _sceneManager->GetImageDataSizeZ();
+ }
+
+ void wxContourViewPanel::GetImageDataRange(double *range){
+ _sceneManager->GetImageDataRange(range);
+ }
+
+ void wxContourViewPanel::SetWidthContour(double width ){
+ _sceneManager->SetWidthContour( width );
+ }
+
+ int wxContourViewPanel::getColorWindow(){
+ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
+ vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
+ int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
+ return colorwindow;
+ }
+
+ int wxContourViewPanel::getWindowLevel(){
+ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
+ vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
+ int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
+ return windowlevel;
+ }
+
+ void wxContourViewPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel){
+ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
+ vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
+ imageviewer->SetColorWindow(colorwindow);
+ imageviewer->SetColorLevel(windowlevel);
+ }
+
+ void wxContourViewPanel::onInterpolation(bool interpolate){
+ wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
+ vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
+
+ if (interpolate){
+ imageviewer->GetImageActor()->InterpolateOn();
+ } else {
+ imageviewer->GetImageActor()->InterpolateOff();
+ }
+ }
+
+ void wxContourViewPanel::GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ ){
+ _sceneManager->GetPointsOfActualContour(vecX, vecY, vecZ);
+ }
\ No newline at end of file
-#ifndef __wxContourViewPanel_h_INCLUDED_H__
-#define __wxContourViewPanel_h_INCLUDED_H__
+#ifndef __wxContourViewPaneL_h_INCLUDED_H__
+#define __wxContourViewPaneL_h_INCLUDED_H__
// -----------------------------------------------------------------------------------------------------------
#include "wxVtkBaseView.h"
#include <iostream>
#include <wx/event.h>
+#include "wxVtkBaseView_SceneManager.h"
+#include "manualContour.h"
+
+#include <vtkImageMapToWindowLevelColors.h>
+
+
//------------------------------------------------------------------------------------------------------------
// Events declaration
//------------------------------------------------------------------------------------------------------------
void Refresh();
-private:
- //------------------------------------------------------------------------------------------------------------
- // Private methods
- //------------------------------------------------------------------------------------------------------------
+//this method should be deleted
+ wxVtkBaseView_SceneManager* getSceneManager();
+////////////7
+ void initializeScenceManager();
+ bool isEditableCControler(std::string theKeyName);
+ void removeFromScene(std::string theKeyName);
+
+/////////////////////////////////////////////////////
+ void onChangeInstant(wxCommandEvent& event);
+ void onCreateMultipleROI (wxCommandEvent& event);
+ void onCreateROI (wxCommandEvent& event);
+ void onStopCreateROI (wxCommandEvent& event);
+ void onChangedDeep (wxCommandEvent& event);
+ void onActionButtonPressed(wxCommandEvent& event);
+
+ void removeSceneContours();
+ void addNameWrapperToScene();
+
+ std::vector<std::string> getSelectedObjects();
+
+ void RefreshInterface();
+
+ vtkImageData* getImageData();
+
+ void configureViewControlTo(std::string theName,manualContourModel* manModelContour,double* spc,int typeofcontour);
+
+ int GetImageDataSizeZ();
+
+ void GetImageDataRange(double *range);
+ void SetWidthContour(double width );
+
+ int getColorWindow();
+
+ int getWindowLevel();
+
+ void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
+
+ void onInterpolation(bool interpolate);
+
+ void GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ );
+
+ void changeImage(vtkImageData* img);
+private:
+
//------------------------------------------------------------------------------------------------------------
// Attributtes
//------------------------------------------------------------------------------------------------------------
+ wxVtkBaseView_SceneManager* _sceneManager;
/*
* Represents the outer sizer of the ContourViewPanel
*/
wxEvtHandler * _eventHandler;
//EED
+
+ //------------------------------------------------------------------------------------------------------------
+ // Private methods
+ //------------------------------------------------------------------------------------------------------------
+
+
+
wxVtkMPR2DView * GetwxVtkMPR2DView();
#include "wxContourMainFrame.h"
//Test JCP 13-10-08
-#include "wxContourEventHandler.h"
+//#include "wxContourEventHandler.h"
//Test JCP 13-10-08
//----------------------------------------------------------------------------------------------------------------
sizer->Add( _outSizer, 1, wxEXPAND| wxGROW );
sizer->Add( resolutionSizer, 1, wxEXPAND | wxGROW );
SetSizer( sizer );
- Connect( wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxInstantChooserPanel:: onChechBoxClicked );
+ Connect( wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxInstantChooserPanel:: onCheckBoxClicked );
}
sizer->Add( _outSizer, 1, wxEXPAND| wxGROW );
sizer->Add( _resolutionSlider, 1, wxEXPAND | wxGROW );
SetSizer( sizer );
- Connect( wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxInstantChooserPanel:: onChechBoxClicked );
+ Connect( wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxInstantChooserPanel:: onCheckBoxClicked );
}
wxInstantChooserPanel :: ~wxInstantChooserPanel()
}
//------------------------------------------------------------------------------------------------------------
- void wxInstantChooserPanel :: onChechBoxClicked( wxCommandEvent& event )
+ void wxInstantChooserPanel :: onCheckBoxClicked( wxCommandEvent& event )
{
- int groupID = (int)event.GetClientData();
+ /*int groupID = (int)event.GetClientData();
wxConceptControl * eventConcept = (wxConceptControl *)event.GetEventObject();
if ( eventConcept->getIfChecked( groupID ) )
{
}
}
}
+ }*/
+
+ int groupID = (int)event.GetClientData();
+ wxConceptControl * eventConcept = (wxConceptControl *)event.GetEventObject();
+ if ( eventConcept->getIfChecked( groupID ) )
+ {
+ int size = _concepts->size();
+ wxConceptControl * aConcept = NULL;
+ int accum = 0;
+
+ for(int i = 0; i < eventConcept->getNumCheckBox();i++){
+ if(i!=groupID){
+ eventConcept->clearCheckAt(i);
+ }
+ }
+ for(int i=0; i<size; i++)
+ {
+ aConcept = (*_concepts)[i];
+ if( aConcept!= eventConcept )
+ {
+ if( aConcept->getIfChecked( groupID ) )
+ {
+ aConcept->clearCheckAt( groupID );
+ }
+ }
+ }
+
}
}
//-------------------------------------------------
wxCommandEvent newevent(wxINSTANT_CHOOSER_CHANGE,GetId());
//this->onChangeInstant(newevent);
- ((wxContourEventHandler*)_eventHandler)->onChangeInstant(newevent);
+ ConceptDataWrap * dataConcept = getLastConceptData();
+ if(getIfConceptCheckedAt( dataConcept->getName(), 0 )){
+ wxContourMainFrame::getInstance()->onChangeInstantInstantPanel(dataConcept->getName(), dataConcept->getActualValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue());
+ }
+ //((wxContourEventHandler*)_eventHandler)->onChangeInstant(newevent);
//_eventHandler->ProcessEvent(newevent);
}
}
+ void wxInstantChooserPanel::addConcepts(std::vector<std::string> conceptNameVect,std::vector<int> conceptSizeVect){
+ int i=0;
+ int max = conceptNameVect.size();
+ for( ; i<max; i++)
+ {
+ if( conceptNameVect[i].compare("Axe Depth") == 0 )
+ {
+ addConcept( conceptNameVect[i], 0, conceptSizeVect[i], 1);
+ } else {
+ addConcept( conceptNameVect[i], 1, conceptSizeVect[i], 1);
+ } // if
+ }
+ }
\ No newline at end of file
//------------------------------------------------------------------------------------------------------------
void onResolutionSlider( wxScrollEvent& event );
- void onChechBoxClicked( wxCommandEvent& event );
+ void onCheckBoxClicked( wxCommandEvent& event );
void onConceptRelease( wxCommandEvent& event );
//------------------------------------------------------------------------------------------------------------
void onChangeInstant( wxCommandEvent& event );
+ void addConcepts(std::vector<std::string> conceptNameVect,std::vector<int> conceptSizeVect);
+
private:
//------------------------------------------------------------------------------------------------------------
// Private methods
std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
iter = _contours_ViewControl->find( theName );
return iter->second;
+ //return iter->first;
}
//------------------------------------------------------------------------------------------------------------
ContourWrap_ViewControl * wxVtkBaseView_SceneManager :: getContourWrap_ViewControlOf ( std::string theName, std::map<std::string, ContourWrap_ViewControl *> * theMap )
cViewer->SetWidthLine(_widthOfContour);
}
}
+
+ bool wxVtkBaseView_SceneManager::isEditableCControler(std::string theKeyName){
+
+ ContourWrap_ViewControl* ccon = getContourWrap_ViewControlOf(theKeyName);
+ if(ccon != NULL ){
+ manualContourBaseControler* cControler = ccon->getControler();
+ if(cControler != NULL && cControler->IsEditable() == false){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void wxVtkBaseView_SceneManager::deleteCViewerCControler(std::string theKeyName){
+
+
+ ContourWrap_ViewControl* ccon = getContourWrap_ViewControlOf(theKeyName);
+
+ manualViewBaseContour * cViewer = ccon->getViewer();
+ manualContourBaseControler * cControler = ccon->getControler();
+
+ removeFromScene(theKeyName);
+ removeWrap(theKeyName);
+
+ delete cViewer;
+ delete cControler;
+ }
+
\ No newline at end of file
void GetImageDataRange( double *range );
void SetWidthContour(double width);
-
+//JCP 21 - 09 - 08
+ bool isEditableCControler(std::string theKeyName);
+ void deleteCViewerCControler(std::string theKeyName);
private:
//------------------------------------------------------------------------------------------------------------
// Private methods
--- /dev/null
+
+//----------------------------------------------------------------------------------------------------------------
+// Class definition include
+//----------------------------------------------------------------------------------------------------------------
+#include "KernelManagerContour.h"
+
+
+KernelManagerContour::KernelManagerContour(){
+
+
+/**THIS ALL SHOULD BE IN AN OTHER LIB CALLED PERSISTANCE
+**
+**/
+ inredo = 0;
+ inundo = 0;
+ stundoredo = "data/temp";
+ _currentIndex = 0;
+
+ _contourPropagation = NULL;
+#if(WIN32)
+ mkdir(stundoredo.c_str());
+#else
+ mkdir(stundoredo.c_str(),755);
+#endif
+ stundoredo += "/cont";
+/**
+** FINISH PERSISTANCE
+**/
+
+}
+KernelManagerContour::KernelManagerContour(std::vector<vtkImageData*> images){
+
+
+/**THIS ALL SHOULD BE IN AN OTHER LIB CALLED PERSISTANCE
+**
+**/
+ inredo = 0;
+ inundo = 0;
+ stundoredo = "data/temp";
+ _currentIndex = 0;
+
+ _contourPropagation = NULL;
+#if(WIN32)
+ mkdir(stundoredo.c_str());
+#else
+ mkdir(stundoredo.c_str(),755);
+#endif
+ stundoredo += "/cont";
+/**
+** FINISH PERSISTANCE
+**/
+ setVectImages(images);
+ initializeEnvironment();
+
+}
+KernelManagerContour::~KernelManagerContour(){
+}
+
+std::vector<vtkImageData*> KernelManagerContour::getVectImages(){
+ return vectimages;
+}
+void KernelManagerContour::setVectImages(std::vector<vtkImageData*> vectimg){
+ vectimages = vectimg;
+}
+
+void KernelManagerContour::initializeEnvironment(){
+ std::string conceptsFN = "data/holaConceptsFile.cf";
+ std::string imageSourcesFN = "data/holaImagesInstantsFile.of";
+ std::string imageSectionsFN = "";
+ std::string axeThingsFN = "";
+
+ std::map<std::string, ImageSourceThing *> * sourcesMap = new std::map<std::string, ImageSourceThing *>();
+ std::map<std::string, ImageSectionThing *>* sectionsMap = new std::map<std::string, ImageSectionThing *>();
+ std::map<std::string, AxeThing *>* axesMap = new std::map<std::string, AxeThing *>();
+ std::map<std::string, ContourThing *>* outlinesMap = new std::map<std::string, ContourThing *>();
+
+ for(int i = 0; i < vectimages.size(); i++){
+ vtkImageData* selectedimage = vectimages[i];
+ ImageSourceThing * thing = new ImageSourceThing(selectedimage);
+ std::string imgstring = "Source Image "+intToString(i+1);
+ sourcesMap->insert(std::pair<std::string, ImageSourceThing *>( imgstring, thing));
+ }
+
+
+ OutlineModelBuilder * _builder = new OutlineModelBuilder( conceptsFN );
+ _builder->buildImageSource_Envornment( imageSourcesFN, sourcesMap );
+ _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap );
+ _builder->buildAxe_Envornment(axeThingsFN, axesMap );
+ _builder->buildCountour_Envornment( imageSectionsFN, outlinesMap );
+
+ //Creating the objects to manage
+ modelManager = new OutlineModelManager( _builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv() );
+
+ imageSource = modelManager->getImageSourceThingByKeyName( "Source Image 1" );
+
+}
+vtkImageData* KernelManagerContour::getSourceImage(){
+ return imageSource->getSourceImage();
+}
+OutlineModelManager* KernelManagerContour::getOutlineModelManager(){
+ return modelManager;
+}
+
+std::string KernelManagerContour::createOutline(manualContourModel * manModelContour,std::vector<int> instantVector){
+ return modelManager->createOutline( manModelContour, instantVector );
+}
+
+std::string KernelManagerContour::intToString(int num){
+ std::string result;
+ if(num == 0){
+ result = "0";
+ }else{
+ int k=num;
+ while (k > 0){
+ char temp = k % 10 + 48;
+ k = k / 10;
+ result = temp + result;
+ }
+ }
+ return result;
+}
+
+std::vector<std::string> KernelManagerContour::GetLstNameThingsStatic(){
+ return modelManager->GetLstNameThingsStatic();
+}
+
+void KernelManagerContour::SaveThingName(FILE* pFile, std::string name ){
+ modelManager->SaveThingName(pFile, name);
+}
+std::vector<std::string> KernelManagerContour::GetLstNameThings(){
+ return modelManager->GetLstNameThings();
+}
+//int KernelManagerContour::IsPartOfStaticList(std::string keyName ){
+// return modelManager->IsPartOfStaticList(keyName);
+//}
+
+bool KernelManagerContour::IsPartOfStaticList(std::string theKeyName){
+ return modelManager->IsPartOfStaticList(theKeyName) == -1;
+}
+
+void KernelManagerContour::deleteCModel(std::string theKeyName){
+ manualContourModel* cModel = modelManager->getOutlineByKeyName(theKeyName)->getModel();
+ modelManager->removeOutline( theKeyName );
+
+ delete cModel;
+}
+
+void KernelManagerContour::removeAllOutlines(){
+ modelManager->removeAllOutlines();
+}
+
+std::vector<NameWrapper *> KernelManagerContour::getActualInstantOutlines(){
+ return modelManager->getActualInstantOutlines();
+}
+
+int KernelManagerContour::getNamesWrappingSize(){
+ return getActualInstantOutlines().size();
+}
+
+std::string KernelManagerContour::getNameWrapping(int i){
+ return getActualInstantOutlines()[i]->getKeyName();
+}
+
+void KernelManagerContour::setInstant(Instant * theInstant){
+ modelManager->setInstant(theInstant);
+ //_actualInstant = theInstant;
+}
+
+Instant * KernelManagerContour::getCurrentInstant(){
+ return modelManager->getInstant();
+}
+void KernelManagerContour::setInstant(std::vector<int> vectInstant){
+ Instant* act = new Instant ( &vectInstant );
+ modelManager->setInstant(act);
+}
+
+std::string KernelManagerContour::createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData){
+ return modelManager->createCopyContourOf(anExistingKName, instantNoTouchData);
+}
+manualContourModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName){
+ return modelManager->getOutlineByKeyName (cloneName )->getModel();
+}
+
+bool KernelManagerContour::onRedo(std::string& filename){
+ if(inredo > 0){
+ inredo--;
+ inundo++;
+ std::string str = intToString(inundo);
+ filename = stundoredo + str + ".roi";
+ //loadState(temp);
+ return true;
+ }
+ return false;
+}
+
+bool KernelManagerContour::onUndo(std::string& filename){
+ if(inundo>0){
+ inredo++;
+ inundo--;
+
+ //char str[9000];
+ //itoa(inundo, str, 10);
+ std::string str = intToString(inundo);
+
+
+ filename = stundoredo + str + ".roi";
+
+ return true;//loadState(temp);
+ }
+ return false;
+}
+
+std::string KernelManagerContour::saveState(){
+ inredo=0;
+ std::string str = intToString(inundo);
+ std::string temp = stundoredo + str + ".roi";
+ inundo++;
+ return temp;
+}
+
+bool KernelManagerContour::onUndoSaveFile(std::string& filename){
+ if(inundo>0){
+ if(inredo==0){
+
+ //char str[9000];
+ //itoa(inundo, str, 10);
+ std::string str = intToString(inundo);
+
+ filename = stundoredo + str + ".roi";
+ return true;
+ //saveFileWithContours(temp);
+
+ }
+ }
+ return false;
+}
+
+void KernelManagerContour :: changeContourOfManager(std::string keyName, Instant *instant)
+{
+ modelManager->ChangeContourOfList(keyName, instant);
+}
+
+void KernelManagerContour ::resetAppend(){
+ if(isInitContourPropagation()){
+ _contourPropagation->resetAppend();
+ }
+}
+
+bool KernelManagerContour::isInitContourPropagation(){
+ if(_contourPropagation == NULL){
+ _contourPropagation = new ContourPropagation();
+ }else{
+ return true;
+ }
+ return false;
+
+}
+
+std::string KernelManagerContour::onSpreadAdd( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ, std::vector<int> instants){
+ if(isInitContourPropagation()){
+ if (vecX->size()!=0){
+
+ int i,size=vecZ->size();
+ int actualSlice = instants[1];
+ for ( i=0 ; i<size ; i++ )
+ {
+ (*vecZ)[i] = actualSlice;
+ } // for
+
+ _contourPropagation->appendContour(vecX , vecY , vecZ);
+ return intToString(actualSlice);
+ }
+ }
+ return "";
+}
+
+void KernelManagerContour::getMaxMinZ(double *minZ,double *maxZ){
+ if(isInitContourPropagation()){
+ _contourPropagation->getMaxMinZ(minZ, maxZ);
+ }
+}
+void KernelManagerContour::CalculeSplinePropagation(){
+ _contourPropagation->setInterpolationNumber(100);
+ _contourPropagation->CalculeSplinePropagation();
+}
+
+manualContourModel* KernelManagerContour::GetPoints(int z,int type, std::vector<double>* vecCtrlPointX,std::vector<double>* vecCtrlPointY,std::vector<double>* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector<int> tempVector){
+
+
+ bool addedModel = false;
+ manualContourModel* manModelContour=NULL;
+
+ if (_contourPropagation->ifSliceKeyContourExist(z)==false){
+
+ manModelContour = factoryManualContourModel( typeofcontour );
+
+ int idTmp = _contourPropagation->FindIdWithZ(z);
+
+ if (type==0) // Initial Points
+ {
+ _contourPropagation->GetInitialControlPoints( idTmp , vecCtrlPointX,vecCtrlPointY,vecCtrlPointZ);
+ }
+ if (type==1) // Automatique Method
+ {
+ _contourPropagation->GetControlPoints( idTmp ,vecCtrlPointX,vecCtrlPointY,vecCtrlPointZ);
+ }
+ if (type==2) // sampling
+ {
+ _contourPropagation->GetControlPoints( idTmp , 20.0 ,vecCtrlPointX,vecCtrlPointY,vecCtrlPointZ);
+ }
+//--------------------------------------------------------------------
+ int sizeCtrPt = vecCtrlPointX->size();
+ for (int j=0 ; j<sizeCtrPt ; j++)
+ {
+//JSTG_16-07-08_----------------------------------------------------------------
+ manModelContour->AddPoint( (*vecCtrlPointX)[j] , (*vecCtrlPointY)[j] , -900 );
+//--------------------------------------------------------------------
+ } // for j
+
+ tempVector[1]=z;
+ theName = modelManager->createOutline( manModelContour, tempVector );
+ addedModel = theName.compare("") != 0;
+ if(!addedModel){
+ manModelContour = NULL;
+ }
+
+ }// ifSliceKeyContourExist
+ return manModelContour;
+
+}
+
+manualContourModel * KernelManagerContour::factoryManualContourModel(int typeContour)
+{
+ manualContourModel *manModelContour=NULL;
+
+ // spline
+ if (typeContour==0)
+ {
+ manModelContour = new manualContourModel();
+ }
+
+ // spline
+ if (typeContour==1)
+ {
+ manModelContour = new manualContourModel();
+ }
+
+ // rectangle
+ if (typeContour==2)
+ {
+ manModelContour = new manualContourModelRoi();
+ }
+
+ // circle
+ if (typeContour==3)
+ {
+ manModelContour = new manualContourModelCircle();
+ }
+
+ return manModelContour;
+}
+
+std::vector<std::string> KernelManagerContour::getOutlinesNameAtInstant(std::vector<int> tempvector){
+ Instant instant(&tempvector);
+ std::vector<ContourThing**> vectcont = modelManager->getOutlinesAtInstant( &instant );
+ std::vector<std::string> vectname;
+ for(int i = 0; i < vectcont.size(); i++){
+ ContourThing **contourthing = vectcont[i];
+ vectname.push_back((*contourthing)->getName());
+ }
+ return vectname;
+}
+
+std::vector<ContourThing**> KernelManagerContour::getOutlinesAtInstant(Instant* instant ){
+ return modelManager->getOutlinesAtInstant(instant);
+}
+
+std::vector<manualContourModel*> KernelManagerContour::ExploseEachModel( std::vector<manualContourModel*> lstManConMod ){
+ std::vector<manualContourModel*> lstTmp;
+ std::vector<manualContourModel*> lstResult;
+ int j,jSize;
+ int i,iSize=lstManConMod.size();
+ for (i=0;i<iSize;i++)
+ {
+ lstTmp = lstManConMod[i]->ExploseModel();
+ jSize=lstTmp.size();
+ for (j=0;j<jSize;j++)
+ {
+ lstResult.push_back( lstTmp[j] );
+ }
+ }
+ return lstResult;
+}
+
+void KernelManagerContour::getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect){
+ modelManager-> getConceptsInformation(conceptNameVect, conceptSizeVect);
+}
+
+
+vtkImageData* KernelManagerContour::getImageAtInstant(std::vector<int> inst){
+ int index = inst[5]-1;
+
+ if(index < vectimages.size()&&index!=_currentIndex){
+ _currentIndex=index;
+ return vectimages[index];
+ }
+ return NULL;
+}
\ No newline at end of file
--- /dev/null
+#ifndef __KERNELMANAGERCONTOUR__
+#define __KERNELMANAGERCONTOUR__
+
+
+
+//------------------------------------------------------------------------------------------------------------
+// Includes
+//------------------------------------------------------------------------------------------------------------
+#include "ImageSourceThing.h"
+#include "ImageSectionThing.h"
+#include "AxeThing.h"
+#include "ContourThing.h"
+#include "OutlineModelManager.h"
+#include "OutlineModelBuilder.h"
+
+#include "Contour/ContourPropagation.h"
+
+
+class KernelManagerContour{
+
+//------------------------------------------------------------------------------------------------------------
+// Constructors & Destructors
+//------------------------------------------------------------------------------------------------------------
+public:
+
+ /**
+ ** With this constructor the setVectImages and initialize environment must be called
+ **/
+ KernelManagerContour();
+ /**
+ ** If images are available before the construction of the kernelManager this method should be used
+ ** it sets the vector images and initializes the environment
+ **/
+ KernelManagerContour(std::vector<vtkImageData*> images);
+ ~KernelManagerContour();
+
+ std::vector<vtkImageData*> getVectImages();
+ void setVectImages(std::vector<vtkImageData*> vectimg);
+
+ /**
+ ** This method returns the source of the image data selected by the user.
+ */
+ vtkImageData* getSourceImage();
+
+
+
+ void initializeEnvironment();
+
+
+ /**
+ ** This methods connect the event in the class interfNewContourMenu with the world of the appli
+ **/
+
+ std::string createOutline(manualContourModel * manModelContour,std::vector<int> instantVector);
+ /////////////////////////////////
+
+ std::string intToString(int num);
+
+ std::vector<std::string> GetLstNameThingsStatic();
+
+ void SaveThingName(FILE* pFile, std::string name );
+
+ std::vector<std::string> GetLstNameThings();
+
+ bool IsPartOfStaticList(std::string keyName );
+
+ void deleteCModel(std::string theKeyName);
+
+ void removeAllOutlines();
+
+ //void setInstance(theInstant);
+
+ std::vector<NameWrapper *> getActualInstantOutlines();
+
+ int getNamesWrappingSize();
+
+ std::string getNameWrapping(int i);
+
+ void setInstant(Instant* theInstant);
+ void setInstant(std::vector<int> vectInstant);
+ std::string createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData);
+
+ Instant * getCurrentInstant();
+
+ manualContourModel* getOutlineByKeyName(std::string cloneName);
+
+ bool onRedo(std::string& filename);
+
+ bool onUndo(std::string& filename);
+
+ bool onUndoSaveFile(std::string& filename);
+
+ std::string saveState();
+
+ void changeContourOfManager(std::string keyName, Instant *instant);
+
+ void resetAppend();
+
+ std::string onSpreadAdd( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ, std::vector<int> instants);
+
+ void getMaxMinZ(double *minZ,double *maxZ);
+
+ manualContourModel* GetPoints(int z,int type, std::vector<double>* vecCtrlPointX,std::vector<double>* vecCtrlPointY,std::vector<double>* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector<int> tempVector);
+
+ manualContourModel* factoryManualContourModel(int typeContour);
+
+ void CalculeSplinePropagation();
+
+ std::vector<std::string> getOutlinesNameAtInstant(std::vector<int> tempvector);
+
+ std::vector<ContourThing**> getOutlinesAtInstant(Instant* instant );
+
+ std::vector<manualContourModel*> ExploseEachModel( std::vector<manualContourModel*> lstManConMod );
+
+
+ void getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect);
+
+ vtkImageData* getImageAtInstant(std::vector<int> inst);
+
+//------------------------------------------------------------------------------------------------------------
+// Constants
+//------------------------------------------------------------------------------------------------------------
+
+private:
+//------------------------------------------------------------------------------------------------------------
+// Attributes
+//------------------------------------------------------------------------------------------------------------
+ std::vector<vtkImageData*> vectimages;
+
+ ImageSourceThing * imageSource;
+
+ //Instant * _actualInstant;
+//Temporary attribute should be removed
+ OutlineModelManager * modelManager;
+
+ int inredo;
+ int inundo;
+ int _currentIndex;
+ std::string stundoredo;
+
+ ContourPropagation* _contourPropagation;
+
+ bool isInitContourPropagation();
+
+ OutlineModelManager* getOutlineModelManager();
+};
+#endif
updateToActualInstant();
}
+ Instant* OutlineModelManager :: getInstant()
+ {
+ return actualInstant;
+ }
+
/*
* Gets the an axe with a given keyName
* @axeKName The axe keyName for searching in the axes environment
void ChangeContourOfList(std::string keyName, Instant *instant);
int IsPartOfStaticList(std::string ss);
-
+ Instant* getInstant();
private :
bool setAutomaticConcepts();
+
//------------------------------------------------------------------------------------------------------------