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, ...@@ -92,6 +92,7 @@ TextNode( BaseNode* _parent,
bool _alwaysOnTop) bool _alwaysOnTop)
: BaseNode(_parent, _name), : BaseNode(_parent, _name),
size_(1.0), size_(1.0),
pixelSize_(12),
textMode_(_textMode), textMode_(_textMode),
vbo_(0), vbo_(0),
vertexBuffer_(0), vertexBuffer_(0),
...@@ -102,6 +103,7 @@ TextNode( BaseNode* _parent, ...@@ -102,6 +103,7 @@ TextNode( BaseNode* _parent,
alwaysOnTop_(_alwaysOnTop), alwaysOnTop_(_alwaysOnTop),
blendSrc_(0), blendSrc_(0),
blendDest_(0) blendDest_(0)
{ {
updateFont(); updateFont();
vertexDecl_.addElement(GL_FLOAT, 3, ACG::VERTEX_USAGE_POSITION); vertexDecl_.addElement(GL_FLOAT, 3, ACG::VERTEX_USAGE_POSITION);
...@@ -203,7 +205,7 @@ setText(std::string _text) { ...@@ -203,7 +205,7 @@ setText(std::string _text) {
void void
TextNode:: TextNode::
setSize(double _size) { setSize(const double _size) {
size_ = _size; updateVBO(); size_ = _size; updateVBO();
} }
...@@ -625,13 +627,23 @@ void TextNode::applyScreenAligned(GLState &_state) ...@@ -625,13 +627,23 @@ void TextNode::applyScreenAligned(GLState &_state)
_state.reset_modelview(); _state.reset_modelview();
Vec3d unprojected = _state.unproject(projected); Vec3d unprojected = _state.unproject(projected);
_state.translate(unprojected);
if (textMode_ == SCREEN_ALIGNED_STATIC_SIZE) 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); _state.scale(scale);
} }
//----------------------------------------------------------------------------
void TextNode::setPixelSize(const unsigned int _size)
{
pixelSize_ = _size;
}
//============================================================================= //=============================================================================
} // namespace SceneGraph } // namespace SceneGraph
......
...@@ -83,7 +83,7 @@ namespace SceneGraph { ...@@ -83,7 +83,7 @@ namespace SceneGraph {
* via the setRenderingMode(TextMode _textMode) function. Alternatively the quads can be aligned * 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 * 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 * 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 class ACGDLLEXPORT TextNode : public BaseNode
...@@ -148,7 +148,10 @@ public: ...@@ -148,7 +148,10 @@ public:
void setText(std::string _text); void setText(std::string _text);
/// sets the size by which the quads displaying the text will be scaled /// 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 /// sets the font to be used for generating a texture with most characters of the chosen font
void setFont(const QFont& _font); void setFont(const QFont& _font);
...@@ -190,10 +193,13 @@ private: ...@@ -190,10 +193,13 @@ private:
/// scaling factor by which the quads in #vbo_ are scaled /// scaling factor by which the quads in #vbo_ are scaled
double size_; double size_;
/// pixelSize of the text for the SCREEN_ALIGNED_STATIC_SIZE mode
unsigned pixelSize_;
/// text to be displayed on quads in #vbo_ /// text to be displayed on quads in #vbo_
std::string text_; 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_; TextMode textMode_;
/** /**
......
...@@ -85,7 +85,7 @@ void Ruler::updateNodes() ...@@ -85,7 +85,7 @@ void Ruler::updateNodes()
//set params for the text //set params for the text
ACG::Vec3d distVec = Point1 - Point2; ACG::Vec3d distVec = Point1 - Point2;
QString distanceStr = QString().number((distVec).length()); QString distanceStr = QString().number(distVec.length());
textNode_->setText(distanceStr.toStdString()); textNode_->setText(distanceStr.toStdString());
textNode_->multipassNodeSetActive(8, true); textNode_->multipassNodeSetActive(8, true);
...@@ -94,7 +94,6 @@ void Ruler::updateNodes() ...@@ -94,7 +94,6 @@ void Ruler::updateNodes()
textTransformNode_->translate(Point1); textTransformNode_->translate(Point1);
ACG::Vec3d halfDist = distVec/2.f; ACG::Vec3d halfDist = distVec/2.f;
textTransformNode_->translate(-halfDist); textTransformNode_->translate(-halfDist);
textTransformNode_->scale(0.025);
emit updateView(); emit updateView();
} }
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
public slots: 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: private:
......
...@@ -46,4 +46,5 @@ RulerOptions::RulerOptions(QWidget *parent) ...@@ -46,4 +46,5 @@ RulerOptions::RulerOptions(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
textSizeSpinBox->setSuffix(" px");
} }
...@@ -113,7 +113,7 @@ void RulerPlugin::slotMouseEvent(QMouseEvent* _event) ...@@ -113,7 +113,7 @@ void RulerPlugin::slotMouseEvent(QMouseEvent* _event)
{ {
currentRuler_.reset(new Ruler(object,name(),0)); currentRuler_.reset(new Ruler(object,name(),0));
connect(currentRuler_.get(),SIGNAL(updateView()),this,SIGNAL(updateView())); 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_->setTextSize(textSize);
currentRuler_->setPoints(hitPoint,hitPoint); currentRuler_->setPoints(hitPoint,hitPoint);
enableDragMode(1); enableDragMode(1);
...@@ -263,7 +263,7 @@ bool RulerPlugin::initializeOptionsWidget(QWidget*& _widget) ...@@ -263,7 +263,7 @@ bool RulerPlugin::initializeOptionsWidget(QWidget*& _widget)
optionsWidget_ = new RulerOptions(); optionsWidget_ = new RulerOptions();
} }
unsigned textSize = OpenFlipperSettings().value(textSizeSettingName_,10).toUInt(); unsigned textSize = OpenFlipperSettings().value(textSizeSettingName_,16).toUInt();
optionsWidget_->textSizeSpinBox->setValue(textSize); optionsWidget_->textSizeSpinBox->setValue(textSize);
_widget = optionsWidget_; _widget = optionsWidget_;
return true; 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