Commit cf843920 authored by Mike Kremer's avatar Mike Kremer
Browse files

Added Scenegraph Dialog for texture node

Added buttons to collapse and expand all

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9889 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 70949a18
......@@ -53,6 +53,7 @@
#include "QtSceneGraphWidget.hh"
#include "QtMaterialDialog.hh"
#include "QtTextureDialog.hh"
#include "QtClippingDialog.hh"
#include "QtCoordFrameDialog.hh"
#include "QtShaderDialog.hh"
......@@ -60,6 +61,7 @@
#include "../Scenegraph/BaseNode.hh"
#include "../Scenegraph/DrawModes.hh"
#include "../Scenegraph/MaterialNode.hh"
#include "../Scenegraph/TextureNode.hh"
#include "../Scenegraph/ClippingNode.hh"
#include "../Scenegraph/ShaderNode.hh"
#include "../Scenegraph/CoordFrameNode.hh"
......@@ -248,7 +250,7 @@ update(SceneGraph::BaseNode* _node, Item* _parent)
void
QtSceneGraphWidget::
slotItemExpandedOrCollapsed( QTreeWidgetItem * /* _item */ )
slotItemExpandedOrCollapsed( QTreeWidgetItem* _item )
{
resizeColumnToContents( 0 );
}
......@@ -335,6 +337,14 @@ slotItemPressed( QTreeWidgetItem * _item,
this, SLOT( slotEditMaterial() ) );
}
if ( dynamic_cast<SceneGraph::TextureNode*>( node ) )
{
modeMenu_->addSeparator();
QAction * action = modeMenu_->addAction( "Edit texture" );
connect( action, SIGNAL( triggered() ),
this, SLOT( slotEditTexture() ) );
}
if ( dynamic_cast<SceneGraph::ShaderNode*>( node ) )
{
modeMenu_->addSeparator();
......@@ -399,6 +409,27 @@ void QtSceneGraphWidget::slotEditMaterial()
//-----------------------------------------------------------------------------
void QtSceneGraphWidget::slotEditTexture()
{
if ( curItem_ )
{
SceneGraph::TextureNode * node =
dynamic_cast< SceneGraph::TextureNode * >( curItem_->node() );
QtTextureDialog* dialog = new QtTextureDialog( this, node );
connect(dialog,
SIGNAL(signalNodeChanged(ACG::SceneGraph::BaseNode*)),
this,
SLOT(slotNodeChanged(ACG::SceneGraph::BaseNode*)));
dialog->show();
}
}
//-----------------------------------------------------------------------------
void QtSceneGraphWidget::slotEditShader()
{
if ( curItem_ )
......@@ -517,6 +548,14 @@ void QtSceneGraphWidget::keyReleaseEvent(QKeyEvent *_event)
//-----------------------------------------------------------------------------
void QtSceneGraphWidget::expandAll() {
QTreeWidget::expandAll();
resizeColumnToContents(0);
}
//-----------------------------------------------------------------------------
void
QtSceneGraphWidget::
......@@ -595,17 +634,32 @@ QtSceneGraphDialog( QWidget* _parent,
: QDialog(_parent)
{
setModal( false );
QVBoxLayout* l = new QVBoxLayout( this );
QWidget* buttons = new QWidget(this);
QHBoxLayout* butLayout = new QHBoxLayout(buttons);
sgw_ =
new QtSceneGraphWidget( this, _rootNode );
// Add buttons to hbox layout
QPushButton* expAll = new QPushButton("Expand all");
QPushButton* collAll = new QPushButton("Collapse all");
butLayout->addWidget(expAll);
butLayout->addWidget(collAll);
l->addWidget(buttons);
l->addWidget(sgw_);
connect( sgw_,
SIGNAL(signalNodeChanged(ACG::SceneGraph::BaseNode*)),
this,
SLOT(slotNodeChanged(ACG::SceneGraph::BaseNode*)) );
connect(sgw_,
SIGNAL(signalNodeChanged(ACG::SceneGraph::BaseNode*)),
this,
SLOT(slotNodeChanged(ACG::SceneGraph::BaseNode*)) );
connect(expAll, SIGNAL(pressed()), sgw_, SLOT(expandAll()));
connect(collAll, SIGNAL(pressed()), sgw_, SLOT(collapseAll()));
}
......
......@@ -122,6 +122,8 @@ protected:
QMap< SceneGraph::BaseNode* , QWidget* > widgetMap_;
};
/** \class QtSceneGraphWidget QtSceneGraphWidget.hh <ACG/QtWidgets/QtSceneGraphWidget.hh>
This class is used within the QtExaminerWidget to display and
......@@ -137,8 +139,8 @@ class ACGDLLEXPORT QtSceneGraphWidget : public QTreeWidget
public:
/// default constructor
QtSceneGraphWidget( QWidget * _parent = 0,
SceneGraph::BaseNode * _rootNode = 0 );
QtSceneGraphWidget(QWidget* _parent = 0,
SceneGraph::BaseNode* _rootNode = 0);
/// destructor
......@@ -151,12 +153,12 @@ public:
{
public:
// root constructor
Item( QTreeWidget * _parent,
SceneGraph::BaseNode * _node );
Item(QTreeWidget* _parent,
SceneGraph::BaseNode* _node);
// child constructor
Item( Item * _parent,
SceneGraph::BaseNode * _node );
Item(Item* _parent,
SceneGraph::BaseNode* _node);
// get node
SceneGraph::BaseNode * node() { return node_; }
......@@ -196,6 +198,7 @@ private slots:
void slotStatusMenu( QAction * _action );
void slotEditMaterial();
void slotEditTexture();
void slotEditShader();
void slotEditClipPlanes();
void slotEditCoordinateFrame();
......@@ -233,6 +236,10 @@ private:
QAction * actionHideChildren_;
QAction * actionHideSubtree_;
} statusActions_;
public slots:
void expandAll();
public:
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2010 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: 9595 $ *
* $Author: moebius $ *
* $Date: 2010-06-17 12:48:23 +0200 (Thu, 17 Jun 2010) $ *
* *
\*===========================================================================*/
//=============================================================================
//
// CLASS QtTextureDialog - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
#include "QtTextureDialog.hh"
#include "../Scenegraph/TextureNode.hh"
#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
#include <QSpinBox>
#include <QLayout>
#include <QVariant>
#include <QToolTip>
#include <QColorDialog>
#include <QSlider>
//== NAMESPACES ==============================================================
namespace ACG {
namespace QtWidgets {
//== IMPLEMENTATION ==========================================================
QtTextureDialog::QtTextureDialog( QWidget * _parent,
SceneGraph::TextureNode * _node )
: QDialog( _parent ),
node_(_node) {
ui_.setupUi( this );
// get initial values from node
mipmapping_ = bak_mipmapping_ = node_->mipmapping();
ui_.mipmapping->setChecked(mipmapping_);
connect( ui_.mipmapping, SIGNAL( toggled(bool) ),
this, SLOT( changeMipmapping(bool) ) );
connect( ui_.okButton, SIGNAL( clicked() ),
this, SLOT( accept() ) );
connect( ui_.cancelButton, SIGNAL( clicked() ),
this, SLOT( reject() ) );
}
//-----------------------------------------------------------------------------
void QtTextureDialog::reject() {
undoChanges();
QDialog::reject();
}
//-----------------------------------------------------------------------------
void QtTextureDialog::applyChanges() {
if ( mipmapping_ )
node_->enable_mipmapping();
else
node_->disable_mipmapping();
emit signalNodeChanged(node_);
}
//-----------------------------------------------------------------------------
void QtTextureDialog::undoChanges() {
if ( bak_mipmapping_ )
node_->enable_mipmapping();
else
node_->disable_mipmapping();
emit signalNodeChanged(node_);
}
//-----------------------------------------------------------------------------
void
QtTextureDialog::changeMipmapping(bool _b) {
mipmapping_ = _b;
applyChanges();
}
//=============================================================================
} // namespace QtWidgets
} // namespace ACG
//=============================================================================
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2010 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: 9595 $ *
* $Author: moebius $ *
* $Date: 2010-06-17 12:48:23 +0200 (Thu, 17 Jun 2010) $ *
* *
\*===========================================================================*/
//=============================================================================
//
// CLASS QtTextureDialog
//
//=============================================================================
#ifndef ACG_QTTEXTUREDIALOG_HH
#define ACG_QTTEXTUREDIALOG_HH
//== INCLUDES =================================================================
#include "ui_QtTextureDialogUi.hh"
#include "../Math/VectorT.hh"
#include "../GL/gl.hh"
#include <QColor>
#include <QDialog>
//== FORWARDDECLARATIONS ======================================================
namespace ACG {
namespace SceneGraph {
class TextureNode;
class BaseNode;
}
}
//== NAMESPACE ================================================================
namespace ACG {
namespace QtWidgets {
//== CLASS DEFINITION =========================================================
class ACGDLLEXPORT QtTextureDialog : public QDialog
{
Q_OBJECT
public:
QtTextureDialog( QWidget * _parent,
SceneGraph::TextureNode * _node );
~QtTextureDialog() {}
signals:
void signalNodeChanged( ACG::SceneGraph::BaseNode * _node );
private slots:
void changeMipmapping(bool _b);
void applyChanges();
void undoChanges();
void reject();
private:
bool mipmapping_, bak_mipmapping_;
SceneGraph::TextureNode* node_;
Ui::QtTextureDialogUi ui_;
};
//=============================================================================
} // namespace QtWidgets
} // namespace ACG
//=============================================================================
#endif // ACG_QTTEXTUREDIALOG_HH defined
//=============================================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QtTextureDialogUi</class>
<widget class="QWidget" name="QtTextureDialogUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>312</width>
<height>235</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Edit Texture</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Rendering</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="mipmapping">
<property name="text">
<string>Mipmapping</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="sp1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="l1">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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