Exemple #1
0
/*!
  \reimp
*/
QSize QLabel::minimumSizeHint() const
{
    Q_D(const QLabel);
    if (d->valid_hints) {
        if (d->sizePolicy == sizePolicy())
            return d->msh;
    }

    ensurePolished();
    d->valid_hints = true;
    d->sh = d->sizeForWidth(-1); // wrap ? golden ratio : min doc size
    QSize msh(-1, -1);

    if (!d->isTextLabel) {
        msh = d->sh;
    } else {
        msh.rheight() = d->sizeForWidth(QWIDGETSIZE_MAX).height(); // height for one line
        msh.rwidth() = d->sizeForWidth(0).width(); // wrap ? size of biggest word : min doc size
        if (d->sh.height() < msh.height())
            msh.rheight() = d->sh.height();
    }
    d->msh = msh;
    d->sizePolicy = sizePolicy();
    return msh;
}
Exemple #2
0
void ISCExport::saveMesh(FILE *file,TriObject *pTriobj,const Matrix3* pM,Mtl *pMeshMtl,SceneEnumerator& enumerator)
{
	ion::math::Meshconv msh(true,false);
	Mesh &maxmesh=pTriobj->GetMesh();

	DWORD meshMtlID=(pMeshMtl!=0) ? (DWORD)(enumerator.findMaterial(pMeshMtl)) : 0;

	bool negScale = (pM) ? (DotProd(CrossProd(pM->GetRow(0),pM->GetRow(1)),pM->GetRow(2))>0.0) : false;

	int vx[3];

	if (negScale) {
		vx[0]=2;
		vx[1]=1;
		vx[2]=0;
	} else {
		vx[0]=0;
		vx[1]=1;
		vx[2]=2;
	}

	{
		// TODO: Normals

		/*ion::math::Meshconv::InNormal n;
		n.m_X=1;
		n.m_Y=n.m_Z=0;
		msh.addNormal(n);*/

		for (int facenr=0;facenr<maxmesh.getNumFaces();++facenr) {
			ion::math::Meshconv::InTriangle intr;

			Face *pVFace=&maxmesh.faces[facenr];

			intr.m_XYZ[0]=pVFace->v[vx[0]];
			intr.m_XYZ[1]=pVFace->v[vx[1]];
			intr.m_XYZ[2]=pVFace->v[vx[2]];

			if (maxmesh.tvFace!=0) {
				TVFace *pTVFace=&maxmesh.tvFace[facenr];

				intr.m_Texcoords2D[0]=pTVFace->t[vx[0]];
				intr.m_Texcoords2D[1]=pTVFace->t[vx[1]];
				intr.m_Texcoords2D[2]=pTVFace->t[vx[2]];
			} else {
				intr.m_Texcoords2D[0]=0;
				intr.m_Texcoords2D[1]=0;
				intr.m_Texcoords2D[2]=0;
			}

			intr.m_Normals[0]=pVFace->v[vx[0]];
			intr.m_Normals[1]=pVFace->v[vx[1]];
			intr.m_Normals[2]=pVFace->v[vx[2]];

			msh.addTriangle(intr);
		}

		if (maxmesh.normalsBuilt==0)
			maxmesh.buildNormals();

		for (int vtxnr=0;vtxnr<maxmesh.getNumVerts();++vtxnr) {
			Point3 *pVtx=&maxmesh.verts[vtxnr];

			Point3 vtx2;
			if (pM)
				vtx2=pM->PointTransform(*pVtx);
			else vtx2=*pVtx;

			// Swapping y and z to correct the coordinate system
			ion::math::Meshconv::InVtx invtx;
			invtx.m_X=vtx2.x;
			invtx.m_Y=vtx2.z;
			invtx.m_Z=vtx2.y;

			//vn =getVertexNormal(&maxmesh, i, maxmesh.getRVertPtr(vert));
			Point3 vn=maxmesh.getNormal(vtxnr);
			float vnl=sqrtf(vn.x*vn.x+vn.y*vn.y+vn.z*vn.z);
			if (vnl!=0) vnl=1.0f/vnl;
			ion::math::Meshconv::InNormal n;
			n.m_X=vn.x*vnl;
			n.m_Y=vn.z*vnl;
			n.m_Z=vn.y*vnl;

			msh.addXYZVtx(invtx);
			msh.addNormal(n);
		}

		for (int tuvnr=0;tuvnr<maxmesh.getNumTVerts();++tuvnr) {
			UVVert *pUV=&maxmesh.tVerts[tuvnr];

			// TODO: need to check whether UV, VW, or WU is used
			ion::math::Meshconv::InTexcoord2D intexcoord;
			intexcoord.m_U=pUV->x;
			intexcoord.m_V=pUV->y;

			msh.addTexcoord2D(intexcoord);
		}

		msh.calculate();

	}


	{ DWORD numTris=msh.numOutTriangles(); fwrite(&numTris,1,4,file); }
	{ DWORD numVtx=msh.numOutVertices(); fwrite(&numVtx,1,4,file); }

	// Indices
	{
		for (unsigned long trinr=0;trinr<msh.numOutTriangles();++trinr) {
			const ion::math::Meshconv::OutTriangle &tri=msh.outTriangle(trinr);

			fwrite(&tri.m_Indices[0],1,4,file);
			fwrite(&tri.m_Indices[1],1,4,file);
			fwrite(&tri.m_Indices[2],1,4,file);
		}
	}

	// Face attributes
	// TODO: Read the attributes from max
	{
		for (unsigned long trinr=0;trinr<msh.numOutTriangles();++trinr) {
			//DWORD id=maxmesh.faces[trinr].getMatID();
			fwrite(&meshMtlID,1,4,file);
		}
	}

	// Vertices
	{
		for (unsigned long vtxnr=0;vtxnr<msh.numOutVertices();++vtxnr) {
			const ion::math::Meshconv::OutVertex &vtx=msh.outVertex(vtxnr);

			float tangent[3]={1,0,0};
			float binormal[3]={0,1,0};

			fwrite(&vtx.m_XYZ.m_X,1,sizeof(float),file);
			fwrite(&vtx.m_XYZ.m_Y,1,sizeof(float),file);
			fwrite(&vtx.m_XYZ.m_Z,1,sizeof(float),file);
			fwrite(&vtx.m_Normal.m_X,1,sizeof(float),file);
			fwrite(&vtx.m_Normal.m_Y,1,sizeof(float),file);
			fwrite(&vtx.m_Normal.m_Z,1,sizeof(float),file);
			fwrite(&vtx.m_Texcoord.m_U,1,sizeof(float),file);
			fwrite(&vtx.m_Texcoord.m_V,1,sizeof(float),file);
			fwrite(tangent,1,3*sizeof(float),file);
			fwrite(binormal,1,3*sizeof(float),file);
		}
	}

}
Exemple #3
0
int execute  (char const *comm, char **envp)
{
   int         status = 0;
   char const *(argv[1024]);
   char const *script;
   char const *shell = Tenv::appGet("SHELL");
   
   if (NULL == comm) return(0);
   
   if ('\0' == *comm)
   {
      status = 0;
   }
   else if ((shell == NULL) || !strcmp(shell, INTERNAL_SHELL))
   {
   	  // Use the internal shell
      int rtn;
      int i;
      
      // Pass on the target and dependents as arguments
      Tstr target = Tenv::appGet("TARGET");
      Tstr deps   = Tenv::appGet("DEPS");
         
      char *d = (char*)malloc(strlen((char const*)deps)+1);
      strcpy(d, (char const*)deps);
            
      char *p = d;
      char *q = p;
      
      argv[0] = INTERNAL_SHELL;
            
      argv[1] = (char const*)target;
         
      while (isspace(*p)) p++;
      for (i = 2; (i < 1023) && ('\0' != *p); i++)
      {
         q = p;
         while ((!isspace(*p)) && ('\0' != *p)) p++;
         *(p++) = '\0';
         while (isspace(*p)) p++;
            
         argv[i] = q;
      }
         
      argv[i] = NULL;
            
      rtn = msh(comm, argv, envp);
      
      // Free the space
      free(d);
      
      if (0 != rtn) printT("Build failed [%d]\n", rtn);
      status = rtn;
   }
   else if (NULL != (script = makeScript(comm)))
   {
   	  // Use the internal shell
      int rtn;
      int i;
      
      // Pass on the target and dependents as arguments
      Tstr target = Tenv::appGet("TARGET");
      Tstr deps   = Tenv::appGet("DEPS");
         
      char *d = (char*)malloc(strlen((char const*)deps)+1);
      strcpy(d, (char const*)deps);
            
      char *p = d;
      char *q = p;
      
      argv[0] = INTERNAL_SHELL;
            
      argv[1] = (char const*)target;
         
      while (isspace(*p)) p++;
      for (i = 2; (i < 1023) && ('\0' != *p); i++)
      {
         q = p;
         while ((!isspace(*p)) && ('\0' != *p)) p++;
         *(p++) = '\0';
         while (isspace(*p)) p++;
            
         argv[i] = q;
      }
         
      argv[i] = NULL;
            
      rtn = MYspawnve(MY_WAIT, (char*)script, argv, envp);
      
      // Free the space
      free(d);
      
      unlink((char*)script);
      
      if (0 != rtn) printT("Build failed [%d]\n", rtn);
      status = rtn;
   }
   
   return(status);
}