HowManyAreAnalyzed(): use status_user_agent to report progress
[linguistica.git] / linguisticamainwindow_graphicdisplay.cpp
blob6c8a477dae4917bd6a714f6fa35891a47b1a1bd0
1 // Maintaining the small graphic display
2 // Copyright © 2009 The University of Chicago
3 #include "linguisticamainwindow.h"
5 #include <iostream>
7 #include <QList>
8 #include "MiniLexicon.h"
9 #include "Lexicon.h"
10 #include "StateEmitHMM.h"
11 #include "GraphicView.h"
12 #include "Signature.h"
13 #include "Compound.h"
14 #include "Stem.h"
15 #include "Edge.h"
16 #include "SignatureCollection.h"
17 #include "generaldefinitions.h"
19 void LinguisticaMainWindow::updateSmallGraphicDisplaySlot()
21 CState* pState;
22 Q3PtrList<CEdge> parses;
23 CEdge* pEdge;
24 CCompoundListViewItem* item;
26 switch( m_docType )
29 case COMPOUNDS:
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 );
39 else
41 m_SmallGraphicDisplay->SetMyRoots( ((CCompound*)m_commandParse)->GetParses() );
43 m_SmallGraphicDisplay->PlotStates();
45 break;
47 case FSA_DOC:
49 m_SmallGraphicDisplay->update();
51 break;
52 default:
53 pState = this->m_CommonState;
55 if ( !pState) return;
57 m_SmallGraphicDisplay->SetMyState(pState);
59 m_SmallGraphicDisplay->PlotStates();
61 break;
66 void LinguisticaMainWindow::updateSmallGraphicDisplaySlotForPhonogy(CStem* selectedWord)
69 CStem* theWord;
71 theWord = selectedWord;
73 if ( theWord ->m_donephonology)
75 m_SmallGraphicDisplay ->SetMyStem(selectedWord);
76 m_SmallGraphicDisplay ->PlotStems();
79 return;
82 void LinguisticaMainWindow::updateSmallGraphicDisplaySlotForMultiDimensionData
83 (int numberOfDimension,
84 int numberOfDataPoints,
85 double** ptrData,
86 IntToString listOfSymbols)
90 m_SmallGraphicDisplay ->PlotNVectors(numberOfDimension,
91 numberOfDataPoints,
92 ptrData,
93 listOfSymbols);
96 void LinguisticaMainWindow::updateSignatureGraphicDisplaySlot()
99 QString QstrSignature;
100 CSignature *pThisSig;
101 CStem* pStem;
102 IntToString ListOfSymbols;
104 if (m_docType != SIGNATURES && m_docType != SUFFIX_SIGNATURES )
105 { return;}
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++;
117 selectedItem = item;
118 QstrSignature = ((CSignatureListViewItem*)selectedItem)->text(0);
120 ++it;
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();
133 int stemno;
134 double** ptrData;
136 QString temp;
137 temp = pThisSig->Display();
138 int* data = NULL;
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(
156 NumberOfSuffixes,
157 NumberOfStems,
158 ptrData,
159 ListOfSymbols);
160 delete data;
165 //////////////////////////////////////////////////////////////////////////////
166 // Test
167 //////////////////////////////////////////////////////////////////////////////
169 void LinguisticaMainWindow::testSignatureDisplaySlot()
171 int NumberOfSuffixes;
172 int NumberOfStems;
173 double** ptrData;
174 int i;
175 CStem* pStem;
176 IntToString ListOfSymbols;
178 struct not_implemented { };
179 throw not_implemented();
181 // XXX. pThisSig has to be initialized for this
182 // code to work.
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(
208 NumberOfSuffixes,
209 pThisSig->GetNumberOfStems(),
210 ptrData,
211 ListOfSymbols);
216 void LinguisticaMainWindow::DisplayVideoHMM()
218 if (m_lexicon->GetHMM() && m_lexicon->GetHMM()->m_Video )
220 m_SmallGraphicDisplay ->PlotVideo ( m_lexicon->GetHMM()->m_Video );