GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GoDBTWContainerForContourMesh.cxx
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 =========================================================================*/
35 
37  std::string iTraceName, std::string iCollectionName, int iImgSessionID) :
38  GoDBTableWidgetContainer(iTraceName, iCollectionName, iImgSessionID)
39 {
41 }
42 
43 //--------------------------------------------------------------------------
44 
45 //--------------------------------------------------------------------------
47 {
48 }
49 
50 //--------------------------------------------------------------------------
51 
52 //--------------------------------------------------------------------------
54 {
56 
57  std::pair< GoDBTraceInfoForTableWidget, std::vector< std::string > > PairTemp;
58 
59  //Get the info for the Time Point:
60  temp.InfoName = "TimePoint";
61  temp.ColumnNameDatabase = "TCoord";
62  temp.ColumnNameTableWidget = "TimePoint";
63  temp.TableNameDatabase = "coordinate";
64  temp.TableForeignKeyDatabase = "CoordIDMin";
65  temp.TableKeyDatabase = "CoordID";
66  m_ColumnsInfos.push_back(temp);
67  PairTemp.first = temp;
68  m_RowContainer.push_back(PairTemp);
69  temp.Clear();
70 
72 }
73 
74 //--------------------------------------------------------------------------
75 
76 //--------------------------------------------------------------------------
78  vtkMySQLDatabase *iDatabaseConnector, std::string iRestrictionName,
79  std::string iRestrictionValue)
80 {
82  iRestrictionName, iRestrictionValue);
83  this->FillColumnShowHide(iDatabaseConnector);
84 }
85 
86 //--------------------------------------------------------------------------
87 
88 //--------------------------------------------------------------------------
89 void GoDBTWContainerForContourMesh::FillColumnShowHide(vtkMySQLDatabase *iDatabaseConnector)
90 {
91  //get the current timepoint which is also the min timepoint for the
92  // imagingsession:
93  //std::vector<std::string> SelectedFields;
94  //SelectedFields.push_back("TCoord");
95  //std::string JoinCondition = "imagingsession.CoordIDMin =
96  // coordinate.CoordID";
97  //std::vector<std::string> Conditions(2);
98  //Conditions[0]="imagingsessionID";
99  //Conditions[1] = ConvertToString<int>(this->m_ImgSessionID);
100  //std::list<unsigned int> VectorMinTimePoint =
101  // GetAllSelectedValuesFromTwoTables(
102  // iDatabaseConnector, "imagingsession", "coordinate",SelectedFields,
103  // JoinCondition,Conditions);
104  FieldWithValue JoinCondition = { "CoordIDMin", "CoordID", "=" };
105 
106  std::vector< FieldWithValue > Condition (1);
107  FieldWithValue ImgSession = { "ImagingsessionID", ConvertToString< int >(this->m_ImgSessionID), "=" };
108  Condition[0] = ImgSession;
109  std::list< unsigned int > VectorMinTimePoint = GetAllSelectedValuesFromTwoTables(
110  iDatabaseConnector, "imagingsession", "coordinate", "TCoord", JoinCondition, Condition);
111 
112  std::string MinTimePoint = ConvertToString< unsigned int >( VectorMinTimePoint.front() );
113  std::vector< std::vector< std::string > > Values;
114  std::vector< std::string > ShowHideValue;
115 
116  int IndexTimePoint = this->GetIndexInsideRowContainer("TimePoint");
117  std::vector< std::string >::iterator iter = this->m_RowContainer.at(IndexTimePoint).second.begin();
118  while ( iter != this->m_RowContainer.at(IndexTimePoint).second.end() )
119  {
120  if ( *iter == MinTimePoint )
121  {
122  ShowHideValue.push_back("true");
123  }
124  else
125  {
126  ShowHideValue.push_back("false");
127  }
128  Values.push_back(ShowHideValue);
129  ShowHideValue.clear();
130  ++iter;
131  }
132 
133  std::vector< std::string > Fields;
134  Fields.push_back("Show");
135  if ( !Values.empty() )
136  {
137  this->FillRowContainer(Values, Fields, "ColumnNameTableWidget");
138  }
139 }
140 
141 //--------------------------------------------------------------------------
142 
143 //--------------------------------------------------------------------------
145 {
146  return this->GetIndexInsideRowContainer("Show");
147 }
int GetIndexShowColumn()
return the index of the column in the RowContainer corresponding to the show/hide column ...
std::list< unsigned int > GetAllSelectedValuesFromTwoTables(vtkMySQLDatabase *iDatabaseConnector, const std::string &iTableOne, const std::string &iTableTwo, const std::string &iColumn, const FieldWithValue &iJoinCondition, const std::vector< FieldWithValue > &iFieldsWithValues, bool Distinct)
void SetCommonInfoForTwoTracesTable()
Virtual Pure method Fill the vector of GoDBTraceInfoForTableWidget with the info common to 2 traces o...
structure to pass the column information between the Table Widget and the Database ...
virtual std::vector< GoDBTraceInfoForTableWidget > GetColumnsInfoForTraceTable()
Fill a vector of GoDBTraceInfoForTableWidget with the info needed to fill the table widget for all th...
void FillRowContainer(std::vector< std::vector< std::string > > iResultsFromQuery, std::vector< std::string > iSelectFields, std::string BaseOn="")
fill the columns of the row container following the vector of string containing the columns to be fil...
void FillRowContainerWithDBValues(vtkMySQLDatabase *iDatabaseConnector, std::string iRestrictionName, std::string iRestrictionValue)
std::vector< GoDBTraceInfoForTableWidget > m_ColumnsInfos
int GetIndexInsideRowContainer(std::string iInfoName)
return the index in the row container for the column with the given InfoName
this class describes the columns of the table widget with the corresponding info to find their values...
virtual void FillRowContainerWithDBValues(vtkMySQLDatabase *iDatabaseConnector, std::string iRestrictionName, std::string iRestrictionValue, std::list< unsigned int > iListTimepoints=std::list< unsigned int >())
void FillColumnShowHide(vtkMySQLDatabase *iDatabaseConnector)