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/"; //m_startupDefaultDirectory += "/My Documents/";
#endif #endif
setDefaultFileDialogDirectory("MULTICASEIMPORT", "/"); 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; 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

@ -116,11 +116,13 @@ public:
bool launchProcess(const QString& program, const QStringList& arguments); bool launchProcess(const QString& program, const QStringList& arguments);
void terminateProcess(); void terminateProcess();
RiaPreferences* preferences(); RiaPreferences* preferences();
void readPreferences(); void readPreferences();
void writePreferences(); void writePreferences();
void applyPreferences(); void applyPreferences();
cvf::Font* standardFont();
private: private:
void onProjectOpenedOrClosed(); void onProjectOpenedOrClosed();
void setWindowCaptionFromAppState(); void setWindowCaptionFromAppState();
@ -132,15 +134,17 @@ private slots:
private: private:
caf::PdmPointer<RimReservoirView> m_activeReservoirView; caf::PdmPointer<RimReservoirView> m_activeReservoirView;
caf::PdmPointer<RimProject> m_project; caf::PdmPointer<RimProject> m_project;
RiaSocketServer* m_socketServer; RiaSocketServer* m_socketServer;
caf::UiProcess* m_workerProcess; caf::UiProcess* m_workerProcess;
RiaPreferences* m_preferences; RiaPreferences* m_preferences;
std::map<QString, QString> m_fileDialogDefaultDirectories; std::map<QString, QString> m_fileDialogDefaultDirectories;
QString m_startupDefaultDirectory; QString m_startupDefaultDirectory;
cvf::ref<cvf::Font> m_standardFont;
}; };

View File

@ -33,8 +33,6 @@ RivReservoirPipesPartMgr::RivReservoirPipesPartMgr(RimReservoirView* reservoirVi
m_reservoirView = reservoirView; m_reservoirView = reservoirView;
m_scaleTransform = new cvf::Transform(); 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); m_wellPipesPartMgrs.push_back(wppmgr);
wppmgr->setScaleTransform(m_scaleTransform.p()); 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); m_wellHeadPartMgrs.push_back(wellHeadMgr);
wellHeadMgr->setScaleTransform(m_scaleTransform.p()); wellHeadMgr->setScaleTransform(m_scaleTransform.p());
} }

View File

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

View File

@ -41,17 +41,16 @@
#include "RivPipeGeometryGenerator.h" #include "RivPipeGeometryGenerator.h"
#include "RivWellPipesPartMgr.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_rimReservoirView = reservoirView;
m_rimWell = well; m_rimWell = well;
m_font = font;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -232,10 +231,10 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
if (m_rimReservoirView->wellCollection()->showWellLabel() && well->showWellLabel()) 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; cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
drawableText->setFont(m_font.p()); drawableText->setFont(standardFont);
drawableText->setCheckPosVisible(false); drawableText->setCheckPosVisible(false);
drawableText->setDrawBorder(false); drawableText->setDrawBorder(false);
drawableText->setDrawBackground(false); drawableText->setDrawBackground(false);

View File

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

View File

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

View File

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