GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoTraceSettingsWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 
35 #ifndef __QGoTraceSettingsWidget_h
36 #define __QGoTraceSettingsWidget_h
37 
38 #include <QWidget>
39 #include <QComboBox>
40 #include <QLabel>
41 #include <QHBoxLayout>
42 #include <QVBoxLayout>
45 #include "QGoComboBox.h"
46 
47 #include <QToolBar>
48 #include "QGoGUILibConfigure.h"
49 
56 class QGOGUILIB_EXPORT QGoTraceSettingsWidget:
57  public QWidget
58 {
59  Q_OBJECT
60 public:
61  explicit QGoTraceSettingsWidget(QWidget *parent = 0);
63 
65  typedef std::vector< std::pair< std::string, std::string > >
67 
77  std::string GetTraceName();
78 
83  void SetCurrentCellType(std::string iCellTypeText);
84 
89  void SetCurrentCellTypeToSelectedOne();
90 
95  void SetCurrentSubCellType(std::string iSubCellTypeText);
96 
101  void SetCurrentSubCellTypeToSelectedOne();
102 
107  void SetCurrentColor(std::string iColorText);
108 
113  void SetCurrentColorToSelectedOne();
114 
119  void SetCurrentCollectionID(std::string iID);
120 
121  void SetCurrentTraceName(std::string iTraceName);
122 
130  //void UpdateTraceAndCollection(
131  // std::string iTrace, std::string iCollection);
132 
140  void SetListCollectionID(
141  std::list< ItemColorComboboxData > iListExistingID,
142  std::string iCollectionIDtoSelect = "");
143 
151  void SetListColors(std::list< ItemColorComboboxData > iListColors,
152  std::string iColorToSelect = "");
153 
159  void SetListColorsWithSelectedOne(std::list< ItemColorComboboxData > iListColors);
160 
169  void SetListCellTypes(NamesDescrContainerType iCellTypesData,
170  std::string iCellTypeToSelect = "");
171 
178  void SetListCellTypeWithSelectedOne(NamesDescrContainerType iCellTypesData);
179 
188  void SetListSubCellTypes(NamesDescrContainerType iSubCellData,
189  std::string iSubCellTypeToSelect = "");
190 
197  void SetListSubCellTypeWithSelectedOne(NamesDescrContainerType iSubCellTypesData);
198 
199  std::string* GetPointerSelectedCellType();
200  std::string* GetPointerSelectedSubCellType();
201  ItemColorComboboxData* GetPointerCollectionData();
202  ItemColorComboboxData* GetPointerColorData();
203 
204  void SetPointerSelectedCellType(std::string* iCellType);
205  void SetPointerSelectedSubCellType(std::string* iSubCellType);
206  void SetPointerCollectionData(ItemColorComboboxData* iCollectionData);
207  void SetPointerColorData(ItemColorComboboxData* iColorData);
208 
209  unsigned int GetCurrentSelectedCollectionID();
210  //bool GetIsToolBarVisible();
211 
212 public slots:
213 
218  void AddANewCollectionID(std::pair<std::string, QColor> iNewCollectionID);
222  void SetSelectedPointersToNull();
223 
224  //void SetVisibilityStatus(bool IsVisible);
225 
226 signals:
227  void AddANewCellType();
228 
229  void DeleteCellType();
230 
231  void AddANewSubCellType();
232 
233  void DeleteSubCellType();
234 
235  void AddNewColor();
236 
237  void DeleteColor();
238 
239  void NewCollectionToBeCreated();
240 
241  void TraceChanged( int );
242 
243 protected:
247  std::string * m_SelectedCellType;
248  std::string * m_SelectedSubCellType;
251  //bool m_IsToolBarVisible;
252 
253  void SetUpUi();
254 
259  void SetSelectedColorComboBox(QHBoxLayout* iColorLayout);
260 
266  void SetTraceCollectionColorComboBox(
267  QHBoxLayout* iLayoutTraceCollection, QLabel* iLabel);
268 
273  void SetCellTypeComboBox(
274  QHBoxLayout* iCellLayout);
275 
280  void SetSubCellTypeComboBox(
281  QHBoxLayout* iSubCellLayout);
282 
283  void SetWidgetFont();
284 
285  void UpdateCollection(std::string iCollection);
286 
295  template< typename T >
296  void SetListItemAndSelect(T *iComboBox, NamesDescrContainerType iItemsData,
297  std::string iTextItemToSelect = "")
298  {
299  if ( !iTextItemToSelect.empty() )
300  {
301  iComboBox->SetItemsFromList(iItemsData);
302  if ( iComboBox->findText( iTextItemToSelect.c_str() ) != -1 )
303  {
304  iComboBox->SetCurrentItem(iTextItemToSelect);
305  }
306  else
307  {
308  iComboBox->SetCurrentItemAndActivate(0);
309  }
310  }
311  else
312  {
313  iComboBox->InitializeTheList(iItemsData);
314  }
315  }
316 
320  template< typename T >
321  void SetListItemAndSelect(T *iComboBox, std::list< ItemColorComboboxData > iItemsData,
322  std::string iTextItemToSelect = "")
323  {
324  if ( !iTextItemToSelect.empty() )
325  {
326  iComboBox->SetItemsFromListWithColor(iItemsData);
327  if ( iComboBox->findText( iTextItemToSelect.c_str() ) != -1 )
328  {
329  iComboBox->SetCurrentItem(iTextItemToSelect);
330  }
331  else
332  {
333  iComboBox->SetCurrentItemAndActivate(0);
334  }
335  }
336  else
337  {
338  iComboBox->InitializeTheListWithColor(iItemsData);
339  }
340  }
341 
342 protected slots:
343 
344  void UpdateValueSelectedCollection(ItemColorComboboxData iCollectionData);
345  void UpdateValueSelectedCellType(std::string iCellType);
346  void UpdateValueSelectedSubCellType(std::string iSubCellType);
347  void UpdateValueSelectedColor(ItemColorComboboxData iColorData);
352  void CurrentTraceToUpdate(int iIndex);
353 };
354 #endif
this class inherits from QGoColorComboBox, has only the add item option and update the text according...
void SetListItemAndSelect(T *iComboBox, NamesDescrContainerType iItemsData, std::string iTextItemToSelect="")
call the right methods to initialize the list if there is no iTextItemToSelect or select the iTextIte...
QGoCollectionColorComboBox * m_CollectionColorComboBox
This class enables the Combobox to display item with colors icon for the color and sends a signal whe...
std::pair< std::string, QColor > ItemColorComboboxData
ItemColorComboboxData * m_SelectedCollectionData
QGoSelectedColorComboBox * m_SelectedColorComboBox
std::vector< std::pair< std::string, std::string > > NamesDescrContainerType
void SetListItemAndSelect(T *iComboBox, std::list< ItemColorComboboxData > iItemsData, std::string iTextItemToSelect="")
this class contains all the comboboxes for collectionID,color, celltypes and subcelltypes, and displays the trace and collection name.
inherits from Qt QCombobox but add a the end of the list of items, 1 or 2 items: the first one to add...
Definition: QGoComboBox.h:47
QGoColorComboBox::ItemColorComboboxData ItemColorComboboxData
ItemColorComboboxData * m_SelectedColorData