git-svn-id: svn://db.shs.com.ru/pip@764 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Variant type
|
||||
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru
|
||||
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -146,6 +146,8 @@ PIVariant::Type PIVariant::typeFromName(const PIString & tname) {
|
||||
if (s == "color") return PIVariant::pivColor;
|
||||
if (s == "point") return PIVariant::pivPoint;
|
||||
if (s == "rect") return PIVariant::pivRect;
|
||||
if (s == "vector") return PIVariant::pivMathVector;
|
||||
if (s == "matrix") return PIVariant::pivMathMatrix;
|
||||
return PIVariant::pivInvalid;
|
||||
}
|
||||
|
||||
@@ -189,6 +191,8 @@ PIString PIVariant::typeName(PIVariant::Type type) {
|
||||
case PIVariant::pivColor: return "Color";
|
||||
case PIVariant::pivPoint: return "Point";
|
||||
case PIVariant::pivRect: return "Rect";
|
||||
case PIVariant::pivMathVector: return "Vector";
|
||||
case PIVariant::pivMathMatrix: return "Matrix";
|
||||
case PIVariant::pivCustom: return "Custom";
|
||||
default: break;
|
||||
}
|
||||
@@ -593,3 +597,24 @@ PIRectd PIVariant::toRect() const {
|
||||
if (_type == PIVariant::pivRect) {PIRectd r; ba >> r; return r;}
|
||||
return PIRectd();
|
||||
}
|
||||
|
||||
|
||||
/** \brief Returns variant content as math vector
|
||||
* \details In case of PIMathVectord type returns rect value. \n
|
||||
* In case of other types returns empty PIMathVectord. */
|
||||
PIMathVectord PIVariant::toMathVector() const {
|
||||
PIByteArray ba(_content);
|
||||
if (_type == PIVariant::pivMathVector) {PIMathVectord r; ba >> r; return r;}
|
||||
return PIMathVectord();
|
||||
}
|
||||
|
||||
|
||||
/** \brief Returns variant content as math matrix
|
||||
* \details In case of PIMathMatrixd type returns rect value. \n
|
||||
* In case of other types returns empty PIMathMatrixd. */
|
||||
PIMathMatrixd PIVariant::toMathMatrix() const {
|
||||
PIByteArray ba(_content);
|
||||
if (_type == PIVariant::pivMathMatrix) {PIMathMatrixd r; ba >> r; return r;}
|
||||
return PIMathMatrixd();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user