///
void GimmickView::Initialize()
{
+ row="";
+ col="";
+ plane="";
+ selectionSize=0;
}
//======================================================================
i->second->UpdateLevel(l);
}
//======================================================================
+ /// Clears the status and begins a new selection process
+ void GimmickView::ClearStatus()
+ {
+ row="";
+ col="";
+ plane="";
+ selectionSize=0;
+ valid=true;
+ }
+ //======================================================================
///Validates the dimension compliance of the images with the maximum and
///minimum given, and between their sizes
- bool GimmickView::ValidateSelected (std::vector<tree::Node*>& sel, int min_dim, int max_dim)
+ bool GimmickView::ValidateSelected (tree::Node* sel, int min_dim, int max_dim)
{
GimmickMessage(2,"Validating selected"<<std::endl);
-
- bool valid=true;
-
- // EED validate all
+ selectionSize++;
+ /*// EED validate all
mValidationSignal(valid);
- return valid;
+ return valid;*/
int level;
std::string mMessage;
- if(sel.size()>0)
+
+ if(row.compare("")==0 || col.compare("")==0)
{
- std::vector<tree::Node*>::iterator i;
- std::string row;
- std::string col;
- std::string plane;
-
- //Validation between image sizes
- for (i=sel.begin(); i!=sel.end() && valid; ++i)
- {
- if(i==sel.begin())
- {
- row=(*i)->GetAttribute("D0028_0010");
- col=(*i)->GetAttribute("D0028_0011");
- plane=(*i)->GetAttribute("D0028_0012");
- level=(*i)->GetLevel();
-
- }
- else
+ row=(*sel).GetAttribute("D0028_0010");
+ col=(*sel).GetAttribute("D0028_0011");
+ plane=(*sel).GetAttribute("D0028_0012");
+ level=(*sel).GetLevel();
+ }
+ else
+ {
+ if(((*sel).GetAttribute("D0028_0010"))!=row ||
+ ((*sel).GetAttribute("D0028_0011"))!=col ||
+ ((*sel).GetAttribute("D0028_0012"))!=plane)
{
- if(((*i)->GetAttribute("D0028_0010"))!=row ||
- ((*i)->GetAttribute("D0028_0011"))!=col ||
- ((*i)->GetAttribute("D0028_0012"))!=plane)
- {
- mMessage="The selected images are not compatible.";
- valid=false;
- }
+ mMessage="The selected images are not compatible.";
+ valid=false;
}
- }
+ }
+
//Dimention validation
//Compatibility with maximum and minimum
valid= false;
}
- if ( dim < min_dim && sel.size()<2 )
+ if ( dim < min_dim )
{
- GimmickDebugMessage(2, "State Check: Dim: "
+ GimmickMessage(1, "State Check: Dim: "
<<dim
<<" Dim min:"
<<min_dim
<<std::endl);
mMessage="Cannot build the selection as it would result in a ";
- mMessage+=dim;
+ std::string a;
+ std::stringstream out;
+ out<<dim;
+ a=out.str();
+ mMessage+=a;
mMessage+="D image, and the minimum is ";
- mMessage+=min_dim;
+ out<<min_dim;
+ a=out.str();
+ mMessage+=a;
mMessage+="D!";
valid= false;
}
}
- }
- else
- {
- mMessage="Cannot have 0 images selected";
- valid=false;
- }
+
+
if(valid)
{
mMessage="Selection OK !";
{
if (filename.size()==0)
{
+ //What to do in this case?
+ /*
GimmickDebugMessage(5,
"Pushing unknown image in queue"
<<std::endl);
- mImageEventQueue.push_back(ImageEventType(image));
+ mImageEventQueue.push_back(ImageEventType(image));*/
return;
}
ImageEventTypeMap::iterator i;
virtual void GetSelectedFiles(std::vector<std::string>& s)
{ GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); }
- virtual void OnSelectionChange(std::vector<tree::Node*>& s)
+ virtual void OnSelectionChange(std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess)
{ GimmickError("INTERNAL ERROR : OnSelectionChange not implemented"); }
virtual void ClearSelection()
{ GimmickError("INTERNAL ERROR : ClearSelection not implemented"); }
///Validates the dimension compliance of the images with the maximum and minimum given, and between their sizes
- bool ValidateSelected (std::vector<tree::Node*>& sel, int min_dim, int max_dim);
+ bool ValidateSelected (tree::Node* sel, int min_dim, int max_dim);
///Reads the vector of nodes, builds images in the dimension required and returns them in the supplied vector.
void ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<tree::Node*> im, int dim);
///Requests the reading of an image with priority and index in the
/// current selection (-1 if not in selection)
void RequestReading(tree::Node* n, int prio, int selection_index , ImagePointerHolder *p);
-
- ///Returns true if the ImageEventQueue is empty
- bool IsQueueEmpty(){return mImageEventQueue.empty();}
- ///Clears the queue
- void ClearQueue(){mImageEventQueue.clear();}
- ///Returns the next in line EventType's image
- vtkImageData* GetNextImageQueued(){return mImageEventQueue.front().image;}
- ///Returns the next in line EventType's node
- tree::Node* GetNextNodeQueued(){return mImageEventQueue.front().node;}
- ///Returns the next in line EventType's index in selection
- int GetNextSelectionIndexQueued(){return mImageEventQueue.front().index;}
- ///Unqueus the next in line EventType
- void UnqueueNext(){mImageEventQueue.pop_front();}
-
+
///Obtains the message of the state
std::string GetMessage(){return mMess;}
///Obtains the message of the state
void SetMessage(std::string mess){mMess=mess;}
+ ///Clears status and begins a new selection
+ void ClearStatus();
/// Create the tree views
void CreateTreeViews();
ImageEventTypeMap mImageEventMap;
// queue of image event
typedef std::deque<ImageEventType> ImageEventQueueType;
- ImageEventQueueType mImageEventQueue;
+ //ImageEventQueueType mImageEventQueue;
ValidationSignalType mValidationSignal;
+ std::string row;
+ std::string col;
+ std::string plane;
+ int selectionSize;
+ bool valid;
};
// EO class GimmickView
//=================================================
//=================================================
- void WxGimmickView::OnSelectionChange(std::vector<tree::Node*>& sel)
+ void WxGimmickView::OnSelectionChange(std::vector<tree::Node*>& sel, bool isSelection, int selection, bool needProcess)
{
GimmickDebugMessage(5,
"WxGimmickView::OnSelectionChange"
<<std::endl);
wxBusyCursor busy;
- bool valid = ValidateSelected(sel,
- mSelectionMinDimension,
- mSelectionMaxDimension );
+ bool valid=true;
+ if(sel.size()==0)
+ {
+ SetMessage("Cannot have 0 images selected!");
+ }
+ else if(needProcess)
+ {
+ ClearStatus();
+ std::vector<tree::Node*>::iterator i;
+ for(i=sel.begin();i!=sel.end()&&valid;++i)
+ {
+ valid= ValidateSelected((*i),
+ mSelectionMinDimension,
+ mSelectionMaxDimension );
+ }
+ }
+ else if(isSelection)
+ {
+ valid= ValidateSelected(sel.front(),
+ mSelectionMinDimension,
+ mSelectionMaxDimension );
+ }
+ else
+ {
+ ClearStatus();
+ std::vector<tree::Node*>::iterator i;
+ for(i=sel.begin();i!=sel.end()&&valid;++i)
+ {
+ valid= ValidateSelected((*i),
+ mSelectionMinDimension,
+ mSelectionMaxDimension );
+ }
+ }
+
mText->SetLabel(crea::std2wx(GetMessage()));
- if(valid)
+ /*if(valid)
{
ReadImageThreaded(sel);
}
else
{
ClearSelection();
- }
+ }*/
+ ReadImageThreaded(sel);
}
if (prio == maxprio) break;
}
}
+ else
+ {
+ pointers.clear();
+ ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
+ pointers.push_back(ph);
+ mViewer->SetImageVector(pointers);
+ }
}
//==================================================
pointers.push_back(new ImagePointerHolder(GetDefaultImage()));
mViewer->SetImageVector(pointers);
mViewer->RefreshIfNecessary();
+ ClearStatus();
}
//=================================================
void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
/// Callback called when a selection from a TreeView has changed
//(overloaded from GimmickView)
- void OnSelectionChange(std::vector<tree::Node*>& s);
+ void OnSelectionChange(std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess);
///Stops the player
void StopPlayer(){mViewer->StopPlayer();}
///Resets the default image
" Level "<<level+1
<<std::endl);
+ GimmickMessage(1,
+ " Event type "<<event.GetEventType()
+ <<std::endl);
if(event.m_itemIndex!=0)
{
if(level<mLevelList.size()-1)
if (level==mLevelList.size()-2) SelectLowerLevel();
if (level==(mLevelList.size()-1)&&mProcess)
{
- ValidateSelectedImages ();
+ if(event.GetEventType()==10145)
+ {
+ ValidateSelectedImages (true);
+ }
+ else
+ {
+ ValidateSelectedImages (false);
+ }
}
+ //SetColor(level,event.m_itemIndex);
}
else
{
}
//================================================================
- void WxTreeView::ValidateSelectedImages()
+ void WxTreeView::ValidateSelectedImages(bool isSelection)
{
GimmickDebugMessage(7,
"WxTreeView::ValidateSelectedImages"
<<std::endl);
std::vector<tree::Node*> sel(GetSelected(mLevelList.size()+1));
- GetGimmickView()->OnSelectionChange(sel);
+ GetGimmickView()->OnSelectionChange(sel,isSelection,(mLastSelected-1), mProcess);
}
//================================================================
}
//================================================================
- void WxTreeView::SetColor(int l)
+ void WxTreeView::SetColor(int l, int item)
{
- /*
+ int colorId=12;
+ GetCtrl(l)->SetItemTextColour(item, wxColourDatabase().Find
+ (crea::std2wx(mColorPalette[colorId])));
+ GetCtrl(l)->SetItemState(item,wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED); /*
int colorId=0;
//Setting the color according to the parent
if(l==0)
/// Gets the user selected data from the level passed as a parameter
std::vector<tree::Node*> GetSelected(int level);
///Validates the selected images
- void ValidateSelectedImages();
+ void ValidateSelectedImages(bool isSelection);
///Gets selected filenames
void GetSelectedAsString(std::vector<std::string>&s);
/// Gets the next nodes on the list, be it up(true) or down(false).
/// Recursive method
virtual void RecursiveUpdateLevel( int );
///Sets the color of a selected item
- void SetColor(int level);
+ void SetColor(int level, int item);
///Creates the color palette for the first level
void CreateColorPalette();
///Selects the lowest level (images)
}
return false;
}
+ //================================================================
+
//==================================================
void WxViewer::StopPlayer()
{
mPlayer->Delete();
mPlayer=0;
}
-
+ //================================================================
+
//==================================================
void WxViewer::StartPlayer()
{
{
public:
- /// Ctor
+ /// Ctors
WxViewer();
WxViewer(wxWindow *parent,
const wxWindowID id,
const wxSize& size);
/// Dtor
virtual ~WxViewer();
- ///
+ /// Shows the next image in the image vector
void ShowNextImage();
-
+ ///Starts the image player
void StartPlayer();
-
+ ///Stops the image player
void StopPlayer();
-
+ ///Refreshes the interface if the current image shown has changed
bool RefreshIfNecessary();
-
+ ///Sets a new image vector to be read
void SetImageVector(std::vector<ImagePointerHolder*>& pointers);
private:
- ///Shows the image passed as parameter
+ ///Shows the image passed as parameter
void ShowImage(vtkImageData* im);
-
/// Previewer
vtkImageViewer2* mViewer;
/// Associated wxvtk interactor
crea::creawxVTKRenderWindowInteractor *mInteractor;
-
/// Current extent
int mx1,mx2,my1,my2,mz1,mz2;
/// Current spacing
double mspx,mspy,mspz;
-
- ///
+ /// Current image shown
int mCurrent;
///The threaded movie player
WxViewerPlayer* mPlayer;
-
/// The mutex
wxMutex mMutex;
-
- ///
+ /// Boolean that declares if the player needs to be refreshed
bool mNeedRefresh;
-
-
+ ///Last image shown
vtkImageData* mLastImageShown;
+ ///The vectors of images to be shown
std::vector<ImagePointerHolder*> imagePointers;
};