ResInsight/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h

86 lines
2.7 KiB
C
Raw Permalink Normal View History

#pragma once
#include "cafTitledOverlayFrame.h"
#include "cvfArray.h"
2020-06-19 00:53:59 -05:00
#include "cvfBase.h"
#include "cvfCamera.h"
#include "cvfOverlayItem.h"
#include "cvfRect.h"
#include "cvfString.h"
2020-06-19 00:53:59 -05:00
namespace cvf
{
class Font;
class ShaderProgram;
class MatrixState;
class TextDrawer;
2020-06-19 00:53:59 -05:00
} // namespace cvf
2020-06-19 00:53:59 -05:00
namespace caf
{
class CategoryMapper;
//==================================================================================================
//
//
//==================================================================================================
class CategoryLegend : public caf::TitledOverlayFrame
{
public:
2020-06-19 00:53:59 -05:00
CategoryLegend( cvf::Font* font, const CategoryMapper* categoryMapper );
~CategoryLegend() override;
2020-06-19 00:53:59 -05:00
size_t categoryCount() const;
2020-06-19 00:53:59 -05:00
cvf::Vec2ui preferredSize() override;
protected:
2020-06-19 00:53:59 -05:00
void render( cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size ) override;
void renderSoftware( cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size ) override;
bool pick( int oglXCoord, int oglYCoord, const cvf::Vec2i& position, const cvf::Vec2ui& size ) override;
struct OverlayColorLegendLayoutInfo
{
2020-06-19 00:53:59 -05:00
OverlayColorLegendLayoutInfo( const cvf::Vec2ui& setSize )
{
2020-06-19 00:53:59 -05:00
charHeight = 0.0f;
lineSpacing = 0.0f;
margins = cvf::Vec2f::ZERO;
tickStartX = 0.0f;
tickMidX = 0.0f;
tickEndX = 0.0f;
tickTextLeadSpace = 0.0f;
overallLegendSize = setSize;
}
2020-06-19 00:53:59 -05:00
float charHeight;
float lineSpacing;
cvf::Vec2f margins;
2020-06-19 00:53:59 -05:00
float tickStartX, tickMidX, tickEndX;
float tickTextLeadSpace;
cvf::Rectf colorBarRect;
cvf::Vec2ui overallLegendSize;
};
2020-06-19 00:53:59 -05:00
void layoutInfo( OverlayColorLegendLayoutInfo* layout );
2020-06-19 00:53:59 -05:00
void renderGeneric( cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software );
void setupTextDrawer( cvf::TextDrawer* textDrawer, const OverlayColorLegendLayoutInfo* layout );
void renderLegendUsingShaders( cvf::OpenGLContext* oglContext,
OverlayColorLegendLayoutInfo* layout,
const cvf::MatrixState& matrixState );
void renderLegendImmediateMode( cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout );
protected:
2020-06-19 00:53:59 -05:00
std::vector<bool> m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label
OverlayColorLegendLayoutInfo m_layout;
cvf::ref<cvf::TextDrawer> m_textDrawer;
cvf::cref<CategoryMapper> m_categoryMapper;
};
2020-06-19 00:53:59 -05:00
} // namespace caf