tahoma2d/toonz/sources/toonzlib/sandor_fxs/Params.h

82 lines
1.9 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
// Params.h: interface for the CParams class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_PARAMS_H__40D9A921_F329_11D5_B92E_0040F674BE6A__INCLUDED_)
#define AFX_PARAMS_H__40D9A921_F329_11D5_B92E_0040F674BE6A__INCLUDED_
2016-04-15 17:11:23 +12:00
#ifdef _WIN32
#include "windows.h"
2016-03-19 06:57:51 +13:00
#endif
#include <fstream>
#include <vector>
#include "InputParam.h"
#define P(d) tmsg_info(" - %d -\n", d)
template <class EParam>
2016-06-15 18:43:10 +12:00
class CParams {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
std::vector<EParam> m_params;
double m_scale;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
CParams() : m_params(0), m_scale(1.0){};
CParams(const CParams &cp) : m_params(cp.m_params), m_scale(cp.m_scale){};
virtual ~CParams(){};
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
CParams(const CInputParam &ip) : m_scale(ip.m_scale) {
if (ip.m_isEconf) {
// read(ip.m_econfFN);
} else {
m_params.resize(1);
m_params[0].read(ip);
}
}
/*
void print()
2016-03-19 06:57:51 +13:00
{ char s[1024];
2016-06-15 18:43:10 +12:00
int i;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
OutputDebugString("===== PARAMS =====\n");
2020-04-12 17:19:20 +12:00
snprintf(s, sizeof(s), "Scale=%f\n",m_scale);
2016-06-15 18:43:10 +12:00
OutputDebugString(s);
i=0;
for( vector<EParam>::iterator p=m_params.begin();
p!=m_params.end(); ++p,++i ){
2020-04-12 17:19:20 +12:00
snprintf(s, sizeof(s), "--- %d. Param ---\n",i);
2016-06-15 18:43:10 +12:00
OutputDebugString(s);
p->print();
}
OutputDebugString("==================\n");
2016-03-19 06:57:51 +13:00
}
*/
2016-06-15 18:43:10 +12:00
/*
2016-03-19 06:57:51 +13:00
void read(const basic_string<char>& name)
{ basic_ifstream<char> in(name.c_str());
2016-06-15 18:43:10 +12:00
for( bool isOK=true; isOK; ) {
m_params.resize(m_params.size()+1);
vector<EParam>::iterator p=m_params.end();
p--;
isOK=p->read(in);
if ( !isOK )
m_params.resize(m_params.size()-1);
}
in.close();
2016-03-19 06:57:51 +13:00
}
*/
2016-06-15 18:43:10 +12:00
void scale(const double sc) {
for (int i = 0; i < m_params.size(); ++i) m_params[i]->scale(sc);
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void scale() {
for (int i = 0; i < m_params.size(); ++i) m_params[i]->scale(m_scale);
}
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // !defined(AFX_PARAMS_H__40D9A921_F329_11D5_B92E_0040F674BE6A__INCLUDED_)