Esempio n. 1
0
         HError(999,"Can only update linear transforms OR model parameters!");

      xfInfo.useOutXForm = TRUE;

      /* This initialises things - temporary hack - THINK!! */

      CreateAdaptXForm(hset, "tmp");

   } 



   

   /* initialise and  pass information to the forward backward library */

   InitialiseForBack(fbInfo, x, hset, uFlags, pruneInit, pruneInc,

                     pruneLim, minFrwdP);



   if (parMode != 0) {

      ConvLogWt(hset);

   }

   /* 2-model reestimation */

   if (al_hmmUsed){

       if (trace&T_TOP)

           printf("2-model re-estimation enabled\n");

       /* load alignment HMM set */

       CreateHMMSet(&al_hset,&hmmStack,TRUE);

       xfInfo.al_hset = &al_hset;

       if (xfInfo.alXFormExt == NULL) xfInfo.alXFormExt = xfInfo.inXFormExt;

       /* load multiple MMFs */

       if (strlen(al_hmmMMF) > 0 ) {

           char *p,*q;

           Boolean eos;

           p=q=al_hmmMMF;

           for(;;) {

               eos = (*p=='\0');

               if ( ( isspace((int) *p) || *p == '\0' ) && (q!=p) ) {
void idChoiceWindow::RunNamedEvent( const char *eventName ) {
	idStr event, group;
	if( !idStr::Cmpn( eventName, "cvar read ", 10 ) ) {
		event = eventName;
		group = event.Mid( 10, event.Length() - 10 );
		if( !group.Cmp( updateGroup ) ) {
			UpdateVars( true, true );
		}
	} else if( !idStr::Cmpn( eventName, "cvar write ", 11 ) ) {
		event = eventName;
		group = event.Mid( 11, event.Length() - 11 );
		if( !group.Cmp( updateGroup ) ) {
			UpdateVars( false, true );
		}
	}
}
EXCEL_RC EvaluateX(double* newVars, int numVars, int numCons,
                   const double* bestSolution, bool feasibility,
                   double* newCons) {
  EXCEL_RC rc;

  rc = CheckForEscapeKeypress(true);
  if (rc != SUCCESS) {
    goto ErrorHandler;
  }

  rc = UpdateVars(newVars, numVars, bestSolution, feasibility);
  if (rc != SUCCESS) {
    goto ErrorHandler;
  }

  rc = RecalculateValues();
  if (rc != SUCCESS) {
    goto ErrorHandler;
  }

  rc = GetConstraintValues(numCons, newCons);
  if (rc != SUCCESS) {
    goto ErrorHandler;
  }

  return SUCCESS;

ErrorHandler:
  // Confirm whether the error is the result of an escape keypress
  if (GetErrorCode(CheckForEscapeKeypress(false)) == ESC_ABORT) {
    return ESC_ABORT;
  } else {
    return rc;
  }
}
Esempio n. 4
0
void idChoiceWindow::UpdateChoice() {
	if ( !updateStr.Num() ) {
		return;
	}
	UpdateVars( true );	
	updateStr.Update();
	if ( choiceType == 0 ) {
		// ChoiceType 0 stores current as an integer in either cvar or gui
		// If both cvar and gui are defined then cvar wins, but they are both updated
		if ( updateStr[ 0 ]->NeedsUpdate() ) {
			currentChoice = atoi( updateStr[ 0 ]->c_str() );
		}
		ValidateChoice();
	} else {
		// ChoiceType 1 stores current as a cvar string
		int c = ( values.Num() ) ? values.Num() : choices.Num();
		int i;
		for ( i = 0; i < c; i++ ) {
			if ( idStr::Icmp( cvarStr.c_str(), ( values.Num() ) ? values[i] : choices[i] ) == 0 ) {
				break;
			}
		}
		if (i == c) {
			i = 0;
		}
		currentChoice = i;
		ValidateChoice();
	}
}
GetMargin::GetMargin(QWidget* parent)
		: QDialog(parent)
{
	setupUi(this);
	Genable = false;
	unitas = setter.value("CurrentRunningUnit").toString();
	if (unitas.size() < 1)
	{
		unitas = "pt";
		comboBox->setCurrentIndex(3);
	}
	else
	{
		comboBox->setCurrentIndex(comboBox->findText(unitas));
		UnitChange(unitas);
	}
	current = QRectF(0, 0, 0, 0);
	connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(UnitChange(QString)));
	///////connect(doubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
	/////connect(doubleSpinBox_2, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
	////////connect(doubleSpinBox_3, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
	//////////////connect(doubleSpinBox_4, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
	connect(pushButton, SIGNAL(clicked()),this, SLOT(UpdateVars()));

	Genable = true;
}
Esempio n. 6
0
VariableEditor::VariableEditor(ExpressionEditor *_editor, ScriptGlobals *_globals)
	: Panel("VariableEditor", (GameControl::Get()->Width() - WIDTH)/2, 
				          (GameControl::Get()->Height() - HEIGHT)/2,
						  WIDTH, HEIGHT)
{
	SetModal();
	SetToolTip(TIP_VARIABLEEDITOR);

	editor = _editor;
	globals = _globals;
	

	Text *text;
	Button *button;	
	int y;

	//Title
	text = AddText("User Variables", CENTER_TEXT, 5);
	y = DrawHLine(text->Down() + 2);

	//Body
	text = AddText("Variables: ", 10, y);
	listVars = AddListPop(text->Right() + 2, text->Top(), 300); listVars->SetToolTip(TIP_VARIABLEEDITOR_VARIABLES);
	button = AddButton("Add", listVars->Left(), listVars->Down() + 2, 0, 0, BT_ADD); button->SetToolTip(TIP_VARIABLEEDITOR_ADD);
	button = AddButton("Edit", button->Right(), button->Top(), 0, 0, BT_EDIT); button->SetToolTip(TIP_VARIABLEEDITOR_EDIT);
	button = AddButton("Remove", button->Right(), button->Top(), 0, 0, BT_REMOVE); button->SetToolTip(TIP_VARIABLEEDITOR_REMOVE);
	
	//Close
	y = DrawHLine(button->Down() + 4);
	button = AddButton("Close", (WIDTH - 60)/2, y, 0, 0, BT_CLOSE);

	UpdateVars();
}
void idChoiceWindow::PostParse() {
	idWindow::PostParse();
	UpdateChoicesAndVals();
	InitVars();
	UpdateChoice();
	UpdateVars( false );
	flags |= WIN_CANFOCUS;
}
/// returns result in pixels
void	cColourClipTextOverlay::GetTextBounds	(Ogre::Real& w,Ogre::Real& h) {
	_update(); // get the variables right
	UpdateVars();
	// set up variables used in loop
	cOgreFontHelper myFontHelper(mpFont,mCharHeight * mViewportAspectCoef,mCharHeight,mSpaceWidth,mWrapMaxW,cOgreFontHelper::Alignment(mAlignment));
	myFontHelper.GetTextBounds(mCaption,w,h);
	w *= (Real) (cOgreWrapper::GetSingleton().GetViewportWidth());
	h *= (Real) (cOgreWrapper::GetSingleton().GetViewportHeight());
}
Esempio n. 9
0
/* EXPORT->MAPUpdateModels: update all models and save them in newDir if set,
   new files have newExt if set */
void MAPUpdateModels(HMMSet *hset, UPDSet uFlags)
{
  HMMScanState hss;
  HLink hmm;
  int px,nmapped=0,totM;
  long n;

  if (hset->logWt == TRUE) HError(999,"HMap: requires linear weights");

  /* Intialise a few global variables */
  SetVFloor( hset, vFloor, minVar);
  maxM = MaxMixInSet(hset);
  totM = TotMixInSet(hset);
  S = hset->swidth[0];

  if (hset->hsKind == TIEDHS){ /* TIEDHS - update mu & var once per HMMSet */
    HError(999,"TIEDHS kind not currently supported in MAP estimation");
  }

  NewHMMScan(hset,&hss);
  px=1;
  do {   
    hmm = hss.hmm;
    n = (long)hmm->hook;
    if (n<minEgs && !(trace&T_UPD))
      HError(-2331,"UpdateModels: %s[%d] copied: only %d egs\n",
	     HMMPhysName(hset,hmm),px,n);
    if (n>=minEgs && n>0) {
      if (uFlags & UPTRANS)
	HError(999,"No support for MAP updating transition probabilities");
      if (maxM>1 && uFlags & UPMIXES)
	UpdateWeights(hset,px,hmm);
      if (hset->hsKind != TIEDHS){
	if (uFlags & UPVARS)
	  UpdateVars(hset,px,hmm);
	if (uFlags & UPMEANS)
	  nmapped += UpdateMeans(hset,px,hmm);
	if (uFlags & (UPMEANS|UPVARS))
	  FixGConsts(hmm);
      }  
    }
    px++;
  } while (GoNextHMM(&hss));
  EndHMMScan(&hss);
  if (trace&T_TOP) {
    printf("Observed components (means) %d of %d: %.2f\n",nmapped,totM,100*(float)nmapped/(float)totM);
    if (nFloorVar > 0)
      printf("Total %d floored variance elements in %d different mixes\n",
	     nFloorVar,nFloorVarMix);
    fflush(stdout);
  }
   
  /* Reset vfloor */
  ResetVFloor(hset,vFloor);
}
/// internal method for setting up geometry, called by OverlayElement::update
void cColourClipTextOverlay::updatePositionGeometry(void) {
	if (mpFont.isNull()) return;
	UpdateVars();
	
	// big vars static for efficiency
	static VertexRect clipped;
	static Ogre::Rectangle clippingRegion;
	
	// calc clipping
	if (mbClipInitialized) {
		clippingRegion = mClip;
		// calc clip region in screen-relative coords
		if (mMetricsMode != GMM_RELATIVE) {
			clippingRegion.left		*= mPixelScaleX;
			clippingRegion.right	*= mPixelScaleX;
			clippingRegion.top		*= mPixelScaleY;
			clippingRegion.bottom	*= mPixelScaleY;
		}
	}
	
	// set up variables used in loop
	clipped.lt.col = clipped.rt.col = mColourTop;
	clipped.lb.col = clipped.rb.col = mColourBottom;
	float left = _getDerivedLeft();
	float top = _getDerivedTop();
	cOgreFontHelper myFontHelper(mpFont,mCharHeight * mViewportAspectCoef,mCharHeight,mSpaceWidth,mWrapMaxW,cOgreFontHelper::Alignment(mAlignment));
	cOgreFontHelper::cTextIterator itor(myFontHelper,mCaption);
	Real z = -1.0;
	
	// iterate over all chars in caption
	Begin(mCaption.size() * 6,0,false,false,Ogre::RenderOperation::OT_TRIANGLE_LIST);
	while (itor.HasNext()) {
		cOgreFontHelper::unicode_char c = itor.Next();
		if (cOgreFontHelper::IsWhiteSpace(c)) {
			// whitespace character, skip triangles
			cRobRenderOp::SkipVertices(6);
		} else {
			// draw character
			clipped.SetLTWH(left+itor.x,top+itor.y,myFontHelper.GetCharWidth(c),mCharHeight);
			// TODO : if (mbClipInitialized && invis by clip) { cRobRenderOp::SkipVertices(6); continue; }

			Ogre::Font::UVRect uvRect = mpFont->getGlyphTexCoords( c );
			clipped.SetUV(uvRect.left,uvRect.top,uvRect.right,uvRect.bottom);
			if (mbClipInitialized) clipped = clipped.Intersect(clippingRegion);
			clipped.DrawList(this,z);
		}
	}
	End();
}
/// input pos in absolute pixel coordinates
/// (e.g. clicking to place the caret)
/// returns the INDEX of the char in the string, not the charcode
/// returns -1 if nothing was hit
/// TODO : TEST ME !
int		cColourClipTextOverlay::GetGlyphAtPos	(const size_t x,const size_t y) {
		_update(); // get the variables right
	UpdateVars();
	if (mpFont.isNull()) return -1;
	
	// set up variables used in loop
	float left = _getDerivedLeft();
	float top = _getDerivedTop();
	float vw = float(cOgreWrapper::GetSingleton().GetViewportWidth());
	float vh = float(cOgreWrapper::GetSingleton().GetViewportHeight());
	if (vw == 0) vw = 1; // avoid division by zero
	if (vh == 0) vh = 1; // avoid division by zero
	cOgreFontHelper myFontHelper(mpFont,mCharHeight * mViewportAspectCoef,mCharHeight,mSpaceWidth,mWrapMaxW,cOgreFontHelper::Alignment(mAlignment));
	return myFontHelper.GetGlyphAtPos(mCaption,x/vw-left,y/vh-top);
}
/// returns result in pixels
/// TODO : TEST ME !
void	cColourClipTextOverlay::GetGlyphBounds	(const size_t iIndex,Ogre::Real& l,Ogre::Real& t,Ogre::Real& r,Ogre::Real& b) {
	_update(); // get the variables right
	UpdateVars();
	l=t=r=b=0;
	if (mpFont.isNull()) return;
	
	// set up variables used in loop
	cOgreFontHelper myFontHelper(mpFont,mCharHeight * mViewportAspectCoef,mCharHeight,mSpaceWidth,mWrapMaxW,cOgreFontHelper::Alignment(mAlignment));
	myFontHelper.GetGlyphBounds(mCaption,iIndex,l,t,r,b);
	
	float left = _getDerivedLeft();
	float top = _getDerivedTop();
	float vw = float(cOgreWrapper::GetSingleton().GetViewportWidth());
	float vh = float(cOgreWrapper::GetSingleton().GetViewportHeight());
	l = (l + left)*vw; r = (r + left)*vw;
	t = (t + top)*vh; b = (b + top)*vh;
}
Esempio n. 13
0
const char* idChoiceWindow::HandleEvent( const sysEvent_t* event, bool* updateVisuals )
{
	int key;
	bool runAction = false;
	bool runAction2 = false;
	
	if( event->evType == SE_KEY )
	{
		key = event->evValue;
		
		if( key == K_RIGHTARROW || key == K_KP_6 || key == K_MOUSE1 )
		{
			// never affects the state, but we want to execute script handlers anyway
			if( !event->evValue2 )
			{
				RunScript( ON_ACTIONRELEASE );
				return cmd;
			}
			currentChoice++;
			if( currentChoice >= choices.Num() )
			{
				currentChoice = 0;
			}
			runAction = true;
		}
		
		if( key == K_LEFTARROW || key == K_KP_4 || key == K_MOUSE2 )
		{
			// never affects the state, but we want to execute script handlers anyway
			if( !event->evValue2 )
			{
				RunScript( ON_ACTIONRELEASE );
				return cmd;
			}
			currentChoice--;
			if( currentChoice < 0 )
			{
				currentChoice = choices.Num() - 1;
			}
			runAction = true;
		}
		
		if( !event->evValue2 )
		{
			// is a key release with no action catch
			return "";
		}
		
	}
	else if( event->evType == SE_CHAR )
	{
	
		key = event->evValue;
		
		int potentialChoice = -1;
		for( int i = 0; i < choices.Num(); i++ )
		{
			if( toupper( key ) == toupper( choices[i][0] ) )
			{
				if( i < currentChoice && potentialChoice < 0 )
				{
					potentialChoice = i;
				}
				else if( i > currentChoice )
				{
					potentialChoice = -1;
					currentChoice = i;
					break;
				}
			}
		}
		if( potentialChoice >= 0 )
		{
			currentChoice = potentialChoice;
		}
		
		runAction = true;
		runAction2 = true;
		
	}
	else
	{
		return "";
	}
	
	if( runAction )
	{
		RunScript( ON_ACTION );
	}
	
	if( choiceType == 0 )
	{
		cvarStr.Set( va( "%i", currentChoice ) );
	}
	else if( values.Num() )
	{
		cvarStr.Set( values[ currentChoice ] );
	}
	else
	{
		cvarStr.Set( choices[ currentChoice ] );
	}
	
	UpdateVars( false );
	
	if( runAction2 )
	{
		RunScript( ON_ACTIONRELEASE );
	}
	
	return cmd;
}
Esempio n. 14
0
void CMainTab::OnBnClickedIC()
{
	UpdateVars();
}
Esempio n. 15
0
void VariableEditor::OnButton(Button *button, int buttonId)
{
	switch(buttonId)
	{
	case BT_CLOSE:
		delete this;
		break;

	case BT_ADD:
		new CreateVar(this);
		break;

	case BT_EDIT:
		{
			if(listVars->GetSelectedIndex() == -1)
			{
				new PanelInfo("Please, select a variable");
				return;
			}

			gedString variable(listVars->GetText());
			int i = variable.find('[');
			if(i == gedString::npos) i = variable.find(' ');

			variable = variable.substr(0, i);

			new CreateVar(this, variable, (int)listVars->GetItemData(listVars->GetSelectedIndex()));
		}
		break;

	case BT_REMOVE:	
		{
			if(listVars->GetSelectedIndex() == -1)
			{
				new PanelInfo("Please, select a variable");
				return;
			}

			PanelQuestion *panel = new PanelQuestion("Remove variable?");
			if(panel->Wait() == OK_BUTTON)
			{
				gedString variable(listVars->GetText());
				int i = variable.find('[');
				if(i == gedString::npos) i = variable.find(' ');

				variable = variable.substr(0, i);

				int next = listVars->GetSelectedIndex();

				if(!GenericScript::RemoveAndVerifyVariable(variable, (int)listVars->GetItemData(listVars->GetSelectedIndex())))
				{
					delete panel;

					panel = new PanelQuestion(GenericScript::GetError() + "\nProceed anyway?", "Error");
					if(panel->Wait() != OK_BUTTON)
					{
						delete panel;						
						return;
					}
					
					delete panel;
					
					//Force remotion
					GenericScript::RemoveAndVerifyVariable(variable, (int)listVars->GetItemData(listVars->GetSelectedIndex()), NULL, -1, true);
					panel = NULL;
					
				}

				if(next >= listVars->Count() - 1)
				{
					next = 0;
				}

				UpdateVars();
				listVars->SetItem(next);
			}

			if(panel) delete panel;
		}
		break;
	}
}
Esempio n. 16
0
ExpressionEditor::ExpressionEditor(Actor *actor, bool bOnCollision)
	: BaseAction("Expression Editor", (GameControl::Get()->Width() - WIDTH)/2, 
				          (GameControl::Get()->Height() - HEIGHT)/2,
						  WIDTH, HEIGHT)
{
	expressionEditor = this;
	SetModal();
	SetToolTip(TIP_SCRIPTEDITOR);

	eventActor = actionActor = actor;
	this->bOnCollision = bOnCollision;

	Text *text;
	Button *button;	
	int y;

	//Title: Script Editor: oi -> Key Down (left)
	gedString title(EXPRESSION_EDITOR), actionDesc;
	title += ": ";
	actionDesc = actor->getActorName();
	actionDesc += " -> ";

	editAction = Action::getEditAction();
	if(editAction)
	{		
		actionDesc += Action::GetDescription(editAction, false);

		MainPanel::AddLastScript(actionDesc);
	}
	else
	{
		stAction tmp;
		tmp.eventData = Action::getActualEvent();

		actionDesc += Action::GetDescription(&tmp, false);
	}

	title += actionDesc;

	text = AddText(title, CENTER_TEXT, 5);
	textLine = AddText("Ln 1    ", WIDTH-45, 5, ALIGN_LEFT);
	y = DrawHLine(text->Down() + 2);

	//Body
	editExp = AddEditBox(10, y, WIDTH-34, HEIGHT-85, true);
	listActor = AddListPop(10, editExp->Down()+4, 120, 0, LS_ACTOR, "actors"); listActor->SetToolTip(TIP_SCRIPTEDITOR_ACTORS);
	listAutoComplete = AddListPop(listActor->Right(), listActor->Top(), 215, 0, LS_COMPLETE, "variables/functions"); listAutoComplete->SetToolTip(TIP_SCRIPTEDITOR_VARIABLES_FUNCTIONS);
	button = AddButton("Variables", listAutoComplete->Right(), listAutoComplete->Top(), 0, 0, BT_CREATEVAR); button->SetToolTip(TIP_SCRIPTEDITOR_VARIABLES);
	button = AddButton("Global code", button->Right(), button->Top(), 0, 0, BT_GLOBALS); button->SetToolTip(TIP_SCRIPTEDITOR_GLOBALCODE);
	listFile = AddListPop(button->Right() + 2, button->Top(), 64, 0, LS_FILE, "File"); listFile->SetToolTip(TIP_SCRIPTEDITOR_FILE);

	//button = AddButton("Web", listFile->Right() + 2, listFile->Top(), 35, 0, BT_WEB); button->SetToolTip(TIP_SCRIPTEDITOR_WEB);

	
	
	//Close
	y = DrawHLine(listAutoComplete->Down() + 2);
	button = AddButton(Action::getEditAction()?"Ok":"Add", WIDTH/2 - 65, y, 0, 0, BT_ADD); button->SetToolTip(TIP_ACTION_ADD);
	button = AddButton("Cancel", button->Right()+8, y, 0, 0, BT_CLOSE); button->SetToolTip(TIP_ACTION_CANCEL); //Don't exit on ESC (crash the editor)


	//Populate actors
	GameControl::Get()->PopulateActors(listActor);
	if(bOnCollision) listActor->AddText("collide");

	UpdateVars();

	listFile->AddText("Save");
	listFile->AddText("Load");

	bDelimit = false;

	editExp->SetSyntaxColorize(true);
	editExp->ShowScrollBar();

	pScript = NULL;
	UpdateEdition();
	if(!pScript) pScript = new Script();
}
Esempio n. 17
0
void GetMargin::closeEvent(QCloseEvent* e)
{
	UpdateVars();
	e->accept();
}