Changed: #1301 Fix typos in comments/code.

--HG--
branch : gsoc2011-worldeditorqt
This commit is contained in:
dnk-88 2011-08-19 00:14:40 +03:00
parent eb3c9d2b90
commit da6828daf0
20 changed files with 117 additions and 118 deletions

View file

@ -85,7 +85,7 @@ void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zoneP
return;
checkBeginMacro();
nlinfo(QString("%1 %2 %3 (%4 %5)").arg(data.zoneName.c_str()).arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).toStdString().c_str());
// nlinfo(QString("%1 %2 %3 (%4 %5)").arg(data.zoneName.c_str()).arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).toStdString().c_str());
m_zonePositionList.push_back(zonePos);
m_undoStack->push(new LigoTileCommand(data, zonePos, this, m_landscapeScene));
}
@ -96,7 +96,6 @@ void ZoneBuilder::actionLigoMove(uint index, sint32 deltaX, sint32 deltaY)
return;
checkBeginMacro();
nlinfo("ligoMove");
//m_undoStack->push(new LigoMoveCommand(index, deltaX, deltaY, this));
}
@ -106,7 +105,7 @@ void ZoneBuilder::actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, s
return;
checkBeginMacro();
nlinfo(QString("minX=%1 maxX=%2 minY=%3 maxY=%4").arg(newMinX).arg(newMaxX).arg(newMinY).arg(newMaxY).toStdString().c_str());
// nlinfo(QString("minX=%1 maxX=%2 minY=%3 maxY=%4").arg(newMinX).arg(newMaxX).arg(newMinY).arg(newMaxY).toStdString().c_str());
m_undoStack->push(new LigoResizeCommand(index, newMinX, newMaxX, newMinY, newMaxY, this));
}
@ -274,7 +273,7 @@ int ZoneBuilder::createZoneRegion(const QString &fileName)
landItem.zoneRegionObject = new ZoneRegionObject();
landItem.zoneRegionObject->load(fileName.toStdString());
if (!checkOverlaps(landItem.zoneRegionObject->ligoZoneRegion()))
if (checkOverlaps(landItem.zoneRegionObject->ligoZoneRegion()))
{
delete landItem.zoneRegionObject;
return -1;
@ -334,7 +333,11 @@ int ZoneBuilder::currentIdZoneRegion() const
ZoneRegionObject *ZoneBuilder::currentZoneRegion() const
{
return m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject;
ZoneRegionObject *result = 0;
if (m_landscapeMap.contains(m_currentZoneRegion))
result = m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject;
return result;
}
int ZoneBuilder::countZoneRegion() const
@ -344,17 +347,23 @@ int ZoneBuilder::countZoneRegion() const
ZoneRegionObject *ZoneBuilder::zoneRegion(int id) const
{
return m_landscapeMap.value(id).zoneRegionObject;
ZoneRegionObject *result = 0;
if (m_landscapeMap.contains(id))
result = m_landscapeMap.value(id).zoneRegionObject;
return result;
}
void ZoneBuilder::ligoData(LigoData &data, const ZonePosition &zonePos)
{
m_landscapeMap.value(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y);
if (m_landscapeMap.contains(zonePos.region))
m_landscapeMap.value(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y);
}
void ZoneBuilder::setLigoData(LigoData &data, const ZonePosition &zonePos)
{
m_landscapeMap.value(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y);
if (m_landscapeMap.contains(zonePos.region))
m_landscapeMap.value(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y);
}
bool ZoneBuilder::initZoneBank (const QString &pathName)
@ -390,14 +399,10 @@ QString ZoneBuilder::dataPath() const
bool ZoneBuilder::getZoneMask(sint32 x, sint32 y)
{
if ((x < m_minX) || (x > m_maxX) ||
(y < m_minY) || (y > m_maxY))
{
(y < m_minY) || (y > m_maxY))
return true;
}
else
{
return m_zoneMask[(x - m_minX) + (y - m_minY) * (1 + m_maxX - m_minX)];
}
}
void ZoneBuilder::calcMask()
@ -485,7 +490,7 @@ void ZoneBuilder::checkBeginMacro()
{
m_createdAction = true;
m_undoStack->beginMacro(m_titleAction);
m_undoScanRegionCommand = new UndoScanRegionCommand(this, m_landscapeScene);
m_undoScanRegionCommand = new UndoScanRegionCommand(true, this, m_landscapeScene);
m_undoStack->push(m_undoScanRegionCommand);
}
}
@ -494,9 +499,13 @@ void ZoneBuilder::checkEndMacro()
{
if (m_createdAction)
{
RedoScanRegionCommand *redoScanRegionCommand = new RedoScanRegionCommand(this, m_landscapeScene);
UndoScanRegionCommand *redoScanRegionCommand = new UndoScanRegionCommand(false, this, m_landscapeScene);
// Sets list positions in which need apply changes
m_undoScanRegionCommand->setScanList(m_zonePositionList);
redoScanRegionCommand->setScanList(m_zonePositionList);
// Adds command in the stack
m_undoStack->push(redoScanRegionCommand);
m_undoStack->endMacro();
}
@ -517,11 +526,11 @@ bool ZoneBuilder::checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion)
{
const std::string &zoneName = newZoneRegion.getName(x, y);
if ((zoneName != STRING_UNUSED) && (zoneName != STRING_OUT_OF_BOUND))
return false;
return true;
}
}
}
return true;
return false;
}
} /* namespace LandscapeEditor */

View file

@ -59,17 +59,25 @@ public:
ZoneBuilder(LandscapeScene *landscapeScene, ListZonesWidget *listZonesWidget = 0, QUndoStack *undoStack = 0);
~ZoneBuilder();
/// Init zoneBank and init zone pixmap database
/// Inits zoneBank and init zone pixmap database
bool init(const QString &pathName, bool displayProgress = false);
void calcMask();
/// @return false if in point (x, y) placed zone brick, else true
bool getZoneMask (sint32 x, sint32 y);
bool getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y);
/// Ligo Actions
/// @{
/// Adds the LigoTileCommand in undo stack
void actionLigoTile(const LigoData &data, const ZonePosition &zonePos);
void actionLigoMove(uint index, sint32 deltaX, sint32 deltaY);
/// Adds the LigoResizeCommand in undo stack
void actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY);
/// @}
@ -82,11 +90,24 @@ public:
/// Zone Region
/// @{
/// Creates empty zone region and adds in the workspace
/// @return id zone region
int createZoneRegion();
/// Loads zone region from file @fileName and adds in the workspace.
/// @return id zone region
int createZoneRegion(const QString &fileName);
/// Unloads zone region from the workspace
void deleteZoneRegion(int id);
/// Sets the current zone region with @id
void setCurrentZoneRegion(int id);
/// @return id the current zone region, if workspace is empty then returns (-1)
int currentIdZoneRegion() const;
ZoneRegionObject *currentZoneRegion() const;
int countZoneRegion() const;
ZoneRegionObject *zoneRegion(int id) const;
@ -106,12 +127,18 @@ public:
private:
/// Scan ./zoneligos dir and add all *.ligozone files to zoneBank
/// Scans ./zoneligos dir and add all *.ligozone files to zoneBank
bool initZoneBank (const QString &path);
/// Checks enabled beginMacro mode for undo stack, if false, then enables mode
void checkBeginMacro();
/// Checks enabled on beginMacro mode for undo stack, if true, then adds UndoScanRegionCommand
/// in undo stack and disables beginMacro mode
void checkEndMacro();
/// Checks intersects between them zone regions
/// @return true if newZoneRegion intersects with loaded zone regions, else return false
bool checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion);
struct LandscapeItem

View file

@ -67,8 +67,8 @@ struct ZonePosition
};
/**
@class ZoneBuilder
@brief ZoneBuilder contains all the shared data between the tools and the engine.
@class ZoneBuilderBase
@brief ZoneBuilderBase contains all the shared data between the tools and the engine.
@details ZoneBank contains the macro zones that is composed of several zones plus a mask.
PixmapDatabase contains the graphics for the zones
*/

View file

@ -93,8 +93,9 @@ void LigoTileCommand::redo ()
m_zoneBuilder->setLigoData(m_newLigoData, m_zonePos);
}
UndoScanRegionCommand::UndoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent)
UndoScanRegionCommand::UndoScanRegionCommand(bool direction, ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent)
: QUndoCommand(parent),
m_direction(direction),
m_zoneBuilder(zoneBuilder),
m_scene(scene)
{
@ -112,45 +113,21 @@ void UndoScanRegionCommand::setScanList(const QList<ZonePosition> &zonePositionL
void UndoScanRegionCommand::undo()
{
for (int i = 0; i < m_zonePositionList.size(); ++i)
m_scene->deleteItemZone(m_zonePositionList.at(i));
for (int i = 0; i < m_zonePositionList.size(); ++i)
{
LigoData data;
m_zoneBuilder->ligoData(data, m_zonePositionList.at(i));
m_scene->createItemZone(data, m_zonePositionList.at(i));
}
if (m_direction)
applyChanges();
}
void UndoScanRegionCommand::redo()
{
if (!m_direction)
applyChanges();
}
RedoScanRegionCommand::RedoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent)
: QUndoCommand(parent),
m_zoneBuilder(zoneBuilder),
m_scene(scene)
{
}
RedoScanRegionCommand::~RedoScanRegionCommand()
{
m_zonePositionList.clear();
}
void RedoScanRegionCommand::setScanList(const QList<ZonePosition> &zonePositionList)
{
m_zonePositionList = zonePositionList;
}
void RedoScanRegionCommand::undo()
{
}
void RedoScanRegionCommand::redo()
void UndoScanRegionCommand::applyChanges()
{
for (int i = 0; i < m_zonePositionList.size(); ++i)
m_scene->deleteItemZone(m_zonePositionList.at(i));
for (int i = 0; i < m_zonePositionList.size(); ++i)
{
LigoData data;

View file

@ -32,6 +32,11 @@
namespace LandscapeEditor
{
/**
@class OpenLandscapeCommand
@brief
@details
*/
class OpenLandscapeCommand: public QUndoCommand
{
public:
@ -45,6 +50,11 @@ private:
QString m_fileName;
};
/**
@class NewLandscapeCommand
@brief
@details
*/
class NewLandscapeCommand: public QUndoCommand
{
public:
@ -56,7 +66,11 @@ public:
private:
};
// Modify the landscape
/**
@class LigoTileCommand
@brief
@details
*/
class LigoTileCommand: public QUndoCommand
{
public:
@ -76,10 +90,15 @@ private:
LandscapeScene *m_scene;
};
/**
@class UndoScanRegionCommand
@brief
@details
*/
class UndoScanRegionCommand: public QUndoCommand
{
public:
UndoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0);
UndoScanRegionCommand(bool direction, ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0);
virtual ~UndoScanRegionCommand();
void setScanList(const QList<ZonePosition> &zonePositionList);
@ -87,49 +106,19 @@ public:
virtual void redo();
private:
void applyChanges();
bool m_direction;
QList<ZonePosition> m_zonePositionList;
ZoneBuilder *m_zoneBuilder;
LandscapeScene *m_scene;
};
class RedoScanRegionCommand: public QUndoCommand
{
public:
RedoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0);
virtual ~RedoScanRegionCommand();
void setScanList(const QList<ZonePosition> &zonePositionList);
virtual void undo();
virtual void redo();
private:
QList<ZonePosition> m_zonePositionList;
ZoneBuilder *m_zoneBuilder;
LandscapeScene *m_scene;
};
/*
// Move the landscape
class LigoMoveCommand: public QUndoCommand
{
public:
LigoMoveCommand(int index, sint32 deltaX, sint32 deltaY, ZoneBuilder *zoneBuilder, QUndoCommand *parent = 0);
virtual ~LigoMoveCommand();
virtual void undo();
virtual void redo();
private:
int m_index;
sint32 m_deltaX;
sint32 m_deltaY;
ZoneBuilder *m_zoneBuilder;
};
/**
@class LigoResizeCommand
@brief
@details
*/
// Modify the landscape
class LigoResizeCommand: public QUndoCommand
{
public:

View file

@ -1,5 +1,4 @@
// 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

View file

@ -1,5 +1,4 @@
// 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
@ -75,7 +74,7 @@ QString LandscapeEditorPlugin::name() const
QString LandscapeEditorPlugin::version() const
{
return "0.1";
return "0.8";
}
QString LandscapeEditorPlugin::vendor() const

View file

@ -1,5 +1,4 @@
// 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

View file

@ -1,5 +1,4 @@
// 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

View file

@ -1,5 +1,4 @@
// 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

View file

@ -27,6 +27,11 @@
namespace LandscapeEditor
{
/**
@class LandscapeView
@brief Provides graphics view for viewing zone regions.
@details Also provides zooming, panning and displaying grid
*/
class LANDSCAPE_EDITOR_EXPORT LandscapeView: public QGraphicsView
{
Q_OBJECT
@ -42,11 +47,16 @@ public:
bool isVisibleGrid() const;
public Q_SLOTS:
/// Enable/disable displaying grid.
void setVisibleGrid(bool visible);
/// Enable/disable displaying text(coord.) above each zone bricks.
void setVisibleText(bool visible);
private Q_SLOTS:
protected:
//Take over the interaction
virtual void wheelEvent(QWheelEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);

View file

@ -35,8 +35,8 @@ class PixmapDatabase;
/**
@class ListZonesModel
@brief ListZonesModel contains the small images for QListView
@details
@brief ListZonesModel is used for managed list bricks by ListZonesWidget
@details ListZonesModel contains the small images for QListView
*/
class ListZonesModel : public QAbstractListModel
{
@ -55,7 +55,7 @@ public:
/// Value should be set before calling rebuildModel
void setScaleRatio(int scaleRatio);
/// Unload all images and reset model
/// Delete all small images and reset model
void resetModel();
/// Set current list zones which will be available in QListView

View file

@ -1,5 +1,4 @@
// 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
@ -45,16 +44,16 @@ public:
void updateUi();
// Set zone builder, call this method before using this class
/// Set zone builder, call this method before using this class
void setZoneBuilder(ZoneBuilder *zoneBuilder);
// Get current zone name which user selected from list.
/// Get current zone name which user selected from list.
QString currentZoneName();
// Get current rotation value which user selected (Rot 0-0deg, 1-90deg, 2-180deg, 3-270deg).
/// Get current rotation value which user selected (Rot 0-0deg, 1-90deg, 2-180deg, 3-270deg).
int currentRot();
// Get current flip value which user selected (Flip 0-false, 1-true).
/// Get current flip value which user selected (Flip 0-false, 1-true).
int currentFlip();
bool isNotPropogate() const;

View file

@ -39,6 +39,7 @@ PixmapDatabase::PixmapDatabase(int textureSize)
: m_textureSize(textureSize),
m_errorPixmap(0)
{
// Create pixmap for case if pixmap and LIGO files not found
m_errorPixmap = new QPixmap(QSize(m_textureSize, m_textureSize));
QPainter painter(m_errorPixmap);
painter.setRenderHint(QPainter::Antialiasing, true);
@ -46,7 +47,7 @@ PixmapDatabase::PixmapDatabase(int textureSize)
painter.setFont(QFont("Helvetica [Cronyx]", 14));
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
painter.drawText(m_errorPixmap->rect(), Qt::AlignCenter | Qt::TextWordWrap,
QObject::tr("Pixmap and LIGO files not found. Set the correct data path and reload landscape."));
QObject::tr("Pixmap and LIGO files not found."));
painter.end();
}
@ -84,7 +85,7 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon
QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png");
if (pixmap->isNull())
{
// Generate filled pixmap
// Generate filled pixmap if could not load pixmap
QPixmap *emptyPixmap = new QPixmap(QSize(sizeX * m_textureSize, sizeY * m_textureSize));
QPainter painter(emptyPixmap);
painter.setRenderHint(QPainter::Antialiasing, true);

View file

@ -52,7 +52,8 @@ public:
QStringList listPixmaps() const;
/// Get original pixmap
/// @return QPixmap* if the image is in the database ; otherwise returns 0.
/// @return QPixmap* if the image is in the database ;
/// otherwise returns pixmap which contains error message.
QPixmap *pixmap(const QString &zoneName) const;
int textureSize() const;

View file

@ -1,5 +1,4 @@
// 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

View file

@ -1,5 +1,4 @@
// 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

View file

@ -1,5 +1,4 @@
// 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

View file

@ -1,5 +1,4 @@
// 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
@ -40,9 +39,6 @@ public:
int widthSnapshot() const;
int heightSnapshot() const;
private Q_SLOTS:
private:
Ui::SnapshotDialog m_ui;

View file

@ -28,8 +28,6 @@
// STL includes
#include <string>
// Qt includes
namespace LandscapeEditor
{
@ -80,7 +78,7 @@ struct LigoData
/**
@class ZoneRegionObject
@brief
@brief The class contains NLLIGO::CZoneRegion object and provides basic operations above it
@details
*/
class LANDSCAPE_EDITOR_EXPORT ZoneRegionObject
@ -115,7 +113,7 @@ public:
/// Check position, it belongs to the landscape
bool checkPos(const sint32 x, const sint32 y);
/// Helper flag to know if a ps has been modified
/// Helper flag to know if the zone region has been modified
/// @{
bool isModified() const;