2016-08-02 03:25:55 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-04-05 08:25:33 -05:00
|
|
|
#include "cafTitledOverlayFrame.h"
|
2016-08-02 03:25:55 -05:00
|
|
|
#include "cvfArray.h"
|
2020-06-19 00:53:59 -05:00
|
|
|
#include "cvfBase.h"
|
2016-08-02 03:25:55 -05:00
|
|
|
#include "cvfCamera.h"
|
|
|
|
#include "cvfOverlayItem.h"
|
|
|
|
#include "cvfRect.h"
|
|
|
|
#include "cvfString.h"
|
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
namespace cvf
|
|
|
|
{
|
2016-08-02 03:25:55 -05:00
|
|
|
class Font;
|
|
|
|
class ShaderProgram;
|
|
|
|
class MatrixState;
|
|
|
|
class TextDrawer;
|
2020-06-19 00:53:59 -05:00
|
|
|
} // namespace cvf
|
2016-08-02 03:25:55 -05:00
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
namespace caf
|
|
|
|
{
|
2016-08-02 03:25:55 -05:00
|
|
|
class CategoryMapper;
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==================================================================================================
|
2018-04-05 08:25:33 -05:00
|
|
|
class CategoryLegend : public caf::TitledOverlayFrame
|
2016-08-02 03:25:55 -05:00
|
|
|
{
|
|
|
|
public:
|
2020-06-19 00:53:59 -05:00
|
|
|
CategoryLegend( cvf::Font* font, const CategoryMapper* categoryMapper );
|
2019-01-10 15:13:19 -06:00
|
|
|
~CategoryLegend() override;
|
2016-08-02 03:25:55 -05:00
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
size_t categoryCount() const;
|
2016-09-22 08:31:21 -05:00
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
cvf::Vec2ui preferredSize() override;
|
2018-04-20 06:33:44 -05:00
|
|
|
|
2016-08-02 03:25:55 -05:00
|
|
|
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;
|
2016-08-02 03:25:55 -05:00
|
|
|
|
|
|
|
struct OverlayColorLegendLayoutInfo
|
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
OverlayColorLegendLayoutInfo( const cvf::Vec2ui& setSize )
|
2016-08-02 03:25:55 -05:00
|
|
|
{
|
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;
|
2020-03-03 13:22:03 -06:00
|
|
|
tickTextLeadSpace = 0.0f;
|
2017-03-06 12:22:32 -06:00
|
|
|
|
2018-04-20 04:27:34 -05:00
|
|
|
overallLegendSize = setSize;
|
2016-08-02 03:25:55 -05:00
|
|
|
}
|
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
float charHeight;
|
|
|
|
float lineSpacing;
|
2016-08-02 03:25:55 -05:00
|
|
|
cvf::Vec2f margins;
|
2020-06-19 00:53:59 -05:00
|
|
|
float tickStartX, tickMidX, tickEndX;
|
|
|
|
float tickTextLeadSpace;
|
2016-08-02 03:25:55 -05:00
|
|
|
|
2018-04-20 02:23:19 -05:00
|
|
|
cvf::Rectf colorBarRect;
|
2016-08-02 03:25:55 -05:00
|
|
|
|
2018-04-20 04:27:34 -05:00
|
|
|
cvf::Vec2ui overallLegendSize;
|
2016-08-02 03:25:55 -05:00
|
|
|
};
|
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
void layoutInfo( OverlayColorLegendLayoutInfo* layout );
|
2016-08-02 03:25:55 -05:00
|
|
|
|
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 );
|
2016-08-02 03:25:55 -05:00
|
|
|
|
|
|
|
protected:
|
2020-06-19 00:53:59 -05:00
|
|
|
std::vector<bool> m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label
|
2023-03-23 09:49:06 -05:00
|
|
|
OverlayColorLegendLayoutInfo m_layout;
|
2018-04-06 07:07:00 -05:00
|
|
|
cvf::ref<cvf::TextDrawer> m_textDrawer;
|
|
|
|
cvf::cref<CategoryMapper> m_categoryMapper;
|
2016-08-02 03:25:55 -05:00
|
|
|
};
|
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
} // namespace caf
|