OGS
StratScene Class Reference

Detailed Description

The scene for the visualisation of the stratigraphy of a borehole.

Definition at line 28 of file StratScene.h.

#include <StratScene.h>

Inheritance diagram for StratScene:
[legend]
Collaboration diagram for StratScene:
[legend]

Public Member Functions

 StratScene (GeoLib::StationBorehole *station, std::map< std::string, DataHolderLib::Color > *stratColors=nullptr, QObject *parent=nullptr)
 Constructor.
 
 ~StratScene () override
 

Static Public Attributes

static const int MARGIN = 50
 The margin between the boundary of the scene and the bounding box of all items within the scene.
 

Private Member Functions

void addDepthLabels (std::vector< GeoLib::Point * > profile, double offset)
 Adds text labels indicating the depth at the beginning and end of each soil layer.
 
QNonScalableGraphicsTextItemaddNonScalableText (const QString &text, const QFont &font=QFont())
 Add a non-scalable text item to the scene.
 
void addSoilNameLabels (std::vector< std::string > soilNames, std::vector< GeoLib::Point * > profile, double offset)
 Adds text labels indicating the name of each soil layer.
 
StratBaraddStratBar (GeoLib::StationBorehole *station, std::map< std::string, DataHolderLib::Color > *stratColors=nullptr)
 Add a stratigraphy-bar to the scene.
 

Constructor & Destructor Documentation

◆ StratScene()

StratScene::StratScene ( GeoLib::StationBorehole * station,
std::map< std::string, DataHolderLib::Color > * stratColors = nullptr,
QObject * parent = nullptr )
explicit

Constructor.

Definition at line 26 of file StratScene.cpp.

29 : QGraphicsScene(parent)
30{
31 QRectF textBounds;
32 int stratBarOffset = 250;
33
34 QFont font("Arial", 15, QFont::DemiBold, false);
35
36 QNonScalableGraphicsTextItem* boreholeTag =
37 addNonScalableText("Borehole", font);
39 "\"" + QString::fromStdString(station->getName()) + "\"", font);
40 textBounds = boreholeTag->boundingRect();
41 boreholeTag->setPos((textBounds.width() / 2.0), 80);
42 textBounds = boreholeName->boundingRect();
43 boreholeName->setPos((textBounds.width() / 2.0), 200);
44
46 "Depth: " + QString::number(station->getDepth()) + " m");
47 textBounds = totalDepth->boundingRect();
48 totalDepth->setPos((textBounds.width() / 2.0), 350);
49 /*
50 QNonScalableGraphicsTextItem* dateText = addNonScalableText("Date: " +
51 QString::fromStdString(date2string(station->getDate()))); textBounds =
52 dateText->boundingRect(); dateText->setPos(this->MARGIN +
53 (textBounds.width()/2.0), 350);
54 */
56 dot->setPos(0, 0);
57
58 StratBar* stratBar = addStratBar(station, stratColors);
59 stratBar->setPos(stratBarOffset, MARGIN);
60 QRectF stratBarBounds = stratBar->boundingRect();
61
62 addDepthLabels(station->getProfile(),
63 stratBarOffset + stratBarBounds.width());
64
65 if (!station->getSoilNames().empty())
66 {
67 addSoilNameLabels(station->getSoilNames(), station->getProfile(),
68 stratBarOffset + (stratBarBounds.width() / 2));
69 }
70}
const std::vector< std::string > & getSoilNames() const
const std::vector< Point * > & getProfile() const
std::string const & getName() const
Returns the name of the station.
Definition Station.h:60
A QGraphicsTextItem that will ignore all geometric transformations.
QRectF boundingRect() const override
Returns the bounding rectangle of the text item.
A 2D bar visualisation of a borehole stratigraphy.
Definition StratBar.h:30
QRectF boundingRect() const override
Returns the bounding rectangle of the bar.
Definition StratBar.cpp:30
QNonScalableGraphicsTextItem * addNonScalableText(const QString &text, const QFont &font=QFont())
Add a non-scalable text item to the scene.
void addSoilNameLabels(std::vector< std::string > soilNames, std::vector< GeoLib::Point * > profile, double offset)
Adds text labels indicating the name of each soil layer.
void addDepthLabels(std::vector< GeoLib::Point * > profile, double offset)
Adds text labels indicating the depth at the beginning and end of each soil layer.
static const int MARGIN
The margin between the boundary of the scene and the bounding box of all items within the scene.
Definition StratScene.h:39
StratBar * addStratBar(GeoLib::StationBorehole *station, std::map< std::string, DataHolderLib::Color > *stratColors=nullptr)
Add a stratigraphy-bar to the scene.

References addDepthLabels(), addNonScalableText(), addSoilNameLabels(), addStratBar(), QNonScalableGraphicsTextItem::boundingRect(), StratBar::boundingRect(), GeoLib::StationBorehole::getDepth(), GeoLib::Station::getName(), GeoLib::StationBorehole::getProfile(), GeoLib::StationBorehole::getSoilNames(), and MARGIN.

◆ ~StratScene()

StratScene::~StratScene ( )
overridedefault

Member Function Documentation

◆ addDepthLabels()

void StratScene::addDepthLabels ( std::vector< GeoLib::Point * > profile,
double offset )
private

Adds text labels indicating the depth at the beginning and end of each soil layer.

Definition at line 74 of file StratScene.cpp.

76{
77 QRectF textBounds;
78 double vertPos = MARGIN;
79 std::vector<QNonScalableGraphicsTextItem*> depthText;
80 depthText.push_back(
81 addNonScalableText(QString::number((*(profile[0]))[2])));
82 textBounds = depthText[0]->boundingRect();
83 depthText[0]->setPos(offset + textBounds.width() / 2, vertPos);
84
85 for (std::size_t i = 1; i < profile.size(); i++)
86 {
87 depthText.push_back(
88 addNonScalableText(QString::number((*(profile[i]))[2])));
89 vertPos += log((*(profile[i - 1]))[2] - (*(profile[i]))[2] + 1) * 100;
90 textBounds = depthText[i]->boundingRect();
91 depthText[i]->setPos(offset + textBounds.width() / 2, vertPos);
92 }
93}

References addNonScalableText(), and MARGIN.

Referenced by StratScene().

◆ addNonScalableText()

QNonScalableGraphicsTextItem * StratScene::addNonScalableText ( const QString & text,
const QFont & font = QFont() )
private

Add a non-scalable text item to the scene.

Definition at line 95 of file StratScene.cpp.

97{
98 auto* item = new QNonScalableGraphicsTextItem(text);
99 item->setFont(font);
100 addItem(item);
101 return item;
102}

Referenced by StratScene(), addDepthLabels(), and addSoilNameLabels().

◆ addSoilNameLabels()

void StratScene::addSoilNameLabels ( std::vector< std::string > soilNames,
std::vector< GeoLib::Point * > profile,
double offset )
private

Adds text labels indicating the name of each soil layer.

Definition at line 104 of file StratScene.cpp.

108{
109 // QRectF textBounds;
110 double vertPos = MARGIN;
111 double halfHeight = 0;
112 std::vector<QNonScalableGraphicsTextItem*> soilText;
113 soilText.push_back(
114 addNonScalableText(QString::fromStdString(soilNames[0])));
115 // textBounds = soilText[0]->boundingRect();
116 soilText[0]->setPos(offset /* - textBounds.width() */, vertPos);
117
118 for (std::size_t i = 1; i < soilNames.size(); i++)
119 {
120 soilText.push_back(
121 addNonScalableText(QString::fromStdString(soilNames[i])));
122 halfHeight =
123 log((*(profile[i - 1]))[2] - (*(profile[i]))[2] + 1) * 100 / 2;
124 // textBounds = soilText[i]->boundingRect();
125 soilText[i]->setPos(offset /* - textBounds.width() */,
126 vertPos + halfHeight);
127 vertPos += (2 * halfHeight);
128 }
129}

References addNonScalableText(), and MARGIN.

Referenced by StratScene().

◆ addStratBar()

StratBar * StratScene::addStratBar ( GeoLib::StationBorehole * station,
std::map< std::string, DataHolderLib::Color > * stratColors = nullptr )
private

Add a stratigraphy-bar to the scene.

Definition at line 131 of file StratScene.cpp.

134{
135 auto* b = new StratBar(station, stratColors);
136 addItem(b);
137 return b;
138}

Referenced by StratScene().

Member Data Documentation

◆ MARGIN

const int StratScene::MARGIN = 50
static

The margin between the boundary of the scene and the bounding box of all items within the scene.

Definition at line 39 of file StratScene.h.

Referenced by StratScene(), addDepthLabels(), addSoilNameLabels(), StratView::minimumSizeHint(), StratView::saveAsImage(), StratView::sizeHint(), and StratView::update().


The documentation for this class was generated from the following files: