예제 #1
0
파일: Channel.cpp 프로젝트: hernando/Livre
    void drawCacheStatistics()
    {
        glLogicOp( GL_XOR );
        glEnable( GL_COLOR_LOGIC_OP );
        glDisable( GL_LIGHTING );
        glDisable( GL_DEPTH_TEST );

        glColor3f( 1.f, 1.f, 1.f );

        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        _channel->applyScreenFrustum();
        glMatrixMode( GL_MODELVIEW );

        livre::Node* node = static_cast< livre::Node* >( _channel->getNode( ));
        std::ostringstream os;
        const size_t all = _frameInfo.allNodes.size();
        const size_t missing = _frameInfo.notAvailableRenderNodes.size();
        const float done = all > 0 ? float( all - missing ) / float( all ) : 0;
        os << node->getTextureDataCache().getStatistics() << "  "
           << int( 100.f * done + .5f ) << "% loaded" << std::endl;
        float y = 220;
        _drawText( os.str(), y );

        Window* window = static_cast< Window* >( _channel->getWindow( ));
        os.str("");
        os << window->getTextureCache().getStatistics();
        _drawText( os.str(), y );

        ConstVolumeDataSourcePtr dataSource = static_cast< livre::Node* >(
            _channel->getNode( ))->getDashTree()->getDataSource();
        const VolumeInformation& info = dataSource->getVolumeInformation();
        Vector3f voxelSize = info.boundingBox.getDimension() / info.voxels;
        std::string unit = "m";
        if( voxelSize.x() < 0.000001f )
        {
            unit = "um";
            voxelSize *= 1000000;
        }
        if( voxelSize.x() < 0.001f )
        {
            unit = "mm";
            voxelSize *= 1000;
        }

        os.str("");
        os << "Total resolution " << info.voxels << " depth "
           << info.rootNode.getDepth() << std::endl
           << "Block resolution " << info.maximumBlockSize << std::endl
           << unit << "/voxel " << voxelSize;
        _drawText( os.str( ), y );
    }
예제 #2
0
void THMapFlagsOverlay::drawCell(THRenderTarget* pCanvas, int iCanvasX,
                                 int iCanvasY, const THMap* pMap, int iNodeX,
                                 int iNodeY)
{
    const THMapNode *pNode = pMap->getNode(iNodeX, iNodeY);
    if(!pNode)
        return;
    if(m_pSprites)
    {
        if(pNode->flags.passable)
            m_pSprites->drawSprite(pCanvas, 3, iCanvasX, iCanvasY, 0);
        if(pNode->flags.hospital)
            m_pSprites->drawSprite(pCanvas, 8, iCanvasX, iCanvasY, 0);
        if(pNode->flags.buildable)
            m_pSprites->drawSprite(pCanvas, 9, iCanvasX, iCanvasY, 0);
        if(pNode->flags.can_travel_n && pMap->getNode(iNodeX, iNodeY - 1)->flags.passable)
        {
            m_pSprites->drawSprite(pCanvas, 4, iCanvasX, iCanvasY, 0);
        }
        if(pNode->flags.can_travel_e && pMap->getNode(iNodeX + 1, iNodeY)->flags.passable)
        {
            m_pSprites->drawSprite(pCanvas, 5, iCanvasX, iCanvasY, 0);
        }
        if(pNode->flags.can_travel_s && pMap->getNode(iNodeX, iNodeY + 1)->flags.passable)
        {
            m_pSprites->drawSprite(pCanvas, 6, iCanvasX, iCanvasY, 0);
        }
        if(pNode->flags.can_travel_w && pMap->getNode(iNodeX - 1, iNodeY)->flags.passable)
        {
            m_pSprites->drawSprite(pCanvas, 7, iCanvasX, iCanvasY, 0);
        }
    }
    if(m_pFont)
    {
        if(!pNode->objects.empty())
        {
            std::ostringstream str;
            str << 'T' << static_cast<int>(pNode->objects.front());
            _drawText(pCanvas, iCanvasX, iCanvasY - 8, str.str());
        }
        if(pNode->iRoomId)
        {
            std::ostringstream str;
            str << 'R' << static_cast<int>(pNode->iRoomId);
            _drawText(pCanvas, iCanvasX, iCanvasY + 8, str.str());
        }
    }
}
예제 #3
0
void Sample::draw() {
    ofPushStyle();
    isSelected() ? ofSetColor(255, 255, 0) : ofSetColor(255);
    _drawCrosshair();
    _drawText();
    ofPopStyle();
}
예제 #4
0
void THMapFlagsOverlay::drawCell(THRenderTarget* pCanvas, int iCanvasX,
                                 int iCanvasY, const THMap* pMap, int iNodeX,
                                 int iNodeY)
{
    const THMapNode *pNode = pMap->getNode(iNodeX, iNodeY);
    if(!pNode)
        return;
    if(m_pSprites)
    {
        if(pNode->iFlags & THMN_Passable)
            m_pSprites->drawSprite(pCanvas, 3, iCanvasX, iCanvasY, 0);
        if(pNode->iFlags & THMN_Hospital)
            m_pSprites->drawSprite(pCanvas, 8, iCanvasX, iCanvasY, 0);
        if(pNode->iFlags & THMN_Buildable)
            m_pSprites->drawSprite(pCanvas, 9, iCanvasX, iCanvasY, 0);
#define TRAVEL(flag, dx, dy, sprite) \
        if(pNode->iFlags & flag && pMap->getNode(iNodeX + dx, iNodeY + dy)-> \
            iFlags & THMN_Passable) \
        { \
            m_pSprites->drawSprite(pCanvas, sprite, iCanvasX, iCanvasY, 0); \
        }
        TRAVEL(THMN_CanTravelN,  0, -1, 4);
        TRAVEL(THMN_CanTravelE,  1,  0, 5);
        TRAVEL(THMN_CanTravelS,  0,  1, 6);
        TRAVEL(THMN_CanTravelW, -1,  0, 7);
#undef TRAVEL
    }
    if(m_pFont)
    {
        if(pNode->iFlags >> 24)
            _drawText(pCanvas, iCanvasX, iCanvasY - 8, "T%i", (int)(pNode->iFlags >> 24));
        if(pNode->iRoomId)
            _drawText(pCanvas, iCanvasX, iCanvasY + 8, "R%i", (int)pNode->iRoomId);
    }
}
예제 #5
0
void THMapTextOverlay::drawCell(THRenderTarget* pCanvas, int iCanvasX,
                                int iCanvasY, const THMap* pMap, int iNodeX,
                                int iNodeY)
{
    if(m_pSprites && m_iBackgroundSprite)
    {
        m_pSprites->drawSprite(pCanvas, m_iBackgroundSprite, iCanvasX,
            iCanvasY, 0);
    }
    if(m_pFont)
    {
        _drawText(pCanvas, iCanvasX, iCanvasY, getText(pMap, iNodeX, iNodeY));
    }
}
예제 #6
0
void THMapParcelsOverlay::drawCell(THRenderTarget* pCanvas, int iCanvasX,
                                   int iCanvasY, const THMap* pMap, int iNodeX,
                                   int iNodeY)
{
    const THMapNode *pNode = pMap->getNode(iNodeX, iNodeY);
    if(!pNode)
        return;
    if(m_pFont)
        _drawText(pCanvas, iCanvasX, iCanvasY, "%i", (int)pNode->iParcelId);
    if(m_pSprites)
    {
        uint16_t iParcel = pNode->iParcelId;
#define DIR(dx, dy, sprite) \
        pNode = pMap->getNode(iNodeX + dx, iNodeY + dy); \
        if(!pNode || pNode->iParcelId != iParcel) \
            m_pSprites->drawSprite(pCanvas, sprite, iCanvasX, iCanvasY, 0)
        DIR( 0, -1, 18);
        DIR( 1,  0, 19);
        DIR( 0,  1, 20);
        DIR(-1,  0, 21);
#undef DIR
    }
}