~ubuntu-branches/ubuntu/trusty/dasher/trusty

« back to all changes in this revision

Viewing changes to Src/DasherCore/UserLogTrial.cpp

  • Committer: Package Import Robot
  • Author(s): Josselin Mouette
  • Date: 2013-05-08 12:16:17 UTC
  • mfrom: (1.2.29)
  • Revision ID: package-import@ubuntu.com-20130508121617-4lxrxxv00jkhb8m5
Tags: 4.11+git20130508.adc653-1
* New upstream git snapshot.
* Switch to 3.0 quilt format.
* error-format-security.patch, fix-binutils-gold.patch: dropped, 
  obsolete.
* Disable joystick support, it doesn’t build.
* Revamp build-dependencies, use gtk3 and at-spi2.
* Enable Cairo, which is necessary for Gtk3. Sad it’s so slow.
* Explicitly disable GSettings, the schemas don’t work. Use GConf 
  instead.
* Update install files.
* Build-depend on docbook-xml which is needed to build help files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
            pSpan = NULL;
85
85
          }
86
86
 
87
 
          Dasher::VECTOR_SYMBOL_PROB_DISPLAY* pVectorAdded = pLocation->pVectorAdded;
 
87
          Dasher::VECTOR_SYMBOL_PROB* pVectorAdded = pLocation->pVectorAdded;
88
88
          if (pVectorAdded != NULL)
89
89
          {
90
90
            delete pVectorAdded;
252
252
// The user has entered one or more new symbols.  UserLog object will
253
253
// pass us the pointer to the current alphabet that is being used.
254
254
void CUserLogTrial::AddSymbols(Dasher::VECTOR_SYMBOL_PROB* vpNewSymbolProbs, 
255
 
                               eUserLogEventType iEvent, 
256
 
                               Dasher::CAlphabet* pCurrentAlphabet)
 
255
                               eUserLogEventType iEvent)
257
256
{
258
 
  //CFunctionLogger f1("CUserLogTrial::AddSymbols", g_pLogger);
259
 
 
260
 
  if (pCurrentAlphabet == NULL)
261
 
  {
262
 
    g_pLogger->Log("CUserLogTrial::AddSymbols, pCurrentAlphabet was NULL!", logNORMAL);
263
 
    return;
264
 
  }
265
 
  if (vpNewSymbolProbs == NULL)
266
 
  {
267
 
    g_pLogger->Log("CUserLogTrial::AddSymbols, vectorNewSymbolProbs was NULL!", logNORMAL);
268
 
    return;
269
 
  }
270
 
 
271
 
  Dasher::VECTOR_SYMBOL_PROB_DISPLAY* pVectorAdded = NULL;
272
 
  pVectorAdded = new Dasher::VECTOR_SYMBOL_PROB_DISPLAY;
273
 
 
274
 
  if (pVectorAdded == NULL)
275
 
  {
276
 
    g_pLogger->Log("CUserLogTrial::AddSymbols, failed to create pVectorAdded!", logNORMAL);
277
 
    return;
278
 
  }
279
 
 
280
 
  for (unsigned int i = 0; i < vpNewSymbolProbs->size(); i++)
281
 
  {
282
 
    Dasher::SymbolProb sNewSymbolProb   = (Dasher::SymbolProb) (*vpNewSymbolProbs)[i];
283
 
 
284
 
    Dasher::SymbolProbDisplay sNewSymbolProbDisplay;
285
 
 
286
 
    sNewSymbolProbDisplay.sym           = sNewSymbolProb.sym;
287
 
    sNewSymbolProbDisplay.prob          = sNewSymbolProb.prob;
288
 
    sNewSymbolProbDisplay.strDisplay    = pCurrentAlphabet->GetText(sNewSymbolProb.sym);
289
 
 
290
 
    pVectorAdded->push_back(sNewSymbolProbDisplay);
291
 
 
292
 
    // Add this symbol to our running total of symbols.  
293
 
    // We track the symbols and not the display text
294
 
    // since we may need to delete symbols later and 
295
 
    // a given symbol might take up multiple chars.
296
 
    // We also keep the probability around so we can
297
 
    // calculate the average bits of the history.
298
 
    m_vHistory.push_back(sNewSymbolProbDisplay);        
299
 
  }
 
257
  // Add the symbols to our running total of symbols.
 
258
  
 
259
  // ACL: Old comment said "We track the symbols and not the display text
 
260
  // since we may need to delete symbols later and 
 
261
  // a given symbol might take up multiple chars."
 
262
  //   - yet stored the display text????
 
263
  
 
264
  // We also keep the probability around so we can
 
265
  // calculate the average bits of the history.
 
266
  m_vHistory.insert(m_vHistory.end(), vpNewSymbolProbs->begin(), vpNewSymbolProbs->end());
300
267
 
301
268
  StopPreviousTimer();
302
269
 
315
282
  pLocation->avgBits       = GetHistoryAvgBits();
316
283
  pLocation->event         = iEvent;
317
284
  pLocation->numDeleted    = 0;
318
 
  pLocation->pVectorAdded  = pVectorAdded;
 
285
  pLocation->pVectorAdded  = new std::vector<Dasher::SymbolProb>(*vpNewSymbolProbs);
319
286
 
320
287
  NavCycle* pCycle = GetCurrentNavCycle();
321
288
  if (pCycle != NULL)
559
526
 
560
527
  for (unsigned int i = 0; i < m_vHistory.size(); i++)
561
528
  {
562
 
    Dasher::SymbolProbDisplay sItem = (Dasher::SymbolProbDisplay) m_vHistory[i];
 
529
    Dasher::SymbolProb sItem = (Dasher::SymbolProb) m_vHistory[i];
563
530
    strResult += sItem.strDisplay;
564
531
  }
565
532
 
576
543
  {
577
544
    for (unsigned int i = 0; i < m_vHistory.size(); i++)
578
545
    {
579
 
      Dasher::SymbolProbDisplay sItem = (Dasher::SymbolProbDisplay) m_vHistory[i];
 
546
      Dasher::SymbolProb sItem = (Dasher::SymbolProb) m_vHistory[i];
580
547
 
581
548
      dResult += log(sItem.prob);
582
549
    }
646
613
    strResult += m_szTempBuffer;
647
614
    strResult += "</NumAdded>\n";
648
615
 
649
 
    Dasher::VECTOR_SYMBOL_PROB_DISPLAY* pVectorAdded = pLocation->pVectorAdded;
 
616
    Dasher::VECTOR_SYMBOL_PROB* pVectorAdded = pLocation->pVectorAdded;
650
617
 
651
618
    if (pVectorAdded != NULL)
652
619
    {
653
620
      // Output the details of each add
654
621
      for (unsigned int j = 0; j < pVectorAdded->size(); j++)
655
622
      {            
656
 
        Dasher::SymbolProbDisplay sItem = (Dasher::SymbolProbDisplay) (*pVectorAdded)[j];
 
623
        Dasher::SymbolProb sItem = (Dasher::SymbolProb) (*pVectorAdded)[j];
657
624
 
658
625
        strResult += strPrefix;
659
626
        strResult += "\t<Add>\n";
1261
1228
 
1262
1229
        // Handle the multiple <Add> tags that might exist
1263
1230
        vAdded                    = XMLUtil::GetElementStrings("Add", *iter2);                
1264
 
        pLocation->pVectorAdded   = new Dasher::VECTOR_SYMBOL_PROB_DISPLAY;
 
1231
        pLocation->pVectorAdded   = new Dasher::VECTOR_SYMBOL_PROB;
1265
1232
 
1266
1233
        for (VECTOR_STRING_ITER iter3 = vAdded.begin(); iter3 < vAdded.end(); iter3++)
1267
1234
        {
1268
 
          Dasher::SymbolProbDisplay sAdd;
1269
 
 
1270
 
          sAdd.prob           = XMLUtil::GetElementFloat("Prob", *iter3);
1271
 
          sAdd.strDisplay     = XMLUtil::GetElementString("Text", *iter3);
1272
 
          sAdd.sym            = 0;    // We don't have the original integer symbol index
 
1235
          Dasher::SymbolProb sAdd(0, // We don't have the original integer symbol index
 
1236
                                  XMLUtil::GetElementString("Text", *iter3),
 
1237
                                  XMLUtil::GetElementFloat("Prob", *iter3));
1273
1238
 
1274
1239
          if (pLocation->pVectorAdded != NULL)
1275
1240
            pLocation->pVectorAdded->push_back(sAdd);