Commit 661016e2 authored by Jan Möbius's avatar Jan Möbius

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10244 383ad7c9-94d9-4d36-a494-682f7c89f535
parents
include (plugin)
openflipper_plugin ()
################################################################################
#
################################################################################
include( $$TOPDIR/qmake/all.include )
Plugin()
DIRECTORIES = .
# Input
HEADERS += $$getFilesFromDir($$DIRECTORIES,*.hh)
SOURCES += $$getFilesFromDir($$DIRECTORIES,*.cc)
FORMS += $$getFilesFromDir($$DIRECTORIES,*.ui)
################################################################################
#include <QtGui>
#include "SubdividerPlugin.hh"
#include <iostream>
#include <algorithm>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/INIFile/INIFile.hh>
#include <ACG/Scenegraph/PointNode.hh>
void SubdividerPlugin::initializePlugin()
{
if ( OpenFlipper::Options::gui() ) {
tool_ = new subdividerToolbarWidget();
QSize size(300, 300);
tool_->resize(size);
connect(tool_->subdivide_toolButton, SIGNAL( clicked() ), this, SLOT( slot_subdivide() ) );
emit addToolbox( tr("Subdivider") , tool_ );
}
}
void SubdividerPlugin::slotPickModeChanged( const std::string& /*_mode*/)
{
}
void SubdividerPlugin::pluginsInitialized()
{
}
//-----------------------------------------------------------------------------
void SubdividerPlugin::slot_subdivide()
{
std::vector< int > ids;
if ( PluginFunctions::getTargetIdentifiers( ids ) )
{
for (unsigned int i = 0; i < ids.size(); ++i)
{
BaseObjectData* object;
if(!test_trimesh_object(ids[i], object))
return;
int steps = tool_->subdivision_steps_spinBox->value();
TriMesh* mesh = PluginFunctions::triMesh(object);
if(tool_->loop_radioButton->isChecked())
{
OpenMesh::Subdivider::Uniform::LoopT<TriMesh,double> subdivider;
subdivider.attach(*mesh);
subdivider(steps);
subdivider.detach();
}
else
{
OpenMesh::Subdivider::Uniform::Sqrt3T<TriMesh,double> subdivider;
subdivider.attach(*mesh);
subdivider(steps);
subdivider.detach();
}
mesh->update_face_normals();
mesh->update_vertex_normals();
TriMeshObject* tmo = PluginFunctions::triMeshObject(object);
tmo->update();
// Create backup
emit createBackup(object->id(), "Subdivider");
emit updatedObject(object->id(), UPDATE_TOPOLOGY);
}
}
emit updateView();
}
//-----------------------------------------------------------------------------
bool SubdividerPlugin::test_trimesh_object(int _identifier, BaseObjectData*& _object)
{
if ( _identifier == -1)
return false;
if (! PluginFunctions::getObject(_identifier,_object) )
return false;
if (!_object->dataType(DATA_TRIANGLE_MESH) )
return false;
return true;
}
//-----------------------------------------------------------------------------
void SubdividerPlugin::slotMouseEvent( QMouseEvent* /*_event*/ )
{
}
//-----------------------------------------------------------------------------
void SubdividerPlugin::slotKeyEvent( QKeyEvent* _event )
{
switch (_event->key())
{
default:
break;
}
} // END slotKeyEvent
Q_EXPORT_PLUGIN2( subdividerplugin , SubdividerPlugin );
\ No newline at end of file
#ifndef SUBDIVIDERPLUGIN_HH
#define SUBDIVIDERPLUGIN_HH
/** Simple Subdivider Plugin based on Subdivider code from Martin Habbeke
*/
#include <QObject>
#include <QMenuBar>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/MouseInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/LoopT.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/Sqrt3T.hh>
#include "subdividerToolbar.hh"
// Subdivider types
//typename OpenMesh::Subdivider::Uniform:LoopT<TriMesh> LoopT;
//typename OpenMesh::Subdivider::Uniform:Sqrt3T<TriMesh> Sqrt3T;
class SubdividerPlugin : public QObject, BaseInterface , ToolboxInterface, LoggingInterface, PickingInterface, MouseInterface, LoadSaveInterface, KeyInterface, ScriptInterface, BackupInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(MouseInterface)
Q_INTERFACES(PickingInterface)
Q_INTERFACES(LoadSaveInterface)
Q_INTERFACES(KeyInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(BackupInterface)
signals:
void updateView();
void updatedObject(int _id, const UpdateType _type);
void addPickMode( const std::string _mode );
void log(Logtype _type, QString _message);
void log(QString _message);
void addEmptyObject( DataType _type, int& _id );
void defineViewMode(QString _mode, QStringList _usedWidgets);
void scriptInfo( QString _functionName );
void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
// ToolboxInterface
void addToolbox( QString _name , QWidget* _widget );
// BackupInterface
void createBackup( int _id , QString _name );
private slots:
void slotMouseEvent( QMouseEvent* _event );
void slotMouseWheelEvent(QWheelEvent * /*_event*/, const std::string & /*_mode*/){};
void slotPickModeChanged( const std::string& _mode);
void slotKeyEvent( QKeyEvent* _event );
void initializePlugin();
void pluginsInitialized();
/// Make plugin available in no-GUI mode
void noguiSupported( ) {} ;
public slots:
void slot_subdivide();
public :
~SubdividerPlugin() {};
QString name() { return (QString("Subdivider")); };
QString description( ) { return (QString("Subdivide a mesh")); };
private :
/// Widget for Toolbox
subdividerToolbarWidget* tool_;
private:
bool test_trimesh_object(int _identifier, BaseObjectData*& _object);
public slots:
QString version() { return QString("1.0"); };
};
#endif //SUBDIVIDERPLUGIN_HH
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SubdividerControls</class>
<widget class="QWidget" name="SubdividerControls">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<height>646</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Subdivision steps:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="subdivision_steps_spinBox">
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Method:</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="loop_radioButton">
<property name="text">
<string>Loop</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QRadioButton" name="sqrt3_radioButton">
<property name="text">
<string>Sqrt3</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QToolButton" name="subdivide_toolButton">
<property name="text">
<string>Subdivide</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>495</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "subdividerToolbar.hh"
#include <QtGui>
subdividerToolbarWidget::subdividerToolbarWidget(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
}
#include "ui_subdividerControls.hh"
#include <QtGui>
class subdividerToolbarWidget : public QWidget, public Ui::SubdividerControls
{
Q_OBJECT
public:
subdividerToolbarWidget(QWidget *parent = 0);
};
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