Commit 2ba46828 authored by Martin Heistermann's avatar Martin Heistermann

Add feature: display entity counts in status bar, ala InfoMeshObject

parent 2d8594a5
include (plugin)
openflipper_plugin (DEPS OpenVolumeMesh
TYPES POLYHEDRALMESH HEXAHEDRALMESH )
TYPES POLYHEDRALMESH TETRAHEDRALMESH HEXAHEDRALMESH )
<RCC>
<qresource prefix="Plugin-InfoVolumeMeshObject">
<file>dialogIcons/bar_face.png</file>
<file>dialogIcons/bar_edge.png</file>
<file>dialogIcons/bar_vertex.png</file>
</qresource>
</RCC>
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
#include "VolumeMeshInfoBar.hh"
VolumeMeshInfoBar::VolumeMeshInfoBar(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
hideCounts();
}
void VolumeMeshInfoBar::hideCounts(){
hide();
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
#pragma once
#include "ui_VolumeMeshInfoBar.h"
class VolumeMeshInfoBar : public QWidget, public Ui::VolumeMeshInfoBar
{
Q_OBJECT
public:
explicit VolumeMeshInfoBar(QWidget *parent = nullptr);
void hideCounts();
void showTargetCount(int _count);
template<typename MeshT>
void showCounts(const char *typeName, const MeshT *mesh) {
auto v = mesh->n_logical_vertices();
cellsLabel->setText(QString(typeName) + " Cells: ");
vertices->setText(QString::number(mesh->n_logical_vertices()));
edges->setText(QString::number(mesh->n_logical_edges()));
faces->setText(QString::number(mesh->n_logical_faces()));
cells->setText(QString::number(mesh->n_logical_cells()));
show();
}
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VolumeMeshInfoBar</class>
<widget class="QWidget" name="VolumeMeshInfoBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>558</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="verticesIcon">
<property name="maximumSize">
<size>
<width>10</width>
<height>10</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/Plugin-InfoVolumeMeshObject/dialogIcons/bar_vertex.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="vertices">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>#vertex</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="margin">
<number>2</number>
</property>
<property name="indent">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="edgesIcon">
<property name="maximumSize">
<size>
<width>10</width>
<height>10</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/Plugin-InfoVolumeMeshObject/dialogIcons/bar_edge.png</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="indent">
<number>-1</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="edges">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>#edges</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="margin">
<number>2</number>
</property>
<property name="indent">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="facesIcon">
<property name="maximumSize">
<size>
<width>10</width>
<height>10</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/Plugin-InfoVolumeMeshObject/dialogIcons/bar_face.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="faces">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>#faces</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="margin">
<number>2</number>
</property>
<property name="indent">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="cellsLabel">
<property name="text">
<string>Cells:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="cells">
<property name="text">
<string>#cells</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -50,6 +50,11 @@
//== INCLUDES =================================================================
#include "VolumeMeshObjectInfoPlugin.hh"
#include "OpenFlipper/common/GlobalOptions.hh"
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
#include "Type-OpenVolumeMesh/ObjectTypes/HexahedralMesh/PluginFunctionsHexahedralMesh.hh"
#include "Type-OpenVolumeMesh/ObjectTypes/TetrahedralMesh/PluginFunctionsTetrahedralMesh.hh"
#include "Type-OpenVolumeMesh/ObjectTypes/PolyhedralMesh/PluginFunctionsPolyhedralMesh.hh"
//== IMPLEMENTATION ==========================================================
......@@ -62,6 +67,41 @@ InfoVolumeMeshObjectPlugin::~InfoVolumeMeshObjectPlugin()
{
}
void InfoVolumeMeshObjectPlugin::updateInfoBar()
{
if (!infoBar_) {
return;
}
if ( PluginFunctions::targetCount() != 1) {
infoBar_->hideCounts();
return;
}
BaseObjectData *target = nullptr;
DataType supported(DATA_TETRAHEDRAL_MESH | DATA_POLYHEDRAL_MESH | DATA_HEXAHEDRAL_MESH);
for (auto *obj: PluginFunctions::objects(PluginFunctions::TARGET_OBJECTS, supported))
{
target = obj;
break;
}
if (!target) {
infoBar_->hideCounts();
return;
}
auto *pmo = PluginFunctions::polyhedralMeshObject(target);
auto *hmo = PluginFunctions::hexahedralMeshObject(target);
auto *tmo = PluginFunctions::tetrahedralMeshObject(target);
if (pmo && pmo->mesh()) {
infoBar_->showCounts("Poly", pmo->mesh());
} else if (hmo && hmo->mesh()) {
infoBar_->showCounts("Hex", hmo->mesh());
} else if (tmo && tmo->mesh()) {
infoBar_->showCounts("Tet", tmo->mesh());
} else {
infoBar_->hideCounts();
}
}
void InfoVolumeMeshObjectPlugin::initializePlugin()
{
......@@ -72,13 +112,23 @@ void InfoVolumeMeshObjectPlugin::pluginsInitialized() {
//set the slot descriptions
setDescriptions();
if ( OpenFlipper::Options::gui()) {
// Create info bar
infoBar_ = new VolumeMeshInfoBar();
emit addWidgetToStatusbar(infoBar_);
}
}
//------------------------------------------------------------------------------
void InfoVolumeMeshObjectPlugin::slotObjectUpdated( int _identifier , const UpdateType& _type)
{
updateInfoBar();
}
//------------------------------------------------------------------------------
......
......@@ -39,9 +39,7 @@
* *
\*===========================================================================*/
#ifndef INFOPLUGIN_HH
#define INFOPLUGIN_HH
#pragma once
//== INCLUDES =================================================================
......@@ -49,8 +47,11 @@
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/StatusbarInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include "VolumeMeshInfoBar.hh"
//== CLASS DEFINITION =========================================================
......@@ -58,11 +59,15 @@
Plugin to visualize information about open volume meshs in the scene
*/
class InfoVolumeMeshObjectPlugin : public QObject, BaseInterface, LoggingInterface
class InfoVolumeMeshObjectPlugin : public QObject,
BaseInterface,
LoggingInterface,
StatusbarInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(StatusbarInterface)
Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-VolumeMeshObjectInfo")
......@@ -75,6 +80,9 @@ class InfoVolumeMeshObjectPlugin : public QObject, BaseInterface, LoggingInterfa
void log(Logtype _type, QString _message);
void log(QString _message);
// StatusbarInterface
void addWidgetToStatusbar(QWidget* _widget);
private slots :
// BaseInterface
......@@ -105,6 +113,9 @@ class InfoVolumeMeshObjectPlugin : public QObject, BaseInterface, LoggingInterfa
template< class MeshT >
void printMeshInfo( MeshT* _mesh, int _id, unsigned int _face, ACG::Vec3d& _hitPoint );
void updateInfoBar();
VolumeMeshInfoBar *infoBar_ = nullptr;
//===========================================================================
/** @name Scripting Functions
* @{ */
......@@ -132,5 +143,3 @@ class InfoVolumeMeshObjectPlugin : public QObject, BaseInterface, LoggingInterfa
};
#endif //MOVEPLUGIN_HH
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