1 // Maintaining the small graphic display
2 // Copyright © 2009 The University of Chicago
3 #include "linguisticamainwindow.h"
8 #include "MiniLexicon.h"
10 #include "StateEmitHMM.h"
11 #include "GraphicView.h"
12 #include "Signature.h"
16 #include "SignatureCollection.h"
17 #include "generaldefinitions.h"
19 void LinguisticaMainWindow::updateSmallGraphicDisplaySlot()
22 Q3PtrList
<CEdge
> parses
;
24 CCompoundListViewItem
* item
;
30 if( !m_commandParse
) break;
32 item
= (CCompoundListViewItem
*)m_collectionView
->currentItem();
33 if( item
->GetParse() >= 0 )
35 pEdge
= ((CCompound
*)m_commandParse
)->GetParses()->at( item
->GetParse() );
36 parses
.append( pEdge
);
37 m_SmallGraphicDisplay
->SetMyRoots( &parses
);
41 m_SmallGraphicDisplay
->SetMyRoots( ((CCompound
*)m_commandParse
)->GetParses() );
43 m_SmallGraphicDisplay
->PlotStates();
49 m_SmallGraphicDisplay
->update();
53 pState
= this->m_CommonState
;
57 m_SmallGraphicDisplay
->SetMyState(pState
);
59 m_SmallGraphicDisplay
->PlotStates();
66 void LinguisticaMainWindow::updateSmallGraphicDisplaySlotForPhonogy(CStem
* selectedWord
)
71 theWord
= selectedWord
;
73 if ( theWord
->m_donephonology
)
75 m_SmallGraphicDisplay
->SetMyStem(selectedWord
);
76 m_SmallGraphicDisplay
->PlotStems();
82 void LinguisticaMainWindow::updateSmallGraphicDisplaySlotForMultiDimensionData
83 (int numberOfDimension
,
84 int numberOfDataPoints
,
86 IntToString listOfSymbols
)
90 m_SmallGraphicDisplay
->PlotNVectors(numberOfDimension
,
96 void LinguisticaMainWindow::updateSignatureGraphicDisplaySlot()
99 QString QstrSignature
;
100 CSignature
*pThisSig
;
102 IntToString ListOfSymbols
;
104 if (m_docType
!= SIGNATURES
&& m_docType
!= SUFFIX_SIGNATURES
)
107 int NumberOfSignaturesSelected
= 0;
108 Q3ListViewItem
* selectedItem
= NULL
;
110 Q3ListViewItemIterator
it( m_collectionView
);
111 while ( it
.current() )
113 Q3ListViewItem
*item
= it
.current();
114 if (item
->isSelected() )
116 NumberOfSignaturesSelected
++;
118 QstrSignature
= ((CSignatureListViewItem
*)selectedItem
)->text(0);
123 //:TODO if NumberOfSignaturesSelected == 0, then send a message to user;
126 pThisSig
= *m_lexicon
->GetMiniLexicon( m_lexicon
->GetActiveMiniIndex())
127 ->GetSignatures() ^= QstrSignature
;
129 if (!pThisSig
) return;
131 int NumberOfSuffixes
= pThisSig
->Size();
132 int NumberOfStems
= pThisSig
->GetNumberOfStems();
137 temp
= pThisSig
->Display();
139 ptrData
= new double* [ NumberOfStems
];
140 for ( stemno
=0; stemno
<NumberOfStems
; stemno
++)
142 ptrData
[stemno
] = new double [ NumberOfSuffixes
] ;
145 for ( stemno
= 0; stemno
< pThisSig
->GetStemPtrList()->size(); stemno
++)
146 { pStem
= pThisSig
->GetStemPtrList()->at(stemno
);
147 ListOfSymbols
.insert(stemno
, pStem
->Display() );
148 for (int affixno
= 0; affixno
< pThisSig
->Size(); affixno
++)
150 ptrData
[stemno
][affixno
] = data
[stemno
* NumberOfStems
+ affixno
];
154 // Display on Graphic View
155 updateSmallGraphicDisplaySlotForMultiDimensionData(
165 //////////////////////////////////////////////////////////////////////////////
167 //////////////////////////////////////////////////////////////////////////////
169 void LinguisticaMainWindow::testSignatureDisplaySlot()
171 int NumberOfSuffixes
;
176 IntToString ListOfSymbols
;
178 struct not_implemented
{ };
179 throw not_implemented();
181 // XXX. pThisSig has to be initialized for this
183 CSignature
*pThisSig
;
184 NumberOfSuffixes
= pThisSig
->Size();
185 NumberOfStems
= pThisSig
->GetNumberOfStems();
188 QString temp
; temp
= pThisSig
->Display();
191 ptrData
= new double* [ NumberOfStems
];
192 for ( i
=0; i
<NumberOfStems
; i
++)
194 ptrData
[i
] = new double [ NumberOfSuffixes
] ;
197 for (int stemno
= 0; stemno
< NumberOfStems
; stemno
++)
199 pStem
= pThisSig
->GetStemPtrList()->at(stemno
);
200 ListOfSymbols
.insert(stemno
, pStem
->Display() );
201 for (int affixno
= 0; affixno
<= NumberOfSuffixes
; affixno
++)
203 ptrData
[stemno
][affixno
] = pThisSig
->GetWordCount( stemno
, affixno
);
206 // Display on Graphic View
207 updateSmallGraphicDisplaySlotForMultiDimensionData(
209 pThisSig
->GetNumberOfStems(),
216 void LinguisticaMainWindow::DisplayVideoHMM()
218 if (m_lexicon
->GetHMM() && m_lexicon
->GetHMM()->m_Video
)
220 m_SmallGraphicDisplay
->PlotVideo ( m_lexicon
->GetHMM()->m_Video
);