Commit eaaeb655 authored by Matthias Möller's avatar Matthias Möller
Browse files

changed rulersize to pixelunits

default is 16
refs #1626

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16963 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f3b7bf65
......@@ -92,6 +92,7 @@ TextNode( BaseNode* _parent,
bool _alwaysOnTop)
: BaseNode(_parent, _name),
size_(1.0),
pixelSize_(12),
textMode_(_textMode),
vbo_(0),
vertexBuffer_(0),
......@@ -102,6 +103,7 @@ TextNode( BaseNode* _parent,
alwaysOnTop_(_alwaysOnTop),
blendSrc_(0),
blendDest_(0)
{
updateFont();
vertexDecl_.addElement(GL_FLOAT, 3, ACG::VERTEX_USAGE_POSITION);
......@@ -203,7 +205,7 @@ setText(std::string _text) {
void
TextNode::
setSize(double _size) {
setSize(const double _size) {
size_ = _size; updateVBO();
}
......@@ -625,13 +627,23 @@ void TextNode::applyScreenAligned(GLState &_state)
_state.reset_modelview();
Vec3d unprojected = _state.unproject(projected);
_state.translate(unprojected);
if (textMode_ == SCREEN_ALIGNED_STATIC_SIZE)
scale *= (unprojected - _state.eye()).length();
{
ACG::Vec3d nullProj = _state.project(Vec3d(0.0,0.0,0.0));
ACG::Vec3d nullUnproj = _state.unproject(nullProj);
ACG::Vec3d heightUnproj = _state.unproject(nullProj+ACG::Vec3d(0.0,pixelSize_,0.0));
scale *= heightUnproj.length();
}
_state.translate(unprojected);
_state.scale(scale);
}
//----------------------------------------------------------------------------
void TextNode::setPixelSize(const unsigned int _size)
{
pixelSize_ = _size;
}
//=============================================================================
} // namespace SceneGraph
......
......@@ -83,7 +83,7 @@ namespace SceneGraph {
* via the setRenderingMode(TextMode _textMode) function. Alternatively the quads can be aligned
* to the screen (SCREEN_ALIGNED). The font that is used to display text on the screen
* can be set with the setFont(const QFont& _font) function. Finally the quads can be scaled
* via the setSize(unsigned int _size) function.
* via the setSize(double _size) function.
**/
class ACGDLLEXPORT TextNode : public BaseNode
......@@ -148,7 +148,10 @@ public:
void setText(std::string _text);
/// sets the size by which the quads displaying the text will be scaled
void setSize(double _size);
void setSize(const double _size);
/// sets the pixelsize of the text (only available for the SCREEN_ALIGNED_STATIC_SIZE mode and only works, if scaling is 1)
void setPixelSize(const unsigned int _size);
/// sets the font to be used for generating a texture with most characters of the chosen font
void setFont(const QFont& _font);
......@@ -190,10 +193,13 @@ private:
/// scaling factor by which the quads in #vbo_ are scaled
double size_;
/// pixelSize of the text for the SCREEN_ALIGNED_STATIC_SIZE mode
unsigned pixelSize_;
/// text to be displayed on quads in #vbo_
std::string text_;
/// current display mode of #text_ (SCREEN_ALIGNED or OBJECT_ALIGNED)
/// current display mode of #text_ (SCREEN_ALIGNED, SCREEN_ALIGNED_STATIC_SIZE or OBJECT_ALIGNED)
TextMode textMode_;
/**
......
......@@ -85,7 +85,7 @@ void Ruler::updateNodes()
//set params for the text
ACG::Vec3d distVec = Point1 - Point2;
QString distanceStr = QString().number((distVec).length());
QString distanceStr = QString().number(distVec.length());
textNode_->setText(distanceStr.toStdString());
textNode_->multipassNodeSetActive(8, true);
......@@ -94,7 +94,6 @@ void Ruler::updateNodes()
textTransformNode_->translate(Point1);
ACG::Vec3d halfDist = distVec/2.f;
textTransformNode_->translate(-halfDist);
textTransformNode_->scale(0.025);
emit updateView();
}
......@@ -72,7 +72,7 @@ public:
public slots:
void setTextSize(const unsigned _size){textNode_->setSize(_size*0.1); emit updateView();}
void setTextSize(const unsigned _size){textNode_->setPixelSize(_size); emit updateView();}
private:
......
......@@ -46,4 +46,5 @@ RulerOptions::RulerOptions(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
textSizeSpinBox->setSuffix(" px");
}
......@@ -113,7 +113,7 @@ void RulerPlugin::slotMouseEvent(QMouseEvent* _event)
{
currentRuler_.reset(new Ruler(object,name(),0));
connect(currentRuler_.get(),SIGNAL(updateView()),this,SIGNAL(updateView()));
unsigned textSize = OpenFlipperSettings().value(textSizeSettingName_,10).toUInt();
unsigned textSize = OpenFlipperSettings().value(textSizeSettingName_,16).toUInt();
currentRuler_->setTextSize(textSize);
currentRuler_->setPoints(hitPoint,hitPoint);
enableDragMode(1);
......@@ -263,7 +263,7 @@ bool RulerPlugin::initializeOptionsWidget(QWidget*& _widget)
optionsWidget_ = new RulerOptions();
}
unsigned textSize = OpenFlipperSettings().value(textSizeSettingName_,10).toUInt();
unsigned textSize = OpenFlipperSettings().value(textSizeSettingName_,16).toUInt();
optionsWidget_->textSizeSpinBox->setValue(textSize);
_widget = optionsWidget_;
return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment