As creation of a font is time consuming, create one application font instance

p4#: 21338
This commit is contained in:
Magne Sjaastad 2013-04-19 08:02:36 +02:00
parent fc84fce67f
commit b5b9a736e2
8 changed files with 42 additions and 27 deletions

View File

@ -135,6 +135,10 @@ RiaApplication::RiaApplication(int& argc, char** argv)
//m_startupDefaultDirectory += "/My Documents/";
#endif
setDefaultFileDialogDirectory("MULTICASEIMPORT", "/");
// The creation of a font is time consuming, so make sure you really need your own font
// instead of using the application font
m_standardFont = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
}
@ -1422,3 +1426,16 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames)
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Font* RiaApplication::standardFont()
{
CVF_ASSERT(m_standardFont.notNull());
// The creation of a font is time consuming, so make sure you really need your own font
// instead of using the application font
return m_standardFont.p();
}

View File

@ -121,6 +121,8 @@ public:
void writePreferences();
void applyPreferences();
cvf::Font* standardFont();
private:
void onProjectOpenedOrClosed();
void setWindowCaptionFromAppState();
@ -143,4 +145,6 @@ private:
std::map<QString, QString> m_fileDialogDefaultDirectories;
QString m_startupDefaultDirectory;
cvf::ref<cvf::Font> m_standardFont;
};

View File

@ -33,8 +33,6 @@ RivReservoirPipesPartMgr::RivReservoirPipesPartMgr(RimReservoirView* reservoirVi
m_reservoirView = reservoirView;
m_scaleTransform = new cvf::Transform();
m_font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
}
//--------------------------------------------------------------------------------------------------
@ -105,7 +103,7 @@ void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasic
m_wellPipesPartMgrs.push_back(wppmgr);
wppmgr->setScaleTransform(m_scaleTransform.p());
RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i], m_font.p());
RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]);
m_wellHeadPartMgrs.push_back(wellHeadMgr);
wellHeadMgr->setScaleTransform(m_scaleTransform.p());
}

View File

@ -44,7 +44,6 @@ public:
private:
caf::PdmPointer<RimReservoirView> m_reservoirView;
cvf::ref<cvf::Transform> m_scaleTransform;
cvf::ref<cvf::Font> m_font;
cvf::Collection< RivWellPipesPartMgr > m_wellPipesPartMgrs;
cvf::Collection< RivWellHeadPartMgr > m_wellHeadPartMgrs;

View File

@ -41,17 +41,16 @@
#include "RivPipeGeometryGenerator.h"
#include "RivWellPipesPartMgr.h"
#include "RiaApplication.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellHeadPartMgr::RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well, cvf::Font* font)
RivWellHeadPartMgr::RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well)
{
m_rimReservoirView = reservoirView;
m_rimWell = well;
m_font = font;
}
//--------------------------------------------------------------------------------------------------
@ -232,10 +231,10 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
if (m_rimReservoirView->wellCollection()->showWellLabel() && well->showWellLabel())
{
CVF_ASSERT(m_font.p());
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
drawableText->setFont(m_font.p());
drawableText->setFont(standardFont);
drawableText->setCheckPosVisible(false);
drawableText->setDrawBorder(false);
drawableText->setDrawBackground(false);

View File

@ -38,7 +38,7 @@ class RimReservoirView;
class RivWellHeadPartMgr : public cvf::Object
{
public:
RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well, cvf::Font* font);
RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well);
~RivWellHeadPartMgr();
void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform;}
@ -56,6 +56,4 @@ private:
cvf::ref<cvf::Transform> m_scaleTransform;
cvf::Collection< cvf::Part > m_wellHeadParts;
cvf::ref<cvf::Font> m_font;
};

View File

@ -24,6 +24,7 @@
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cvfScalarMapperDiscreteLog.h"
#include "RiaApplication.h"
CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend");
@ -92,9 +93,8 @@ RimLegendConfig::RimLegendConfig()
m_currentScalarMapper = m_linDiscreteScalarMapper;
cvf::FixedAtlasFont* font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
m_legend = new cvf::OverlayScalarMapperLegend(font);
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
m_legend = new cvf::OverlayScalarMapperLegend(standardFont);
m_position = cvf::Vec2ui(20, 50);
updateFieldVisibility();
@ -394,8 +394,8 @@ void RimLegendConfig::recreateLegend()
// has been removed, (and thus the opengl resources has been deleted) The text in
// the legend disappeared because of this, so workaround: recreate the legend when needed:
cvf::FixedAtlasFont* font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
m_legend = new cvf::OverlayScalarMapperLegend(font);
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
m_legend = new cvf::OverlayScalarMapperLegend(standardFont);
updateLegend();
}

View File

@ -57,8 +57,8 @@ const double RI_MIN_NEARPLANE_DISTANCE = 0.1;
RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
: caf::Viewer(format, parent)
{
cvf::FixedAtlasFont* font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
cvf::OverlayAxisCross* axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), font);
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
cvf::OverlayAxisCross* axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont);
axisCross->setAxisLabels("E", "N", "Z");
m_mainRendering->addOverlayItem(axisCross, cvf::OverlayItem::BOTTOM_LEFT, cvf::OverlayItem::VERTICAL);