Перечисленные изменения должны повысить интерес к программному средству и его полезность для разных групп пользователей.
Список использованных источников
1) Бьёрн Страуструп Дизайн и эволюция языка C++ – М.: ДМК пресс, 2006. – 448с.
2) Ефремова О.С. Требования охраны труда при работе на персональных электронно-вычислительных машинах (ПК) – М.: Альфа-пресс, 2005. – 150с.
4) Санитарные нормы для образовательных учреждений . – 5-е изд., доп. – М.: Образование в документах, 2002. – 200с.
5) Замбржицкий О.Н. Гигиеническая оценка естественного и искусственного освещения помещений. – Мн.: БГМУ, 2005. – 18 с.
6) СанПиН N 9-131 РБ 2000 Гигиенические требования к видеодисплейным терминалам (ВДТ), электронно-вычислительным машинам (ЭВМ) и организации работы
7) Косилина Н.И., Колтановского А.П. Производственная гимнастика для работников умственного труда – М.: Физкультура и спорт, 1983.
8) Кляуззе В.П. Безопасность & компьютер. – Мн.: В.П.Кляуззе, 2001. – 155с.
Приложение А
(обязательное)
Текст программного модуля обработки частиц
//ParticleSystemChain.cpp (очередьэмиттеров)
#include "ParticleSystemChain.h"
#include "PSOutputFrame.h"//just for using canvas to get current reflecting mode ang zoom
#define BLEND_SRC "blend_src"
#define BLEND_DST "blend_dst"
#define ITEM_SELECTED "item_selected"
#define PSBOUND_SELECTED_COLOR wxColour(200, 200, 200, 255)
#define PSBOUNS_CHOOSED_COLOR wxColour(70, 70, 70, 255)
#define PSBOUND_COLOR wxColour(50, 50, 50, 255)
#define MIN_RUN_PSCHAIN_ITEM_DIMENSION 20
ParticleSystemChain *ParticleSystemChain::singletonChain = NULL;
ParticleSystemChain* ParticleSystemChain::Master()
{
if(!singletonChain)
singletonChain = new ParticleSystemChain();
return singletonChain;
}
void ParticleSystemChain::CleanSingleton()
{
if(singletonChain)
{
delete singletonChain;
singletonChain = NULL;
}
}
int ParticleSystemChain::AddSystem()
{
ParticleSystem* ps = new ParticleSystem();
all_ps.push_back(ps);
if(workMode != ParticleSystemChainWorkMode_STATIC)
ps->start();
int new_ps_layer = (int)all_ps.size() - 1;
if(selectedSystemLayer < 0)
selectedSystemLayer = new_ps_layer;
return new_ps_layer;
}
bool ParticleSystemChain::RemoveSystemAtLayer(int layer)
{
if( (layer < 0) || (layer >= (int)all_ps.size()) )
return false;
delete all_ps.at(layer);
all_ps.erase(all_ps.begin() + layer);
if(layer == choosedSystemLayer)
choosedSystemLayer = -1;
if(all_ps.size() == 0)
selectedSystemLayer = -1;
else
if(selectedSystemLayer >= layer && selectedSystemLayer > 0)
selectedSystemLayer--;
return true;
}
void ParticleSystemChain::RemoveAll()
{
vector<ParticleSystem*>::iterator iter = all_ps.begin();
while(iter != all_ps.end())
{
delete((ParticleSystem*)*iter);
++iter;
}
all_ps.clear();
selectedSystemLayer = choosedSystemLayer = -1;
}
void ParticleSystemChain::MoveSystem(int from, int to)
{
int numof_systems = (int)all_ps.size();
if( (from == to) || (from < 0) || (from >= numof_systems) || (to < 0) || (to >= numof_systems) )
return;
ParticleSystem *tmp_ps_ptr = all_ps.at(from);
all_ps.erase(all_ps.begin() + from);
all_ps.insert(all_ps.begin() + to, tmp_ps_ptr);
}
void ParticleSystemChain::CopySystemsData(int layer_from, int layer_to)
{
int numof_systems = (int)all_ps.size();
if(layer_from == layer_to || layer_from < 0 || layer_from >= numof_systems || layer_to < 0 || layer_to >= numof_systems )
return;
all_ps.at(layer_to)->copyDataFromParticleSystem(all_ps.at(layer_from));
}
bool ParticleSystemChain::Save(TiXmlElement* root) const
{
TiXmlElement tmp("BLENDING");
TiXmlElement *caption = (TiXmlElement*)root->InsertEndChild(tmp);
if(!caption)
return false;
caption->SetAttribute(BLEND_SRC, blendModeSrc);
caption->SetAttribute(BLEND_DST, blendModeDst);
return saveSystems(root);
}
bool ParticleSystemChain::Load(TiXmlElement *root)
{
TiXmlElement *blending_attrs_ptr = (TiXmlElement*)root->FirstChild("BLENDING");
if(!blending_attrs_ptr)//old version file (1.0), just set defaults
{
blendModeSrc = GL_ONE;
blendModeDst = GL_ONE_MINUS_SRC_ALPHA;
}
else
{
blending_attrs_ptr->Attribute(BLEND_SRC, &blendModeSrc);
blending_attrs_ptr->Attribute(BLEND_DST, &blendModeDst);
}
return loadSystems(root);
}
ParticleSystemOutputCoordCharacter ParticleSystemChain::AnalyseOutputCoords(MYPoint2D point) const
{
ParticleSystemOutputCoordCharacter res;
res.psLayer = -1;
res.isLeft = res.isRight = res.isTop = res.isBottom = false;
//first find selecting system layer
vector<ParticleSystem*>::const_iterator iter = all_ps.end();
vector<ParticleSystem*>::const_iterator begin_iter = all_ps.begin();
size_t i = all_ps.size();
wxRect system_rect, tmp_rect;
bool chain_is_run = (workMode != ParticleSystemChainWorkMode_STATIC);
while(iter != begin_iter)
{
--iter, --i;
wxRect tmp_rect;
MYPoint2D appear_box_position = MYPoint2DMake((*iter)->getX(), (*iter)->getY());
MYSize2D appear_box_size = (*iter)->getAppearBoxSize();
if(chain_is_run)
{
tmp_rect = wxRect(appear_box_position.x, appear_box_position.y, appear_box_size.width, appear_box_size.height);
if(tmp_rect.GetWidth() < MIN_RUN_PSCHAIN_ITEM_DIMENSION)
{
int diff = MIN_RUN_PSCHAIN_ITEM_DIMENSION - tmp_rect.GetWidth();
tmp_rect.SetX(tmp_rect.GetX() - diff / 2);
tmp_rect.SetWidth(MIN_RUN_PSCHAIN_ITEM_DIMENSION);
}
if(tmp_rect.GetHeight() < MIN_RUN_PSCHAIN_ITEM_DIMENSION)
{
int diff = MIN_RUN_PSCHAIN_ITEM_DIMENSION - tmp_rect.GetHeight();
tmp_rect.SetY(tmp_rect.GetY() - diff / 2);
tmp_rect.SetHeight(MIN_RUN_PSCHAIN_ITEM_DIMENSION);
}
}
else
tmp_rect = wxRect(appear_box_position.x - BOUND_DIMENSION, appear_box_position.y - BOUND_DIMENSION,
appear_box_size.width + BOUND_DIMENSION * 2, appear_box_size.height + BOUND_DIMENSION * 2);
if(point.x >= tmp_rect.x && point.x < (tmp_rect.x + tmp_rect.width) &&
point.y >= tmp_rect.y && point.y < (tmp_rect.y + tmp_rect.height) )
{
res.psLayer = (int)i;
system_rect = tmp_rect;
break;
}
}
if( res.psLayer == -1/*no selected ps*/ || chain_is_run )
return res;
//selecting system has been finded, and <!chainIsRun> - maybe we touched on some ps's bottom(-s)
if( (point.x >= system_rect.x) && (point.x < system_rect.x + BOUND_DIMENSION) )
res.isLeft = true;
if( (point.x < system_rect.x + system_rect.width) && (point.x >= system_rect.x + system_rect.width - BOUND_DIMENSION) )
res.isRight = true;
if( (point.y >= system_rect.y) && (point.y < system_rect.y + BOUND_DIMENSION) )
res.isTop = true;
if( (point.y < system_rect.y + system_rect.height) && (point.y >= system_rect.y + system_rect.height - BOUND_DIMENSION) )
res.isBottom = true;
return res;
}
void ParticleSystemChain::ChooseSystemAtLayer(int layer)
{
if( (layer < 0) || (layer >= (int)all_ps.size()) )
choosedSystemLayer = -1;
else
choosedSystemLayer = layer;
}
int ParticleSystemChain::GetChoosedSystemLayer() const
{
return choosedSystemLayer;
}
void ParticleSystemChain::SelectSystemAtLayer(int layer)
{
if( (layer < 0) || (layer >= (int)all_ps.size()) )
selectedSystemLayer = -1;
else
selectedSystemLayer = layer;
}
int ParticleSystemChain::GetSelectedSystemLayer() const
{
return selectedSystemLayer;
}
ParticleSystemChainWorkMode ParticleSystemChain::GetWorkMode() const
{
return workMode;
}
void ParticleSystemChain::SetWorkMode(ParticleSystemChainWorkMode mode)
{
vector<ParticleSystem*>::iterator begin_iter = all_ps.begin();
vector<ParticleSystem*>::iterator end_iter = all_ps.end();
vector<ParticleSystem*>::iterator iter = begin_iter;
if(mode == ParticleSystemChainWorkMode_PLAYBACK || mode == ParticleSystemChainWorkMode_PLAYBACK_LOOP)
{
while(iter != end_iter)
{
(*iter)->start();
++iter;
}
timer.reset();
}
else//if(mode == ParticleSystemChainWorkMode_STATIC)
{
while(iter != end_iter)
{
(*iter)->stopExtra();
++iter;
}
}
workMode = mode;
}
void ParticleSystemChain::CallbackSystems()
{
if(workMode == ParticleSystemChainWorkMode_STATIC)
return;
double sec_interval = timer.getMilliseconds() / 1000.0;
timer.reset();
vector<ParticleSystem*>::iterator iter = all_ps.begin();
bool chain_is_run = false;
while(iter != all_ps.end())
{
(*iter)->callback(sec_interval);
if(!(*iter)->isFinished())
chain_is_run = true;
++iter;
}
if(chain_is_run)
return;
//!chain_is_run
if(workMode == ParticleSystemChainWorkMode_PLAYBACK)
SetWorkMode(ParticleSystemChainWorkMode_STATIC);
else// if(workMode == ParticleSystemChainWorkMode_PLAYBACK_LOOP)
SetWorkMode(ParticleSystemChainWorkMode_PLAYBACK_LOOP);//just restart
}
void ParticleSystemChain::DrawSystems()
{
vector<ParticleSystem*>::iterator iter = all_ps.begin();
if(workMode != ParticleSystemChainWorkMode_STATIC)
{
glEnable(GL_BLEND);
glBlendFunc(blendModeSrc, blendModeDst);
while(iter != all_ps.end())
{
(*iter)->draw();
++iter;
}
glDisable(GL_BLEND);
}
else
{
int i = 0;
while(iter != all_ps.end())
{
ParticleSystem* curr_ps = (*iter);
if(i == selectedSystemLayer)
curr_ps->setBoundColor(PSBOUND_SELECTED_COLOR);
else if(i == choosedSystemLayer)
curr_ps->setBoundColor(PSBOUNS_CHOOSED_COLOR);
else
curr_ps->setBoundColor(PSBOUND_COLOR);
curr_ps->drawBound();
++iter, ++i;
}
}
}
int ParticleSystemChain::GetBlendModeSrc() const
{
return blendModeSrc;
}
int ParticleSystemChain::GetBlendModeDst() const
{
return blendModeDst;
}
void ParticleSystemChain::SetBlendModeSrc(int mode)
{
blendModeSrc = mode;
}
void ParticleSystemChain::SetBlendModeDst(int mode)
{
blendModeDst = mode;
}
ParticleSystem* ParticleSystemChain::GetSystemAtLayer(int layer)
{
if( layer < 0 || layer >= (int)all_ps.size() )
return NULL;
return all_ps.at(layer);
}
MYRect ParticleSystemChain::GetInitialSystemsRect(unsigned int *systems_counter) const//systems bound rect on gl
{
*systems_counter = (unsigned int)all_ps.size();
double min_x = 0.0;
double min_y = 0.0;
double max_x = 0.0;
double max_y = 0.0;
vector<ParticleSystem*>::const_iterator begin_iter = all_ps.begin();
vector<ParticleSystem*>::const_iterator end_iter = all_ps.end();
vector<ParticleSystem*>::const_iterator iter = begin_iter;
while(iter != end_iter)
{
bool thereis_begin_ps = (iter == begin_iter);
if(thereis_begin_ps || min_x > (*iter)->data.initialX)
min_x = (*iter)->data.initialX;
if(thereis_begin_ps || min_y > (*iter)->data.initialY)
min_y = (*iter)->data.initialY;
double new_max = (*iter)->data.initialX + (*iter)->data.pAppearBoxSize.width;
if(thereis_begin_ps || max_x < new_max)
max_x = new_max;
new_max = (*iter)->data.initialY + (*iter)->data.pAppearBoxSize.height;
if(thereis_begin_ps || max_y < new_max)
max_y = new_max;
++iter;
}
MYPoint2D pos = MYPoint2DMake(min_x, min_y);
MYSize2D sz = MYSize2DMake(max_x - min_x, max_y - min_y);
return(MYRectMake(pos,sz));
}
int ParticleSystemChain::GetNumofSystems() const
{
return (int)all_ps.size();
}
//internals
ParticleSystemChain::ParticleSystemChain()
{
workMode = DEFAULT_PARTICLE_SYSTEM_CHAIN_WORK_MODE;
blendModeSrc = GL_ONE;
blendModeDst = GL_ONE_MINUS_SRC_ALPHA;
selectedSystemLayer = choosedSystemLayer = -1;
}
ParticleSystemChain::~ParticleSystemChain()
{
RemoveAll();
}
bool ParticleSystemChain::saveSystems(TiXmlElement* root) const
{
TiXmlElement tmp("SYSTEMS_DATA");
TiXmlElement *sys_data = (TiXmlElement*)root->InsertEndChild(tmp);
if(!sys_data)
return false;
sys_data->SetAttribute(ITEM_SELECTED, selectedSystemLayer);
if(all_ps.size() == 0)
return true;
vector<ParticleSystem*>::const_iterator iter = all_ps.end();
do
{
--iter;
if(!(*iter)->save(root))
return false;
}
while(iter != all_ps.begin());
return true;
}
bool ParticleSystemChain::loadSystems(TiXmlElement* root)
{
TiXmlElement *systems_data_ptr = (TiXmlElement*)root->FirstChild("SYSTEMS_DATA");
int selected_system_layer = -1;
if(systems_data_ptr)//new format file (ver. above 1.0)
systems_data_ptr->Attribute(ITEM_SELECTED, &selected_system_layer);
vector<ParticleSystem*> tmp_all_ps;
ParticleSystem *tmp_ps_ptr = new ParticleSystem();
while(bool is_success = tmp_ps_ptr->load(root))
{
tmp_all_ps.insert(tmp_all_ps.begin(), tmp_ps_ptr);
tmp_ps_ptr = new ParticleSystem();
}
delete tmp_ps_ptr;
if(tmp_all_ps.size() > 0 && selected_system_layer < 0)
selectedSystemLayer = 0;
else
selectedSystemLayer = selected_system_layer;
//remove all old-created and add new
vector<ParticleSystem*>::iterator iter = all_ps.begin();
while(iter != all_ps.end())
{
delete((ParticleSystem*)*iter);
++iter;
}
all_ps.clear();
tmp_all_ps.swap(all_ps);
workMode = ParticleSystemChainWorkMode_STATIC;
return true;
}
//ParticleSystem.cpp (эмиттер)
#include "ParticleSystem.h"
#include "MYSpinCtrld.h"
#define PS_BOUNDED_RECT_COLOR wxColour(150, 150, 150, 255)
//XML element's attributes of PSs
#define TEXTURE_ATTR "texture_file_name"
#define LIFE_TIME_ATTR "life_time"
#define APPEAR_DELAY_ATTR "appear_delay"
#define PARTICLE_SPEED_X_ATTR "particle_speed_x"
#define PARTICLE_SPEED_Y_ATTR "particle_speed_y"
#define GRAVITY_X_ATTR "gravity_x"
#define GRAVITY_Y_ATTR "gravity_y"
#define MAX_COUNT_ATTR "max_count"
#define START_COUNT_ATTR "start_count"
#define APPEAR_BOX_W_ATTR "appear_box_w"
#define APPEAR_BOX_H_ATTR "appear_box_h"
#define RED_BEGIN_ATTR "red_begin"
#define RED_END_ATTR "red_end"
#define GREEN_BEGIN_ATTR "green_begin"
#define GREEN_END_ATTR "green_end"
#define BLUE_BEGIN_ATTR "blue_begin"
#define BLUE_END_ATTR "blue_end"
#define ALPHA_BEGIN_ATTR "alpha_begin"
#define ALPHA_END_ATTR "alpha_end"
#define SCALE_BEGIN_W_ATTR "scale_begin_w"
#define SCALE_BEGIN_H_ATTR "scale_begin_h"
#define SCALE_END_W_ATTR "scale_end_w"