Commit 45b06053 authored by Matthias Möller's avatar Matthias Möller

TextNode:

- setSize uses a double type for scaling
- new Mode: SCREEN_ALIGNED_STATIC_SIZE (for both renderers)

Ruler:
- textsize is not depending on the cameraposition
- optionsdialog for textsize
- update doc

refs #1626

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16922 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a90d43ef
......@@ -29,7 +29,7 @@ Ruler::Ruler(BaseObjectData* _obj,const QString &_pluginName, unsigned index)
if (!_obj->getAdditionalNode(textNode_,_pluginName,textNodeName_.c_str()))
{
textNode_ = new ACG::SceneGraph::TextNode(textTransformNode_,textNodeName_,ACG::SceneGraph::TextNode::SCREEN_ALIGNED,true);
textNode_ = new ACG::SceneGraph::TextNode(textTransformNode_,textNodeName_,ACG::SceneGraph::TextNode::SCREEN_ALIGNED_STATIC_SIZE,true);
_obj->addAdditionalNode(textNode_,_pluginName,textNodeName_.c_str());
}
......@@ -88,14 +88,13 @@ void Ruler::updateNodes()
QString distanceStr = QString().number((distVec).length());
textNode_->setText(distanceStr.toStdString());
textNode_->multipassNodeSetActive(8, true);
textNode_->setSize(1);
//translate and scale text
textTransformNode_->loadIdentity();
textTransformNode_->translate(Point1);
ACG::Vec3d halfDist = distVec/2.f;
textTransformNode_->translate(-halfDist);
textTransformNode_->scale(distVec.length()*0.125);
textTransformNode_->scale(0.025);
emit updateView();
}
......@@ -70,6 +70,10 @@ public:
const BaseObject* getBaseObj(){return obj_;}
public slots:
void setTextSize(const unsigned _size){textNode_->setSize(_size*0.1); emit updateView();}
private:
void updateNodes();
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include "RulerOptions.hh"
RulerOptions::RulerOptions(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include "ui_rulerOptions.hh"
#include <QtGui>
class RulerOptions : public QWidget, public Ui::rulerOptions
{
Q_OBJECT
public:
RulerOptions(QWidget *parent = 0);
};
......@@ -44,6 +44,7 @@
#include "RulerPlugin.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
//------------------------------------------------------------------------------
RulerPlugin::RulerPlugin()
......@@ -51,7 +52,9 @@ RulerPlugin::RulerPlugin()
buttonAction_(0),
pickModeName_("MeasureDistance"),
lineDrag_(-1),
dblClickCheck_(false)
dblClickCheck_(false),
optionsWidget_(0),
textSizeSettingName_(name()+QString("/TextSize"))
{
}
......@@ -110,6 +113,8 @@ 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();
currentRuler_->setTextSize(textSize);
currentRuler_->setPoints(hitPoint,hitPoint);
enableDragMode(1);
}
......@@ -250,5 +255,26 @@ void RulerPlugin::objectDeleted(int _id)
currentRuler_.reset();
}
}
//------------------------------------------------------------------------------
bool RulerPlugin::initializeOptionsWidget(QWidget*& _widget)
{
if (!optionsWidget_)
{
optionsWidget_ = new RulerOptions();
}
unsigned textSize = OpenFlipperSettings().value(textSizeSettingName_,10).toUInt();
optionsWidget_->textSizeSpinBox->setValue(textSize);
_widget = optionsWidget_;
return true;
}
//------------------------------------------------------------------------------
void RulerPlugin::applyOptions()
{
int textSize = optionsWidget_->textSizeSpinBox->value();
if (currentRuler_)
currentRuler_->setTextSize(textSize);
OpenFlipperSettings().setValue(textSizeSettingName_,textSize);
}
Q_EXPORT_PLUGIN2( rulerPlugin , RulerPlugin );
......@@ -53,14 +53,16 @@
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/OptionsInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include "Ruler.hh"
#include "RulerOptions.hh"
class RulerPlugin : public QObject, BaseInterface, MouseInterface, PickingInterface, ToolbarInterface, LoadSaveInterface
class RulerPlugin : public QObject, BaseInterface, MouseInterface, PickingInterface, ToolbarInterface, LoadSaveInterface, OptionsInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
......@@ -68,6 +70,7 @@ class RulerPlugin : public QObject, BaseInterface, MouseInterface, PickingInterf
Q_INTERFACES(PickingInterface)
Q_INTERFACES(ToolbarInterface)
Q_INTERFACES(LoadSaveInterface)
Q_INTERFACES(OptionsInterface)
signals:
void addToolbar(QToolBar *_toolbar);
......@@ -87,6 +90,9 @@ public slots:
public:
// OptionsInterface
bool initializeOptionsWidget(QWidget*& _widget);
RulerPlugin();
~RulerPlugin();
......@@ -114,6 +120,10 @@ private:
bool dblClickCheck_;
ptr::shared_ptr<Ruler> currentRuler_;
RulerOptions* optionsWidget_;
const QString textSizeSettingName_;
private slots:
void initializePlugin();
......@@ -126,6 +136,8 @@ private slots:
void objectDeleted(int _id);
// OptionsInterface
void applyOptions();
public slots:
QString version(){ return QString("1.0"); }
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>rulerOptions</class>
<widget class="QWidget" name="rulerOptions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="textSizeLabel">
<property name="text">
<string>Text Size:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="textSizeSpinBox"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -18,6 +18,8 @@ Once, the ruler tool is enabled you can use following actions:
\note If you click outside of your mesh, the ruler gets a reset.
The <b>textsize</b> can be customized in the Pluginoptions under \a File -> \a Options -> \a Plugins -> \a RulerPlugin
*/
......
Markdown is supported
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