Skip to content
Permalink
Browse files

Extend Object interface of plugin interface to include a dedicated me…

…thod to easily return the datatypes PT_INTPAIRLIST and PT_UINTPAIRLIST
  • Loading branch information...
sodevel committed Mar 23, 2019
1 parent a580ef0 commit 4bbedbc9c83c60f323893beb0202bc6246f35c2b
Showing with 24 additions and 1 deletion.
  1. +4 −0 sdk/plugin_interface/component.h
  2. +19 −1 src/model/objectbase.cpp
  3. +1 −0 src/model/objectbase.h
@@ -26,6 +26,9 @@
#pragma once


#include <vector>
#include <utility>

#include "wx/wx.h"
#include "fontcontainer.h"

@@ -72,6 +75,7 @@ class IObject
virtual wxBitmap GetPropertyAsBitmap (const wxString& pname) = 0;
virtual wxArrayInt GetPropertyAsArrayInt(const wxString& pname) = 0;
virtual wxArrayString GetPropertyAsArrayString(const wxString& pname) = 0;
virtual std::vector<std::pair<int, int>> GetPropertyAsVectorIntPair(const wxString& pname) = 0;
virtual double GetPropertyAsFloat(const wxString& pname) = 0;
virtual wxString GetChildFromParentProperty( const wxString& parentName, const wxString& childName ) = 0;
virtual wxString GetClassName() = 0;
@@ -725,7 +725,7 @@ wxArrayInt ObjectBase::GetPropertyAsArrayInt(const wxString& pname)
PProperty property = GetProperty( pname );
if (property)
{
IntList il( property->GetValue(), property->GetType() == PT_UINTLIST );
IntList il(property->GetValue(), property->GetType() == PT_UINTLIST, (property->GetType() == PT_INTPAIRLIST || property->GetType() == PT_UINTPAIRLIST));
for (unsigned int i=0; i < il.GetSize() ; i++)
array.Add(il.GetValue(i));
}
@@ -742,6 +742,24 @@ wxArrayString ObjectBase::GetPropertyAsArrayString(const wxString& pname)
return wxArrayString();
}

std::vector<std::pair<int, int>> ObjectBase::GetPropertyAsVectorIntPair(const wxString& pname)
{
std::vector<std::pair<int, int>> result;

auto property = GetProperty(pname);
if (property)
{
IntList il(property->GetValue(), property->GetType() == PT_UINTLIST, (property->GetType() == PT_INTPAIRLIST || property->GetType() == PT_UINTPAIRLIST));
result.reserve(il.GetSize());
for (unsigned int i = 0; i < il.GetSize(); ++i)
{
result.emplace_back(il.GetPair(i));
}
}

return result;
}

wxString ObjectBase::GetChildFromParentProperty( const wxString& parentName, const wxString& childName )
{
PProperty property = GetProperty( parentName );
@@ -530,6 +530,7 @@ class ObjectBase : public IObject, public std::enable_shared_from_this<ObjectBas

wxArrayInt GetPropertyAsArrayInt(const wxString& pname) override;
wxArrayString GetPropertyAsArrayString(const wxString& pname) override;
std::vector<std::pair<int, int>> GetPropertyAsVectorIntPair(const wxString& pname) override;
wxString GetChildFromParentProperty(const wxString& parentName,
const wxString& childName) override;

0 comments on commit 4bbedbc

Please sign in to comment.
You can’t perform that action at this time.