Skip to content

Commit

Permalink
Implemented copying properties from selected object in case of adding…
Browse files Browse the repository at this point in the history
… new custom object.
  • Loading branch information
mamontov-cpp committed Sep 17, 2015
1 parent dcea966 commit 2c28cc1
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 73 deletions.
121 changes: 55 additions & 66 deletions plugins/ifaceed/ifaceed/gui/customobjectactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,39 +183,7 @@ void gui::CustomObjectActions::add()

void gui::CustomObjectActions::addBySimplePlacing()
{
sad::db::custom::Object* object = new sad::db::custom::Object();
object->setTreeName(sad::Renderer::ref(), "");
object->setSchemaName(m_panel->UI()->rtwCustomObjectSchemas->selectedResourceName().value());
sad::AColor acolor;
core::typeconverters::QColorToSadAColor::convert(m_panel->UI()->clpSceneNodeColor->selectedColor(), acolor);
object->setColor(acolor);
object->setFontSize(m_panel->UI()->fswLabelFontSize->value());
object->setLineSpacingRatio(m_panel->UI()->dsbLineSpacingRatio->value());
object->setString(Q2STDSTRING(m_panel->UI()->txtLabelText->toPlainText()));

object->setMaximalLineWidth(m_panel->UI()->spbMaximalLineWidth->value());
object->setBreakTextFromIndex(m_panel->UI()->cmbLabelBreakText->currentIndex());
object->setOverflowStrategyFromIndex(m_panel->UI()->cmbLabelOverflowStrategy->currentIndex());
object->setTextEllipsisPositionAsIndex(m_panel->UI()->cmbLabelTextEllipsis->currentIndex());

object->setMaximalLinesCount(m_panel->UI()->spbMaximalLinesCount->value());
object->setOverflowStrategyForLinesFromIndex(m_panel->UI()->cmbLabelOverflowStrategyForLines->currentIndex());
object->setTextEllipsisPositionForLinesAsIndex(m_panel->UI()->cmbLabelTextEllipsisForLines->currentIndex());


sad::Rect2D area = object->area();
const sad::Settings & settings = sad::Renderer::ref()->settings();

sad::Point2D middle = (area[0] + area[2]) / 2.0;
sad::Point2D screeenmiddle = sad::Point2D(settings.width() / 2.0, settings.height() / 2.0);
sad::moveBy(screeenmiddle - middle, area);
object->setArea(area);

QString name = m_panel->UI()->txtObjectName->text();
if (name.length())
{
object->setObjectName(Q2STDSTRING(name));
}
sad::db::custom::Object* object = this->makeNewCustomObject();

m_panel->currentScene()->add(object);
m_panel->editor()->shared()->setActiveObject(object);
Expand All @@ -231,39 +199,7 @@ void gui::CustomObjectActions::addBySimplePlacing()

void gui::CustomObjectActions::addByDiagonalPlacing()
{
sad::db::custom::Object* object = new sad::db::custom::Object();
object->setTreeName(sad::Renderer::ref(), "");
object->setSchemaName(m_panel->UI()->rtwCustomObjectSchemas->selectedResourceName().value());
sad::AColor acolor;
core::typeconverters::QColorToSadAColor::convert(m_panel->UI()->clpSceneNodeColor->selectedColor(), acolor);
object->setColor(acolor);
object->setFontSize(m_panel->UI()->fswLabelFontSize->value());
object->setLineSpacingRatio(m_panel->UI()->dsbLineSpacingRatio->value());
object->setString(Q2STDSTRING(m_panel->UI()->txtLabelText->toPlainText()));

object->setMaximalLineWidth(m_panel->UI()->spbMaximalLineWidth->value());
object->setBreakTextFromIndex(m_panel->UI()->cmbLabelBreakText->currentIndex());
object->setOverflowStrategyFromIndex(m_panel->UI()->cmbLabelOverflowStrategy->currentIndex());
object->setTextEllipsisPositionAsIndex(m_panel->UI()->cmbLabelTextEllipsis->currentIndex());

object->setMaximalLinesCount(m_panel->UI()->spbMaximalLinesCount->value());
object->setOverflowStrategyForLinesFromIndex(m_panel->UI()->cmbLabelOverflowStrategyForLines->currentIndex());
object->setTextEllipsisPositionForLinesAsIndex(m_panel->UI()->cmbLabelTextEllipsisForLines->currentIndex());

sad::Rect2D area = object->area();
const sad::Settings & settings = sad::Renderer::ref()->settings();

sad::Point2D middle = (area[0] + area[2]) / 2.0;
sad::Point2D screeenmiddle = sad::Point2D(settings.width() / 2.0, settings.height() / 2.0);
sad::moveBy(screeenmiddle - middle, area);
object->setArea(area);

QString name = m_panel->UI()->txtObjectName->text();
if (name.length())
{
object->setObjectName(Q2STDSTRING(name));
}

sad::db::custom::Object* object = this->makeNewCustomObject();
object->setVisible(false);

m_panel->currentScene()->add(object);
Expand Down Expand Up @@ -310,3 +246,56 @@ void gui::CustomObjectActions::schemaChanged(sad::String s)
}
}
}

sad::db::custom::Object* gui::CustomObjectActions::makeNewCustomObject()
{
sad::db::custom::Object* object = new sad::db::custom::Object();
object->setTreeName(sad::Renderer::ref(), "");
object->setSchemaName(m_panel->UI()->rtwCustomObjectSchemas->selectedResourceName().value());
sad::AColor acolor;
core::typeconverters::QColorToSadAColor::convert(m_panel->UI()->clpSceneNodeColor->selectedColor(), acolor);
object->setColor(acolor);
object->setFontSize(m_panel->UI()->fswLabelFontSize->value());
object->setLineSpacingRatio(m_panel->UI()->dsbLineSpacingRatio->value());
object->setString(Q2STDSTRING(m_panel->UI()->txtLabelText->toPlainText()));

object->setMaximalLineWidth(m_panel->UI()->spbMaximalLineWidth->value());
object->setBreakTextFromIndex(m_panel->UI()->cmbLabelBreakText->currentIndex());
object->setOverflowStrategyFromIndex(m_panel->UI()->cmbLabelOverflowStrategy->currentIndex());
object->setTextEllipsisPositionAsIndex(m_panel->UI()->cmbLabelTextEllipsis->currentIndex());

object->setMaximalLinesCount(m_panel->UI()->spbMaximalLinesCount->value());
object->setOverflowStrategyForLinesFromIndex(m_panel->UI()->cmbLabelOverflowStrategyForLines->currentIndex());
object->setTextEllipsisPositionForLinesAsIndex(m_panel->UI()->cmbLabelTextEllipsisForLines->currentIndex());
tryCopySelectedObjectCustomProperties(object);
sad::Rect2D area = object->area();
const sad::Settings & settings = sad::Renderer::ref()->settings();

sad::Point2D middle = (area[0] + area[2]) / 2.0;
sad::Point2D screeenmiddle = sad::Point2D(settings.width() / 2.0, settings.height() / 2.0);
sad::moveBy(screeenmiddle - middle, area);
object->setArea(area);

QString name = m_panel->UI()->txtObjectName->text();
if (name.length())
{
object->setObjectName(Q2STDSTRING(name));
}
return object;
}

void gui::CustomObjectActions::tryCopySelectedObjectCustomProperties(sad::db::custom::Object* object)
{
sad::SceneNode* node = m_panel->editor()->shared()->selectedObject();
if (node)
{
if (node->isInstanceOf("sad::db::custom::Object"))
{
sad::db::custom::Object* selected_object = static_cast<sad::db::custom::Object*>(node);
if (selected_object->schemaName() == object->schemaName())
{
object->copyCustomPropertyValuesFrom(selected_object);
}
}
}
}
25 changes: 25 additions & 0 deletions plugins/ifaceed/ifaceed/gui/customobjectactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@

class MainPanel;

namespace sad
{

namespace db
{

namespace custom
{

class Object;

}

}

}

namespace gui
{
/*! A group of actions, linked to custom objects
Expand Down Expand Up @@ -65,6 +82,14 @@ public slots:
*/
void schemaChanged(sad::String s);
private:
/*! Makes new custom object
\return new custom object
*/
sad::db::custom::Object* makeNewCustomObject();
/*! Try copy custom properties for selected object
\param[in] object an object values
*/
void tryCopySelectedObjectCustomProperties(sad::db::custom::Object* object);
/*! An panel, which actions are belong to
*/
MainPanel* m_panel;
Expand Down
3 changes: 3 additions & 0 deletions plugins/ifaceed/ifaceed/ifaceed.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,9 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugQt4|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='GUITests|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='UnitTests|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="GeneratedFiles\ReleaseQt4\moc_delegate.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugQt4|Win32'">true</ExcludedFromBuild>
Expand Down
14 changes: 7 additions & 7 deletions plugins/ifaceed/ifaceed/ifaceed.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<QTDIR>D:\SDKs\Qt-4.8.6-msvc2010</QTDIR>
<QTDIR>E:\SDKs\Qt5.4.1-MSVC-2010\5.4\msvc2010_opengl</QTDIR>
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
<LocalDebuggerWorkingDirectory>../../../bin/ifaceed/</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>-resources globalconfig.json -width 800 -height 600</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugQt4|Win32'">
<QTDIR>D:\SDKs\Qt-4.8.6-msvc2010</QTDIR>
<QTDIR>E:\SDKs\Qt5.4.1-MSVC-2010\5.4\msvc2010_opengl</QTDIR>
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
<LocalDebuggerWorkingDirectory>../../../bin/ifaceed/</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>-resources globalconfig.json -width 800 -height 600</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='GUITests|Win32'">
<QTDIR>D:\SDKs\Qt-4.8.6-msvc2010</QTDIR>
<QTDIR>E:\SDKs\Qt5.4.1-MSVC-2010\5.4\msvc2010_opengl</QTDIR>
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<QTDIR>D:\SDKs\Qt-4.8.6-msvc2010</QTDIR>
<QTDIR>E:\SDKs\Qt5.4.1-MSVC-2010\5.4\msvc2010_opengl</QTDIR>
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
<LocalDebuggerCommandArguments>-resources globalconfig.json -width 800 -height 600</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>../../../bin/ifaceed/</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">
<QTDIR>D:\SDKs\Qt-4.8.6-msvc2010</QTDIR>
<QTDIR>E:\SDKs\Qt5.4.1-MSVC-2010\5.4\msvc2010_opengl</QTDIR>
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='UnitTests|Win32'">
<QTDIR>D:\SDKs\Qt-4.8.6-msvc2010</QTDIR>
<QTDIR>E:\SDKs\Qt5.4.1-MSVC-2010\5.4\msvc2010_opengl</QTDIR>
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseQt4|Win32'">
<QTDIR>D:\SDKs\Qt-4.8.6-msvc2010</QTDIR>
<QTDIR>E:\SDKs\Qt5.4.1-MSVC-2010\5.4\msvc2010_opengl</QTDIR>
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
</PropertyGroup>
</Project>

0 comments on commit 2c28cc1

Please sign in to comment.