Пример #1
0
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
                            int32_t iLength,
                            const CFX_RectF& rect,
                            const CFX_RectF& rtClip) {
  ASSERT(m_pFont && m_fFontSize >= 1.0f);
  if (!pwsStr || iLength < 1)
    return;

  if (rect.width < m_fFontSize || rect.height < m_fFontSize) {
    return;
  }
  FX_FLOAT fLineWidth = rect.width;
  if (m_dwStyles & FDE_TTOSTYLE_VerticalLayout) {
    fLineWidth = rect.height;
  }
  m_pTxtBreak->SetLineWidth(fLineWidth);
  m_ttoLines.RemoveAll(TRUE);
  m_wsText.clear();
  LoadText(pwsStr, iLength, rect);
  if (m_dwStyles & FDE_TTOSTYLE_Ellipsis) {
    ReplaceWidthEllipsis();
  }
  Reload(rect);
  DoAlignment(rect);
  OnDraw(rtClip);
}
Пример #2
0
void wxSFGridShape::Update()
{
    wxSFShapeBase *pShape;

    // check an existence of already assigned shapes
    for(size_t i = 0; i < m_arrCells.GetCount(); )
    {
        if( !GetChild(m_arrCells[i])) m_arrCells.RemoveAt(i);
		else
			i++;
    }

    // check whether all child shapes' IDs are present in the cells array...
    SerializableList::compatibility_iterator node = GetFirstChildNode();
    while(node)
    {
        pShape = (wxSFShapeBase*)node->GetData();
        if( m_arrCells.Index(pShape->GetId()) == wxNOT_FOUND ) m_arrCells.Add(pShape->GetId());

        node = node->GetNext();
    }

    // do self-alignment
    DoAlignment();

    // do alignment of shape's children
    this->DoChildrenLayout();

    // fit the shape to its children
    this->FitToChildren();

    // do it recursively on all parent shapes
    if( GetParentShape() )GetParentShape()->Update();
}
Пример #3
0
int main(int argc, char *argv[])
{
   char *s;

   void Initialise(void);
   void DoRecognition(void);
   void DoAlignment(void);

   if(InitShell(argc,argv,hvite_version,hvite_vc_id)<SUCCESS)
      HError(3200,"HVite: InitShell failed");

   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();

   if(InitParm()<SUCCESS)  
      HError(3200,"HVite: InitParm failed");

   InitDict();
   InitNet();   InitRec();
   InitUtil(); 
   InitAdapt(&xfInfo); InitMap();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(0);

   SetConfParms();
   CreateHeap(&modelHeap, "Model heap",  MSTAK, 1, 0.0, 100000, 800000 );
   CreateHMMSet(&hset,&modelHeap,TRUE); 

   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(3219,"HVite: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'a':
         loadLabels=TRUE; break;
      case 'b':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: Utterance boundary word expected");
         bndId = GetLabId(GetStrArg(),TRUE); break;
      case 'c':
         tmBeam = GetChkedFlt(0.0,1000.0,s); break;          
      case 'd':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: HMM definition directory expected");
         hmmDir = GetStrArg(); break;
      case 'e':
         saveAudioOut=TRUE; break;
      case 'f':
         states=TRUE; break;
      case 'g':
         replay=TRUE; break;
      case 'i':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: Output MLF file name expected");
         /* if(SaveToMasterfile(GetStrArg())<SUCCESS)
            HError(3214,"HCopy: Cannot write to MLF"); */
         SaveToMasterfile(GetStrArg());
         break;
      case 'k':
	 xfInfo.useInXForm = TRUE;
	 break;
      case 'j':
         if (NextArg()!=INTARG)
            HError(3219,"HVite: No. of files per online adaptation step expected");
         update = GetChkedInt(1,256,s);
         break;
      case 'l':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: Label file directory expected");
         labDir = GetStrArg(); break;
      case 'm':
         models=TRUE; break;
      case 'n':
         nToks = GetChkedInt(2,MAX_TOKS,s);
         if (NextArg()==FLOATARG || NextArg()==INTARG)
            nTrans = GetChkedInt(1,10000,s);
         else
            nTrans = 1;
         break;      
      case 'o':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: Output label format expected");
         labForm = GetStrArg(); break;
      case 'p':
         wordPen = GetChkedFlt(-1000.0,1000.0,s);  break;
      case 'q':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: Output lattice format expected");
         latForm = GetStrArg(); break;
      case 'r':
         prScale = GetChkedFlt(0.0,1000.0,s);  break;
      case 's':
         lmScale = GetChkedFlt(0.0,1000.0,s);  break;
      case 't':
         genBeam = GetChkedFlt(0,1.0E20,s); 
	 if (genBeam == 0.0)
	    genBeam = -LZERO;
         if (NextArg()==FLOATARG || NextArg()==INTARG) {
             genBeamInc = GetChkedFlt(0.0,1.0E20,s);
             genBeamLim = GetChkedFlt(0.0,1.0E20,s);
             if (genBeamLim < (genBeam + genBeamInc)) {
                genBeamLim = genBeam; genBeamInc = 0.0;
             }
          }
          else {
             genBeamInc = 0.0;
             genBeamLim = genBeam;
          }  
          break;
      case 'w':
         if (NextArg()!=STRINGARG)
            loadNetworks=TRUE;
         else {
            wdNetFn = GetStrArg();
            if (strlen(wdNetFn)==0) {
               wdNetFn=NULL;
               loadNetworks=TRUE;
            }
         }
         break;
      case 'u':
         maxActive = GetChkedInt(0,100000,s); break;      
      case 'v':
         wordBeam = GetChkedFlt(0,1.0E20,s); 
         if (wordBeam == 0.0)
            wordBeam = -LZERO;
         break;
      case 'x':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: HMM file extension expected");
         hmmExt = GetStrArg(); break;
      case 'y':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: Output label file extension expected");
         labExt = GetStrArg(); break;
      case 'z':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: Lattice output file extension expected");
         latExt = GetStrArg(); break;
      case 'F':
         if (NextArg() != STRINGARG)
            HError(3219,"HVite: Data File format expected");
         if((dfmt = Str2Format(GetStrArg())) == ALIEN)
            HError(-3289,"HVite: Warning ALIEN Input file format set");
         break;
      case 'G':
         if (NextArg() != STRINGARG)
            HError(3219,"HVite: Source Label File format expected");
         if((ifmt = Str2Format(GetStrArg())) == ALIEN)
            HError(-3289,"HVite: Warning ALIEN Input file format set");
         break;
      case 'H':
         if (NextArg() != STRINGARG)
            HError(3219,"HVite: MMF File name expected");
         AddMMF(&hset,GetStrArg()); 
         break;
      case 'I':
         if (NextArg() != STRINGARG)
            HError(3219,"HVite: MLF file name expected");
         LoadMasterFile(GetStrArg()); break;
      case 'L':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: Label/network file directory expected");
         labInDir = GetStrArg(); break;
      case 'P':
         if (NextArg() != STRINGARG)
            HError(3219,"HVite: Target Label File format expected");
         if((ofmt = Str2Format(GetStrArg())) == ALIEN)
            HError(-3289,"HVite: Warning ALIEN Label output file format set");
         break;
      case 'B':
         saveBinary = TRUE;
         break;
      case 'T':
         trace = GetChkedInt(0,511,s); break;
      case 'X':
         if (NextArg()!=STRINGARG)
            HError(3219,"HVite: Input label/network file extension expected");
         labInExt = GetStrArg(); break;
      case 'h':
	if (NextArg()!=STRINGARG)
	  HError(1,"Speaker name pattern expected");
	xfInfo.outSpkrPat = GetStrArg();
	if (NextArg()==STRINGARG) {
	  xfInfo.inSpkrPat = GetStrArg();
	  if (NextArg()==STRINGARG)
	    xfInfo.paSpkrPat = GetStrArg(); 
	}
	if (NextArg() != SWITCHARG)
	  HError(2319,"HERest: cannot have -h as the last option");	  
	break;
      case 'E':
         if (NextArg()!=STRINGARG)
            HError(2319,"HERest: parent transform directory expected");
	 xfInfo.usePaXForm = TRUE;
         xfInfo.paXFormDir = GetStrArg(); 
         if (NextArg()==STRINGARG)
	   xfInfo.paXFormExt = GetStrArg(); 
	 if (NextArg() != SWITCHARG)
	   HError(2319,"HVite: cannot have -E as the last option");	  
         break;              
      case 'J':
         if (NextArg()!=STRINGARG)
            HError(2319,"HERest: input transform directory expected");
         AddInXFormDir(&hset,GetStrArg());
         if (NextArg()==STRINGARG)
	   xfInfo.inXFormExt = GetStrArg(); 
	 if (NextArg() != SWITCHARG)
	   HError(2319,"HVite: cannot have -J as the last option");	  
         break;              
      case 'K':
         if (NextArg()!=STRINGARG)
            HError(2319,"HVite: output transform directory expected");
         xfInfo.outXFormDir = GetStrArg(); 
	 xfInfo.useOutXForm = TRUE;
         if (NextArg()==STRINGARG)
	   xfInfo.outXFormExt = GetStrArg(); 
	 if (NextArg() != SWITCHARG)
	   HError(2319,"HVite: cannot have -K as the last option");	  
         break;              
      default:
         HError(3219,"HVite: Unknown switch %s",s);
      }
   }
   
   if (NextArg()!=STRINGARG)
      HError(3219,"HVite: Dictionary file name expected");
   dictFn = GetStrArg();
   if (NextArg()!=STRINGARG)
      HError(3219,"HVite: HMM list  file name expected");
   hmmListFn = GetStrArg();

#ifndef PHNALG
   if ((states || models) && nToks>1)
      HError(3230,"HVite: Alignment using multiple tokens is not supported");
#endif
   if (NumArgs()==0 && wdNetFn==NULL)
      HError(3230,"HVite: Network must be specified for recognition from audio");
   if (loadNetworks && loadLabels)
      HError(3230,"HVite: Must choose either alignment from network or labels");
   if (nToks>1 && latExt==NULL && nTrans==1)
      HError(-3230,"HVite: Performing nbest recognition with no nbest output");
   if (nToks > 1 && latExt != NULL && nTrans > 1) 
      HError(-3230,"HVite: Performing nbest recognition with 1-best and latttices output");
   if ((update>0) && (!xfInfo.useOutXForm))
      HError(3230,"HVite: Must use -K option with incremental adaptation");


   Initialise();


   /* Process the data */
   if (wdNetFn==NULL)
      DoAlignment();
   else
      DoRecognition();

   /* Free up and we are done */

   if (trace & T_MEM) {
      printf("Memory State on Completion\n");
      PrintAllHeapStats();
   }


   DeleteVRecInfo(vri);
   ResetHeap(&netHeap);
   FreePSetInfo(psi);
   UpdateSpkrStats(&hset,&xfInfo, NULL); 
   ResetHeap(&regHeap);
   ResetHeap(&modelHeap);
   Exit(0);
   return (0);          /* never reached -- make compiler happy */
}