Test integrating a Qt app into a DFHack plugin. It was a success!

develop
Petr Mrázek 2011-07-16 12:26:31 +02:00
parent 9025066a2b
commit 70dbc3cef9
19 changed files with 978 additions and 15 deletions

@ -7,22 +7,96 @@ IF(UNIX)
ENDIF() ENDIF()
include_directories("${dfhack_SOURCE_DIR}/library/include") include_directories("${dfhack_SOURCE_DIR}/library/include")
MACRO(CAR var)
SET(${var} ${ARGV1})
ENDMACRO(CAR)
MACRO(DFHACK_PLUGIN PLUGIN_NAME PLUGIN_SOURCES) MACRO(CDR var junk)
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES}) SET(${var} ${ARGN})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack) ENDMACRO(CDR)
IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.so PREFIX "") MACRO(LIST_CONTAINS var value)
ELSE() SET(${var})
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dll) FOREACH (value2 ${ARGN})
ENDIF() IF (${value} STREQUAL ${value2})
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${DFHACK_PLUGIN_OUTPUT_DIR}) SET(${var} TRUE)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${DFHACK_PLUGIN_OUTPUT_DIR}) ENDIF (${value} STREQUAL ${value2})
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${DFHACK_PLUGIN_OUTPUT_DIR}) ENDFOREACH (value2)
install(TARGETS ${PLUGIN_NAME} ENDMACRO(LIST_CONTAINS)
LIBRARY DESTINATION ${DFHACK_PLUGIN_DESTINATION}
RUNTIME DESTINATION ${DFHACK_PLUGIN_DESTINATION}) MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
ENDMACRO() SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
IF (is_arg_name)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name)
LIST_CONTAINS(is_option ${arg} ${option_names})
IF (is_option)
SET(${prefix}_${arg} TRUE)
ELSE (is_option)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option)
ENDIF (is_arg_name)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
MACRO(DFHACK_PLUGIN)
PARSE_ARGUMENTS(PLUGIN
"LINK_LIBRARIES;DEPENDS"
"SOME_OPT"
${ARGN}
)
CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS})
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack ${PLUGIN_LINK_LIBRARIES})
IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.so PREFIX "")
ELSE()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dll)
ENDIF()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${DFHACK_PLUGIN_OUTPUT_DIR})
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${DFHACK_PLUGIN_OUTPUT_DIR})
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${DFHACK_PLUGIN_OUTPUT_DIR})
install(TARGETS ${PLUGIN_NAME}
LIBRARY DESTINATION ${DFHACK_PLUGIN_DESTINATION}
RUNTIME DESTINATION ${DFHACK_PLUGIN_DESTINATION})
#MESSAGE("Depends: ${PLUGIN_DEPENDS}")
#IF (PLUGIN_AUTO_INSTALL)
# MESSAGE("Auto install")
#ENDIF (PLUGIN_AUTO_INSTALL)
#IF (PLUGIN_NO_MODULE)
# MESSAGE("No module")
#ENDIF (PLUGIN_NO_MODULE)
ENDMACRO(DFHACK_PLUGIN)
# add all subdirectories. can be used in those subdirectories, etc...
# needs a re-run of cmake to pick up the changes
#macro(RECURSE_DIRS)
# file(GLOB sub-dir RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
# foreach(dir ${sub-dir})
# if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
# add_subdirectory (${dir})
# endif()
# endforeach()
#endmacro()
#RECURSE_DIRS()
add_subdirectory (qtplug)
DFHACK_PLUGIN(reveal reveal.cpp) DFHACK_PLUGIN(reveal reveal.cpp)
OPTION(BUILD_KITTENS "Build the kittens plugin." OFF) OPTION(BUILD_KITTENS "Build the kittens plugin." OFF)

@ -0,0 +1,39 @@
find_package(Qt4 QUIET)
find_package(OpenGL QUIET)
if(QT4_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND)
IF(QT_VERSION_MAJOR MATCHES 4 AND QT_VERSION_MINOR GREATER 6)
set( QT_USE_QTGUI TRUE )
set( QT_USE_QTOPENGL TRUE )
INCLUDE( ${QT_USE_FILE} )
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
set ( qtplug_SRCS
qtplug.cpp
blankslade.cpp
glwidget.cpp
)
SET ( qtplug_UI
gui/main.ui
)
SET( qtplug_RCS
gui/resources.qrc
)
# this command will generate rules that will run rcc on all files from blankslade_RCS
# in result blankslade_RC_SRCS variable will contain paths to files produced by rcc
QT4_ADD_RESOURCES( qtplug_RC_SRCS ${qtplug_RCS} )
QT4_WRAP_UI(qtplug_UI_h ${qtplug_UI})
qt4_automoc(${qtplug_SRCS})
DFHACK_PLUGIN(qtplug ${qtplug_SRCS} ${qtplug_RC_SRCS} ${qtplug_UI_h})
target_link_libraries(qtplug ${OPENGL_LIBRARIES} ${QT_LIBRARIES} )
ELSE(QT_VERSION_MAJOR MATCHES 4 AND QT_VERSION_MINOR GREATER 6)
MESSAGE(STATUS "Can't build the Qt plugin. Your Qt is too old.")
ENDIF(QT_VERSION_MAJOR MATCHES 4 AND QT_VERSION_MINOR GREATER 6)
else(QT4_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND)
MESSAGE(STATUS "Required libraries (Qt, GL, GLU) not found - Qt plugin can't be built.")
endif(QT4_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND)

@ -0,0 +1,98 @@
/*
* Copyright (c) 2010 Petr Mrázek (peterix)
* See LICENSE for details.
*/
#include "blankslade.h"
#include <QFileDialog>
#include <QDebug>
#include "glwidget.h"
blankslade::blankslade(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
GLWidget * glw = new GLWidget();
ui.gridding->addWidget(glw);
connect(ui.actionOpen,SIGNAL(triggered(bool)),this,SLOT(slotOpen(bool)));
connect(ui.actionQuit,SIGNAL(triggered(bool)),this,SLOT(slotQuit(bool)));
connect(ui.actionSave,SIGNAL(triggered(bool)),this,SLOT(slotSave(bool)));
connect(ui.actionSave_As,SIGNAL(triggered(bool)),this,SLOT(slotSaveAs(bool)));
ui.actionOpen->setIcon(QIcon::fromTheme("document-open"));
ui.actionOpen->setIconText(tr("Open"));
ui.actionSave->setIcon(QIcon::fromTheme("document-save"));
ui.actionSave->setIconText(tr("Save"));
ui.actionSave_As->setIcon(QIcon::fromTheme("document-save-as"));
ui.actionSave_As->setIconText(tr("Save As"));
ui.actionQuit->setIcon(QIcon::fromTheme("application-exit"));
ui.actionQuit->setIconText(tr("Run DF"));
}
blankslade::~blankslade()
{}
void blankslade::slotOpen(bool )
{
/*
QFileDialog fd(this,tr("Locate the Memoxy.xml file"));
fd.setNameFilter(tr("Memory definition (*.xml)"));
fd.setFileMode(QFileDialog::ExistingFile);
fd.setAcceptMode(QFileDialog::AcceptOpen);
int result = fd.exec();
if(result == QDialog::Accepted)
{
QStringList files = fd.selectedFiles();
QString fileName = files[0];
QDomDocument doc("memxml");
QFile file(fileName);
if(!file.open(QIODevice::ReadOnly))
{
return;
}
if(!doc.setContent(&file))
{
file.close();
return;
}
mod = new MemXMLModel(doc,this);
ui.entryView->setModel(mod);
file.close();
}
*/
}
void blankslade::slotQuit(bool )
{
close();
}
void blankslade::slotSave(bool )
{
// blah
}
void blankslade::slotRunDF(bool )
{
// blah
}
void blankslade::slotSaveAs(bool )
{
QFileDialog fd(this,tr("Choose file to save as..."));
fd.setNameFilter(tr("Memory definition (*.xml)"));
fd.setFileMode(QFileDialog::AnyFile);
fd.selectFile("Memory.xml");
fd.setAcceptMode(QFileDialog::AcceptSave);
int result = fd.exec();
if(result == QDialog::Accepted)
{
QStringList files = fd.selectedFiles();
QString file = files[0];
qDebug() << "File:" << file;
}
}
void blankslade::slotSetupDFs(bool )
{
}
#include "blankslade.moc"

@ -0,0 +1,29 @@
/*
* Copyright (c) 2010 Petr Mrázek (peterix)
* See LICENSE for details.
*/
#ifndef blankslade_H
#define blankslade_H
#include <QtGui/QMainWindow>
#include "ui_main.h"
class blankslade : public QMainWindow
{
Q_OBJECT
public:
blankslade(QWidget *parent = 0);
virtual ~blankslade();
private:
Ui::MainWindow ui;
public slots:
void slotOpen(bool);
void slotQuit(bool);
void slotSave(bool);
void slotSaveAs(bool);
void slotRunDF(bool);
void slotSetupDFs(bool);
};
#endif // blankslade_H

@ -0,0 +1,245 @@
/*
* Copyright (c) 2010 Petr Mrázek (peterix)
* See LICENSE for details.
*/
#include "glwidget.h"
#include <QtOpenGL>
#include <QGLBuffer>
#include <QGLShaderProgram>
#include <QGLPixelBuffer>
#include <iostream>
struct Vertex
{
float texcoord[2];
float color[3];
float position[3];
};
#define FRS 0.0625
#define FRX FRS/2
// this is crap
const Vertex house_vert[] =
{
// walls
{ { 0.0, 0.0 }, { 0.0, 0.0, 1.0 }, { -4.0, -4.0, -4.0 } },
{ { 0.0, FRS }, { 0.0, 1.0, 0.0 }, { -4.0, -4.0, 4.0 } },
{ { FRS, FRS }, { 0.0, 1.0, 1.0 }, { 4.0, -4.0, 4.0 } },
{ { FRS, 0.0 }, { 1.0, 0.0, 0.0 }, { 4.0, -4.0, -4.0 } },
{ { 0.0, 0.0 }, { 1.0, 0.0, 1.0 }, { -4.0, 4.0, -4.0 } },
{ { 0.0, FRS }, { 1.0, 1.0, 0.0 }, { -4.0, 4.0, 4.0 } },
{ { FRS, FRS }, { 1.0, 1.0, 1.0 }, { 4.0, 4.0, 4.0 } },
{ { FRS, 0.0 }, { 0.0, 0.0, 1.0 }, { 4.0, 4.0, -4.0 } },
{ { 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { -4.0, -4.0, -4.0 } },
{ { 0.0, FRS }, { 0.0, 1.0, 1.0 }, { -4.0, -4.0, 4.0 } },
{ { FRS, FRS }, { 1.0, 0.0, 0.0 }, { -4.0, 4.0, 4.0 } },
{ { FRS, 0.0 }, { 1.0, 0.0, 1.0 }, { -4.0, 4.0, -4.0 } },
{ { 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 4.0, -4.0, -4.0 } },
{ { 0.0, FRS }, { 0.0, 1.0, 1.0 }, { 4.0, -4.0, 4.0 } },
{ { FRS, FRS }, { 1.0, 0.0, 0.0 }, { 4.0, 4.0, 4.0 } },
{ { FRS, 0.0 }, { 1.0, 0.0, 1.0 }, { 4.0, 4.0, -4.0 } },
// roof
{ { 0.0, 0.0 }, { 0.0, 0.0, 1.0 }, { -4.0, 4.0, -4.0 } },
{ { FRS, 0.0 }, { 0.0, 1.0, 1.0 }, { 4.0, 4.0, -4.0 } },
{ { FRX, FRX }, { 1.0, 1.0, 1.0 }, { 0.0, 9.0, 0.0 } },
{ { FRS, 0.0 }, { 1.0, 0.0, 0.0 }, { 4.0, 4.0, -4.0 } },
{ { FRS, FRS }, { 1.0, 1.0, 0.0 }, { 4.0, 4.0, 4.0 } },
{ { FRX, FRX }, { 1.0, 1.0, 1.0 }, { 0.0, 9.0, 0.0 } },
{ { FRS, FRS }, { 0.0, 1.0, 0.0 }, { 4.0, 4.0, 4.0 } },
{ { 0.0, FRS }, { 0.0, 1.0, 1.0 }, { -4.0, 4.0, 4.0 } },
{ { FRX, FRX }, { 1.0, 1.0, 1.0 }, { 0.0, 9.0, 0.0 } },
{ { 0.0, FRS }, { 0.0, 1.0, 0.0 }, { -4.0, 4.0, 4.0 } },
{ { 0.0, 0.0 }, { 1.0, 1.0, 0.0 }, { -4.0, 4.0, -4.0 } },
{ { FRX, FRX }, { 1.0, 1.0, 1.0 }, { 0.0, 9.0, 0.0 } }
};
const unsigned char house_idx[] =
{
// walls
0, 1, 2, 0, 2, 3,
4, 5, 6, 4, 6, 7,
8, 9, 10, 8, 10, 11,
12, 13, 14, 12, 14, 15,
// roof
16, 17, 18,
19, 20, 21,
22, 23, 24,
25, 26, 27
};
class GLWPrivate
{
public:
QGLBuffer *VBO;
QGLBuffer *EBO;
QGLShaderProgram prog;
int positionAttrib;
int colorAttrib;
int texcoordsAttrib;
int mvpUniform;
int textureUniform;
int terrain;
float pz,rx,ry;
QPoint lastMouse;
};
GLWidget::GLWidget()
{
d = new GLWPrivate;
d->pz = -140.0f;
d->rx = d->ry = 0.0f;
d->VBO = d->EBO = 0;
startTimer( 10 );
}
GLWidget::~GLWidget()
{
if(d->VBO) delete d->VBO;
if(d->EBO) delete d->EBO;
delete d;
}
const char * VS_src =
"#version 130\n"
"in vec3 position; in vec3 color; uniform mat4 mvp; out vec3 c;"
"in vec2 tc_in; out vec2 coord;"
"void main()"
"{"
"gl_Position = mvp*vec4(position,1);"
"c = color;"
"coord = tc_in;"
"}";
const char * FS_src =
"#version 130\n"
"in vec3 c;"
//"out vec4 gl_FragColor;"
"in vec2 coord; uniform sampler2D tex;"
"void main()"
"{"
// "gl_FragColor = vec4(c,1);"
// "gl_FragColor = mix( texture(tex, coord), vec4(c,1), 0.5);"
// "gl_FragColor = vec4(c,1) - texture(tex, coord);"
"gl_FragColor = vec4(c,1) * texture(tex, coord);"
"}";
//initialization of OpenGL
void GLWidget::initializeGL()
{
bool test = 1;
test &= d->prog.addShaderFromSourceCode(QGLShader::Vertex,VS_src);
test &= d->prog.addShaderFromSourceCode(QGLShader::Fragment,FS_src);
test &= d->prog.link();
if(!test)
std::cout << "OUCH!" << std::endl;
d->positionAttrib = d->prog.attributeLocation("position");
d->colorAttrib = d->prog.attributeLocation("color");
d->texcoordsAttrib = d->prog.attributeLocation("tc_in");
d->mvpUniform = d->prog.uniformLocation("mvp");
d->textureUniform = d->prog.uniformLocation("tex");
if(d->positionAttrib == -1 || d->colorAttrib == -1 || d->mvpUniform == -1)
std::cout << "Bad attribs!" << std::endl;
QGLBuffer &VBO = *(d->VBO = new QGLBuffer(QGLBuffer::VertexBuffer));
VBO.create();
VBO.bind();
VBO.allocate(sizeof(house_vert));
VBO.write(0,house_vert,sizeof(house_vert));
QGLBuffer &EBO = *(d->EBO = new QGLBuffer(QGLBuffer::IndexBuffer));
EBO.create();
EBO.bind();
EBO.allocate(sizeof(house_idx));
EBO.write(0,house_idx,sizeof(house_idx));
QImage texture;
texture.load("terrain.png");
d->terrain = bindTexture(texture);
glClearColor(0.0f, 0.0f, 0.0f, 0.f);
glShadeModel( GL_SMOOTH );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
glEnable( GL_TEXTURE_2D );
glEnable( GL_DEPTH_TEST );
}
void GLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
d->prog.bind();
QMatrix4x4 projection;
QMatrix4x4 mvp;
//projection.ortho(-10,10,-10,10,1,1000);
float aspect = (float)width()/(float)height();
projection.perspective(10,aspect,1,1000);
mvp = projection;
mvp.translate(0,0,d->pz);
mvp.rotate(d->ry,1,0,0);
mvp.rotate(d->rx,0,1,0);
d->prog.setUniformValue(d->mvpUniform,mvp);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, d->terrain);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
d->prog.setUniformValue(d->textureUniform,0);
d->prog.enableAttributeArray(d->positionAttrib);
d->prog.enableAttributeArray(d->colorAttrib);
d->prog.enableAttributeArray(d->texcoordsAttrib);
d->VBO->bind();
d->prog.setAttributeBuffer(d->texcoordsAttrib, GL_FLOAT, offsetof(Vertex, texcoord), 2, sizeof(Vertex));
d->prog.setAttributeBuffer(d->positionAttrib, GL_FLOAT, offsetof(Vertex, position), 3, sizeof(Vertex));
d->prog.setAttributeBuffer(d->colorAttrib, GL_FLOAT, offsetof(Vertex, color), 3, sizeof(Vertex));
d->EBO->bind();
glDrawElements(GL_TRIANGLES, d->EBO->size(), GL_UNSIGNED_BYTE, NULL);
d->prog.release();
}
void GLWidget::resizeGL(int width, int height)
{
glViewport(0, 0, width, height);
}
void GLWidget::mousePressEvent(QMouseEvent *event)
{
d->lastMouse = event->pos();
}
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
int dx = event->x() - d->lastMouse.x();
int dy = event->y() - d->lastMouse.y();
if (event->buttons() & Qt::LeftButton)
{
d->rx = d->rx + dx;
d->ry = d->ry + dy;
}
d->lastMouse = event->pos();
}
void GLWidget::timerEvent(QTimerEvent *event)
{
updateGL();
}

@ -0,0 +1,32 @@
/*
* Copyright (c) 2010 Petr Mrázek (peterix)
* See LICENSE for details.
*/
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QGLWidget>
class GLWPrivate;
class GLWidget : public QGLWidget
{
public:
GLWidget();
~GLWidget();
float rot;
void resizeGL(int width, int height);
protected:
void initializeGL();
void paintGL();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void timerEvent(QTimerEvent *event);
private:
GLWPrivate * d;
};
#endif // GLWIDGET_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

@ -0,0 +1,361 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>662</width>
<height>836</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<normaloff>:/main_icon/main_64.png</normaloff>:/main_icon/main_64.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridding">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QDockWidget" name="scene_dock">
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="allowedAreas">
<set>Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Scéna</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Exponent n</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QSlider" name="slideExponentN">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="spinExponentN"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Exponent e</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QSlider" name="slideExponentE">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="spinExponentE"/>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QDial" name="dialLight"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Světlo</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Objekt</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDial" name="dial_2"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Textura</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/blah/tileable.jpg</normaloff>:/blah/tileable.jpg</iconset>
</property>
<property name="iconSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Render</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>40</height>
</size>
</property>
</spacer>
</item>
</layout>
<zorder>pushButton_2</zorder>
<zorder>verticalLayoutWidget</zorder>
<zorder>pushButton</zorder>
<zorder>gridLayoutWidget</zorder>
</widget>
</widget>
<widget class="QDockWidget" name="dock_example">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="allowedAreas">
<set>Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::TopDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Ukázky</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_3">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="listWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectItems</enum>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::TopToBottom</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="layoutMode">
<enum>QListView::SinglePass</enum>
</property>
<property name="spacing">
<number>10</number>
</property>
<property name="viewMode">
<enum>QListView::ListMode</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="selectionRectVisible">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Koule</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/blah/koule.png</normaloff>:/blah/koule.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Krychle</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/blah/krychle.png</normaloff>:/blah/krychle.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Válec</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/blah/valec.png</normaloff>:/blah/valec.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Diamant</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/blah/diamant.png</normaloff>:/blah/diamant.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>a=3,b=3</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/blah/33.png</normaloff>:/blah/33.png</iconset>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget>
<action name="actionOpen">
<property name="text">
<string>Open</string>
</property>
</action>
<action name="actionSave">
<property name="text">
<string>Save</string>
</property>
</action>
<action name="actionSave_As">
<property name="text">
<string>Save As</string>
</property>
</action>
<action name="actionQuit">
<property name="text">
<string>Quit</string>
</property>
</action>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@ -0,0 +1,15 @@
<RCC>
<qresource prefix="main_icon">
<file>main_64.png</file>
<file>main_16.png</file>
<file>main_32.png</file>
</qresource>
<qresource prefix="blah">
<file>tileable.jpg</file>
<file>33.png</file>
<file>diamant.png</file>
<file>koule.png</file>
<file>krychle.png</file>
<file>valec.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@ -0,0 +1,70 @@
#include <dfhack/Core.h>
#include <dfhack/Console.h>
#include <dfhack/Export.h>
#include <dfhack/PluginManager.h>
#include <dfhack/modules/Maps.h>
#include <dfhack/modules/Gui.h>
#include <dfhack/extra/MapExtras.h>
#include <vector>
#include <cstdio>
#include <stack>
#include <string>
#include <QtGui/QApplication>
#include "blankslade.h"
using std::vector;
using std::string;
using std::stack;
using namespace DFHack;
static int runnable(void *);
static SDL::Mutex * instance_mutex = 0;
static bool running = false;
DFhackCExport command_result runqt (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void )
{
return "Qt Test";
}
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{
instance_mutex = SDL_CreateMutex();
commands.clear();
commands.push_back(PluginCommand("runqt","Open an interactive Qt gui.",runqt));
return CR_OK;
}
DFhackCExport command_result plugin_shutdown ( Core * c )
{
return CR_OK;
}
DFhackCExport command_result runqt (Core * c, vector <string> & parameters)
{
SDL_mutexP(instance_mutex);
if(!running)
{
running = true;
SDL::Thread * IO = SDL_CreateThread(runnable, 0);
}
else
{
c->con.printerr("The Qt test plugin is already running!\n");
}
SDL_mutexV(instance_mutex);
return CR_OK;
}
static int runnable(void *)
{
QApplication app(0, 0);
blankslade appGui;
appGui.show();
int ret = app.exec();
SDL_mutexP(instance_mutex);
running = false;
SDL_mutexV(instance_mutex);
return ret;
}