当前位置: 首页>>代码示例>>C++>>正文


C++ GraphicsScene类代码示例

本文整理汇总了C++中GraphicsScene的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsScene类的具体用法?C++ GraphicsScene怎么用?C++ GraphicsScene使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GraphicsScene类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetWorld

/// @copydoc Entity::Attach()
void Camera::Attach()
{
    Base::Attach();

    // Update the scene view associated with this camera.
    if( IsValid( m_sceneViewId ) )
    {
        World* pWorld = GetWorld();
        HELIUM_ASSERT( pWorld );
        GraphicsScene* pScene = pWorld->GetGraphicsScene();
        if( pScene )
        {
            GraphicsSceneView* pSceneView = pScene->GetSceneView( m_sceneViewId );
            if( pSceneView )
            {
                Simd::Matrix44 rotationMatrix( Simd::Matrix44::INIT_ROTATION, GetRotation() );
                pSceneView->SetView(
                    GetPosition(),
                    Vector4ToVector3( rotationMatrix.GetRow( 2 ) ),
                    Vector4ToVector3( rotationMatrix.GetRow( 1 ) ) );
                pSceneView->SetHorizontalFov( m_fov );
            }
        }
    }
}
开发者ID:euler0,项目名称:Helium,代码行数:26,代码来源:Camera.cpp

示例2: GetGraphicsScene

void Viewport::OnResize()
{
	const uint32_t width = (m_Size.x > 0) ? m_Size.x : 64;
	const uint32_t height = (m_Size.y > 0) ? m_Size.y : 64;
	const float32_t aspectRatio =
	static_cast< float32_t >( width ) / static_cast< float32_t >( height );

	if (m_World)
	{
		Renderer* pRenderer = Renderer::GetStaticInstance();

		Renderer::ContextInitParameters ctxParams;
		ctxParams.pWindow = m_Window;
		ctxParams.displayWidth = width;
		ctxParams.displayHeight = height;
		ctxParams.bFullscreen = false;
		ctxParams.bVsync = false;

		RRenderContextPtr renderCtx = pRenderer->CreateSubContext( ctxParams );

		GraphicsScene* pGraphicsScene = GetGraphicsScene();
		GraphicsSceneView* pSceneView = pGraphicsScene->GetSceneView( m_SceneViewId );
		pSceneView->SetRenderContext( renderCtx );
		pSceneView->SetDepthStencilSurface( RenderResourceManager::GetStaticInstance().GetDepthStencilSurface() );
		pSceneView->SetAspectRatio( aspectRatio );
		pSceneView->SetViewport( 0, 0, width, height );
		pSceneView->SetClearColor( Helium::Color( 0x00505050 ) );
	}
}
开发者ID:kevindqc,项目名称:Helium,代码行数:29,代码来源:Viewport.cpp

示例3: UpdateCallback

void GraphicsScene::UpdateCallback( void *param, u32 begin, u32 end )
{
	//    ASSERT ( dynamic_cast<GraphicsScene*>(param));
	GraphicsScene* pThis = static_cast<GraphicsScene*>(param);

	pThis->ProcessRange( begin, end );
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:7,代码来源:GraphicsScene.cpp

示例4: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //connect signals of GUI elements with slots of this class
    connectSignalSlots();

    //hide advanced settings and connect signals/slots to show them
    hideAdvancedSettings();

    //initialize graphicsview
    GraphicsScene *scene = new GraphicsScene();
    ui->graphicsView->setScene(scene);
    scene->setBackgroundBrush(QBrush(Qt::darkGray));
    ui->graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
    scene->addText("Start by dragging images here.");
    ui->graphicsView->setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform);
    ui->graphicsView->setAcceptDrops(true);

    //initialize QImage objects to store the calculated maps
    input = QImage();
    channelIntensity = QImage();
    normalmap = QImage();
    specmap = QImage();
    displacementmap = QImage();
    ssaomap = QImage();

    //initialize calctimes
    lastCalctime_normal = 0;
    lastCalctime_specular = 0;
    lastCalctime_displace = 0;
    lastCalctime_ssao = 0;

    //initialize stopQueue flag
    stopQueue = false;

    //show default status message
    ui->statusBar->showMessage("Drag images into the empty preview window to load them.");

    //hide queue progressbar
    ui->progressBar_Queue->hide();

    //if the program was opened via "open with" by the OS, extract the image paths from the arguments
    //(args[0] is the name of the application)
    QStringList args = QCoreApplication::arguments();
    if(args.size() > 1) {
        QList<QUrl> imageUrls;

        for(int i = 1; i < args.size(); i++) {
            imageUrls.append(QUrl::fromLocalFile(args[i]));
        }

        loadMultipleDropped(imageUrls);
    }
}
开发者ID:magnomatos822,项目名称:NormalmapGenerator,代码行数:57,代码来源:mainwindow.cpp

示例5:

GraphicsObject::GraphicsObject(GraphicsScene & scene, const Vector3 & position)
    :	m_position(position),
      m_scene_node(nullptr)
{
    Ogre::Entity * ogre_head = scene.scene_manager().createEntity("Head", "ogrehead.mesh");
    m_scene_node = scene.scene_manager().getRootSceneNode()->createChildSceneNode();
    m_scene_node->attachObject(ogre_head);
    m_scene_node->setPosition(Ogre::Vector3(m_position.x(), m_position.z(), m_position.y()));
}
开发者ID:edfromspace,项目名称:Swarm,代码行数:9,代码来源:GraphicsObject.cpp

示例6: ChangePaintingRectCmd

 /*!
  * \brief Takes care of resizing upon mouse release event.
  *
  * This method takes care of creating the necessary undo commands
  * upon mouse release event. In this way, when resizing this item
  * (painting) the undo commands are passed to the undostack making
  * them available should an undo/redo command be issued.
  */
 void Painting::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
 {
     GraphicsItem::mouseReleaseEvent(event);
     if(m_activeHandle != Caneda::NoHandle && m_paintingRect != m_store) {
         ChangePaintingRectCmd *cmd = new ChangePaintingRectCmd(this, storedPaintingRect(), m_paintingRect);
         GraphicsScene *scene = qobject_cast<GraphicsScene*>(this->scene());
         scene->undoStack()->push(cmd);
     }
     m_activeHandle = Caneda::NoHandle;
 }
开发者ID:Caneda,项目名称:Caneda,代码行数:18,代码来源:painting.cpp

示例7: LOG4CPP_DEBUG_S

void GraphicsLinesForCurve::updateAfterCommand (GraphicsScene &scene,
                                                const PointStyle &pointStyle,
                                                const Point &point)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsLinesForCurve::updateAfterCommand"
                               << " curve=" << m_curveName.toLatin1().data()
                               << " pointCount=" << m_graphicsPoints.count();

  GraphicsPoint *graphicsPoint = 0;
  if (m_graphicsPoints.contains (point.ordinal())) {

    graphicsPoint = m_graphicsPoints [point.ordinal()];

    // Due to ordinal renumbering, the coordinates may belong to some other point so we override
    // them for consistent ordinal-position mapping. Updating the identifier also was added for
    // better logging (i.e. consistency between Document and GraphicsScene dumps), but happened
    // to fix a bug with the wrong set of points getting deleted from Cut and Delete
    graphicsPoint->setPos (point.posScreen());
    graphicsPoint->setData (DATA_KEY_IDENTIFIER, point.identifier());

  } else {

    // Point does not exist in scene so create it
    graphicsPoint = scene.createPoint (point.identifier (),
                                       pointStyle,
                                       point.posScreen());
    m_graphicsPoints [point.ordinal ()] = graphicsPoint;

  }

  // Mark point as wanted
  ENGAUGE_CHECK_PTR (graphicsPoint);
  graphicsPoint->setWanted ();
}
开发者ID:gitter-badger,项目名称:engauge6,代码行数:34,代码来源:GraphicsLinesForCurve.cpp

示例8: throw

void SI_Symbol::removeFromSchematic(GraphicsScene& scene) throw (Exception)
{
    mComponentInstance->unregisterSymbol(*this);
    scene.removeItem(*mGraphicsItem);
    foreach (SI_SymbolPin* pin, mPins)
        pin->removeFromSchematic(scene);
}
开发者ID:0xB767B,项目名称:LibrePCB,代码行数:7,代码来源:si_symbol.cpp

示例9: throw

void SI_Symbol::addToSchematic(GraphicsScene& scene) throw (Exception)
{
    mGenCompInstance->registerSymbol(*this);
    scene.addItem(*mGraphicsItem);
    foreach (SI_SymbolPin* pin, mPins)
        pin->addToSchematic(scene);
}
开发者ID:nemofisch,项目名称:LibrePCB,代码行数:7,代码来源:si_symbol.cpp

示例10: removeFromSchematic

void SI_SymbolPin::removeFromSchematic(GraphicsScene& scene) noexcept
{
    Q_ASSERT(mAddedToSchematic == true);
    Q_ASSERT(mRegisteredNetPoint == nullptr);
    mComponentSignalInstance->unregisterSymbolPin(*this);
    scene.removeItem(*mGraphicsItem);
    mAddedToSchematic = false;
    updateErcMessages();
}
开发者ID:0xB767B,项目名称:LibrePCB,代码行数:9,代码来源:si_symbolpin.cpp

示例11: HELIUM_ASSERT

/// @copydoc Entity::Attach()
void MeshComponent::Attach(GraphicsScene *pGrahpicsScene, TransformComponent *pTransformComponent)
{
	if (!pTransformComponent)
	{
		return;
	}

	HELIUM_ASSERT( pGrahpicsScene );
	HELIUM_ASSERT( IsInvalid( m_graphicsSceneObjectId ) );

	Mesh* pMesh = m_Mesh;
	if( pMesh && pMesh->GetVertexBuffer() && pMesh->GetIndexBuffer() )
	{
		size_t meshSectionCount = pMesh->GetSectionCount();
		if( meshSectionCount != 0 )
		{
			GraphicsScene* pGraphicsScene = pGrahpicsScene;
			HELIUM_ASSERT( pGraphicsScene );

			m_graphicsSceneObjectId = pGraphicsScene->AllocateSceneObject();
			HELIUM_ASSERT( IsValid( m_graphicsSceneObjectId ) );

			m_graphicsSceneObjectSubMeshDataIds.Reserve( meshSectionCount );
			m_graphicsSceneObjectSubMeshDataIds.Resize( meshSectionCount );

			for( size_t meshSectionIndex = 0; meshSectionIndex < meshSectionCount; ++meshSectionIndex )
			{
				size_t subMeshId = pGraphicsScene->AllocateSceneObjectSubMeshData( m_graphicsSceneObjectId );
				HELIUM_ASSERT( IsValid( subMeshId ) );
				m_graphicsSceneObjectSubMeshDataIds[ meshSectionIndex ] = subMeshId;
			}
			
			SetNeedsGraphicsSceneObjectUpdate(pTransformComponent);
		}
	}
}
开发者ID:kevindqc,项目名称:Helium,代码行数:37,代码来源:MeshComponent.cpp

示例12: addRemoveCurves

void GraphicsLinesForCurves::addRemoveCurves (GraphicsScene &scene,
                                              const QStringList &curveNames)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurves::addRemoveCurves"
                              << " curveCount=" << m_graphicsLinesForCurve.count();

  // Add new curves
  QStringList::const_iterator itrC;
  for (itrC = curveNames.begin (); itrC != curveNames.end (); itrC++) {

    QString curveName = *itrC;

    if (!m_graphicsLinesForCurve.contains (curveName)) {

      GraphicsLinesForCurve *item = new GraphicsLinesForCurve(curveName);
      scene.addItem (item);

      m_graphicsLinesForCurve [curveName] = item;
    }
  }

  // Remove expired curves
  GraphicsLinesContainer::const_iterator itrG, itrGNext;
  for (itrG = m_graphicsLinesForCurve.begin (); itrG != m_graphicsLinesForCurve.end (); itrG = itrGNext) {

    const QString curveName = itrG.key ();
    GraphicsLinesForCurve *graphicsLines = itrG.value();

    itrGNext = itrG;
    itrGNext++;

    if (!curveNames.contains (curveName)) {

      delete graphicsLines;
      m_graphicsLinesForCurve.remove (curveName);
    }
  }
}
开发者ID:TobiasWinchen,项目名称:engauge-digitizer,代码行数:38,代码来源:GraphicsLinesForCurves.cpp

示例13: SCENE_GRAPH_RENDER_SCOPE_TIMER

void Viewport::Draw()
{
	SCENE_GRAPH_RENDER_SCOPE_TIMER( ("") );

	uint64_t start = Helium::TimerGetClock();

	if (!m_World)
	{
		return;
	}

	Camera& camera = m_Cameras[m_CameraMode];

	GraphicsScene* pGraphicsScene = GetGraphicsScene();
	GraphicsSceneView* pSceneView = pGraphicsScene->GetSceneView( m_SceneViewId );
	BufferedDrawer* pDrawer = pGraphicsScene->GetSceneViewBufferedDrawer( m_SceneViewId );

	DrawArgs args;

	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Setup Viewport and Projection") );

		Vector3 pos;
		camera.GetPosition( pos );

		const Matrix4& invView = camera.GetInverseView();

		pSceneView->SetView(
			Simd::Vector3( &pos.x ),
			-Simd::Vector3( &invView.z.x ),
			Simd::Vector3( &invView.y.x ) );

		pSceneView->SetHorizontalFov( Camera::FieldOfView * static_cast< float32_t >(HELIUM_RAD_TO_DEG) );
	}

	if (m_GridVisible)
	{
		m_GlobalPrimitives[GlobalPrimitives::StandardGrid]->Draw( pDrawer, &args );
	}

#ifdef VIEWPORT_REFACTOR
	// this seems like a bad place to do this
	if (m_Tool)
	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Tool Evaluate") );
		m_Tool->Evaluate();
	}

	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Clear and Reset Scene") );

		device->BeginScene();
		device->SetRenderTarget( 0, m_DeviceManager.GetBackBuffer() );
		device->SetDepthStencilSurface( m_DeviceManager.GetDepthBuffer() );
		device->Clear(NULL, NULL, D3DCLEAR_TARGET | D3DCLEAR_STENCIL | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(255, 80, 80, 80), 1.0f, 0);
		device->SetTransform(D3DTS_WORLD, (D3DMATRIX*)&Matrix4::Identity);

		m_ResourceTracker->ResetState();
	}

	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Setup Viewport and Projection") );

		device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)&m_Cameras[m_CameraMode].SetProjection(m_Size.x, m_Size.y));
		device->SetTransform(D3DTS_VIEW, (D3DMATRIX*)&m_Cameras[m_CameraMode].GetViewport());
	}

	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Setup RenderState (culling, lighting, and fill") );

		device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
		device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

		if (m_Cameras[m_CameraMode].IsBackFaceCulling())
		{
			device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
		}
		else
		{
			device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
		}

		device->SetRenderState(D3DRS_LIGHTING, TRUE);
		device->SetRenderState(D3DRS_COLORVERTEX, FALSE);
		device->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
		device->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
		device->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);

		device->SetRenderState(D3DRS_ZENABLE, TRUE);
		device->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
		device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);

		device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
		device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
		device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

		device->SetPixelShader( NULL );
		device->SetVertexShader( NULL );

		D3DLIGHT9 light;    
//.........这里部分代码省略.........
开发者ID:kevindqc,项目名称:Helium,代码行数:101,代码来源:Viewport.cpp

示例14: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    lastCalctime_normal(0),
    lastCalctime_specular(0),
    lastCalctime_displace(0),
    lastCalctime_ssao(0),
    stopQueue(false)
{
    ui->setupUi(this);

    supportedImageformats << "*.png" << "*.jpg" << "*.jpeg" << "*.tiff"
                          << "*.tif" << "*.ppm" << "*.bmp"  << "*.xpm"
                          << "*.tga" << "*.gif";

    //connect signals of GUI elements with slots of this class
    connectSignalSlots();

    //hide advanced settings and connect signals/slots to show them
    hideAdvancedSettings();

    //initialize graphicsview
    GraphicsScene *scene = new GraphicsScene();
    ui->graphicsView->setScene(scene);
    ui->graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
    scene->addText("Start by dragging images here.");
    ui->graphicsView->setRenderHints(QPainter::HighQualityAntialiasing
                                     | QPainter::SmoothPixmapTransform);
    ui->graphicsView->setAcceptDrops(true);

    //show default status message
    ui->statusBar->showMessage("Drag images into the empty preview window to load them.");

    //hide queue progressbar
    ui->progressBar_Queue->hide();
    
    // SSAO map generator is not ready yet, remove it from the UI
    ui->tabWidget->removeTab(4);

    //default UI colors
    useCustomUiColors = false;
    uiColorMainDefault = QColor("#444");
    uiColorTextDefault = QColor("#eee");
    uiColorGraphicsViewDefault = QColor(Qt::darkGray);
    uiColorMain = uiColorMainDefault;
    uiColorText = uiColorTextDefault;
    uiColorGraphicsView = uiColorGraphicsViewDefault;

    //read last window position and color settings from registry
    readSettings();

    //set UI colors
    setUiColors();

    //if the program was opened via "open with" by the OS,
    //extract the image paths from the arguments
    QStringList args = QCoreApplication::arguments();
    if(args.size() > 1) {
        QList<QUrl> imageUrls;

        for(int i = 1; i < args.size(); i++) {
            imageUrls.append(QUrl::fromLocalFile(args[i]));
        }

        loadMultipleDropped(imageUrls);
    }
}
开发者ID:Theverat,项目名称:NormalmapGenerator,代码行数:67,代码来源:mainwindow.cpp

示例15: QWidget

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    QHBoxLayout * hbox = new QHBoxLayout;
    QGraphicsView * view = new QGraphicsView;
    GraphicsScene * scene = new GraphicsScene;

    QPolygonF polygon;
    qreal side = 20;
    qreal dx = qSqrt(3)/2 * side;
    polygon
            // standing on a point
            << QPointF(dx, -side/2)
            << QPointF(0, -side)
            << QPointF(-dx, -side/2)
            << QPointF(-dx, side/2)
            << QPointF(0, side)
            << QPointF(dx, side/2);
    // Sitting flat
    //            << QPointF(-side/2, dx)
    //            << QPointF(-side, 0)
    //            << QPointF(-side/2, -dx)
    //            << QPointF(side/2, -dx)
    //            << QPointF(side, 0)
    //            << QPointF(side/2, dx);

    int h = 9;
    int w = 17;
    int mid_h = h/2;
    int mid_w = w/2;

    for(int r = 0; r < h; r++)
    {
        for(int c = 0; c < w; c++)
        {
            if(qAbs(mid_h - r) + qAbs(mid_w - c) > 8
                    || (r % 2 != c % 2))
            {
                // don't add a hexagon, it isn't on the board!
            }
            else
            {
                BoardHexagon * hexagon = new BoardHexagon(0);
                hexagon->setPolygon(polygon);
                scene->addItem(hexagon);
                hexagon->setPos(dx * c, side * 1.5 * r);
                hexagon->setToolTip(QString::number(r) + "," + QString::number(c));
            }
        }
    }

    QGraphicsEllipseItem * ellipse = scene->addEllipse(-20, -20, 20, 20,QPen(), QBrush(QColor(Qt::green)));
    this->makeDraggable(ellipse);


    view->setRenderHint(QPainter::Antialiasing);
    view->setScene(scene);

    view->setMouseTracking(true);

    hbox->addWidget(view);
    this->setLayout(hbox);

    this->resize(600, 400);
}
开发者ID:peteristhegreat,项目名称:Hexagons,代码行数:65,代码来源:widget.cpp


注:本文中的GraphicsScene类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。