mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-23 15:26:16 +00:00
Changed: #1302 When create zone or path initially has minimal 3 points and path 2 points resp.
This commit is contained in:
parent
2650b86ca8
commit
2ccc79a591
6 changed files with 64 additions and 15 deletions
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
#include <QGraphicsView>
|
||||||
#include <QPersistentModelIndex>
|
#include <QPersistentModelIndex>
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
|
@ -365,6 +366,13 @@ AddPrimitiveByClassCommand::AddPrimitiveByClassCommand(const QString &className,
|
||||||
m_model(model)
|
m_model(model)
|
||||||
{
|
{
|
||||||
setText(QString("Add %1").arg(m_className));
|
setText(QString("Add %1").arg(m_className));
|
||||||
|
|
||||||
|
QGraphicsView *view = m_scene->views().first();
|
||||||
|
|
||||||
|
// TODO: returns incorrect position when zoom in
|
||||||
|
QRectF visibleArea = view->mapToScene(view->rect()).boundingRect();
|
||||||
|
m_delta = visibleArea.height() / 10.0;
|
||||||
|
m_initPos = visibleArea.center();
|
||||||
}
|
}
|
||||||
|
|
||||||
AddPrimitiveByClassCommand::~AddPrimitiveByClassCommand()
|
AddPrimitiveByClassCommand::~AddPrimitiveByClassCommand()
|
||||||
|
@ -381,6 +389,8 @@ void AddPrimitiveByClassCommand::undo()
|
||||||
// set the primitive context
|
// set the primitive context
|
||||||
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = node->rootPrimitiveNode()->primitives();
|
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = node->rootPrimitiveNode()->primitives();
|
||||||
|
|
||||||
|
removeGraphicsItems(index, m_model, m_scene);
|
||||||
|
|
||||||
Utils::deletePrimitive(node->primitive());
|
Utils::deletePrimitive(node->primitive());
|
||||||
|
|
||||||
// unset the context
|
// unset the context
|
||||||
|
@ -397,7 +407,6 @@ void AddPrimitiveByClassCommand::redo()
|
||||||
PrimitiveNode *parentNode = static_cast<PrimitiveNode *>(parentIndex.internalPointer());
|
PrimitiveNode *parentNode = static_cast<PrimitiveNode *>(parentIndex.internalPointer());
|
||||||
const NLLIGO::CPrimitiveClass *primClass = parentNode->primitiveClass();
|
const NLLIGO::CPrimitiveClass *primClass = parentNode->primitiveClass();
|
||||||
|
|
||||||
float delta = 10;
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
while (primClass->DynamicChildren[id].ClassName != m_className.toStdString())
|
while (primClass->DynamicChildren[id].ClassName != m_className.toStdString())
|
||||||
++id;
|
++id;
|
||||||
|
@ -407,12 +416,14 @@ void AddPrimitiveByClassCommand::redo()
|
||||||
|
|
||||||
QString namePrimititve = QString("%1_%2").arg(m_className).arg(parentNode->childCount());
|
QString namePrimititve = QString("%1_%2").arg(m_className).arg(parentNode->childCount());
|
||||||
NLLIGO::IPrimitive *newPrimitive = Utils::createPrimitive(m_className.toStdString().c_str(), namePrimititve.toStdString().c_str(),
|
NLLIGO::IPrimitive *newPrimitive = Utils::createPrimitive(m_className.toStdString().c_str(), namePrimititve.toStdString().c_str(),
|
||||||
NLMISC::CVector(), delta, primClass->DynamicChildren[id].Parameters, parentNode->primitive());
|
NLMISC::CVector(m_initPos.x(), -m_initPos.y(), 0.0), m_delta, primClass->DynamicChildren[id].Parameters, parentNode->primitive());
|
||||||
|
|
||||||
// unset the context
|
// unset the context
|
||||||
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL;
|
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL;
|
||||||
|
|
||||||
m_newPrimIndex = m_model->createPrimitiveNode(newPrimitive, m_parentIndex);
|
m_newPrimIndex = m_model->createPrimitiveNode(newPrimitive, m_parentIndex);
|
||||||
|
|
||||||
|
addNewGraphicsItems(m_model->pathToIndex(m_newPrimIndex), m_model, m_scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveWorldItemsCommand::MoveWorldItemsCommand(const QList<QGraphicsItem *> &items, const QPointF &offset,
|
MoveWorldItemsCommand::MoveWorldItemsCommand(const QList<QGraphicsItem *> &items, const QPointF &offset,
|
||||||
|
@ -471,7 +482,7 @@ RotateWorldItemsCommand::RotateWorldItemsCommand(const QList<QGraphicsItem *> &i
|
||||||
m_scene(scene),
|
m_scene(scene),
|
||||||
m_firstRun(true)
|
m_firstRun(true)
|
||||||
{
|
{
|
||||||
setText(QString("Rotate item(s) %1").arg(m_angle));
|
setText("Rotate item(s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
RotateWorldItemsCommand::~RotateWorldItemsCommand()
|
RotateWorldItemsCommand::~RotateWorldItemsCommand()
|
||||||
|
@ -565,7 +576,7 @@ TurnWorldItemsCommand::TurnWorldItemsCommand(const QList<QGraphicsItem *> &items
|
||||||
m_scene(scene),
|
m_scene(scene),
|
||||||
m_firstRun(true)
|
m_firstRun(true)
|
||||||
{
|
{
|
||||||
setText(QString("Turn item(s) %1").arg(m_angle));
|
setText("Turn item(s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TurnWorldItemsCommand::~TurnWorldItemsCommand()
|
TurnWorldItemsCommand::~TurnWorldItemsCommand()
|
||||||
|
|
|
@ -147,6 +147,8 @@ public:
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
QPointF m_initPos;
|
||||||
|
float m_delta;
|
||||||
const QString m_className;
|
const QString m_className;
|
||||||
Path m_parentIndex, m_newPrimIndex;
|
Path m_parentIndex, m_newPrimIndex;
|
||||||
WorldEditorScene *m_scene;
|
WorldEditorScene *m_scene;
|
||||||
|
|
|
@ -365,11 +365,25 @@ NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NLLIGO::CPrimitiveClass::Path:
|
case NLLIGO::CPrimitiveClass::Path:
|
||||||
primitive = new NLLIGO::CPrimPath;
|
{
|
||||||
|
NLLIGO::CPrimPath *path = new NLLIGO::CPrimPath;
|
||||||
|
primitive = path;
|
||||||
|
path->VPoints.push_back(NLLIGO::CPrimVector(initPos));
|
||||||
|
NLMISC::CVector secondPos = NLMISC::CVector(initPos.x + deltaPos, initPos.y, 0.0);
|
||||||
|
path->VPoints.push_back(NLLIGO::CPrimVector(secondPos));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case NLLIGO::CPrimitiveClass::Zone:
|
case NLLIGO::CPrimitiveClass::Zone:
|
||||||
primitive = new NLLIGO::CPrimZone;
|
{
|
||||||
|
NLLIGO::CPrimZone *zone = new NLLIGO::CPrimZone;
|
||||||
|
primitive = zone;
|
||||||
|
zone->VPoints.push_back(NLLIGO::CPrimVector(initPos));
|
||||||
|
NLMISC::CVector secondPos = NLMISC::CVector(initPos.x + deltaPos, initPos.y, 0.0);
|
||||||
|
zone->VPoints.push_back(NLLIGO::CPrimVector(secondPos));
|
||||||
|
secondPos.y = initPos.y + deltaPos;
|
||||||
|
zone->VPoints.push_back(NLLIGO::CPrimVector(secondPos));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case NLLIGO::CPrimitiveClass::Alias:
|
case NLLIGO::CPrimitiveClass::Alias:
|
||||||
primitive = new NLLIGO::CPrimAlias;
|
primitive = new NLLIGO::CPrimAlias;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -187,7 +187,7 @@ void WorldItemPoint::createCircle()
|
||||||
if (m_radius != 0)
|
if (m_radius != 0)
|
||||||
{
|
{
|
||||||
// Create circle
|
// Create circle
|
||||||
int segmentCount = 30;
|
int segmentCount = 20;
|
||||||
QPointF circlePoint(m_radius, 0);
|
QPointF circlePoint(m_radius, 0);
|
||||||
m_circle << circlePoint;
|
m_circle << circlePoint;
|
||||||
for (int i = 1; i < segmentCount + 1; ++i)
|
for (int i = 1; i < segmentCount + 1; ++i)
|
||||||
|
@ -241,9 +241,13 @@ void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
// if (option->state & QStyle::State_Selected)
|
// if (option->state & QStyle::State_Selected)
|
||||||
if (isActived())
|
if (isActived())
|
||||||
|
{
|
||||||
painter->setBrush(m_selectedBrush);
|
painter->setBrush(m_selectedBrush);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
painter->setBrush(m_brush);
|
painter->setBrush(m_brush);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw point
|
// Draw point
|
||||||
painter->drawRect(m_rect);
|
painter->drawRect(m_rect);
|
||||||
|
|
|
@ -129,7 +129,7 @@ private:
|
||||||
void createCircle();
|
void createCircle();
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
|
|
||||||
static const int SIZE_POINT = 3;
|
static const int SIZE_POINT = 2;
|
||||||
|
|
||||||
QPen m_pen, m_selectedPen;
|
QPen m_pen, m_selectedPen;
|
||||||
QBrush m_brush, m_selectedBrush;
|
QBrush m_brush, m_selectedBrush;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>819</width>
|
||||||
<height>600</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -121,8 +121,9 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<addaction name="visibleLandAction"/>
|
<addaction name="visibleLandAction"/>
|
||||||
<addaction name="visiblePrimitivesAction"/>
|
<addaction name="visibleZonePrimitivesAction"/>
|
||||||
<addaction name="visibleLayersAction"/>
|
<addaction name="visiblePathPrimitivesAction"/>
|
||||||
|
<addaction name="vidiblePointPrimitives"/>
|
||||||
<addaction name="visibleDetailsAction"/>
|
<addaction name="visibleDetailsAction"/>
|
||||||
<addaction name="visibleGridAction"/>
|
<addaction name="visibleGridAction"/>
|
||||||
<addaction name="visibleGridPointsAction"/>
|
<addaction name="visibleGridPointsAction"/>
|
||||||
|
@ -177,7 +178,7 @@
|
||||||
<string>S/H Land</string>
|
<string>S/H Land</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="visiblePrimitivesAction">
|
<action name="visibleZonePrimitivesAction">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -185,10 +186,13 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>S/H Primitives</string>
|
<string>S/H Zone primitives</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>S/H Zone Primitives</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="visibleLayersAction">
|
<action name="visiblePathPrimitivesAction">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -196,7 +200,7 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>S/H Layers</string>
|
<string>S/H Path primitives</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="visibleDetailsAction">
|
<action name="visibleDetailsAction">
|
||||||
|
@ -343,6 +347,20 @@
|
||||||
<string>Project settings</string>
|
<string>Project settings</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="vidiblePointPrimitives">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>S/H Points primitives</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>S/H Points primitives</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
Loading…
Reference in a new issue