コード例 #1
0
	sgMeshTriangle::sgMeshTriangle(void) : sgMesh()
    {
        reset(3, 3, 1);
        
        m_bCounterClockWise = true;
        
        m_pPosData = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
        m_pPosData[0] = Vector3(-1.0f, 0.0f, 0.0f);
		m_pPosData[1] = Vector3(1.0f, 0.0f, 0.0f);
        m_pPosData[2] = Vector3(0.0f, 1.0f, 0.0f);
        
		m_pColorData = static_cast<Color*>(m_pVertexData->createElement(sgVertexBufferElement::ColorAttributeName, RDT_UBYTE, 4, m_iVertexNum)->data());
        m_pColorData[0] = Color::WHITE;
        m_pColorData[1] = Color::WHITE;
        m_pColorData[2] = Color::WHITE;
        
		size_t *pIndex = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());
		pIndex[0] = 0;
		pIndex[1] = 1;
		pIndex[2] = 2;
        
		//setupNormals();
        prepareGeometry();
		m_pFaceNormal = static_cast<Vector3*>(m_pFaceNormalBuffer->data());
	}
コード例 #2
0
ファイル: pageitem.cpp プロジェクト: darealshinji/qpdfview
void PageItem::setRenderParam(const RenderParam& renderParam)
{
    if(m_renderParam != renderParam)
    {
        const bool resolutionChanged = m_renderParam.resolutionX() != renderParam.resolutionX()
                || m_renderParam.resolutionY() != renderParam.resolutionY()
                || !qFuzzyCompare(m_renderParam.devicePixelRatio(), renderParam.devicePixelRatio())
                || !qFuzzyCompare(m_renderParam.scaleFactor(), renderParam.scaleFactor());

        const bool rotationChanged = m_renderParam.rotation() != renderParam.rotation();

        const RenderFlags changedFlags = m_renderParam.flags() ^ renderParam.flags();

        refresh(!rotationChanged && changedFlags == 0);

        m_renderParam = renderParam;

        if(resolutionChanged || rotationChanged)
        {
            prepareGeometryChange();
            prepareGeometry();
        }

        if(changedFlags.testFlag(TrimMargins))
        {
            setFlag(QGraphicsItem::ItemClipsToShape, m_renderParam.trimMargins());
        }
    }
}
コード例 #3
0
void UISlidingToolBar::prepare()
{
    /* Do not count that window as important for application,
     * it will NOT be taken into account when other top-level windows will be closed: */
    setAttribute(Qt::WA_QuitOnClose, false);
    /* Delete window when closed: */
    setAttribute(Qt::WA_DeleteOnClose);

#if   defined(Q_WS_MAC) || defined(Q_WS_WIN)
    /* Make sure we have no background
     * until the first one paint-event: */
    setAttribute(Qt::WA_NoSystemBackground);
    /* Use Qt API to enable translucency: */
    setAttribute(Qt::WA_TranslucentBackground);
#elif defined(Q_WS_X11)
    if (QX11Info::isCompositingManagerRunning())
    {
        /* Use Qt API to enable translucency: */
        setAttribute(Qt::WA_TranslucentBackground);
    }
#endif /* Q_WS_X11 */

    /* Prepare contents: */
    prepareContents();
    /* Prepare geometry: */
    prepareGeometry();
    /* Prepare animation: */
    prepareAnimation();
}
コード例 #4
0
ファイル: WireCube.cpp プロジェクト: SoumyajitG/VolRoverN
Geometry* WireCube::getAxes()
{
    if (m_bOptionsChanged) {
        prepareGeometry();
    }

    return &m_Axes;
}
コード例 #5
0
void WireCubeRenderable::setColor(float r, float g, float b)
{
	m_R = r;
	m_G = g;
	m_B = b;

	prepareGeometry();
}
コード例 #6
0
WireCubeRenderable::WireCubeRenderable() :
GeometryRenderable(&m_WireCubeGeometry, false), m_Boundary(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)
{
	m_GeometriesAllocated = false;
	m_R = 1.0;
	m_G = 1.0;
	m_B = 1.0;

	prepareGeometry();
}
コード例 #7
0
	//  [1/5/2009 zhangxiang]
	void sgMeshCone::init(void){
	/*	if(m_fRadius <= 0 || m_fHeight <= 0 || m_iSlices < 2){
			THROW_SAGI_EXCEPT(sgException::ERR_INVALID_STATE,
							"Invalid parameters for the cone",
							"sgMeshCone::init");
		}
*/
		Vector3 *pPosData = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
		size_t *pIndexData = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());

		// setup vertices
		pPosData[0] = Vector3::ZERO;

		Quaternion Dq(Math::PI_X_2 / m_iSlices, Vector3(0.0, 1.0, 0.0));

		Vector3 o(0.0, 0.0, m_fRadius);
		uInt index = 1;
		for(int i=0; i<m_iSlices; i++){
			pPosData[index++] = o;
		//	m_pVertexList->push_back(o);
			o = Dq * o;
		}
		pPosData[index] = Vector3(0.0, m_fHeight, 0.0);

		// setup faces
		size_t faceNum = m_iSlices + m_iSlices;

		size_t lowCenter = 0;
		size_t highCenter = index; //static_cast<size_t>(m_pVertexList->size() - 1);

		int slice = 1;
		size_t ii = 0;
		for(size_t i=0; i<faceNum; ++i){
			int nextSlice = slice + 1 <= m_iSlices ? slice + 1 : 1;

			pIndexData[ii++] = lowCenter;
			pIndexData[ii++] = nextSlice;
			pIndexData[ii++] = slice;

			++i;

			pIndexData[ii++] = highCenter;
			pIndexData[ii++] = slice;
			pIndexData[ii++] = nextSlice;

			++slice;
		}

		//setupNormals();
	//	setupEdgeNormal(); // for future ...
		prepareGeometry();
	}
コード例 #8
0
	sgMeshVertex::sgMeshVertex() : sgMesh()
    {
        reset(1, 1, 1);
        
		m_pPosition = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
        
		m_pColor = static_cast<Color*>(m_pVertexData->createElement(sgVertexBufferElement::ColorAttributeName, RDT_UBYTE, 4, m_iVertexNum)->data());
        
		size_t *pIndex = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());
		// juse is this variable
		*pIndex = 0;

		prepareGeometry();
	}
コード例 #9
0
    void sgMeshLine::setVertecies(const Vector3 &p1, const Color &c1,
                                  const Vector3 &p2, const Color &c2)
    {
		_setDirty();

        m_pPosData[0] = p1;
		m_pPosData[1] = p2;
        
        m_pColorData[0] = c1;
		m_pColorData[1] = c2;
        
        prepareGeometry();

    }
コード例 #10
0
void WireCubeRenderable::setAspectRatio(double x, double y, double z)
{
	double maxratio, ratioX=x, ratioY=y, ratioZ=z;

	// find the maximum ratio
	maxratio = ( ratioX > ratioY ? ratioX : ratioY );
	maxratio = ( maxratio > ratioZ ? maxratio : ratioZ );

	// normalize so the max ratio is 1.0
	ratioX /= maxratio;
	ratioY /= maxratio;
	ratioZ /= maxratio;
	m_Boundary.setExtents(-0.5*ratioX, 0.5*ratioX, -0.5*ratioY, 0.5*ratioY, -0.5*ratioZ, 0.5*ratioZ);

	prepareGeometry();
}
コード例 #11
0
	//  [1/5/2009 zhangxiang]
	sgMeshLine::sgMeshLine() : sgMesh()
    {
        reset(2, 2, 1);
        
        m_pPosData = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
        m_pPosData[0] = Vector3(0.0f, 0.0f, 0.0f);
		m_pPosData[1] = Vector3(1.0f, 1.0f, 1.0f);
        
        
		m_pColorData = static_cast<Color*>(m_pVertexData->createElement(sgVertexBufferElement::ColorAttributeName, RDT_UBYTE, 4, m_iVertexNum)->data());
        m_pColorData[0] = Color::WHITE;
		m_pColorData[1] = Color::WHITE;
        
		size_t *pIndex = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());
		pIndex[0] = 0;
		pIndex[1] = 1;
        
		prepareGeometry();
	}
コード例 #12
0
    void sgMeshTriangle::setVertecies(const Vector3 &p1, const Color &c1,
                                      const Vector3 &p2, const Color &c2,
                                      const Vector3 &p3, const Color &c3)
    {

		_setDirty();

        m_pPosData[0] = p1;
		m_pPosData[1] = p2;
        m_pPosData[2] = p3;
        
        m_pColorData[0] = c1;
		m_pColorData[1] = c2;
        m_pColorData[2] = c3;
        
		//setupNormals();
		prepareGeometry();
        
    }
コード例 #13
0
		//  [8/18/2008 zhangxiang]
		sgMeshPlane::sgMeshPlane()
		: sgMesh()
	{
		UInt32 aiLengthPerUnit = 50;
		UInt32 aiHUnitNum = 50;
		UInt32 aiVUnitNum = 50;
		//reset(2, 2 * (aiHUnitNum + aiVUnitNum), aiHUnitNum + aiVUnitNum + 2);
		reset(4, aiHUnitNum * aiVUnitNum * 4, aiHUnitNum * aiVUnitNum);

		int hTotalLength = aiLengthPerUnit * aiHUnitNum;
		int vTotalLength = aiLengthPerUnit * aiVUnitNum;
		int hHalfTotalLength = hTotalLength * 0.5;
		int vHalfTotalLength = vTotalLength * 0.5;

		Vector3 *pPosData = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
		Vector2 *pUV0Data = static_cast<Vector2*>(m_pVertexData->createElement(sgVertexBufferElement::UV0AttributeName, RDT_F, 2, m_iVertexNum)->data());
		//Color *pColorData = static_cast<Color*>(m_pVertexData->createElement(sgVertexBufferElement::ET_COLOR, 4, m_iVertexNum)->data());
		size_t *pIndex = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());
        
        Int32 xLeft = -hHalfTotalLength;
        Int32 zTop = -vHalfTotalLength;
        UInt32 iVertex = 0;
        for(UInt32 row=0; row<aiVUnitNum; ++row, zTop+=aiLengthPerUnit)
        {
            xLeft = -hHalfTotalLength;
            for(UInt32 col=0; col<aiHUnitNum; ++col, xLeft+=aiLengthPerUnit, iVertex+=4)
            {
                pPosData[iVertex] = Vector3(xLeft, 0.0f, zTop);
                pPosData[iVertex+1] = Vector3(xLeft, 0.0f, zTop+(Int32)aiLengthPerUnit);
                pPosData[iVertex+2] = Vector3(xLeft+(Int32)aiLengthPerUnit, 0.0f, zTop+(Int32)aiLengthPerUnit);
                pPosData[iVertex+3] = Vector3(xLeft+(Int32)aiLengthPerUnit, 0.0f, zTop);
                
                pUV0Data[iVertex] = Vector2(0.0f, 0.0f);
                pUV0Data[iVertex+1] = Vector2(0.0f, 1.0f);
                pUV0Data[iVertex+2] = Vector2(1.0f, 1.0f);
                pUV0Data[iVertex+3] = Vector2(1.0f, 0.0f);
                
                pIndex[iVertex] = iVertex;
                pIndex[iVertex+1] = iVertex+1;
                pIndex[iVertex+2] = iVertex+2;
                pIndex[iVertex+3] = iVertex+3;
            }
        }
		/*
		pPosData[0] = Vector3(-hHalfTotalLength, 0.0f, -vHalfTotalLength);
		pPosData[1] = Vector3(-hHalfTotalLength, 0.0f, vHalfTotalLength);
		pPosData[2] = Vector3(hHalfTotalLength, 0.0f, vHalfTotalLength);
		pPosData[3] = Vector3(hHalfTotalLength, 0.0f, -vHalfTotalLength);

		pUV0Data[0] = Vector2(0.0f, 0.0f);
		pUV0Data[1] = Vector2(0.0f, 1.0f);
		pUV0Data[2] = Vector2(1.0f, 1.0f);
		pUV0Data[3] = Vector2(0.0f, 0.0f);

		pIndex[0] = 0;
		pIndex[1] = 1;
		pIndex[2] = 2;
		pIndex[3] = 3;
         */

		m_bNormalOuter = true;
        setSmooth(false);

		prepareGeometry();
	}
コード例 #14
0
	//  [8/18/2008 zhangxiang]
	sgMeshGrid::sgMeshGrid()
	: sgMesh()
    {
		UInt32 aiLengthPerUnit = 50;
		UInt32 aiHUnitNum = 50;
		UInt32 aiVUnitNum = 50;
		//Color arColor = Color::YELLOW;
        // smooth true
		reset(2, 2 * (aiHUnitNum + aiVUnitNum), aiHUnitNum + aiVUnitNum + 2);

		int hTotalLength = aiLengthPerUnit * aiHUnitNum;
		int vTotalLength = aiLengthPerUnit * aiVUnitNum;
		int hHalfTotalLength = hTotalLength * 0.5;
		int vHalfTotalLength = vTotalLength * 0.5;

		Vector3 *pPosData = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
		//Color *pColorData = static_cast<Color*>(m_pVertexData->createElement(sgVertexBufferElement::ET_COLOR, 4, m_iVertexNum)->data());
		size_t *pIndex = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());

		size_t vi = 0;
		size_t i = 0;
		size_t ii = 0;
		//	for(int x=-hHalfTotalLength; x<=hHalfTotalLength; x+=aiLengthPerUnit){
		int x = -hHalfTotalLength;
		for(uInt vl=0; vl<=aiVUnitNum; ++vl){
			pPosData[vi] = Vector3(x, 0, -vHalfTotalLength);
			//pColorData[vi] = arColor;
			pIndex[ii] = i;

			++vi; ++i; ++ii;

			pPosData[vi] = Vector3(x, 0, vHalfTotalLength);
			//pColorData[vi] = arColor;
			pIndex[ii] = i;

			++vi; ++i; ++ii;

			x += aiLengthPerUnit;
		}

		pIndex[ii++] = 0;
		pIndex[ii++] = vi - 2;

		pIndex[ii++] = 1;
		pIndex[ii++] = vi - 1;

		//	for(int z=-vHalfTotalLength+aiLengthPerUnit; z<vHalfTotalLength; z+=aiLengthPerUnit){
		int z = -vHalfTotalLength + aiLengthPerUnit;
		for(uInt vh=2; vh<=aiHUnitNum; ++vh){
			pPosData[vi] = Vector3(-hHalfTotalLength, 0, z);
			//pColorData[vi] = arColor;
			pIndex[ii] = i;

			++vi; ++i; ++ii;

			pPosData[vi] = Vector3(hHalfTotalLength, 0, z);
			//pColorData[vi] = arColor;
			pIndex[ii] = i;

			++vi; ++i; ++ii;

			z += aiLengthPerUnit;
		}

		m_bNormalOuter = true;

		prepareGeometry();
	}
コード例 #15
0
	//  [1/5/2009 zhangxiang]
	void sgMeshSphere::init(void){
        /*
		if(m_fRadius <= 0 || m_iSlices < 2 || m_iStacks <= 0){
			THROW_SAGI_EXCEPT(sgException::ERR_INVALID_STATE,
							"Invalid parameters for the sphere.",
							"sgMeshSphere::init");
		}
         */

		Vector3 *pPosData = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
		size_t *pIndexData = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());

		Real RX2 = m_fRadius + m_fRadius;
		Real RUp2 = m_fRadius * m_fRadius;

		Real Dy = RX2 / (m_iStacks + 1);
		Quaternion Dq(Math::PI_X_2 / m_iSlices, Vector3(0.0, 1.0, 0.0));

		size_t index = 0;
		std::vector< std::vector<size_t> > indexedStacks;
		std::vector<size_t> indexedStack;

		// vertices
		pPosData[0] = Vector3(0.0, -m_fRadius, 0.0);
		indexedStack.clear();
		for(int i=0; i<m_iSlices; i++){
			indexedStack.push_back(index);
		}
		indexedStacks.push_back(indexedStack);
		index++;

		Real y = -m_fRadius + Dy;
		for(int k=1; k<=m_iStacks; ++k, y+=Dy){
			indexedStack.clear();

			Real SectionRUp2 = RUp2 - y * y;

			Vector3 o(0.0, y, Math::Sqrt(SectionRUp2));
			for(int i=0; i<m_iSlices; ++i, ++index){
				indexedStack.push_back(index);

				pPosData[index] = o;
				o = Dq * o;
			}
			indexedStacks.push_back(indexedStack);
		}

		pPosData[index] = Vector3(0.0, m_fRadius, 0.0);
		indexedStack.clear();
		for(int i=0; i<m_iSlices; ++i){
			indexedStack.push_back(index);
		}
		indexedStacks.push_back(indexedStack);

		// faces
		int faceNum = (m_iStacks + 1) * m_iSlices;
		uInt ii = 0;
		for(int i=0; i<=m_iStacks; ++i){
			int stack = i;
			int nextStack = i+1;

			for(int j=0; j<m_iSlices; ++j){
				int slice = j;
				int nextSlice = j + 1 < m_iSlices ? j + 1: 0;

				pIndexData[ii++] = indexedStacks[stack][slice];
				pIndexData[ii++] = indexedStacks[stack][nextSlice];
				pIndexData[ii++] = indexedStacks[nextStack][nextSlice];
				pIndexData[ii++] = indexedStacks[nextStack][slice];
			}
		}

		m_Center = Vector3::ZERO;
		m_fAverageRadius = m_fMaxRadius = m_fRadius;

		// will calculate normals 
		//trianglate();
		prepareGeometry();
	}
コード例 #16
0
	//  [1/5/2009 zhangxiang]
	void sgMeshCube::init(void){

		Real halfLength = m_fEdgeLength * 0.5f;

		Vector3 *pPosData = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
		size_t *pIndexData = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());

		// setup vertecies
		pPosData[0] = Vector3(-halfLength, -halfLength, halfLength);
		pPosData[1] = Vector3(halfLength, -halfLength, halfLength);
		pPosData[2] = Vector3(halfLength, halfLength, halfLength);
		pPosData[3] = Vector3(-halfLength, halfLength, halfLength);

		pPosData[4] = Vector3(-halfLength, halfLength, -halfLength);
		pPosData[5] = Vector3(halfLength, halfLength, -halfLength);
		pPosData[6] = Vector3(halfLength, -halfLength, -halfLength);
		pPosData[7] = Vector3(-halfLength, -halfLength, -halfLength);

		// setup faces
		pIndexData[0] = 0;
		pIndexData[1] = 1;
		pIndexData[2] = 2;

		pIndexData[3] = 2;
		pIndexData[4] = 3;
		pIndexData[5] = 0;

		pIndexData[6] = 0;
		pIndexData[7] = 7;
		pIndexData[8] = 6;

		pIndexData[9] = 6;
		pIndexData[10] = 1;
		pIndexData[11] = 0;

		pIndexData[12] = 4;
		pIndexData[13] = 5;
		pIndexData[14] = 6;

		pIndexData[15] = 6;
		pIndexData[16] = 7;
		pIndexData[17] = 4;

		pIndexData[18] = 4;
		pIndexData[19] = 7;
		pIndexData[20] = 0;

		pIndexData[21] = 0;
		pIndexData[22] = 3;
		pIndexData[23] = 4;

		pIndexData[24] = 5;
		pIndexData[25] = 4;
		pIndexData[26] = 3;

		pIndexData[27] = 3;
		pIndexData[28] = 2;
		pIndexData[29] = 5;

		pIndexData[30] = 2;
		pIndexData[31] = 1;
		pIndexData[32] = 6;

		pIndexData[33] = 6;
		pIndexData[34] = 5;
		pIndexData[35] = 2;

        setSmooth(false);
		//setupNormals();
		//	computeEdgeNormal(); for future ...
		prepareGeometry();
	}
コード例 #17
0
void QgsMapToolOffsetCurve::canvasReleaseEvent( QgsMapMouseEvent *e )
{
  mCtrlHeldOnFirstClick = false;

  if ( e->button() == Qt::RightButton )
  {
    cancel();
    return;
  }

  if ( mOriginalGeometry.isNull() )
  {
    // first click, get feature to modify
    deleteRubberBandAndGeometry();
    mGeometryModified = false;

    QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToCurrentLayer( e->pos(),
                                   QgsPointLocator::Types( QgsPointLocator::Edge | QgsPointLocator::Area ) );

    if ( ( match.hasEdge() || match.hasArea() ) && match.layer() )
    {
      mLayer = match.layer();
      QgsFeature fet;
      if ( match.layer()->getFeatures( QgsFeatureRequest( match.featureId() ) ).nextFeature( fet ) )
      {
        mCtrlHeldOnFirstClick = ( e->modifiers() & Qt::ControlModifier ); //no geometry modification if ctrl is pressed
        prepareGeometry( match, fet );
        mRubberBand = createRubberBand();
        if ( mRubberBand )
        {
          mRubberBand->setToGeometry( mManipulatedGeometry, match.layer() );
        }
        mModifiedFeature = fet.id();
        createUserInputWidget();

        bool hasZ = QgsWkbTypes::hasZ( mLayer->wkbType() );
        bool hasM = QgsWkbTypes::hasZ( mLayer->wkbType() );
        if ( hasZ || hasM )
        {
          emit messageEmitted( QStringLiteral( "layer %1 has %2%3%4 geometry. %2%3%4 values be set to 0 when using offset tool." )
                               .arg( mLayer->name() )
                               .arg( hasZ ? "Z" : "" )
                               .arg( hasZ && hasM ? "/" : "" )
                               .arg( hasM ? "M" : "" )
                               , Qgis::Warning );
        }
      }
    }

    if ( mOriginalGeometry.isNull() )
    {
      emit messageEmitted( tr( "Could not find a nearby feature in any vector layer." ) );
      cancel();
      notifyNotVectorLayer();
    }
  }
  else
  {
    // second click - apply changes
    double offset = calculateOffset( e->snapPoint() );
    applyOffset( offset, e->modifiers() );
  }
}