mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-06 15:29:02 +00:00
Changed: #1302 Added initial database of primitives (model/view) (loading of *. primitive file)
This commit is contained in:
parent
2d01de7207
commit
899132aaf6
13 changed files with 701 additions and 17 deletions
|
@ -11,6 +11,7 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
|
|||
|
||||
SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h
|
||||
world_editor_window.h
|
||||
primitives_model.h
|
||||
)
|
||||
|
||||
SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Project includes
|
||||
#include "primitive_item.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QStringList>
|
||||
|
||||
namespace WorldEditor
|
||||
{
|
||||
|
||||
BaseTreeItem::BaseTreeItem(BaseTreeItem *parent)
|
||||
{
|
||||
m_parentItem = parent;
|
||||
m_itemData << QIcon() << "" << "" << "";
|
||||
}
|
||||
|
||||
BaseTreeItem::BaseTreeItem(const QList<QVariant> &data, BaseTreeItem *parent)
|
||||
{
|
||||
m_parentItem = parent;
|
||||
m_itemData = data;
|
||||
}
|
||||
|
||||
BaseTreeItem::~BaseTreeItem()
|
||||
{
|
||||
qDeleteAll(m_childItems);
|
||||
}
|
||||
|
||||
void BaseTreeItem::appendChild(BaseTreeItem *item)
|
||||
{
|
||||
m_childItems.append(item);
|
||||
}
|
||||
|
||||
BaseTreeItem *BaseTreeItem::child(int row)
|
||||
{
|
||||
return m_childItems.value(row);
|
||||
}
|
||||
|
||||
int BaseTreeItem::childCount() const
|
||||
{
|
||||
return m_childItems.count();
|
||||
}
|
||||
|
||||
int BaseTreeItem::columnCount() const
|
||||
{
|
||||
return m_itemData.count();
|
||||
}
|
||||
|
||||
QVariant BaseTreeItem::data(int column) const
|
||||
{
|
||||
return m_itemData.value(column);
|
||||
}
|
||||
|
||||
void BaseTreeItem::setData(int column, const QVariant &data)
|
||||
{
|
||||
m_itemData[column] = data;
|
||||
}
|
||||
|
||||
BaseTreeItem *BaseTreeItem::parent()
|
||||
{
|
||||
return m_parentItem;
|
||||
}
|
||||
|
||||
int BaseTreeItem::row() const
|
||||
{
|
||||
if (m_parentItem)
|
||||
return m_parentItem->m_childItems.indexOf(const_cast<BaseTreeItem *>(this));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BaseTreeItem::setModified(bool value)
|
||||
{
|
||||
m_modified = value;
|
||||
}
|
||||
|
||||
bool BaseTreeItem::isModified() const
|
||||
{
|
||||
return m_modified;
|
||||
}
|
||||
|
||||
PrimitiveItem::PrimitiveItem(NLLIGO::IPrimitive *primitive, BaseTreeItem *parent)
|
||||
: BaseTreeItem(parent),
|
||||
m_primitive(primitive)
|
||||
{
|
||||
setData(1, QString(m_primitive->getName().c_str()));
|
||||
setData(2, QString(m_primitive->getClassName().c_str()));
|
||||
|
||||
std::string className;
|
||||
m_primitive->getPropertyByName("class", className);
|
||||
|
||||
// Set Icon
|
||||
QIcon icon(QString("./old_ico/%1.ico").arg(className.c_str()));
|
||||
if (primitive->getParent() == NULL)
|
||||
icon = QIcon("./old_ico/root.ico");
|
||||
if (icon.isNull())
|
||||
{
|
||||
if (primitive->getNumChildren() == 0)
|
||||
icon = QIcon("./old_ico/property.ico");
|
||||
else
|
||||
icon = QIcon("./old_ico/folder_h.ico");
|
||||
}
|
||||
setData(0, icon);
|
||||
|
||||
setData(3, QString(className.c_str()));
|
||||
}
|
||||
/*
|
||||
PrimitiveItem::PrimitiveItem(const PrimitiveItem &other)
|
||||
{
|
||||
}
|
||||
*/
|
||||
PrimitiveItem::~PrimitiveItem()
|
||||
{
|
||||
}
|
||||
|
||||
PrimitivesItem::PrimitivesItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent)
|
||||
: PrimitiveItem(primitives->RootNode, parent),
|
||||
m_primitives(primitives)
|
||||
{
|
||||
setData(1, name);
|
||||
}
|
||||
/*
|
||||
PrimitivesItem::PrimitivesItem(const PrimitiveItem &other)
|
||||
{
|
||||
}
|
||||
*/
|
||||
PrimitivesItem::~PrimitivesItem()
|
||||
{
|
||||
}
|
||||
|
||||
} /* namespace WorldEditor */
|
|
@ -0,0 +1,99 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef PRIMITIVE_ITEM_H
|
||||
#define PRIMITIVE_ITEM_H
|
||||
|
||||
// Project includes
|
||||
|
||||
// NeL includes
|
||||
#include <nel/ligo/primitive.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QList>
|
||||
#include <QIcon>
|
||||
#include <QVariant>
|
||||
|
||||
namespace WorldEditor
|
||||
{
|
||||
|
||||
/*
|
||||
@class BaseTreeItem
|
||||
@brief
|
||||
@details
|
||||
*/
|
||||
class BaseTreeItem
|
||||
{
|
||||
public:
|
||||
BaseTreeItem(BaseTreeItem *parent = 0);
|
||||
BaseTreeItem(const QList<QVariant> &data, BaseTreeItem *parent = 0);
|
||||
virtual ~BaseTreeItem();
|
||||
|
||||
void appendChild(BaseTreeItem *child);
|
||||
|
||||
BaseTreeItem *child(int row);
|
||||
int childCount() const;
|
||||
int columnCount() const;
|
||||
QVariant data(int column) const;
|
||||
void setData(int column, const QVariant &data);
|
||||
int row() const;
|
||||
BaseTreeItem *parent();
|
||||
void setModified(bool value);
|
||||
bool isModified() const;
|
||||
|
||||
private:
|
||||
|
||||
bool m_modified;
|
||||
QList<BaseTreeItem *> m_childItems;
|
||||
QList<QVariant> m_itemData;
|
||||
BaseTreeItem *m_parentItem;
|
||||
};
|
||||
|
||||
/*
|
||||
@class PrimitiveItem
|
||||
@brief
|
||||
@details
|
||||
*/
|
||||
class PrimitiveItem: public BaseTreeItem
|
||||
{
|
||||
public:
|
||||
PrimitiveItem(NLLIGO::IPrimitive *primitive, BaseTreeItem *parent);
|
||||
PrimitiveItem(const PrimitiveItem &other);
|
||||
virtual ~PrimitiveItem();
|
||||
|
||||
private:
|
||||
NLLIGO::IPrimitive *m_primitive;
|
||||
};
|
||||
|
||||
/*
|
||||
@class PrimitivesItem
|
||||
@brief
|
||||
@details
|
||||
*/
|
||||
class PrimitivesItem: public PrimitiveItem
|
||||
{
|
||||
public:
|
||||
PrimitivesItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent);
|
||||
PrimitivesItem(const PrimitiveItem &other);
|
||||
virtual ~PrimitivesItem();
|
||||
|
||||
private:
|
||||
NLLIGO::CPrimitives *m_primitives;
|
||||
};
|
||||
|
||||
} /* namespace WorldEditor */
|
||||
|
||||
#endif // PRIMITIVE_ITEM_H
|
|
@ -0,0 +1,172 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <nel/ligo/primitive.h>
|
||||
#include <nel/ligo/ligo_config.h>
|
||||
#include <nel/ligo/primitive_class.h>
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
#include "primitive_item.h"
|
||||
#include "primitives_model.h"
|
||||
|
||||
namespace WorldEditor
|
||||
{
|
||||
|
||||
PrimitivesTreeModel::PrimitivesTreeModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
QList<QVariant> rootData;
|
||||
rootData << "Name" << "Class" << "Class";
|
||||
m_rootItem = new BaseTreeItem(rootData);
|
||||
}
|
||||
|
||||
PrimitivesTreeModel::~PrimitivesTreeModel()
|
||||
{
|
||||
delete m_rootItem;
|
||||
}
|
||||
|
||||
int PrimitivesTreeModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return static_cast<BaseTreeItem *>(parent.internalPointer())->columnCount();
|
||||
else
|
||||
return m_rootItem->columnCount();
|
||||
}
|
||||
|
||||
QVariant PrimitivesTreeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
BaseTreeItem *item = static_cast<BaseTreeItem *>(index.internalPointer());
|
||||
switch (role)
|
||||
{
|
||||
// case Qt::TextAlignmentRole:
|
||||
// return int(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
case Qt::DisplayRole:
|
||||
return item->data(index.column() + 1);
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
if (index.column() == 0)
|
||||
return qVariantFromValue(item->data(0));
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags PrimitivesTreeModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
QVariant PrimitivesTreeModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||
return m_rootItem->data(section);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QModelIndex PrimitivesTreeModel::index(int row, int column, const QModelIndex &parent)
|
||||
const
|
||||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
BaseTreeItem *parentItem;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = m_rootItem;
|
||||
else
|
||||
parentItem = static_cast<BaseTreeItem *>(parent.internalPointer());
|
||||
|
||||
BaseTreeItem *childItem = parentItem->child(row);
|
||||
if (childItem)
|
||||
return createIndex(row, column, childItem);
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex PrimitivesTreeModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
BaseTreeItem *childItem = static_cast<BaseTreeItem *>(index.internalPointer());
|
||||
BaseTreeItem *parentItem = childItem->parent();
|
||||
|
||||
if (parentItem == m_rootItem)
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(parentItem->row(), 0, parentItem);
|
||||
}
|
||||
|
||||
int PrimitivesTreeModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
BaseTreeItem *parentItem;
|
||||
if (parent.column() > 0)
|
||||
return 0;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = m_rootItem;
|
||||
else
|
||||
parentItem = static_cast<BaseTreeItem *>(parent.internalPointer());
|
||||
|
||||
return parentItem->childCount();
|
||||
}
|
||||
|
||||
void PrimitivesTreeModel::addPrimitives(const QString &name, NLLIGO::CPrimitives *primitives)
|
||||
{
|
||||
beginResetModel();
|
||||
PrimitivesItem *newPrimitives = new PrimitivesItem(name, primitives, m_rootItem);
|
||||
m_rootItem->appendChild(newPrimitives);
|
||||
for (uint i = 0; i < primitives->RootNode->getNumChildren(); ++i)
|
||||
{
|
||||
NLLIGO::IPrimitive *childPrim;
|
||||
primitives->RootNode->getChild(childPrim, i);
|
||||
scanPrimitive(childPrim, newPrimitives);
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void PrimitivesTreeModel::scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem *parent)
|
||||
{
|
||||
// const NLLIGO::CPrimitiveClass *primClass = NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*prim);
|
||||
// nlassert (primClass);
|
||||
// if (primClass->Type == NLLIGO::CPrimitiveClass::Alias)
|
||||
// return;
|
||||
if (prim->getClassName() == "CPrimAlias")
|
||||
return;
|
||||
|
||||
PrimitiveItem *newItem = new PrimitiveItem(prim, parent);
|
||||
parent->appendChild(newItem);
|
||||
for (uint i = 0; i < prim->getNumChildren(); ++i)
|
||||
{
|
||||
NLLIGO::IPrimitive *childPrim;
|
||||
prim->getChild(childPrim, i);
|
||||
scanPrimitive(childPrim, newItem);
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace WorldEditor */
|
|
@ -0,0 +1,65 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef PRIMITIVES_MODEL_H
|
||||
#define PRIMITIVES_MODEL_H
|
||||
|
||||
#include <nel/ligo/primitive.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QModelIndex>
|
||||
#include <QVariant>
|
||||
|
||||
namespace WorldEditor
|
||||
{
|
||||
|
||||
class BaseTreeItem;
|
||||
|
||||
/**
|
||||
@class PrimitivesTreeModel
|
||||
@brief
|
||||
@details
|
||||
*/
|
||||
class PrimitivesTreeModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PrimitivesTreeModel(QObject *parent = 0);
|
||||
~PrimitivesTreeModel();
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
void addPrimitives(const QString &name, NLLIGO::CPrimitives *primitives);
|
||||
|
||||
private:
|
||||
void scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem *parent = 0);
|
||||
|
||||
BaseTreeItem *m_rootItem;
|
||||
};
|
||||
|
||||
} /* namespace WorldEditor */
|
||||
|
||||
#endif // PRIMITIVES_MODEL_H
|
|
@ -0,0 +1,47 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Project includes
|
||||
#include "world_editor_actions.h"
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/debug.h>
|
||||
|
||||
// Qt includes
|
||||
|
||||
namespace WorldEditor
|
||||
{
|
||||
|
||||
OpenLandscapeCommand::OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent)
|
||||
: QUndoCommand(parent),
|
||||
m_fileName(fileName)
|
||||
{
|
||||
}
|
||||
|
||||
OpenLandscapeCommand::~OpenLandscapeCommand()
|
||||
{
|
||||
}
|
||||
|
||||
void OpenLandscapeCommand::undo()
|
||||
{
|
||||
}
|
||||
|
||||
void OpenLandscapeCommand::redo()
|
||||
{
|
||||
}
|
||||
|
||||
} /* namespace WorldEditor */
|
|
@ -0,0 +1,48 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef WORLD_EDITOR_ACTIONS_H
|
||||
#define WORLD_EDITOR_ACTIONS_H
|
||||
|
||||
// Project includes
|
||||
|
||||
// NeL includes
|
||||
|
||||
// Qt includes
|
||||
#include <QtGui/QUndoCommand>
|
||||
#include <QtGui/QGraphicsScene>
|
||||
#include <QtGui/QGraphicsItem>
|
||||
|
||||
namespace WorldEditor
|
||||
{
|
||||
|
||||
class OpenLandscapeCommand: public QUndoCommand
|
||||
{
|
||||
public:
|
||||
OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent = 0);
|
||||
virtual ~OpenLandscapeCommand();
|
||||
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
private:
|
||||
|
||||
QString m_fileName;
|
||||
};
|
||||
|
||||
} /* namespace WorldEditor */
|
||||
|
||||
#endif // WORLD_EDITOR_ACTIONS_H
|
|
@ -28,6 +28,10 @@ const char * const WORLD_EDITOR_PLUGIN = "WorldEditor";
|
|||
const char * const WORLD_EDITOR_SECTION = "WorldEditor";
|
||||
const char * const WORLD_WINDOW_STATE = "WorldWindowState";
|
||||
const char * const WORLD_WINDOW_GEOMETRY = "WorldWindowGeometry";
|
||||
const char * const WORLD_EDITOR_CELL_SIZE = "WorldEditorCellSize";
|
||||
const char * const WORLD_EDITOR_SNAP = "WorldEditorSnap";
|
||||
const char * const ZONE_SNAPSHOT_RES = "WorldEditorZoneSnapshotRes";
|
||||
const char * const PRIMITIVE_CLASS_FILENAME = "WorldEditorPrimitiveClassFilename";
|
||||
|
||||
//resources
|
||||
const char * const ICON_WORLD_EDITOR = ":/icons/ic_nel_world_editor.png";
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
// NeL includes
|
||||
#include "nel/misc/debug.h"
|
||||
#include <nel/misc/path.h>
|
||||
#include <nel/ligo/primitive_utils.h>
|
||||
#include <nel/ligo/primitive.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QObject>
|
||||
|
@ -43,8 +46,35 @@ WorldEditorPlugin::~WorldEditorPlugin()
|
|||
|
||||
bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||
{
|
||||
Q_UNUSED(errorString);
|
||||
m_plugMan = pluginManager;
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
|
||||
m_ligoConfig.CellSize = settings->value(Constants::WORLD_EDITOR_CELL_SIZE, "160").toFloat();
|
||||
m_ligoConfig.Snap = settings->value(Constants::WORLD_EDITOR_SNAP, "1").toFloat();
|
||||
m_ligoConfig.ZoneSnapShotRes = settings->value(Constants::ZONE_SNAPSHOT_RES, "128").toUInt();
|
||||
QString fileName = settings->value(Constants::PRIMITIVE_CLASS_FILENAME, "world_editor_classes.xml").toString();
|
||||
settings->endGroup();
|
||||
try
|
||||
{
|
||||
// Search path of file world_editor_classes.xml
|
||||
std::string ligoPath = NLMISC::CPath::lookup(fileName.toStdString());
|
||||
// Init LIGO
|
||||
m_ligoConfig.readPrimitiveClass(ligoPath.c_str(), true);
|
||||
NLLIGO::Register();
|
||||
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
||||
}
|
||||
catch (NLMISC::Exception &e)
|
||||
{
|
||||
*errorString = tr("(%1)").arg(e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset
|
||||
m_ligoConfig.resetPrimitiveConfiguration ();
|
||||
|
||||
// Load
|
||||
m_ligoConfig.readPrimitiveClass ("world_editor_primitive_configuration.xml", true);
|
||||
|
||||
|
||||
addAutoReleasedObject(new WorldEditorContext(this));
|
||||
return true;
|
||||
|
@ -115,7 +145,7 @@ QUndoStack *WorldEditorContext::undoStack()
|
|||
|
||||
void WorldEditorContext::open()
|
||||
{
|
||||
//m_worldEditorWindow->open();
|
||||
m_worldEditorWindow->open();
|
||||
}
|
||||
|
||||
QWidget *WorldEditorContext::widget()
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
// NeL includes
|
||||
#include "nel/misc/app_context.h"
|
||||
#include <nel/ligo/ligo_config.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QObject>
|
||||
|
@ -70,6 +71,7 @@ protected:
|
|||
NLMISC::CLibraryContext *m_libContext;
|
||||
|
||||
private:
|
||||
NLLIGO::CLigoConfig m_ligoConfig;
|
||||
ExtensionSystem::IPluginManager *m_plugMan;
|
||||
QList<QObject *> m_autoReleaseObjects;
|
||||
};
|
||||
|
|
|
@ -18,13 +18,25 @@
|
|||
// Project includes
|
||||
#include "world_editor_window.h"
|
||||
#include "world_editor_constants.h"
|
||||
#include "primitives_model.h"
|
||||
|
||||
#include "../core/icore.h"
|
||||
#include "../core/imenu_manager.h"
|
||||
#include "../core/core_constants.h"
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/path.h>
|
||||
#include <nel/ligo/primitive_utils.h>
|
||||
#include <nel/ligo/primitive.h>
|
||||
|
||||
#include <nel/misc/file.h>
|
||||
#include <nel/misc/i_xml.h>
|
||||
#include <nel/ligo/primitive_utils.h>
|
||||
#include <nel/ligo/primitive.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QFileDialog>
|
||||
|
||||
namespace WorldEditor
|
||||
{
|
||||
|
@ -32,11 +44,15 @@ QString _lastDir;
|
|||
|
||||
WorldEditorWindow::WorldEditorWindow(QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
m_primitivesModel(0),
|
||||
m_undoStack(0)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
m_undoStack = new QUndoStack(this);
|
||||
|
||||
m_primitivesModel = new PrimitivesTreeModel();
|
||||
m_ui.treePrimitivesView->setModel(m_primitivesModel);
|
||||
|
||||
createMenus();
|
||||
createToolBars();
|
||||
// readSettings();
|
||||
|
@ -54,20 +70,33 @@ QUndoStack *WorldEditorWindow::undoStack() const
|
|||
|
||||
void WorldEditorWindow::open()
|
||||
{
|
||||
/* QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
||||
tr("Open NeL Ligo land file"), _lastDir,
|
||||
tr("All NeL Ligo land files (*.land)"));
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
||||
tr("Open NeL Ligo primitive file"), _lastDir,
|
||||
tr("All NeL Ligo primitive files (*.primitive)"));
|
||||
|
||||
setCursor(Qt::WaitCursor);
|
||||
if (!fileNames.isEmpty())
|
||||
setCursor(Qt::WaitCursor);
|
||||
if (!fileNames.isEmpty())
|
||||
{
|
||||
QStringList list = fileNames;
|
||||
_lastDir = QFileInfo(list.front()).absolutePath();
|
||||
Q_FOREACH(QString fileName, fileNames)
|
||||
{
|
||||
QStringList list = fileNames;
|
||||
_lastDir = QFileInfo(list.front()).absolutePath();
|
||||
Q_FOREACH(QString fileName, fileNames)
|
||||
{
|
||||
}
|
||||
loadPrimitive(fileName);
|
||||
}
|
||||
setCursor(Qt::ArrowCursor);*/
|
||||
}
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void WorldEditorWindow::loadPrimitive(const QString &fileName)
|
||||
{
|
||||
NLLIGO::CPrimitives *primitives = new NLLIGO::CPrimitives();
|
||||
|
||||
// set the primitive context
|
||||
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = primitives;
|
||||
|
||||
NLLIGO::loadXmlPrimitiveFile(*primitives, fileName.toStdString(), *NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig);
|
||||
|
||||
m_primitivesModel->addPrimitives(fileName, primitives);
|
||||
}
|
||||
|
||||
void WorldEditorWindow::createMenus()
|
||||
|
@ -82,14 +111,15 @@ void WorldEditorWindow::createToolBars()
|
|||
//m_ui.fileToolBar->addAction(action);
|
||||
QAction *action = menuManager->action(Core::Constants::OPEN);
|
||||
m_ui.fileToolBar->addAction(action);
|
||||
m_ui.fileToolBar->addSeparator();
|
||||
|
||||
action = menuManager->action(Core::Constants::UNDO);
|
||||
if (action != 0)
|
||||
m_ui.undoToolBar->addAction(action);
|
||||
m_ui.fileToolBar->addAction(action);
|
||||
|
||||
action = menuManager->action(Core::Constants::REDO);
|
||||
if (action != 0)
|
||||
m_ui.undoToolBar->addAction(action);
|
||||
m_ui.fileToolBar->addAction(action);
|
||||
|
||||
//action = menuManager->action(Core::Constants::SAVE);
|
||||
//m_ui.fileToolBar->addAction(action);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
namespace WorldEditor
|
||||
{
|
||||
class PrimitivesTreeModel;
|
||||
|
||||
class WorldEditorWindow: public QMainWindow
|
||||
{
|
||||
|
@ -48,6 +49,9 @@ private:
|
|||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
void loadPrimitive(const QString &fileName);
|
||||
|
||||
PrimitivesTreeModel *m_primitivesModel;
|
||||
QUndoStack *m_undoStack;
|
||||
Ui::WorldEditorWindow m_ui;
|
||||
}; /* class WorldEditorWindow */
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGraphicsView" name="graphicsView"/>
|
||||
<widget class="LandscapeEditor::LandscapeView" name="graphicsView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -35,7 +35,7 @@
|
|||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="undoToolBar">
|
||||
<widget class="QToolBar" name="worldEditToolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
|
@ -45,8 +45,45 @@
|
|||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="newPrimitiveAction"/>
|
||||
<addaction name="loadPrimitiveAction"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="treePrimitivesDockWidget">
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="treePrimitivesView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<action name="loadPrimitiveAction">
|
||||
<property name="text">
|
||||
<string>loadPrimitive</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="newPrimitiveAction">
|
||||
<property name="text">
|
||||
<string>newPrimitive</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LandscapeEditor::LandscapeView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header>../landscape_editor/landscape_view.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="world_editor.qrc"/>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue