mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add scripting support for Mat4d
This commit is contained in:
parent
925dae6f26
commit
e8bfeded0a
@ -80,3 +80,53 @@ void PdmFieldScriptingCapabilityIOHandler<cvf::Vector3<double>>::readFromField(
|
||||
|
||||
PdmFieldScriptingCapabilityIOHandler<std::vector<double>>::readFromField( fieldVectorValue, outputStream, quoteStrings );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmFieldScriptingCapabilityIOHandler<cvf::Matrix4<double>>::writeToField( cvf::Matrix4<double>& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted )
|
||||
{
|
||||
std::vector<double> fieldVectorValue;
|
||||
PdmFieldScriptingCapabilityIOHandler<std::vector<double>>::writeToField( fieldVectorValue,
|
||||
inputStream,
|
||||
errorMessageContainer,
|
||||
stringsAreQuoted );
|
||||
if ( fieldVectorValue.size() == 16u )
|
||||
{
|
||||
for ( int row = 0; row < 4; ++row )
|
||||
{
|
||||
for ( int col = 0; col < 4; ++col )
|
||||
{
|
||||
fieldValue( row, col ) = fieldVectorValue[row * 4 + col];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QString errMsg = QString( "Expected 16 values, got %1" ).arg( fieldVectorValue.size() );
|
||||
errorMessageContainer->addError( errMsg );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmFieldScriptingCapabilityIOHandler<cvf::Matrix4<double>>::readFromField( const cvf::Matrix4<double>& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings,
|
||||
bool quoteNonBuiltin )
|
||||
{
|
||||
std::vector<double> fieldVectorValue( 16u );
|
||||
for ( int row = 0; row < 4; ++row )
|
||||
{
|
||||
for ( int col = 0; col < 4; ++col )
|
||||
{
|
||||
fieldVectorValue[row * 4 + col] = fieldValue( row, col );
|
||||
}
|
||||
}
|
||||
|
||||
PdmFieldScriptingCapabilityIOHandler<std::vector<double>>::readFromField( fieldVectorValue, outputStream, quoteStrings );
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
namespace caf
|
||||
@ -53,4 +54,18 @@ struct PdmFieldScriptingCapabilityIOHandler<cvf::Vector3<double>>
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false );
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PdmFieldScriptingCapabilityIOHandler<cvf::Matrix4<double>>
|
||||
{
|
||||
static void writeToField( cvf::Matrix4<double>& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true );
|
||||
static void readFromField( const cvf::Matrix4<double>& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false );
|
||||
};
|
||||
|
||||
} // namespace caf
|
||||
|
@ -560,6 +560,7 @@ QString PdmPythonGenerator::dataTypeString( const PdmFieldHandle* field, bool us
|
||||
#ifndef CAF_EXCLUDE_CVF
|
||||
builtins[QString::fromStdString( typeid( cvf::Vec3d ).name() )] = "List[float]";
|
||||
builtins[QString::fromStdString( typeid( cvf::Color3f ).name() )] = "str";
|
||||
builtins[QString::fromStdString( typeid( cvf::Mat4d ).name() )] = "List[float]";
|
||||
#endif
|
||||
|
||||
bool foundBuiltin = false;
|
||||
|
Loading…
Reference in New Issue
Block a user