Пример #1
0
void CartesianWidget::setScale(int scaleX, int scaleY)
{
    m_scaleX = scaleX;
    m_scaleY = scaleY;

    calcBounds();

    emit scaleChanged(m_scaleX, m_scaleY);
}
Пример #2
0
void CartesianWidget::setCenter(double centerX, double centerY)
{
    mcenterX = centerX;
    mcenterY = centerY;

    calcBounds();

    emit centerChanged(mcenterX, mcenterY);
}
Пример #3
0
Foam::searchableCylinder::searchableCylinder
(
    const IOobject& io,
    const dictionary& dict
)
:
    searchableSurface(io),
    point1_(dict.lookup("point1")),
    point2_(dict.lookup("point2")),
    magDir_(mag(point2_-point1_)),
    unitDir_((point2_-point1_)/magDir_),
    radius_(readScalar(dict.lookup("radius")))
{
    bounds() = calcBounds();
}
Пример #4
0
Foam::searchableCylinder::searchableCylinder
(
    const IOobject& io,
    const point& point1,
    const point& point2,
    const scalar radius
)
:
    searchableSurface(io),
    point1_(point1),
    point2_(point2),
    magDir_(mag(point2_-point1_)),
    unitDir_((point2_-point1_)/magDir_),
    radius_(radius)
{
    bounds() = calcBounds();
}
Пример #5
0
	RectF TreeInspector::calcBounds(Actor *actor)
	{
		OX_ASSERT(actor);

		RectF r = getBounds(actor);

		spActor c = actor->getFirstChild();
		while (c)
		{
			if (c->getVisible())
			{
				RectF cr = calcBounds(c.get());				
				cr.pos += c->getPosition();
				r.unite(cr);
			}
			c = c->getNextSibling();
		}

		r.pos = r.pos - actor->getPosition();
		return r;
	}
Пример #6
0
void CartesianWidget::setZoom(double zm)
{
    mzoom = zm;

    calcBounds();

    if (zm == 1.0)
    {
        mzoomLevel = 0;
    }
    if (zm < 1.0)
    {
        mzoomLevel = (int)floor(log(zm*pow(1.25, 1.0/3.0)) / log(2*pow(1.25, 1.0/3.0)));
    }
    if (zm > 1.0)
    {
        mzoomLevel = (int)ceil(log(zm*pow(0.8, 1.0/3.0)) / log(2*pow(1.25, 1.0/3.0)));
    }

    emit zoomChanged(zm);
}
Пример #7
0
void RenderSVGContainer::layout()
{
    ASSERT(needsLayout());

    // Arbitrary affine transforms are incompatible with LayoutState.
    view()->disableLayoutState();

    IntRect oldBounds;
    IntRect oldOutlineBox;
    bool checkForRepaint = checkForRepaintDuringLayout() && selfWillPaint();
    if (checkForRepaint) {
        oldBounds = m_absoluteBounds;
        oldOutlineBox = absoluteOutlineBounds();
    }
    
    calculateLocalTransform();

    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
        // Only force our kids to layout if we're being asked to relayout as a result of a parent changing
        // FIXME: We should be able to skip relayout of non-relative kids when only bounds size has changed
        // that's a possible future optimization using LayoutState
        // http://bugs.webkit.org/show_bug.cgi?id=15391
        if (selfNeedsLayout())
            child->setNeedsLayout(true);

        child->layoutIfNeeded();
        ASSERT(!child->needsLayout());
    }

    calcBounds();

    if (checkForRepaint)
        repaintAfterLayoutIfNeeded(oldBounds, oldOutlineBox);

    view()->enableLayoutState();
    setNeedsLayout(false);
}
Пример #8
0
AtlasDiscreteMesh *AtlasDiscreteMesh::decimate(U32 target)
{
#ifndef ENABLE_DECIMATION
   Con::errorf("AtlasDiscreteMesh::decimate - decimation not enabled, define ENABLE_DECIMATION!");
   return NULL;
#else

// collapse rules:
// 
// side to top, to what vert (if any)
//
//	        center	edge	corner	never
// center  	any	edge	corner	never
// edge	   -	   line	corner	-
// corner	-	   -	   -	      -
// never  	-	   -	   -	      -

   // First, copy ourselves into a MxStdModel
   MxStdModel sm(mVertexCount, mIndexCount/3);

   sm.texcoord_binding(MX_PERVERTEX);
   sm.normal_binding(MX_PERVERTEX);

   for(U32 i=0; i<mVertexCount; i++)
   {
      sm.add_texcoord(mTex[i].x, mTex[i].y);
      sm.add_vertex(mPos[i].x, mPos[i].y, mPos[i].z);
      sm.add_normal(mNormal[i].x, mNormal[i].y, mNormal[i].z);
   }

   for(U32 i=0; i<mIndexCount; i+=3)
      sm.add_face(mIndex[i+0],mIndex[i+1],mIndex[i+2]);

   Con::printf("AtlasDiscreteMesh::decimate - starting with %d verts, %d indices, %d faces allocated.", 
                     sm.vert_count(), mIndexCount, sm.face_count());

   // Run it through the decimator.
   MxEdgeQSlim qslim(sm);

   qslim.placement_policy = MX_PLACE_ENDORMID; //MX_PLACE_OPTIMAL; <-- optimal causes f'ed up results!
   qslim.weighting_policy = MX_WEIGHT_AREA_AVG;
   qslim.compactness_ratio = 0.0;
   qslim.meshing_penalty = 1.0;
   qslim.will_join_only = false;

   // Now, calculate our constraints - basically take everything that's within
   // 0.1 meters of a bounding plane and mark it with that plane's IDs. Our
   // bounding planes are the 4 vertical faces of the bounding box.
   PlaneF planes[4];
   Box3F bounds = calcBounds();

   // Generate planes from three points... Up is z+, and the normal for the
   // plane should face towards the center (but it doesn't really matter, we
   // only ever take absolute distance).
   {
      Point3F a,b,c;
      a.x = bounds.minExtents.x;
      a.y = bounds.minExtents.y;
      a.z = bounds.minExtents.z;

      b.x = bounds.maxExtents.x;
      b.y = bounds.minExtents.y;
      b.z = bounds.minExtents.z;

      c = a + Point3F(0, 0, 10);

      planes[0].set(a,b,c);
   }
   {
      Point3F a,b,c;
      a.x = bounds.maxExtents.x;
      a.y = bounds.minExtents.y;
      a.z = bounds.minExtents.z;

      b.x = bounds.maxExtents.x;
      b.y = bounds.maxExtents.y;
      b.z = bounds.minExtents.z;

      c = a + Point3F(0, 0, 10);

      planes[1].set(a,b,c);
   }
   {
      Point3F a,b,c;
      a.x = bounds.maxExtents.x;
      a.y = bounds.maxExtents.y;
      a.z = bounds.minExtents.z;

      b.x = bounds.minExtents.x;
      b.y = bounds.maxExtents.y;
      b.z = bounds.minExtents.z;

      c = a + Point3F(0, 0, 10);

      planes[2].set(a,b,c);
   }
   {
      Point3F a,b,c;
      a.x = bounds.minExtents.x;
      a.y = bounds.maxExtents.y;
      a.z = bounds.minExtents.z;

      b.x = bounds.minExtents.x;
      b.y = bounds.minExtents.y;
      b.z = bounds.minExtents.z;

      c = a + Point3F(0, 0, 10);

      planes[3].set(a,b,c);
   }

   // Now categorize everything w/ constraints.
   for(U32 i=0; i<mVertexCount; i++)
   {
      U8 bits=0;
      for(S32 j=0; j<4; j++)
      {
         F32 d = mFabs(planes[j].distToPlane(mPos[i]));

         if(d < .1)
            bits |= BIT(j);
      }

      qslim.planarConstraints(i) = bits;
   }

   // Now we initialize and constrain...
   qslim.initialize();
   qslim.decimate(target);

   // Copy everything out to a new ADM
   AtlasDiscreteMesh *admOut = new AtlasDiscreteMesh();

   // First, mark stray vertices for removal
   for(U32 i=0; i<sm.vert_count(); i++)
      if(sm.vertex_is_valid(i) && sm.neighbors(i).length() == 0 )
         sm.vertex_mark_invalid(i);

   // Compact vertex array so only valid vertices remain
   sm.compact_vertices();

   // Copy verts out. Get a count, first.
   U32 vertCount = 0;

   for(U32 i=0; i<sm.vert_count(); i++)
      if(sm.vertex_is_valid(i))
         vertCount++;

   admOut->mVertexCount = vertCount;
   admOut->mPos         = new Point3F[vertCount];
   admOut->mTex         = new Point2F[vertCount];
   admOut->mNormal      = new Point3F[vertCount];

   for(S32 i=0; i<vertCount; i++)
   {
      if(!sm.vertex_is_valid(i))
         continue;

      const MxVertex   &v = qslim.model().vertex(i);
      const MxTexCoord &t = qslim.model().texcoord(i);
      const MxNormal   &n = qslim.model().normal(i);

      admOut->mPos[i].x    = v[0];
      admOut->mPos[i].y    = v[1];
      admOut->mPos[i].z    = v[2];

      admOut->mTex[i].x    = t[0];
      admOut->mTex[i].y    = t[1];
      
      admOut->mNormal[i].x = n[0];
      admOut->mNormal[i].y = n[1];
      admOut->mNormal[i].z = n[2];
   }

   // We have to ignore non-valid faces, so let's recount our idxCount.
   U32 idxCount = 0;

   for(U32 i=0; i < sm.face_count(); i++)
      if(sm.face_is_valid(i))
         idxCount += 3;

   Con::printf("AtlasDiscreteMesh::decimate - %d out of %d verts, %d out of %d indices.", 
      vertCount, sm.vert_count(), idxCount, sm.face_count() * 3);

   admOut->mIndexCount = idxCount;
   admOut->mIndex = new U16[idxCount];

   U16 *idx = admOut->mIndex;

   for(S32 i=0; i < sm.face_count(); i++)
   {
      // Skip invalid.
      if(!sm.face_is_valid(i))
         continue;

      const MxFace &f = sm.face(i);

      idx[0] = f[0];
      idx[1] = f[1];
      idx[2] = f[2];

      //Con::printf("                 face #%d (%d, %d, %d)", i, f[0], f[1], f[2]);

      idx += 3;
   }

   // Make sure our vert and index counts are accurate.
   admOut->mIndexCount = idx - admOut->mIndex;

   return admOut;
#endif
}
Пример #9
0
int DxfMap::write_head(FILE *fp)
{
    calcBounds();

    // head
    write_string(fp, 999, (char*)"DXF Map, RTS, University of Hannover");
    write_string(fp, 0, (char*)"SECTION");
    write_string(fp, 2, (char*)"HEADER");
    write_string(fp, 9, (char*)"$ACADVER");
    write_string(fp, 1, (char*)"AC1021");
    write_string(fp, 9, (char*)"$INSBASE");
    write_real  (fp, 10, 0.0);
    write_real  (fp, 20, 0.0);
    write_real  (fp, 30, 0.0);
    write_string(fp, 9, (char*)"$EXTMIN");
    write_real  (fp, 10, xMin);
    write_real  (fp, 20, yMin);
    write_real  (fp, 30, 0.0);
    write_string(fp, 9, (char*)"$EXTMAX");
    write_real  (fp, 10, xMax);
    write_real  (fp, 20, yMax);
    write_real  (fp, 30, 0.0);
    write_string(fp, 0, (char*)"ENDSEC");
    // Tables
    write_string(fp, 0, (char*)"SECTION");
    write_string(fp, 2, (char*)"TABLES");
    write_string(fp, 0, (char*)"TABLE");
    write_string(fp, 2, (char*)"LTYPE");
    write_number(fp, 70, 1);
    write_string(fp, 0, (char*)"LTYPE");
    write_string(fp, 2, (char*)"CONTINUOUS");
    write_number(fp, 70, 64);
    write_string(fp, 3, (char*)"Solid line");
    write_number(fp, 72, 65);
    write_number(fp, 73, 0);
    write_real  (fp, 40, 0.0);
    write_string(fp, 0, (char*)"ENDTAB");
    write_string(fp, 0, (char*)"TABLE");
    write_string(fp, 2, (char*)"LAYER");
    write_number(fp, 70, 6);
    write_string(fp, 0, (char*)"LAYER");
    write_number(fp, 2, 0);
    write_number(fp, 70, 64);
    write_number(fp, 62, 5);
    write_string(fp, 6, (char*)"CONTINUOUS");
    write_string(fp, 0, (char*)"LAYER");
    write_number(fp, 2, 1);
    write_number(fp, 70, 64);
    write_number(fp, 62, 3);
    write_string(fp, 6, (char*)"CONTINUOUS");
    write_string(fp, 0, (char*)"LAYER");
    write_number(fp, 2, 2);
    write_number(fp, 70, 64);
    write_number(fp, 62, 2);
    write_string(fp, 6, (char*)"CONTINUOUS");
    write_string(fp, 0, (char*)"ENDTAB");
    write_string(fp, 0, (char*)"TABLE");
    write_string(fp, 2, (char*)"STYLE");
    write_number(fp, 70, 0);
    write_string(fp, 0, (char*)"ENDTAB");
    write_string(fp, 0, (char*)"ENDSEC");
    // empty block section
    write_string(fp, 0, (char*)"SECTION");
    write_string(fp, 2, (char*)"BLOCKS");
    write_string(fp, 0, (char*)"ENDSEC");
    // start Entities
    write_string(fp, 0, (char*)"SECTION");
    write_string(fp, 2, (char*)"ENTITIES");

    return 0;
}