123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
- /*
- * resource.cc
- * Copyright (C) 2016 Fran??ois Gautrais <francois@gautrais.eu>
- *
- * histodex is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * histodex is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include "resource.h"
- #include <cassert>
- Resource::Resource() : Data()
- {
- m_data_type=DATA_TYPE_RESOURCE;
- m_scale = Number3d(1,1,1);
- m_stage=0;
- m_type="3D";
- }
- Resource::Resource(Json::Value v) : Data(v)
- {
- m_data_type=DATA_TYPE_RESOURCE;
- set(v);
- }
- Resource::~Resource()
- {
- }
- const std::string& Resource::getName()
- {
- return m_name;
- }
- const std::string& Resource::getComments()
- {
- return m_comments;
- }
- const std::string& Resource::getType()
- {
- return m_type;
- }
- Number3d Resource::getPosition()
- {
- return m_position;
- }
- Number3d Resource::getRotation()
- {
- return m_rotation;
- }
- Number3d Resource::getScale()
- {
- return m_scale;
- }
- int Resource::getStage()
- {
- return m_stage;
- }
- void Resource::setName(const std::string& n)
- {
- m_name=n;
- }
- void Resource::setComments(const std::string& n)
- {
- m_comments=n;
- }
- void Resource::setType(const std::string& n)
- {
- m_type=n;
- }
- void Resource::setPosition(const Number3d& n)
- {
- m_position=n;
- }
- void Resource::setRotation(const Number3d& n)
- {
- m_rotation=n;
- }
-
- void Resource::setScale(const Number3d& n)
- {
- m_scale=n;
- }
- void Resource::setStage(int n)
- {
- m_stage=n;
- }
- const Resource& Resource::operator=(const Resource& a)
- {
- m_name=a.m_name;
- m_title=a.m_title;
- m_comments=a.m_comments;
- m_position=a.m_position;
- m_rotation=a.m_rotation;
- m_scale=a.m_scale;
- m_type=a.m_type;
- m_file=a.m_file;
- m_stage=a.m_stage;
- return a;
- }
- Json::Value Resource::getJson(bool genFinal)
- {
- Json::Value v(Json::objectValue);
- v["name"] = m_name;
- v["stage"] = m_stage;
- v["title"] = m_title;
- v["comment"]= m_comments;
- v["position"]= m_position.getJson();
- v["rotation"]= m_rotation.getJson();
- v["scale"]= m_scale.getJson();
- v["type"] = m_type;
- if(!genFinal) v["file"] = m_file;
- return v;
- }
- Resource& Resource::cast(Data& d)
- {
- if(d.getDataType ()!=DATA_TYPE_RESOURCE)
- assert(0);
- return (Resource&)d;
- }
- void Resource::set(Json::Value& v)
- {
- m_name = v["name"].asString();
- m_stage = v["stage"].asInt();
- m_title = v["title"].asString();
- m_comments = v["comment"].asString();
- m_position = Number3d(v["position"]);
- m_rotation = Number3d(v["rotation"]);
- m_scale = Number3d(v["scale"]);
- m_type = v["type"].asString();
- m_file = v["file"].asString();
- }
|