DConfig::DConfig() : QObject()
{
	DINIT;
#ifdef Q_WS_X11
	configDirectory.setPath(QDir::homePath()+"/."+QCoreApplication::applicationName ());
#elif defined(Q_WS_WIN)
	configDirectory.setPath(QDir::homePath()+"/"+QCoreApplication::applicationName ());
#elif defined(Q_WS_MAC)
	configDirectory.setPath(QDir::homePath()+"/."+QCoreApplication::applicationName ());
#endif

	if ( !configDirectory.exists() )
	{
		dDebug() << tr("%1 not exists... creating...").arg(configDirectory.path()) << endl;
		if(!configDirectory.mkdir(configDirectory.path()))
		{
			dError() << tr("I can't create %1").arg(configDirectory.path()) << endl;
		}
	}

	m_dconfig = new DConfigDocument( configDirectory.path() + "/"+QCoreApplication::applicationName().toLower()+".cfg" );
	
	init();
}
Beispiel #2
0
void dMatrix::operator -= (const dMatrix &a)
{
  if (n != a.n || m != a.m) dDebug (0,"matrix -=, mismatched sizes");
  for (int i=0; i<n*m; i++) data[i] -= a.data[i];
}
Beispiel #3
0
void
dxJointNull::getInfo2( dxJoint::Info2 *info )
{
    dDebug( 0, "this should never get called" );
}
SErrorPackage PostgresErrorHandler::handle(const QSqlError &error)
{
	
	dDebug() << error.databaseText();
	
	QString mensaje;
// 	if("ERROR:  llave duplicada viola restricción unique \"aduser_pke\"" ==error.databaseText())
// 	{
// 	   	mensaje = "El usuario que usted ha intentado ingresar ya existe";
// 	}
// 	
// 	
// 	if("ERROR:  llave duplicada viola restricción unique \"adspace_pkey\""==error.databaseText())
// 	{
// 	   	mensaje = "El espacio que usted ha intentado ingresar ya existe";
// 	}
// 	
// 	
// 	if("ERROR:  llave duplicada viola restricción unique \"adaudiovisual_pkey\""==error.databaseText())
// 	{
// 		mensaje = "La ayuda audiovisual que usted ha intentado ingresar ya existe";
// 	}
// 	
// 	if("ERROR:  inserción o actualización en la tabla \"adaudiovisual\" viola la llave for ánea \"$1\""==error.databaseText())
// 	{
// 		mensaje = "El espacio especificado no existe";
// 	}
// 	
// 	
// 	if("ERROR:  inserción o actualización en la tabla \"adscheduleav\" viola la llave foránea \"$2\""==error.databaseText())
// 	{
// 		mensaje = "La ayuda audiovisual no existe";
// 	}
// 	
// 	if("ERROR:  llave duplicada viola restricción unique \"adscheduleav_pkey\""==error.databaseText())
// 	{
// 		mensaje = "El horario que usted ha intentado ingresar ya existe";
// 	}
// 
// 
// 	if("ERROR:  el nuevo registro para la relación \"adscheduleav\" viola la restricción check \"$1\""==error.databaseText())
// 	{
// 		mensaje = "La fecha no es congruente";
// 	}
// 	
// 	
// 	
// 	if("ERROR:  inserción o actualización en la tabla \"adschedulespace\" viola la llave foránea \"$2\""==error.databaseText())
// 	{
// 		mensaje = "El espacio no existe";
// 	}
// 	
// 	
// 	if("ERROR:  llave duplicada viola restricción unique \"adschedulespace_pkey\""==error.databaseText())
// 	{
// 		mensaje = "El horario que usted ha intentado ingresar ya existe";
// 	}
// 	
// 	
// 	if("ERROR:  el nuevo registro para la relación \"adschedulespace\" viola la restricción check \"$1\""==error.databaseText())
// 	{
// 		mensaje = "La fecha no es congruente";
// 	}
// 	
// 	
// 	
// 	
// 	if("ERROR:  inserción o actualización en la tabla \"adspacereserve\" viola la llave foránea \"$1\""==error.databaseText())
// 	{
// 		mensaje = "El usuario no existe";
// 	}
// 	
// 	if("ERROR:  inserción o actualización en la tabla \"adspacereserve\" viola la llave foránea \"$2\""==error.databaseText())
// 	{
// 		mensaje = "El espacio no existe";
// 	}
// 	
// 	
// 	if("ERROR:  inserción o actualización en la tabla \"adspacereserve\" viola la llave foránea \"$3\""==error.databaseText())
// 	{
// 		mensaje = "El horario asociado al espacio no existe";
// 	}
// 	
// 	
// 	if("ERROR:  llave duplicada viola restricción unique \"adspacereserve_pkey\""==error.databaseText())
// 	{
// 		mensaje = "La reserva ya existe";
// 	}
// 	
// 	if("ERROR:  inserción o actualización en la tabla \"adavreserve\" viola la llave foránea \"$1\""==error.databaseText())
// 	{
// 		mensaje = "El usuario no existe";
// 	}
// 	
// 	
// 	if("ERROR:  inserción o actualización en la tabla \"adavreserve\" viola la llave foránea \"$2\""==error.databaseText())
// 	{
// 		mensaje = "La ayuda audiovisual no existe";
// 	}
// 	
// 	
// 	if("ERROR:  inserción o actualización en la tabla \"adavreserve\" viola la llave foránea \"$3\""==error.databaseText())
// 	{
// 		mensaje = "El horario asociado a la ayuda audiovisual no existe";
// 	}
// 
// 	
// 	if("ERROR:  llave duplicada viola restricción unique \"adavreserve_pkey\""==error.databaseText())
// 	{
// 		mensaje = "La reserva ya existe";
// 	}
// 	
// 	QRegExp rg;
// 	
// 	
// 	rg.setPattern ( "ERROR:  la sintaxis de entrada no es válida para integer: \"*\"" );
// 	if(rg.exactMatch ( error.databaseText() ))
// 	{
// 	QStringList list = error.databaseText().split( '\"' );
// 		mensaje = "El valor "+list[1]+" debe ser numerico";
// 	}
// 	
	
	// TODO: Analizar los textos!
	
	
	SErrorPackage package(error.number(), QObject::tr("PostgresErrorHandler %1").arg(error.databaseText()));
// 	SErrorPackage package(error.number(), QObject::tr("PostgresErrorHandler %1").arg(mensaje));
	
	
	
	return package;
}
Beispiel #5
0
extern "C" ODE_API int dTestSolveLCP()
{
  const int n = 100;

  //size_t memreq = EstimateTestSolveLCPMemoryReq(n);
  //dxWorldProcessMemArena *arena = dxAllocateTemporaryWorldProcessMemArena(memreq, nullptr, nullptr);
  //if (arena == nullptr) {
  //  return 0;
  //}

  //int i,nskip = dPAD(n);
  int i;
  int nskip = n;
#ifdef dDOUBLE
  const dReal tol = REAL(1e-9);
#endif
#ifdef dSINGLE
  const dReal tol = REAL(1e-4);
#endif
  printf ("dTestSolveLCP()\n");

  dReal *A = new dReal[n*nskip];
  dReal *x = new dReal[n];
  dReal *b = new dReal[n];
  dReal *w = new dReal[n];
  dReal *lo = new dReal[n];
  dReal *hi = new dReal[n];
  
  dReal *A2 = new dReal[n*nskip];
  dReal *b2 = new dReal[n];
  dReal *lo2 = new dReal[n];
  dReal *hi2 = new dReal[n];
  
  dReal *tmp1 = new dReal[n];
  dReal *tmp2 = new dReal[n];

  // double total_time = 0;
  for (int count=0; count < 1000; count++) {

      // form (A,b) = a random positive definite LCP problem
      dMakeRandomMatrix (A2,n,n,1.0);
      dMultiply2 (A,A2,A2,n,n,n);
      dMakeRandomMatrix (x,n,1,1.0);
      dMultiply0 (b,A,x,n,n,1);
      for (i=0; i<n; i++) b[i] += (dRandReal()*REAL(0.2))-REAL(0.1);

      // choose `nub' in the range 0..n-1
      int nub = 50; //dRandInt (n);

      // make limits
      for (i=0; i<nub; i++) lo[i] = -dInfinity;
      for (i=0; i<nub; i++) hi[i] = dInfinity;
      //for (i=nub; i<n; i++) lo[i] = 0;
      //for (i=nub; i<n; i++) hi[i] = dInfinity;
      //for (i=nub; i<n; i++) lo[i] = -dInfinity;
      //for (i=nub; i<n; i++) hi[i] = 0;
      for (i=nub; i<n; i++) lo[i] = -(dRandReal()*REAL(1.0))-REAL(0.01);
      for (i=nub; i<n; i++) hi[i] =  (dRandReal()*REAL(1.0))+REAL(0.01);

      // set a few limits to lo=hi=0
      /*
      for (i=0; i<10; i++) {
      int j = dRandInt (n-nub) + nub;
      lo[j] = 0;
      hi[j] = 0;
      }
      */

      // solve the LCP. we must make copy of A,b,lo,hi (A2,b2,lo2,hi2) for
      // SolveLCP() to permute. also, we'll clear the upper triangle of A2 to
      // ensure that it doesn't get referenced (if it does, the answer will be
      // wrong).

      memcpy (A2,A,n*nskip*sizeof(dReal));
      dClearUpperTriangle (A2,n);
      memcpy (b2,b,n*sizeof(dReal));
      memcpy (lo2,lo,n*sizeof(dReal));
      memcpy (hi2,hi,n*sizeof(dReal));
      dSetZero (x,n);
      dSetZero (w,n);

 
      dSolveLCP (n,A2,x,b2,w,nub,lo2,hi2,0);

      // check the solution

      dMultiply0 (tmp1,A,x,n,n,1);
      for (i=0; i<n; i++) tmp2[i] = b[i] + w[i];
      dReal diff = dMaxDifference (tmp1,tmp2,n,1);
      // printf ("\tA*x = b+w, maximum difference = %.6e - %s (1)\n",diff,
      //	    diff > tol ? "FAILED" : "passed");
      if (diff > tol) dDebug (0,"A*x = b+w, maximum difference = %.6e",diff);
      int n1=0,n2=0,n3=0;
      for (i=0; i<n; i++) {
        if (x[i]==lo[i] && w[i] >= 0) {
          n1++;	// ok
        }
        else if (x[i]==hi[i] && w[i] <= 0) {
          n2++;	// ok
        }
        else if (x[i] >= lo[i] && x[i] <= hi[i] && w[i] == 0) {
          n3++;	// ok
        }
        else {
          dDebug (0,"FAILED: i=%d x=%.4e w=%.4e lo=%.4e hi=%.4e",i,
            x[i],w[i],lo[i],hi[i]);
        }
      }

      // pacifier
      printf ("passed: NL=%3d NH=%3d C=%3d   ",n1,n2,n3);
  }
 
  delete[] A;
  delete[] x;
  delete[] b;
  delete[] w;
  delete[] lo ;
  delete[] hi ;

  delete[] A2 ;
  delete[] b2 ;
  delete[] lo2;
  delete[] hi2;
  
  delete[] tmp1;
  delete[] tmp2;

  return 1;
}
Beispiel #6
0
void dxProcessIslands (dxWorld *world, dReal stepsize, dstepper_fn_t stepper)
{
  dxBody *b,*bb,**body;
  dxJoint *j,**joint;

  // nothing to do if no bodies
  if (world->nb <= 0) return;

  // handle auto-disabling of bodies
  dInternalHandleAutoDisabling (world,stepsize);

  // make arrays for body and joint lists (for a single island) to go into
  body = (dxBody**) ALLOCA (world->nb * sizeof(dxBody*));
  joint = (dxJoint**) ALLOCA (world->nj * sizeof(dxJoint*));
  int bcount = 0;	// number of bodies in `body'
  int jcount = 0;	// number of joints in `joint'

  // set all body/joint tags to 0
  for (b=world->firstbody; b; b=(dxBody*)b->next) b->tag = 0;
  for (j=world->firstjoint; j; j=(dxJoint*)j->next) j->tag = 0;

  // allocate a stack of unvisited bodies in the island. the maximum size of
  // the stack can be the lesser of the number of bodies or joints, because
  // new bodies are only ever added to the stack by going through untagged
  // joints. all the bodies in the stack must be tagged!
  int stackalloc = (world->nj < world->nb) ? world->nj : world->nb;
  dxBody **stack = (dxBody**) ALLOCA (stackalloc * sizeof(dxBody*));

  for (bb=world->firstbody; bb; bb=(dxBody*)bb->next) {
    // get bb = the next enabled, untagged body, and tag it
    if (bb->tag || (bb->flags & dxBodyDisabled)) continue;
    bb->tag = 1;

    // tag all bodies and joints starting from bb.
    int stacksize = 0;
    b = bb;
    body[0] = bb;
    bcount = 1;
    jcount = 0;
    goto quickstart;
    while (stacksize > 0) {
      b = stack[--stacksize];	// pop body off stack
      body[bcount++] = b;	// put body on body list
      quickstart:

      // traverse and tag all body's joints, add untagged connected bodies
      // to stack
      for (dxJointNode *n=b->firstjoint; n; n=n->next) {
	if (!n->joint->tag) {
	  n->joint->tag = 1;
	  joint[jcount++] = n->joint;
	  if (n->body && !n->body->tag) {
	    n->body->tag = 1;
	    stack[stacksize++] = n->body;
	  }
	}
      }
      dIASSERT(stacksize <= world->nb);
      dIASSERT(stacksize <= world->nj);
    }

    // now do something with body and joint lists
    stepper (world,body,bcount,joint,jcount,stepsize);

    // what we've just done may have altered the body/joint tag values.
    // we must make sure that these tags are nonzero.
    // also make sure all bodies are in the enabled state.
    int i;
    for (i=0; i<bcount; i++) {
      body[i]->tag = 1;
      body[i]->flags &= ~dxBodyDisabled;
    }
    for (i=0; i<jcount; i++) joint[i]->tag = 1;
  }

  // if debugging, check that all objects (except for disabled bodies,
  // unconnected joints, and joints that are connected to disabled bodies)
  // were tagged.
# ifndef dNODEBUG
  for (b=world->firstbody; b; b=(dxBody*)b->next) {
    if (b->flags & dxBodyDisabled) {
      if (b->tag) dDebug (0,"disabled body tagged");
    }
    else {
      if (!b->tag) dDebug (0,"enabled body not tagged");
    }
  }
  for (j=world->firstjoint; j; j=(dxJoint*)j->next) {
    if ((j->node[0].body && (j->node[0].body->flags & dxBodyDisabled)==0) ||
	(j->node[1].body && (j->node[1].body->flags & dxBodyDisabled)==0)) {
      if (!j->tag) dDebug (0,"attached enabled joint not tagged");
    }
    else {
      if (j->tag) dDebug (0,"unattached or disabled joint tagged");
    }
  }
# endif
}
void KTMainWindow::save()
{
	dDebug() << "Saving..";
	QTimer::singleShot(0, this, SLOT(saveProject()));
}
Beispiel #8
0
extern "C" ODE_API int dTestSolveLCP()
{
  const int n = 100;

  size_t memreq = EstimateTestSolveLCPMemoryReq(n);
  dxWorldProcessMemArena *arena = dxAllocateTemporaryWorldProcessMemArena(memreq, NULL, NULL);
  if (arena == NULL) {
    return 0;
  }

  int i,nskip = dPAD(n);
#ifdef dDOUBLE
  const dReal tol = REAL(1e-9);
#endif
#ifdef dSINGLE
  const dReal tol = REAL(1e-4);
#endif
  printf ("dTestSolveLCP()\n");

  dReal *A = arena->AllocateArray<dReal> (n*nskip);
  dReal *x = arena->AllocateArray<dReal> (n);
  dReal *b = arena->AllocateArray<dReal> (n);
  dReal *w = arena->AllocateArray<dReal> (n);
  dReal *lo = arena->AllocateArray<dReal> (n);
  dReal *hi = arena->AllocateArray<dReal> (n);
  
  dReal *A2 = arena->AllocateArray<dReal> (n*nskip);
  dReal *b2 = arena->AllocateArray<dReal> (n);
  dReal *lo2 = arena->AllocateArray<dReal> (n);
  dReal *hi2 = arena->AllocateArray<dReal> (n);
  
  dReal *tmp1 = arena->AllocateArray<dReal> (n);
  dReal *tmp2 = arena->AllocateArray<dReal> (n);

  double total_time = 0;
  for (int count=0; count < 1000; count++) {
    BEGIN_STATE_SAVE(arena, saveInner) {

      // form (A,b) = a random positive definite LCP problem
      dMakeRandomMatrix (A2,n,n,1.0);
      dMultiply2 (A,A2,A2,n,n,n);
      dMakeRandomMatrix (x,n,1,1.0);
      dMultiply0 (b,A,x,n,n,1);
      for (i=0; i<n; i++) b[i] += (dRandReal()*REAL(0.2))-REAL(0.1);

      // choose `nub' in the range 0..n-1
      int nub = 50; //dRandInt (n);

      // make limits
      for (i=0; i<nub; i++) lo[i] = -dInfinity;
      for (i=0; i<nub; i++) hi[i] = dInfinity;
      //for (i=nub; i<n; i++) lo[i] = 0;
      //for (i=nub; i<n; i++) hi[i] = dInfinity;
      //for (i=nub; i<n; i++) lo[i] = -dInfinity;
      //for (i=nub; i<n; i++) hi[i] = 0;
      for (i=nub; i<n; i++) lo[i] = -(dRandReal()*REAL(1.0))-REAL(0.01);
      for (i=nub; i<n; i++) hi[i] =  (dRandReal()*REAL(1.0))+REAL(0.01);

      // set a few limits to lo=hi=0
      /*
      for (i=0; i<10; i++) {
      int j = dRandInt (n-nub) + nub;
      lo[j] = 0;
      hi[j] = 0;
      }
      */

      // solve the LCP. we must make copy of A,b,lo,hi (A2,b2,lo2,hi2) for
      // SolveLCP() to permute. also, we'll clear the upper triangle of A2 to
      // ensure that it doesn't get referenced (if it does, the answer will be
      // wrong).

      memcpy (A2,A,n*nskip*sizeof(dReal));
      dClearUpperTriangle (A2,n);
      memcpy (b2,b,n*sizeof(dReal));
      memcpy (lo2,lo,n*sizeof(dReal));
      memcpy (hi2,hi,n*sizeof(dReal));
      dSetZero (x,n);
      dSetZero (w,n);

      dStopwatch sw;
      dStopwatchReset (&sw);
      dStopwatchStart (&sw);

      dSolveLCP (arena,n,A2,x,b2,w,nub,lo2,hi2,0);

      dStopwatchStop (&sw);
      double time = dStopwatchTime(&sw);
      total_time += time;
      double average = total_time / double(count+1) * 1000.0;

      // check the solution

      dMultiply0 (tmp1,A,x,n,n,1);
      for (i=0; i<n; i++) tmp2[i] = b[i] + w[i];
      dReal diff = dMaxDifference (tmp1,tmp2,n,1);
      // printf ("\tA*x = b+w, maximum difference = %.6e - %s (1)\n",diff,
      //	    diff > tol ? "FAILED" : "passed");
      if (diff > tol) dDebug (0,"A*x = b+w, maximum difference = %.6e",diff);
      int n1=0,n2=0,n3=0;
      for (i=0; i<n; i++) {
        if (x[i]==lo[i] && w[i] >= 0) {
          n1++;	// ok
        }
        else if (x[i]==hi[i] && w[i] <= 0) {
          n2++;	// ok
        }
        else if (x[i] >= lo[i] && x[i] <= hi[i] && w[i] == 0) {
          n3++;	// ok
        }
        else {
          dDebug (0,"FAILED: i=%d x=%.4e w=%.4e lo=%.4e hi=%.4e",i,
            x[i],w[i],lo[i],hi[i]);
        }
      }

      // pacifier
      printf ("passed: NL=%3d NH=%3d C=%3d   ",n1,n2,n3);
      printf ("time=%10.3f ms  avg=%10.4f\n",time * 1000.0,average);
    
    } END_STATE_SAVE(arena, saveInner);
  }
UnitedStatesMap::~UnitedStatesMap()
{
	dDebug() << "UnitedStatesMap will be removed...";
	delete d->pLoader;
	delete d;
}
Beispiel #10
0
void dMatrixComparison::end()
{
  if (mat.size() <= 0) dDebug (0,"no matrices in sequence");
  afterfirst = 1;
  index = 0;
}
dxGeom* dxQuadTreeSpace::getGeom(int Index){
	dUASSERT(Index >= 0 && Index < count, "index out of range");

	//@@@
	dDebug (0,"dxQuadTreeSpace::getGeom() not yet implemented");

	return 0;

	// This doesnt work

	/*if (CurrentIndex == Index){
		// Loop through all objects in the local list
CHILDRECURSE:
		if (CurrentObject){
			dGeomID g = CurrentObject;
			CurrentObject = CurrentObject->next;
			CurrentIndex++;
		
#ifdef DRAWBLOCKS
			DrawBlock(CurrentBlock);
#endif	//DRAWBLOCKS
			return g;
		}
		else{
			// Now lets loop through our children. Starting at index 0.
			if (CurrentBlock->Children){
				CurrentChild[CurrentLevel] = 0;
PARENTRECURSE:
				for (int& i = CurrentChild[CurrentLevel]; i < SPLITS; i++){
					if (CurrentBlock->Children[i].GeomCount == 0){
						continue;
					}
					CurrentBlock = &CurrentBlock->Children[i];
					CurrentObject = CurrentBlock->First;
				
					i++;
				
					CurrentLevel++;
					goto CHILDRECURSE;
				}
			}
		}
		
		// Now lets go back to the parent so it can continue processing its other children.
		if (CurrentBlock->Parent){
			CurrentBlock = CurrentBlock->Parent;
			CurrentLevel--;
			goto PARENTRECURSE;
		}
	}
	else{
		CurrentBlock = &Blocks[0];
		CurrentLevel = 0;
		CurrentObject = CurrentObject;
		CurrentIndex = 0;

		// Other states are already set
		CurrentObject = CurrentBlock->First;
	}


	if (current_geom && current_index == Index - 1){
		//current_geom = current_geom->next; // next
		current_index = Index;
		return current_geom;
	}
	else for (int i = 0; i < Index; i++){	// this will be verrrrrrry slow
		getGeom(i);
	}*/

	return 0;
}
void ADServerConnection::run()
{
	while(m_client->state() != QAbstractSocket::UnconnectedState)
	{
		QString readed;
		while(m_client->canReadLine())
		{
			readed += m_client->readLine();
			if ( readed.endsWith("%%\n") )
			{
				break;
			}
		}
		if ( !readed.isEmpty() )
		{
			readed.remove(readed.lastIndexOf("%%"), 2);
			dDebug() << "Readed:" <<  readed;
			QDomDocument doc;
			
			if ( doc.setContent(readed) )
			{
				QString root = doc.documentElement().tagName();
				
				dDebug() << root;
				if(root == "Event")
				{
// 					dDebug() << "RECIBI EL EVENTO EN ADSERVERCONNECTION void ADServerConnection::run()";
					ADEventFactory factory;
					ADEvent *request = factory.build( readed );
					
					if ( request )
					{
						emit requestEvent(this, request );
// 						delete request;
					}
				}
			}
			/*
			QXmlInputSource xmlsource;
			xmlsource.setData(readed+'\n');
			
			dDebug() << "READED: " << readed;
			
			if ( m_reader.parse(&xmlsource) )
			{
				QString root = m_parser->root();
				QMap<QString, QString> values = m_parser->values();
				
				if ( root == "Connection")
				{
					
				}
// 				else if ( root == "Chat" )
// 				{
// 					emit requestSendToAll(  SChatPackage(m_login,values["Message"]).toString().remove('\n') );
// 				}
				else if ( root == "Insert" )
				{
					QStringList fields_and_values = values["field"].split(ADS::FIELD_SEPARATOR);
					
					QStringList fieldsList, valuesList;
					
					foreach(QString field_and_value, fields_and_values )
					{
						QStringList tmpFields = field_and_value.split("::");
						
						if ( tmpFields.count() != 2 ) continue;
						
						fieldsList << tmpFields[0];
						valuesList << tmpFields[1];
					}
					
					QString table = values["table"];
					
					ADInsert *insert = new ADInsert(table, fieldsList, valuesList);
					
					if ( !values["where"].isEmpty() )
					{
						insert->setWhere( values["where"] );
					}
					
					if ( !values["condition"].isEmpty() )
					{
						insert->setCondition( values["condition"] );
					}
					
					emit requestOperation( this, insert );
				}
				else if ( root == "Update" )
				{
					QStringList fields_and_values = values["field"].split(ADS::FIELD_SEPARATOR);
					
					QStringList fieldsList, valuesList;
					
					foreach(QString field_and_value, fields_and_values )
					{
						QStringList tmpFields = field_and_value.split("::");
						
						if ( tmpFields.count() != 2 ) continue;
						
						fieldsList << tmpFields[0];
						valuesList << tmpFields[1];
					}
					
					QString table = values["table"];
					
					ADUpdate *update = new ADUpdate(table, fieldsList, valuesList);
					
					if ( !values["where"].isEmpty() )
					{
						update->setWhere( values["where"] );
					}
					
					if ( !values["condition"].isEmpty() )
					{
						update->setCondition( values["condition"] );
					}
					
					emit requestOperation( this, update );
				}
				else if ( root == "Delete" )
				{
					QString table = values["table"];
					
					ADDelete *del = new ADDelete(table);
					
					if ( !values["where"].isEmpty() )
					{
						del->setWhere( values["where"] );
					}
					
					if ( !values["condition"].isEmpty() )
					{
						del->setCondition( values["condition"] );
					}
					
					emit requestOperation( this, del );
				}
				else if ( root == "Select" )
				{
					QString fields = values["field"];
					QString tables = values["table"];
					
					//remove the last (,)
					fields = fields.remove(fields.count()-1,1);
					tables = tables.remove(tables.count()-1,1);
					
					ADSelect *select = new ADSelect(QStringList() << fields, QStringList() << tables, values["distinct"].toInt() );
					
					if ( values.contains( "where" ) )
						select->setWhere( values["where"] );
					
					if ( values.contains("condition") )
						select->setCondition( values["condition"] );
					
					emit requestOperation( this, select);
				}
			}
			else
			{
				m_parser->reset();
				sendToClient( SErrorPackage(0, tr("Bad package ")+readed) );
				if ( !readed.isEmpty() )
				{
					close();
				}
			}*/
		}
	}
	
	// Finish connection
	emit requestRemoveConnection( this );
}
SResourcePackage::SResourcePackage() : QDomDocument()
{
	QDomElement root = createElement("Resources");
	appendChild(root);
	
	// Leemos los datos desde un archivo de indices
	QFile rscIndex(HOME+"/data/index.rsc");
	
	if( rscIndex.open( QIODevice::ReadOnly | QIODevice::Text))
	{
		QDomDocument doc;
		if ( doc.setContent( &rscIndex ) )
		{
			QDomElement docElem = doc.documentElement();
			
			QDomNode n = docElem.firstChild();
			
			QDomElement resource;
			
			while(!n.isNull())
			{
				QDomElement e = n.toElement();
				if(!e.isNull())
				{
					dDebug() << e.tagName();
					
					QString path = e.attribute("path");
						
					QString name = e.attribute("name");
						
					if( name.isEmpty() )
					{
						QFileInfo finfo(path);
						name = finfo.fileName();
					}
					
					if ( e.tagName() == "Image" )
					{
						resource = createElement("Image");
						resource.setAttribute("filename", name);
						
						addResource( resource, path );
						
						documentElement().appendChild(resource);
					}
					else if ( e.tagName() == "Svg" )
					{
						resource = createElement("Svg");
						resource.setAttribute("filename", name);
						
						addResource( resource, path );
						
						documentElement().appendChild(resource);
					}
					else if ( e.tagName() == "Sourd" )
					{
						resource = createElement("Sourd");
						resource.setAttribute("filename", name);
						
						addResource( resource, path );
						
						documentElement().appendChild(resource);
					}
					
					
				}
				n = n.nextSibling();
			}

		}
		else
		{
			dError() << "Invalid resource index file: " << rscIndex.fileName();
		}
		
		rscIndex.close();
	}
}
Beispiel #14
0
void do_tests (int argc, char **argv)
{
  int i,j;

  // process command line arguments
  if (argc >= 2) {
    graphical_test = atoi (argv[1]);
  }

  if (graphical_test) {
    // do one test gaphically and interactively

    if (graphical_test < 1 || graphical_test >= MAX_TESTS ||
	!testslot[graphical_test].name) {
      dError (0,"invalid test number");
    }

    printf ("performing test: %s\n",testslot[graphical_test].name);

    // setup pointers to drawstuff callback functions
    dsFunctions fn;
    fn.version = DS_VERSION;
    fn.start = &start;
    fn.step = &simLoop;
    fn.command = &command;
    fn.stop = 0;
    fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH;

    dsSetSphereQuality (3);
    dsSetCapsuleQuality (8);
    dsSimulationLoop (argc,argv,1280,900,&fn);
  }
  else {
    // do all tests noninteractively

    for (i=0; i<MAX_TESTS; i++) testslot[i].number = i;

    // first put the active tests into a separate array
    int n=0;
    for (i=0; i<MAX_TESTS; i++) if (testslot[i].name) n++;
    TestSlot **ts = (TestSlot**) malloc (n * sizeof(TestSlot*));
    j = 0;
    for (i=0; i<MAX_TESTS; i++) if (testslot[i].name) ts[j++] = testslot+i;
    if (j != n) dDebug (0,"internal");

    // do two test batches. the first test batch has far fewer reps and will
    // catch problems quickly. if all tests in the first batch passes, the
    // second batch is run.

    for (i=0; i<n; i++) ts[i]->failcount = 0;
    int total_reps=0;
    for (int batch=0; batch<2; batch++) {
      int reps = (batch==0) ? TEST_REPS1 : TEST_REPS2;
      total_reps += reps;
      printf ("testing batch %d (%d reps)...\n",batch+1,reps);

      // run tests
      for (j=0; j<reps; j++) {
	for (i=0; i<n; i++) {
	  current_test = ts[i]->number;
	  if (ts[i]->test_fn() != 1) ts[i]->failcount++;
	}
      }

      // check for failures
      int total_fail_count=0;
      for (i=0; i<n; i++) total_fail_count += ts[i]->failcount;
      if (total_fail_count) break;
    }

    // print results
    for (i=0; i<n; i++) {
      printf ("%3d: %-30s: ",ts[i]->number,ts[i]->name);
      if (ts[i]->failcount) {
	printf ("FAILED (%.2f%%) at line %d\n",
		double(ts[i]->failcount)/double(total_reps)*100.0,
		ts[i]->last_failed_line);
      }
      else {
	printf ("ok\n");
      }
    }
  }
}
Beispiel #15
0
dReal & dMatrix::operator () (int i, int j)
{
  if (i < 0 || i >= n || j < 0 || j >= m) dDebug (0,"bad matrix (i,j)");
  return data [i*m+j];
}
bool KTMainWindow::closeProject()
{
	dDebug() << "Closing..";
	if(!m_projectManager->isOpen())
	{
		return true;
	}
	
	QMessageBox mb(QApplication::applicationName (), tr("Do you want to save?"),
		       QMessageBox::Information,
		       QMessageBox::Yes | QMessageBox::Default,
		       QMessageBox::No,
		       QMessageBox::Cancel | QMessageBox::Escape);
	mb.setButtonText(QMessageBox::Yes, tr("Save"));
	mb.setButtonText(QMessageBox::No, tr("Discard"));
	
	switch(mb.exec())
	{
		case QMessageBox::Yes:
		{
			m_projectManager->save();
		}
		break;
		case QMessageBox::No:
		{
		}
		break;
		case QMessageBox::Cancel:
		{
			return false;
		}
		break;
	}
	
	m_pActiveTabWidget->setCurrentWidget(m_drawingSpace);
	m_projectManager->close();
	
	m_drawingSpace->closeAllWindows();
	m_animationSpace->closeAllWindows();
	
// 	QWidgetList cameras = m_animationSpace->windowList();
// 	
// 	foreach (QWidget *widget, cameras)
// 	{
// 		KTViewCamera *view = qobject_cast<KTViewCamera *>(widget);
// 		
// 		if ( view )
// 		{
// 			view->animationArea()->setScene(0);
// 			view->animationArea()->setSize(m_projectManager->documentSize());
// 		}
// 	}
	
	// Clean widgets
	m_exposureSheet->closeAllScenes();
	m_timeLine->closeAllScenes();
	m_scenes->closeAllScenes();
	
	m_fileName = QString();
	
	return true;
}
CHelpWidget::CHelpWidget(QWidget *parent) : CModuleWidget(tr("Help"), parent)
{
	setWindowIcon(QPixmap(THEME_DIR+"/icons/help.png"));
	
	connect(m_pTree, SIGNAL(itemClicked ( QTreeWidgetItem *, int )), this, SLOT(tryToLoadPage(QTreeWidgetItem *, int)));
	
// 	m_pTree->setRootIsDecorated(true);
// 	m_pTree->addColumn(tr("Topics"));
	
	m_helpPath = QDir(DATA_DIR);
	
	QDomDocument document;
	
	dDebug() << m_helpPath.path();
	
	QFile file( m_helpPath.path()+"/help.xml" );
	
	if ( file.open( QIODevice::ReadOnly ) )
	{
		if ( document.setContent(&file) )
		{
			QDomElement root = document.documentElement();
			
			QDomNode section = root.firstChild();
			while( !section.isNull() )
			{
				QDomElement element = section.toElement();
				if( !element.isNull() )
				{
					if ( element.tagName() == "Section" )
					{
						QTreeWidgetItem *item = new QTreeWidgetItem(m_pTree);
						item->setText(0, element.attribute("title"));
						
						QDomNode subSection = element.firstChild();
						while( ! subSection.isNull())
						{
							QDomElement element2 = subSection.toElement();
							if ( !element2.isNull() )
							{
								if ( element2.tagName() == "SubSection" )
								{
									QTreeWidgetItem *subitem = new QTreeWidgetItem(item);
									subitem->setText(0, element2.attribute("title"));
									
									m_files.insert(subitem, element2.attribute("file"));
								}
							}
							subSection = subSection.nextSibling();
						}
					}
				}
				section = section.nextSibling();
			}
		}
		else
		{
			qDebug("CHelpWidget::Can't set contents");
		}
		file.close();
	}
	else
	{
		qDebug("CHelpWidget::Can't open");
	}
	
	m_pTree->setEditable( false );
}
void
CityWeather::debug_PrintCityWeather( const CityWeather & cityInfo )
{
    dDebug() << QString("City <%1> has weatherinfos for %2 day(s)")
             .arg(cityInfo.city()).arg(cityInfo.days().count());

    foreach( const YawpDay * pDay, cityInfo.days() )
    {
        dDebug();
        dDebug() << "Date: " << pDay->date();
        dDebug() << "   date          = " << pDay->date();
        dDebug() << "   sunrise       = " << pDay->sunrise();
        dDebug() << "   sunset        = " << pDay->sunset();
        dDebug();

        int iMax = (pDay->hasNightValues() ? 2 : 1);
        for( int i=0; i<iMax; ++i )
        {
            const YawpWeather & weather = (i == 0 ? pDay->weather() : pDay->nightWeather());
            const QString sPrefix(i==0 ? "" : "night ");

            dDebug() << QString("   %1current temp  = %2")
                     .arg(sPrefix).arg(weather.currentTemperature()).toUtf8().constData();
            dDebug() << QString("   %1current icon  = %2")
                     .arg(sPrefix).arg(weather.currentIconName()).toUtf8().constData();

            dDebug() << QString("   %1iconName      = %2")
                     .arg(sPrefix).arg(weather.iconName()).toUtf8().constData();
            dDebug() << QString("   %1low           = %2")
                     .arg(sPrefix).arg(weather.lowTemperature()).toUtf8().constData();
            dDebug() << QString("   %1realfeellow   = %2")
                     .arg(sPrefix).arg(weather.temperatureRealFeelLow()).toUtf8().constData();
            dDebug() << QString("   %1high          = %2")
                     .arg(sPrefix).arg(weather.highTemperature()).toUtf8().constData();
            dDebug() << QString("   %1realfeelhigh  = %2")
                     .arg(sPrefix).arg(weather.temperatureRealFeelHigh()).toUtf8().constData();
            dDebug() << QString("   %1description   = %2")
                     .arg(sPrefix).arg(weather.description()).toUtf8().constData();
            dDebug() << QString("   %1humidity      = %2")
                     .arg(sPrefix).arg(weather.humidity()).toUtf8().constData();
            dDebug() << QString("   %1windSpeed     = %2")
                     .arg(sPrefix).arg(weather.windSpeed()).toUtf8().constData();
            dDebug() << QString("   %1windDirection = %2")
                     .arg(sPrefix).arg(weather.windDirection()).toUtf8().constData();

            dDebug() << QString("  %1property text lines = %2")
                     .arg(sPrefix).arg(weather.propertyTextLines().count()).toUtf8().constData();

            dDebug();
        }
    }
}