blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
sequencelengths 1
16
| author_lines
sequencelengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
403dd97b01a8a43e18a1ba3d4620397ddfb0eca7 | 0454def9ffc8db9884871a7bccbd7baa4322343b | /src/plugins/shared/QUTaskDialog.cpp | 2cdb85950074cad7359e231355f90ed29a2db1b0 | [] | no_license | escaped/uman | e0187d1d78e2bb07dade7ef6ef041b6ed424a2d3 | bedc1c6c4fc464be4669f03abc9bac93e7e442b0 | refs/heads/master | 2016-09-05T19:26:36.679240 | 2010-07-26T07:55:31 | 2010-07-26T07:55:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,627 | cpp | #include "QUTaskDialog.h"
#include <QCoreApplication>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QFileInfoList>
#include <QFileDialog>
#include <QTextStream>
#include <QIcon>
QUTaskDialog::QUTaskDialog(QUScriptableTask *task, QWidget *parent): QDialog(parent) {
initForTask();
if(task)
initForTask(task);
}
/*!
* General setup for a blank rename task.
*/
void QUTaskDialog::initForTask() {
setupUi(this);
this->setWindowIcon(QIcon(":/control/tasks_add.png"));
this->setWindowTitle(tr("Add Task"));
targetCombo->clear();
iconCombo->clear();
this->fillIconCombo(":/types");
this->fillIconCombo(":/marks");
this->fillIconCombo(":/control");
this->fillIconCombo(":/bullets");
exclusiveChk->setCheckState(Qt::Unchecked);
groupSpin->setEnabled(false);
removeDataBtn->setEnabled(false);
connect(exclusiveChk, SIGNAL(stateChanged(int)), this, SLOT(controlGroupSpin(int)));
connect(addDataBtn, SIGNAL(clicked()), SLOT(addData()));
connect(removeDataBtn, SIGNAL(clicked()), SLOT(removeData()));
// connect buttons
saveBtn->setEnabled(false);
connect(saveAsBtn, SIGNAL(clicked()), this, SLOT(saveTaskAs()));
connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
connect(moveUpBtn, SIGNAL(clicked()), dataTable, SLOT(moveUpCurrentRow()));
connect(moveDownBtn, SIGNAL(clicked()), dataTable, SLOT(moveDownCurrentRow()));
connect(dataTable, SIGNAL(currentCellChanged(int, int, int, int)), this, SLOT(updateMoveButtons(int, int)));
this->updateMoveButtons(0, 0);
}
/*!
* Use given task to fill the dialog. Used for editing.
*/
void QUTaskDialog::initForTask(QUScriptableTask *task) {
// use the basic implementation for untranslated text (should be english)
descriptionEdit->setText(task->QUSimpleTask::description());
toolTipEdit->setPlainText(task->QUSimpleTask::toolTip());
iconCombo->setCurrentIndex(iconCombo->findText(QFileInfo(task->iconSource()).fileName()));
exclusiveChk->setCheckState(task->group() < 0 ? Qt::Unchecked : Qt::Checked);
this->controlGroupSpin(exclusiveChk->checkState());
groupSpin->setValue(task->group());
schemaEdit->setText(task->schema());
dataTable->fillData(task->data());
removeDataBtn->setEnabled(task->data().size() > 0);
this->setWindowIcon(QIcon(":/control/tasks_edit.png"));
this->setWindowTitle(QString(tr("Edit Task: \"%1\"")).arg(task->configFileName()));
_fileName = task->configFileName();
// normal save button only available in edit mode
saveBtn->setEnabled(true);
connect(saveBtn, SIGNAL(clicked()), this, SLOT(saveTask()));
}
/*!
* Add all icons to the iconCombo that are found. Present icons are NOT removed.
*/
void QUTaskDialog::fillIconCombo(const QString &resourcePath) {
QDir iconDir(resourcePath); // reads the resource file
QFileInfoList iconFiList = iconDir.entryInfoList(QStringList("*.png"), QDir::Files);
foreach(QFileInfo iconFi, iconFiList) {
iconCombo->addItem(QIcon(iconFi.absoluteFilePath()), iconFi.fileName(), iconFi.absoluteFilePath());
}
}
/*!
* Enables or disables the spinbox for the group number considering the exclusive checkbox.
*/
void QUTaskDialog::controlGroupSpin(int exclusiveState) {
groupSpin->setEnabled(exclusiveState == Qt::Checked);
}
/*!
* Appends a new data field to the schema.
*/
void QUTaskDialog::addData() {
dataTable->appendRow();
schemaEdit->insert("%" + QVariant(dataTable->rowCount()).toString());
this->removeDataBtn->setEnabled(true);
this->updateMoveButtons(dataTable->currentRow(), dataTable->currentColumn());
}
/*!
* Removes the last added data field from the schema.
*/
void QUTaskDialog::removeData() {
schemaEdit->setText(schemaEdit->text().remove("%" + QVariant(dataTable->rowCount()).toString()));
dataTable->removeLastRow();
this->removeDataBtn->setEnabled(dataTable->rowCount() > 0);
this->updateMoveButtons(dataTable->currentRow(), dataTable->currentColumn());
}
void QUTaskDialog::saveTask() {
if(this->saveTask(this->configurationDirectory().filePath(_fileName)))
this->accept();
else
this->reject();
}
void QUTaskDialog::saveTaskAs() {
QString filePath = QFileDialog::getSaveFileName(this, tr("Save task config"), configurationDirectory().path(), tr("Task Configurations (*.xml)"));
if(!filePath.isEmpty()) {
if(this->saveTask(filePath))
this->accept();
else
this->reject();
}
}
/*!
* Enable or disable the move up/down buttons, according to which action is currently
* possible.
*/
void QUTaskDialog::updateMoveButtons(int row, int column) {
moveUpBtn->setEnabled(!(row < 1) and (row < dataTable->rowCount()));
moveDownBtn->setEnabled(!(row >= dataTable->rowCount() - 1) and (row >= 0));
}
/*!
* Save the contents of a DOM document into a file.
*/
bool QUTaskDialog::saveDocument(const QString &filePath) {
QFile file(filePath);
if(file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QTextStream out(&file);
out << _doc.toString(4);
file.close();
// logSrv->add(QString(tr("The task file \"%1\" was saved successfully.")).arg(filePath), QU::Saving);
return true;
} else {
// logSrv->add(QString(tr("The task file \"%1\" was NOT saved.")).arg(filePath), QU::Warning);
return false;
}
}
/*!
* Append the general part of a task config file to a given parent element.
*/
void QUTaskDialog::appendGeneral(QDomElement &parent, QUScriptableTask::TaskTypes type) {
QDomElement general = _doc.createElement("general");
QDomElement icon = _doc.createElement("icon"); general.appendChild(icon);
QDomElement description = _doc.createElement("description"); general.appendChild(description);
QDomElement tooltip = _doc.createElement("tooltip"); general.appendChild(tooltip);
if(type == QUScriptableTask::RenameTask)
general.setAttribute("type", "rename");
else if(type == QUScriptableTask::AudioTagTask)
general.setAttribute("type", "id3");
if(exclusiveChk->checkState() == Qt::Checked)
general.setAttribute("group", QVariant(groupSpin->value()).toString());
icon.setAttribute("resource", iconCombo->itemData(iconCombo->currentIndex()).toString());
if(!descriptionEdit->text().isEmpty()) {
QDomCDATASection cdataDescr = _doc.createCDATASection(descriptionEdit->text());
description.appendChild(cdataDescr);
}
if(!toolTipEdit->toPlainText().isEmpty()) {
QDomCDATASection cdataToolt = _doc.createCDATASection(toolTipEdit->toPlainText());
tooltip.appendChild(cdataToolt);
}
parent.appendChild(general);
}
| [
"[email protected]"
] | [
[
[
1,
202
]
]
] |
db4a8b7e4b492638a2ac6ea9cb689306c426b1aa | 93eac58e092f4e2a34034b8f14dcf847496d8a94 | /ncl30-cpp/ncl30-generator/src/NclGenerator.cpp | e6fdc437e7248680b94a4cf7fe2180e007c0d53e | [] | no_license | lince/ginga-srpp | f8154049c7e287573f10c472944315c1c7e9f378 | 5dce1f7cded43ef8486d2d1a71ab7878c8f120b4 | refs/heads/master | 2020-05-27T07:54:24.324156 | 2011-10-17T13:59:11 | 2011-10-17T13:59:11 | 2,576,332 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,002 | cpp | /******************************************************************************
Este arquivo eh parte da implementacao do ambiente declarativo do middleware
Ginga (Ginga-NCL).
Copyright (C) 2009 UFSCar/Lince, Todos os Direitos Reservados.
Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob
os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free
Software Foundation.
Este programa eh distribuido na expectativa de que seja util, porem, SEM
NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU
ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do
GNU versao 2 para mais detalhes.
Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto
com este programa; se nao, escreva para a Free Software Foundation, Inc., no
endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
Para maiores informacoes:
[email protected]
http://www.ncl.org.br
http://www.ginga.org.br
http://lince.dc.ufscar.br
******************************************************************************
This file is part of the declarative environment of middleware Ginga (Ginga-NCL)
Copyright (C) 2009 UFSCar/Lince, Todos os Direitos Reservados.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.
This program 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 version 2 for more
details.
You should have received a copy of the GNU General Public License version 2
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
For further information contact:
[email protected]
http://www.ncl.org.br
http://www.ginga.org.br
http://lince.dc.ufscar.br
*******************************************************************************/
/**
* @file NclGenerator.cpp
* @author Caio Viel
* @date 29-01-10
*/
#include "../include/NclGenerator.h"
namespace br {
namespace ufscar {
namespace lince {
namespace ncl {
namespace generator {
NclGenerator::NclGenerator() {
referDocument = NULL;
}
NclGenerator::~NclGenerator() {
}
void NclGenerator::setReferNclDocument(NclDocument* referDocument) {
cerr<<" NclGenerator::setReferNclDocument"<<endl;
cerr<<"Chegamos aqui!"<<endl;
this->referDocument = referDocument;
}
NclDocument* NclGenerator::getReferNclDocument() {
return this->referDocument;
}
string NclGenerator::generateXmlCode(Entity* entity) {
if (entity == NULL) {
string men = "NclGenerator::generateXmlCode(Entity* entity)\n";
men += "Tentativa de Gerar Código para entidade Ncl nula.";
BadArgumentException ex(men);
throw ex;
}
if (referDocument == NULL) {
string men = "NclGenerator::generateXmlCode(Entity* entity)\n";
men += "Tentativa de Gerar Código sem setar o documento Ncl de referência.";
InitializationException ex(men);
throw ex;
}
if (entity->instanceOf("Anchor")) {
return static_cast<AnchorGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("CausalConnector")) {
return static_cast<CausalConnectorGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("CausalLink")) {
return static_cast<CausalLinkGenerator*>(entity)->generateCode(
referDocument->getConnectorBase());
} else if (entity->instanceOf("ContentNode")) {
return static_cast<ContentNodeGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("ContextNode")) {
return static_cast<ContextNodeGenerator*>(entity)->generateCode(referDocument);
} else if (entity->instanceOf("Descriptor")) {
return static_cast<DescriptorGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("LayoutRegion")) {
return static_cast<LayoutRegionGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("Port")) {
return static_cast<PortGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("DescriptorSwitch")) {
return static_cast<DescriptorSwitchGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("Transition")) {
return static_cast<TransitionGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("SimpleRule")) {
return static_cast<SimpleRuleGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("CompositeRule")) {
return static_cast<CompositeRuleGenerator*>(entity)->generateCode();
} else if (entity->instanceOf("SwitchNode")) {
return static_cast<SwitchNodeGenerator*>(entity)->generateCode(referDocument);
} else if (entity->instanceOf("SwitchPort")) {
return static_cast<SwitchPortGenerator*>(entity)->generateCode();
} else {
string men = "NclGenerator::generateXmlCode(Entity* entity)\n";
men += "Tipo de entidade NCl não é suportada pela versão atual de NclGenerator.";
UnsupportedNclEntityException ex(men);
throw ex;
}
}
string NclGenerator::generateXmlCode(ConditionExpression* conditionExpression) {
if (conditionExpression == NULL) {
string men = "NclGenerator::generateXmlCode(ConditionExpression* conditionExpression)\n";
men += "Tentativa de Gerar Código para conditionExpression Ncl nulo.";
BadArgumentException ex(men);
throw ex;
}
if (referDocument == NULL) {
string men = "NclGenerator::generateXmlCode(ConditionExpression* conditionExpression)\n";
men += "Tentativa de Gerar Código sem setar o documento Ncl de referência.";
InitializationException ex(men);
throw ex;
}
if (conditionExpression->instanceOf("CompoundStatement")) {
return static_cast<CompoundStatementGenerator*>(conditionExpression)->generateCode();
} else if (conditionExpression->instanceOf("CompoundCondition")) {
return static_cast<CompoundConditionGenerator*>(conditionExpression)->generateCode();
} else if (conditionExpression->instanceOf("SimpleCondition")) {
return static_cast<SimpleConditionGenerator*>(conditionExpression)->generateCode();
} else if (conditionExpression->instanceOf("AssessmentStatement")) {
return static_cast<AssessmentStatementGenerator*>(conditionExpression)->generateCode();
} else {
string men = "NclGenerator::generateXmlCode(ConditionExpression* conditionExpression)\n";
men += "Tipo de conditionExpression não é suportado pela versão atual de NclGenerator.";
UnsupportedNclEntityException ex(men);
throw ex;
}
}
string NclGenerator::generateXmlCode(Bind* bind) {
if (bind == NULL) {
string men = "NclGenerator::generateXmlCode(Bind* bind)\n";
men += "Tentativa de Gerar Código para bind Ncl nula.";
BadArgumentException ex(men);
throw ex;
}
if (referDocument == NULL) {
string men = "NclGenerator::generateXmlCode(Bind* bind)\n";
men += "Tentativa de Gerar Código sem setar o documento Ncl de referência.";
InitializationException ex(men);
throw ex;
}
if (bind->instanceOf("Bind")) {
return static_cast<BindGenerator*>(bind)->generateCode();
}
}
string NclGenerator::generateXmlCode(Action* action) {
if (action == NULL) {
string men = "NclGenerator::generateXmlCode(Action* action)\n";
men += "Tentativa de Gerar Código para Ação Ncl nula.";
BadArgumentException ex(men);
throw ex;
}
if (referDocument == NULL) {
string men = "NclGenerator::generateXmlCode(Action* action)\n";
men += "Tentativa de Gerar Código sem setar o documento Ncl de referência.";
InitializationException ex(men);
throw ex;
}
if (action->instanceOf("CompoundAction")) {
return static_cast<CompoundActionGenerator*>(action)->generateCode();
} else if (action->instanceOf("SimpleAction")) {
return static_cast<SimpleActionGenerator*>(action)->generateCode();
} else {
string men = "NclGenerator::generateXmlCode(Action* action)\n";
men += "Tipo de parametro Action Ncl não é suportado pela versão atual de NclGenerator.";
UnsupportedNclEntityException ex(men);
throw ex;
}
}
string NclGenerator::generateXmlCode(Base* base) {
if (base == NULL) {
string men = "NclGenerator::generateXmlCode(Base* base)\n";
men += "Tentativa de Gerar Código para base Ncl nula.";
BadArgumentException ex(men);
throw ex;
}
if (referDocument == NULL) {
string men = "NclGenerator::generateXmlCode(Base* base)\n";
men += "Tentativa de Gerar Código sem setar o documento Ncl de referência.";
InitializationException ex(men);
throw ex;
}
if (base->instanceOf("ConnectorBase")) {
return static_cast<ConnectorBaseGenerator*>(base)->generateCode();
} else if (base->instanceOf("DescriptorBase")) {
return static_cast<DescriptorBaseGenerator*>(base)->generateCode();
} else if (base->instanceOf("RegionBase")) {
return static_cast<RegionBaseGenerator*>(base)->generateCode();
} else if (base->instanceOf("TransitionBase")) {
return static_cast<TransitionBaseGenerator*>(base)->generateCode();
} else if (base->instanceOf("RuleBase")) {
return static_cast<RuleBaseGenerator*>(base)->generateCode();
} else {
string men = "NclGenerator::generateXmlCode(Base* base)\n";
men += "Tipo de base NCL não é suportada pela versão atual de NclGenerator.";
UnsupportedNclEntityException ex(men);
throw ex;
}
}
string NclGenerator::generateXmlCode(NclDocument* nclDocument) {
if (nclDocument == NULL) {
nclDocument = referDocument;
}
if (nclDocument == NULL) {
string men = "NclGenerator::generateXmlCode(NclDocument* nclDocument)\n";
men += "Tentativa de gerar documento NCL a partir de instâncias nulas de NclDocument.";
InitializationException ex(men);
throw ex;
}
return static_cast<NclDocumentGenerator*>(nclDocument)->generateCode();
}
string NclGenerator::generateXmlCode(Parameter* parameter, string paramType) {
if (parameter == NULL) {
string men = "NclGenerator::generateXmlCode(Parameter* parameter, string paramType)\n";
men += "Tentativa de Gerar Código para Parametro Ncl nulo.";
BadArgumentException ex(men);
throw ex;
}
if (referDocument == NULL) {
string men = "NclGenerator::generateXmlCode(Parameter* parameter, string paramType)\n";
men += "Tentativa de Gerar Código sem setar o documento Ncl de referência.";
InitializationException ex(men);
throw ex;
}
string valueName;
if (paramType == "descriptorParam") {
valueName = "value";
} else if (paramType == "bindParam") {
valueName = "value";
} else if (paramType == "linkParam") {
valueName = "value";
} else if (paramType == "connectorParam") {
valueName = "type";
} else {
string men = "NclGenerator::generateXmlCode(Parameter* parameter, string paramType)\n";
men += "Tipo de parametro '" + paramType + "' não é suportado pela versão atual de NclGenerator.";
UnsupportedNclEntityException ex(men);
throw ex;
}
return static_cast<ParameterGenerator*>(parameter)->generateCode(paramType, valueName);
}
bool NclGenerator::generateNclFile(string fileName, NclDocument* nclDoc) {
if (nclDoc == NULL) {
nclDoc = referDocument;
}
if (nclDoc == NULL) {
string men = "NclGenerator::generateNclFile(string fileName, NclDocument nclDoc)\n";
men += "Tentativa de gerar documento NCL a partir de instâncias nulas de NclDocument.";
InitializationException ex(men);
throw ex;
}
NclFileGenerator* fileGen = new NclFileGenerator(nclDoc, fileName);
bool result = fileGen->generateFile();
delete fileGen;
return result;
}
}
}
}
}
}
extern "C" ::br::ufscar::lince::ncl::generator::INclGenerator*
createNclGenerator() {
return new::br::ufscar::lince::ncl::generator::NclGenerator::NclGenerator();
}
extern "C" void destroyNclGenerator(
::br::ufscar::lince::ncl::generator::INclGenerator* nclGenerator) {
delete nclGenerator;
}
| [
"[email protected]"
] | [
[
[
1,
359
]
]
] |
23e739137678d44a6605a1637af7fc252fd02da9 | 3533c9f37def95dcc9d6b530c59138f7570ca239 | /plugins/guCApluginPOF/include/guCApluginPOF_ETypes.h | b203c91f6710315324362075b4cdccfba2c8e9db | [] | no_license | LiberatorUSA/GU | 7e8af0dccede7edf5fc9c96c266b9888cff6d76e | 2493438447e5cde3270e1c491fe2a6094dc0b4dc | refs/heads/master | 2021-01-01T18:28:53.809051 | 2011-06-04T00:12:42 | 2011-06-04T00:12:42 | 41,840,823 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,711 | h | /*
* guCApluginPOF: Generic GUCEF plugin for decoding "Violation" POF models
* Copyright (C) 2002 - 2008. Dinand Vanvelzen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GU_CA_PLUGIN_POF_ETYPES_H
#define GU_CA_PLUGIN_POF_ETYPES_H
/*-------------------------------------------------------------------------//
// //
// INCLUDES //
// //
//-------------------------------------------------------------------------*/
#ifndef GU_CORE_ETYPES_H
#include "guCORE_ETypes.h" /* GU::CORE types are imported */
#define GU_CORE_ETYPES_H
#endif /* GU_CORE_ETYPES_H ? */
/*-------------------------------------------------------------------------//
// //
// CONSTANTS //
// //
//-------------------------------------------------------------------------*/
/*
* Maximum and minimal values for the simple types which we are about to
* define.
*/
#define GU_CA_PLUGIN_POF_INT8MAX GUCORE_INT8MAX
#define GU_CA_PLUGIN_POF_INT8MIN GUCORE_INT8MIN
#define GU_CA_PLUGIN_POF_UINT8MAX GUCORE_UINT8MAX
#define GU_CA_PLUGIN_POF_UINT8MIN GUCORE_UINT8MIN
#define GU_CA_PLUGIN_POF_INT16MAX GUCORE_INT16MAX
#define GU_CA_PLUGIN_POF_INT16MIN GUCORE_INT16MIN
#define GU_CA_PLUGIN_POF_UINT16MAX GUCORE_UINT16MAX
#define GU_CA_PLUGIN_POF_UINT16MIN GUCORE_UINT16MIN
#define GU_CA_PLUGIN_POF_INT32MAX GUCORE_INT32MAX
#define GU_CA_PLUGIN_POF_INT32MIN GUCORE_INT32MIN
#define GU_CA_PLUGIN_POF_UINT32MAX GUCORE_UINT32MAX
#define GU_CA_PLUGIN_POF_UINT32MIN GUCORE_UINT32MIN
#define GU_CA_PLUGIN_POF_FLOAT32MAX GUCORE_FLOAT32MAX
#define GU_CA_PLUGIN_POF_FLOAT32MIN GUCORE_FLOAT32MIN
/*--------------------------------------------------------------------------*/
/*
* We only have to define types when using C++ due to namespacing
* For C the gucefCORE versions are automaticly used in the global namespace
*/
#ifdef __cplusplus
/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/
namespace GU {
namespace CA {
namespace PLUGINPOF {
/*-------------------------------------------------------------------------//
// //
// TYPES //
// //
//-------------------------------------------------------------------------*/
typedef GU::CORE::UInt8 UInt8; /* 1 byte, unsigned */
typedef GU::CORE::Int8 Int8; /* 1 byte, signed */
typedef GU::CORE::UInt16 UInt16; /* 2 bytes, unsigned */
typedef GU::CORE::Int16 Int16; /* 2 bytes, signed */
typedef GU::CORE::UInt32 UInt32; /* 4 bytes, unsigned */
typedef GU::CORE::Int32 Int32; /* 4 bytes, signed */
typedef GU::CORE::Int64 Int64; /* 8 bytes, signed */
typedef GU::CORE::UInt64 UInt64; /* 8 bytes, unsigned */
typedef GU::CORE::Float32 Float32; /* 4 bytes, signed, decimal */
typedef GU::CORE::Float64 Float64; /* 8 bytes, signed, decimal */
typedef GU::CORE::CString CString;
/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/
}; /* namespace PLUGINPOF */
}; /* namespace CA */
}; /* namespace GU */
/*--------------------------------------------------------------------------*/
#endif /* __cplusplus ? */
#endif /* GU_CA_PLUGIN_POF_ETYPES_H ? */
/*-------------------------------------------------------------------------//
// //
// Info & Changes //
// //
//-------------------------------------------------------------------------//
- 31-12-2004 :
- Dinand: Added this section
-----------------------------------------------------------------------------*/ | [
"[email protected]"
] | [
[
[
1,
124
]
]
] |
34ba2ea5eeb8b1c4ce67329baec639245c49612f | 580738f96494d426d6e5973c5b3493026caf8b6a | /Include/Vcl/svrlogdetaildlg.hpp | fd18cdbabeaa5e90b6c93e547575b5e4c35f39b1 | [] | no_license | bravesoftdz/cbuilder-vcl | 6b460b4d535d17c309560352479b437d99383d4b | 7b91ef1602681e094a6a7769ebb65ffd6f291c59 | refs/heads/master | 2021-01-10T14:21:03.726693 | 2010-01-11T11:23:45 | 2010-01-11T11:23:45 | 48,485,606 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,172 | hpp | // Borland C++ Builder
// Copyright (c) 1995, 2002 by Borland Software Corporation
// All rights reserved
// (DO NOT EDIT: machine generated header) 'SvrLogDetailDlg.pas' rev: 6.00
#ifndef SvrLogDetailDlgHPP
#define SvrLogDetailDlgHPP
#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <Registry.hpp> // Pascal unit
#include <SvrLogDetailFrame.hpp> // Pascal unit
#include <SvrLogFrame.hpp> // Pascal unit
#include <ActnList.hpp> // Pascal unit
#include <StdCtrls.hpp> // Pascal unit
#include <Dialogs.hpp> // Pascal unit
#include <Forms.hpp> // Pascal unit
#include <Controls.hpp> // Pascal unit
#include <Graphics.hpp> // Pascal unit
#include <Classes.hpp> // Pascal unit
#include <SysUtils.hpp> // Pascal unit
#include <Messages.hpp> // Pascal unit
#include <Windows.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Svrlogdetaildlg
{
//-- type declarations -------------------------------------------------------
class DELPHICLASS TLogDetail;
class PASCALIMPLEMENTATION TLogDetail : public Forms::TForm
{
typedef Forms::TForm inherited;
__published:
Actnlist::TActionList* ActionList1;
Actnlist::TAction* PrevAction;
Actnlist::TAction* NextAction;
Actnlist::TAction* CloseAction;
Stdctrls::TButton* Button1;
Stdctrls::TButton* Button2;
Stdctrls::TButton* Button3;
Svrlogdetailframe::TLogDetailFrame* LogDetailFrame;
void __fastcall PrevActionExecute(System::TObject* Sender);
void __fastcall PrevActionUpdate(System::TObject* Sender);
void __fastcall NextActionExecute(System::TObject* Sender);
void __fastcall NextActionUpdate(System::TObject* Sender);
void __fastcall CloseActionExecute(System::TObject* Sender);
void __fastcall FormShow(System::TObject* Sender);
private:
Svrlogframe::TLogFrame* FLogFrame;
public:
__fastcall virtual TLogDetail(Classes::TComponent* AOwner);
void __fastcall Load(Registry::TRegIniFile* Reg, const AnsiString Section);
void __fastcall Save(Registry::TRegIniFile* Reg, const AnsiString Section);
__property Svrlogframe::TLogFrame* LogFrame = {read=FLogFrame, write=FLogFrame};
public:
#pragma option push -w-inl
/* TCustomForm.CreateNew */ inline __fastcall virtual TLogDetail(Classes::TComponent* AOwner, int Dummy) : Forms::TForm(AOwner, Dummy) { }
#pragma option pop
#pragma option push -w-inl
/* TCustomForm.Destroy */ inline __fastcall virtual ~TLogDetail(void) { }
#pragma option pop
public:
#pragma option push -w-inl
/* TWinControl.CreateParented */ inline __fastcall TLogDetail(HWND ParentWindow) : Forms::TForm(ParentWindow) { }
#pragma option pop
};
//-- var, const, procedure ---------------------------------------------------
extern PACKAGE TLogDetail* FLogDetail;
} /* namespace Svrlogdetaildlg */
using namespace Svrlogdetaildlg;
#pragma option pop // -w-
#pragma option pop // -Vx
#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // SvrLogDetailDlg
| [
"bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b"
] | [
[
[
1,
89
]
]
] |
455f65d4a0ba340396b03ef3e63a97332c283f8a | 52162567444a3dbe666ff591d2fce51ab8fbef68 | /TFormatButton.h | 529146c28720ffc9026f75d57cd6831c07d3e024 | [] | no_license | bravesoftdz/fwcalc | 1f2fdad009c3301b2fe2112c61d28fd4b32fa9a0 | a29cdc0cdbf18f0cf1f45617a41a093a3b7c55e4 | refs/heads/master | 2020-03-21T21:43:00.414710 | 2010-06-26T15:10:42 | 2010-06-26T15:10:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,096 | h | //---------------------------------------------------------------------------
#ifndef TFormatButtonH
#define TFormatButtonH
//---------------------------------------------------------------------------
class TFormatButton : public TGraphicControl
{
private:
bool m_mouse_in_control;
bool m_button_pressed;
bool MouseInControl();
protected:
void __fastcall CMMouseEnter(TMessage &message);
void __fastcall CMMouseLeave(TMessage &message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage,CMMouseLeave);
END_MESSAGE_MAP(TGraphicControl)
DYNAMIC void __fastcall MouseUp(TMouseButton button, TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseDown(TMouseButton button, TShiftState Shift, int X, int Y);
public:
__fastcall TFormatButton(TComponent *Owner);
__fastcall ~TFormatButton();
virtual void __fastcall Paint(void);
__published:
__property Caption;
__property Font;
__property ShowHint;
__property Hint;
__property OnClick;
};
#endif
| [
"shviid@13e02fa6-f819-47ee-9f09-2ea78d7e988d"
] | [
[
[
1,
50
]
]
] |
64f6fe7cf240dc436666d3bed79c721011004161 | 9eaaf34300eab99a399908628aa031e45403e797 | /wintarball/shellext/DirectoryState.hpp | 70a2033997e84505b3b7ff93d7cabbb698b0cb34 | [] | no_license | webstorage119/wintarball | 46e3daa8ea48834fa43ecce5335b9cb5d10cfeb2 | 37af24c07ae4049e096ed3e2dd4deeb72b1e57a9 | refs/heads/master | 2023-09-02T07:08:55.494727 | 2002-02-04T17:46:54 | 2002-02-04T17:46:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 319 | hpp | #ifndef DIRECTORY_STATE_HPP
#define DIRECTORY_STATE_HPP
#include <windows.h>
struct DirectoryState {
char directory[MAX_PATH];
DirectoryState() {
GetCurrentDirectory(MAX_PATH, directory);
}
~DirectoryState() {
SetCurrentDirectory(directory);
}
};
#endif
| [
"aegis@f05a4d3f-5a97-4418-b679-a456eae28545"
] | [
[
[
1,
21
]
]
] |
d43f18b53c2ea97f5a778f4ac4f40fb33bd3a80d | 8cf9b251e0f4a23a6ef979c33ee96ff4bdb829ab | /src-ginga-editing/ncl30-generator-cpp/src/ContentNodeGenerator.cpp | b3fde79282737622154f74d81098426c99c35804 | [] | no_license | BrunoSSts/ginga-wac | 7436a9815427a74032c9d58028394ccaac45cbf9 | ea4c5ab349b971bd7f4f2b0940f2f595e6475d6c | refs/heads/master | 2020-05-20T22:21:33.645904 | 2011-10-17T12:34:32 | 2011-10-17T12:34:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,258 | cpp | /******************************************************************************
Este arquivo eh parte da implementacao do ambiente declarativo do middleware
Ginga (Ginga-NCL).
Copyright (C) 2009 UFSCar/Lince, Todos os Direitos Reservados.
Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob
os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free
Software Foundation.
Este programa eh distribuido na expectativa de que seja util, porem, SEM
NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU
ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do
GNU versao 2 para mais detalhes.
Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto
com este programa; se nao, escreva para a Free Software Foundation, Inc., no
endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
Para maiores informacoes:
[email protected]
http://www.ncl.org.br
http://www.ginga.org.br
http://lince.dc.ufscar.br
******************************************************************************
This file is part of the declarative environment of middleware Ginga (Ginga-NCL)
Copyright (C) 2009 UFSCar/Lince, Todos os Direitos Reservados.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.
This program 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 version 2 for more
details.
You should have received a copy of the GNU General Public License version 2
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
For further information contact:
[email protected]
http://www.ncl.org.br
http://www.ginga.org.br
http://lince.dc.ufscar.br
*******************************************************************************/
/**
* @file ContentNodeGenerator.cpp
* @author Caio Viel
* @date 29-01-10
*/
#include "../include/ContentNodeGenerator.h"
namespace br {
namespace ufscar {
namespace lince {
namespace ncl {
namespace generate {
string ContentNodeGenerator::generateCode() {
string ret = "<media id=\"" + this->getId() + "\" ";
string mediaType = this->getNodeType();
if (mediaType != "") {
ret += "type=\"" + mediaType + "\" ";
}
ReferenceContent* content = (ReferenceContent*) this->getContent();
if (content != NULL) {
string src = content->getReference();
if (src != "") {
ret +="src=\"" + src + "\" ";
}
}
GenericDescriptor* descriptor = getDescriptor();
if (descriptor != NULL) {
ret += "descriptor=\"" + descriptor->getId() + "\" ";
}
vector<Anchor*>* anchors = this->getAnchors();
vector<Anchor*>::iterator it;
it = this->getAnchors()->begin();
if (it != anchors->end()) {
ret +=" >\n";
while (it != anchors->end()) {
Anchor* anchor = *it;
ret+= static_cast<AnchorGenerator*>(anchor)->generateCode();
it++;
}
ret += "</media>\n";
} else {
ret += " />\n";
}
return ret;
}
}
}
}
}
}
| [
"[email protected]"
] | [
[
[
1,
106
]
]
] |
2a295e75c723003fb841c83a68e575d872ec2f50 | 8253a563255bdd5797873c9f80d2a48a690c5bb0 | /configlib/dbmsjdbc/src/native/DictionaryStore.cpp | 6dc704fdba47323b7a4bc0b7ddebfa1c6034cd02 | [] | no_license | SymbianSource/oss.FCL.sftools.depl.swconfigmdw | 4e6ab52bf564299f1ed7036755cf16321bd656ee | d2feb88baf0e94da760738fc3b436c3d5d1ff35f | refs/heads/master | 2020-03-28T10:16:11.362176 | 2010-11-06T14:59:14 | 2010-11-06T14:59:14 | 73,009,096 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,826 | cpp | // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//
#include <jni.h>
#include "dbmsjni/com_symbian_store_DictionaryStore.h"
#include "DictionaryStore.h"
#include "Utils.h"
extern CTrapCleanup* gCleanup; // clean-up stack
extern TPanicHandler gPanicHandler;
extern jclass gExcCls;
// //
// EmbeddedStore class implementation
DictionaryStore::DictionaryStore() {
iStore = NULL;
}
DictionaryStore::~DictionaryStore() {
if ( iStore != NULL ) {
delete iStore;
iStore = NULL;
}
iFs.Close();
}
DictionaryStore* DictionaryStore::CreateL(const TDesC& aFileName, TUid aUid3) {
DictionaryStore* store = new (ELeave) DictionaryStore();
CleanupStack::PushL(store);
User::LeaveIfError(store->iFs.Connect());
store->iStore = CDictionaryFileStore::OpenL(store->iFs, aFileName, aUid3);
CleanupStack::Pop(store);
return store;
}
void DictionaryStore::Close() {
}
// //
// JNI implementations
/*
* Class: com_symbian_store_DictionaryStore
* Method: _initNative
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_com_symbian_store_DictionaryStore__1initNative
(JNIEnv * aEnv, jobject) {
if ( gCleanup == NULL ) {
// init globals
gCleanup=CTrapCleanup::New(); // get clean-up stack
gPanicHandler = &SosPanicHandler;
jclass excCls = aEnv->FindClass("java/lang/RuntimeException");
if ( excCls == NULL )
{
printf("Could not create exception class java/lang/RuntimeException in DbmsConnection::init ...\n");
return KErrGeneral;
}
else
{
gExcCls = (jclass)(aEnv->NewGlobalRef(excCls));
if ( gExcCls == NULL )
{
printf("Could not create glref to exception class java/lang/RuntimeException in DbmsConnection::init ...\n");
return KErrGeneral;
}
}
}
return KErrNone;
}
/*
* Class: com_symbian_store_DictionaryStore
* Method: _create
* Signature: (Ljava/lang/String;I)I
*/
JNIEXPORT jint JNICALL Java_com_symbian_store_DictionaryStore__1create
(JNIEnv *aEnv, jobject, jstring aFileName, jint aUid) {
RJString fname(*aEnv, aFileName);
TUid uid = TUid::Uid(aUid);
DictionaryStore* store;
TRAPD(error, store = DictionaryStore::CreateL(fname, uid));
if(error != KErrNone) {
return error;
}
return (jint) store;
}
/*
* Class: com_symbian_store_DictionaryStore
* Method: _close
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_symbian_store_DictionaryStore__1close
(JNIEnv *, jobject, jint aPeerHandle) {
DictionaryStore* store = (DictionaryStore*)aPeerHandle;
store->Close();
delete store;
}
/*
* Class: com_symbian_store_DictionaryStore
* Method: _commit
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_com_symbian_store_DictionaryStore__1commit
(JNIEnv *, jobject, jint aPeerHandle) {
return ((DictionaryStore*)aPeerHandle)->iStore->Commit();
}
/*
* Class: com_symbian_store_DictionaryStore
* Method: _revert
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_com_symbian_store_DictionaryStore__1revert
(JNIEnv *, jobject, jint aPeerHandle) {
DictionaryStore* store = (DictionaryStore*)aPeerHandle;
TRAPD(error, store->iStore->RevertL());
return error;
}
/*
* Class: com_symbian_store_DictionaryStore
* Method: _remove
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_com_symbian_store_DictionaryStore__1remove
(JNIEnv *, jobject, jint aPeerHandle, jint aUid){
DictionaryStore* store = (DictionaryStore*)aPeerHandle;
TUid uid = TUid::Uid(aUid);
TRAPD(error, store->iStore->RemoveL(uid));
return error;
}
/*
* Class: com_symbian_store_DictionaryStore
* Method: _isNull
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_com_symbian_store_DictionaryStore__1isNull
(JNIEnv *, jobject, jint aPeerHandle) {
DictionaryStore* store = (DictionaryStore*)aPeerHandle;
TRAPD(error, store->iStore->IsNullL());
return error;
}
/*
* Class: com_symbian_store_DictionaryStore
* Method: _isPresent
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_com_symbian_store_DictionaryStore__1isPresent
(JNIEnv *, jobject, jint aPeerHandle, jint aUid) {
DictionaryStore* store = (DictionaryStore*)aPeerHandle;
TUid uid = TUid::Uid(aUid);
TRAPD(error, store->iStore->IsPresentL(uid));
return error;
}
| [
"none@none"
] | [
[
[
1,
180
]
]
] |
a1c8d0b1fb11fa17ca788ba17fed102c83feb236 | 13cabe39277567e7d0f801bfcb69c42fe826995c | /Source/itkSparseImagePixelAccessorFunctor.h | 80fbf907d9c2e1406b0181bd4fd3dff28a6c399e | [] | no_license | midas-journal/midas-journal-646 | d749487f778de124063516df8d63798dbb970a8b | 329cad922bcc2ac1d712b1a49218d04253afaa44 | refs/heads/master | 2021-01-10T22:07:50.458437 | 2011-08-22T13:24:59 | 2011-08-22T13:24:59 | 2,248,638 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,319 | h | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkSparseImagePixelAccessorFunctor.h,v $
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkSparseImagePixelAccessorFunctor_h
#define __itkSparseImagePixelAccessorFunctor_h
namespace itk
{
/** \class SparseImagePixelAccessorFunctor
* \brief Provides accessor interfaces to Access pixels and is meant to be
* used by iterators.
*
* A typical user should not need to use this class. The class is internally
* used by the neighborhood iterators.
*
* The pixel accessor is set with the SetPixelAccessor method. This accessor is
* meant to be used only for SparseImage and not for Image.
*
* \sa DefaultSliceContiguousPixelAccessor
* \sa DefaultPixelAccessor
* \sa DefaultPixelAccessorFunctor
*
* \author Dan Mueller, Philips Healthcare, PII Development
*
* This implementation was taken from the Insight Journal paper:
* http://hdl.handle.net/10380/3068
*
*/
template <class TImageType >
class ITK_EXPORT SparseImagePixelAccessorFunctor
{
public:
typedef TImageType ImageType;
typedef typename ImageType::InternalPixelType InternalPixelType;
typedef typename ImageType::PixelType ExternalPixelType;
typedef typename ImageType::AccessorType PixelAccessorType;
typedef unsigned int VectorLengthType;
/** Set the PixelAccessor. This is set at construction time by the image iterators.
* The type PixelAccessorType is obtained from the ImageType over which the iterators
* are templated.
* */
inline void SetPixelAccessor( PixelAccessorType& accessor )
{
m_PixelAccessor = accessor;
}
/** Set the pointer index to the start of the buffer. */
inline void SetBegin( const InternalPixelType * begin ) // NOTE: begin is always 0
{ this->m_Begin = const_cast< InternalPixelType * >( begin ); }
/** Set output using the value in input */
inline void Set( InternalPixelType & output, const ExternalPixelType &input ) const
{
m_PixelAccessor.Set( output, input, (&output)-m_Begin ); // NOTE: begin is always 0
}
/** Get the value from input */
inline ExternalPixelType Get( const InternalPixelType &input ) const
{
return m_PixelAccessor.Get( input, (&input)-m_Begin ); // NOTE: begin is always 0
}
/** Required for some filters to compile. */
static void SetVectorLength( ImageType *, VectorLengthType )
{
}
/** Required for some filters to compile. */
static VectorLengthType GetVectorLength( const ImageType * )
{
return 1;
}
private:
PixelAccessorType m_PixelAccessor; // The pixel accessor
InternalPixelType *m_Begin; // Begin of the buffer, always 0
};
}
#endif
| [
"[email protected]"
] | [
[
[
1,
96
]
]
] |
89da50f360c83fe811de802958ec315ec07f90c7 | b73f27ba54ad98fa4314a79f2afbaee638cf13f0 | /test/TestUtility/HTTPResponseHeaderTest.cpp | c7717917db077bf6726e4d01d7166b535441594a | [] | no_license | weimingtom/httpcontentparser | 4d5ed678f2b38812e05328b01bc6b0c161690991 | 54554f163b16a7c56e8350a148b1bd29461300a0 | refs/heads/master | 2021-01-09T21:58:30.326476 | 2009-09-23T08:05:31 | 2009-09-23T08:05:31 | 48,733,304 | 3 | 0 | null | null | null | null | GB18030 | C++ | false | false | 6,319 | cpp | #include "StdAfx.h"
#include ".\HTTPResponseHeaderTest .h"
#include <utility\HttpPacket.h>
#include <boost\test\test_tools.hpp>
using namespace boost::unit_test;
const char packet1[] = "HTTP/1.1 302 Found\r\n"
"Date: Thu, 24 Apr 2008 02:37:48 GMT\r\n"
"Server: Apache/1.3.37 (Unix) mod_gzip/1.3.26.1\r\n"
"Vary: Accept-Encoding\r\n"
"Cache-Control: max-age=5184000\r\n"
"Expires: Mon, 23 Jun 2008 02:37:48 GMT\r\n"
"Last-Modified: Fri, 08 Jun 2007 03:13:16 GMT\r\n"
"ETag: \"434610-296-4668c94c\"\r\n"
"Accept-Ranges: bytes\r\n"
"Content-Length: 682\r\n"
"Content-Type: text/html\r\n"
"Age: 220737\r\n"
"X-Cache: HIT from 168479083.sohu.com\r\n"
"Connection: close\r\n\r\n"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012"; // 682
const char packet2[] = "HTTP/1.1 302 Found\r\n"
"Date: Thu, 24 Apr 2008 02:37:48 GMT\r\n"
"Cache-Control: max-age=5184000\r\n"
"Accept-Ranges: bytes\r\n"
"Content-Length: 234\r\n"
"Content-Type: image/gif\r\n"
"X-Cache: HIT from 168479083.sohu.com\r\n"
"Connection: keep-alive\r\n\r\n"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234"; // 234
const char packet3[] = "HTTP/1.1 302 Found\r\n"
"Last-Modified: Fri, 08 Jun 2007 03:13:16 GMT\r\n"
"Accept-Ranges: bytes\r\n"
"Content-Length: 62\r\n"
"Content-Type: image/jpeg\r\n"
"Connection: close\r\n\r\n"
"12345678901234567890123456789012345678901234567890"
"123456789012";
const char packet4[] = "HTTP/1.1 200 OK\r\n"
"Cache-Control: private, max-age=0\r\n"
"Date: Fri, 13 Jun 2008 13:59:34 GMT\r\n"
"Expires: -1\r\n"
"Content-Type: text/html; charset=UTF-8\r\n"
"Content-Encoding: gzip\r\n"
"Transfer-Encoding: chunked\r\n\r\n"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890";
const char packet5[] = "xtyHTTP/1.1 200 OK\r\n"
"Cache-Control: private, max-age=0\r\n";
const char packet6[] = "HTTP/1.1 200 OK\r\n"
"Date: Thu, 24 Apr 2008 02:37:48 GMT\r\n"
"Server: Apache/1.3.37 (Unix) mod_gzip/1.3.26.1\r\n"
"Vary: Accept-Encoding\r\n"
"Content-Length: 3\r\n"
"Content-Type: text/html\r\n"
"Connection: close\r\n\r\n"
"HTTP/1.1 200 OK\r\n"
"Date: Thu, 24 Apr 2008 02:37:48 GMT\r\n"
"Server: Apache/1.3.37 (Unix) mod_gzip/1.3.26.1\r\n"
"Vary: Accept-Encoding\r\n"
"Content-Length: 8283\r\n"
"Content-Type: image/gif\r\n"
"Connection: close\r\n\r\n"
"HTTP/1.1 200 OK\r\n"
"Date: Thu, 24 Apr 2008 02:37:48 GMT\r\n"
"Server: Apache/1.3.37 (Unix) mod_gzip/1.3.26.1\r\n"
"Vary: Accept-Encoding\r\n"
"Content-Length: 231\r\n"
"Content-Type: text/html\r\n"
"Connection: close\r\n\r\n"
"HTTP/1.1 200 OK\r\n"
"Date: Thu, 24 Apr 2008 02:37:48 GMT\r\n"
"Server: Apache/1.3.37 (Unix) mod_gzip/1.3.26.1\r\n"
"Vary: Accept-Encoding\r\n"
"Content-Length: 09\r\n"
"Content-Type: image/jpeg\r\n"
"Transfer-Encoding: chunked\r\n"
"Connection: close\r\n\r\n";
void testHTTPHeaderParsed() {
// 测试头部解析是否正确
HTTP_RESPONSE_HEADER header1;
header1.parseHeader(packet1, (int)strlen(packet1));
BOOST_ASSERT(header1.isChunk()== false);
BOOST_ASSERT(header1.getContentType()== CONTYPE_HTML);
BOOST_ASSERT(header1.getConnectionState()== HTTP_RESPONSE_HEADER::CONNECT_CLOSE);
BOOST_ASSERT(header1.getContentLength() == 682);
BOOST_ASSERT(header1.getResponseCode() == 302);
BOOST_ASSERT(header1.existContent() == true);
HTTP_RESPONSE_HEADER header2;
header2.parseHeader(packet2, (int)strlen(packet2));
BOOST_ASSERT(header2.isChunk()== false);
BOOST_ASSERT(header2.getContentType()== CONTYPE_GIF);
BOOST_ASSERT(header2.getConnectionState()== HTTP_RESPONSE_HEADER::CONNECT_KEEP_ALIVE);
BOOST_ASSERT(header2.getContentLength() == 234);
BOOST_ASSERT(header2.getResponseCode() == 302);
BOOST_ASSERT(header2.existContent() == true);
const char * p = header2.getHeaderLine();
BOOST_ASSERT(0 == strcmp(header2.getDate(), "Thu, 24 Apr 2008 02:37:48 GMT"));
BOOST_ASSERT(0 == strcmp(header2.getHeaderLine(), "HTTP/1.1 302 Found"));
BOOST_ASSERT(0 == strlen(header2.getServer()));
HTTP_RESPONSE_HEADER header3;
header3.parseHeader(packet3, (int)strlen(packet3));
BOOST_ASSERT(header3.isChunk()== false);
BOOST_ASSERT(header3.getContentType()== CONTYPE_JPG);
BOOST_ASSERT(header3.getConnectionState()== HTTP_RESPONSE_HEADER::CONNECT_CLOSE);
BOOST_ASSERT(header3.getContentLength() == 62);
BOOST_ASSERT(header3.getResponseCode() == 302);
BOOST_ASSERT(header3.existContent() == true);
BOOST_ASSERT(0 == strlen(header3.getDate()));
HTTP_RESPONSE_HEADER header4;
header4.parseHeader(packet4, (int)strlen(packet4));
BOOST_ASSERT(header4.getContentType()== CONTYPE_HTML);
BOOST_ASSERT(header4.getConnectionState()== HTTP_RESPONSE_HEADER::NO_DESIGNATION);
BOOST_ASSERT(header4.isChunk()== true);
BOOST_ASSERT(header4.getResponseCode() == 200);
BOOST_ASSERT(header4.existContent() == true);
HTTP_RESPONSE_HEADER header6;
header6.parseHeader(packet6, (int)strlen(packet4));
BOOST_ASSERT(header6.getContentType()== CONTYPE_HTML);
BOOST_ASSERT(header6.getContentLength()== 3);
BOOST_ASSERT(header6.isChunk()== false);
BOOST_ASSERT(header6.getResponseCode() == 200);
BOOST_ASSERT(header6.existContent() == true);
} | [
"[email protected]"
] | [
[
[
1,
155
]
]
] |
a1206241ec41bb3cec6efe17bcb98e97218dfb0c | 842997c28ef03f8deb3422d0bb123c707732a252 | /src/moaicore/MOAIAnimCurve.cpp | d9ca31b6b10ef5f2f2dfda52f378bb25f10d1fcf | [] | no_license | bjorn/moai-beta | e31f600a3456c20fba683b8e39b11804ac88d202 | 2f06a454d4d94939dc3937367208222735dd164f | refs/heads/master | 2021-01-17T11:46:46.018377 | 2011-06-10T07:33:55 | 2011-06-10T07:33:55 | 1,837,561 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,272 | cpp | // Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#include "pch.h"
#include <moaicore/MOAIAnimCurve.h>
#include <moaicore/MOAILogMessages.h>
//================================================================//
// local
//================================================================//
//----------------------------------------------------------------//
/** @name getLength
@text Return the largest key frame time value in the curve.
@in MOAIAnimCurve self
@out number length
*/
int MOAIAnimCurve::_getLength ( lua_State* L ) {
MOAI_LUA_SETUP ( MOAIAnimCurve, "U" );
lua_pushnumber ( state, self->GetLength ());
return 1;
}
//----------------------------------------------------------------//
/** @name reserveKeys
@text Reserve key frames.
@in MOAIAnimCurve self
@in number nKeys
@out nil
*/
int MOAIAnimCurve::_reserveKeys ( lua_State* L ) {
MOAI_LUA_SETUP ( MOAIAnimCurve, "UN" );
self->Init ( state.GetValue < u32 >( 2, 0 ));
return 0;
}
//----------------------------------------------------------------//
/** @name setKey
@text Initialize a key frame at a given time with a give value. Also set the transition type between
the specified key frame and the next key frame.
@in MOAIAnimCurve self
@in number index Index of the keyframe.
@in number time Location of the key frame along the curve.
@in number value Value of the curve at time.
@in number mode The ease mode. One of MOAIEaseType.EASE_IN, MOAIEaseType.EASE_OUT, MOAIEaseType.FLAT MOAIEaseType.LINEAR,
MOAIEaseType.SMOOTH, MOAIEaseType.SOFT_EASE_IN, MOAIEaseType.SOFT_EASE_OUT, MOAIEaseType.SOFT_SMOOTH. Defaults to MOAIEaseType.SMOOTH.
@in number weight Blends between chosen ease type (of any) and a linear transition.
@out nil
*/
int MOAIAnimCurve::_setKey ( lua_State* L ) {
MOAI_LUA_SETUP ( MOAIAnimCurve, "UNNN" );
u32 index = state.GetValue < u32 >( 2, 1 ) - 1;
float time = state.GetValue < float >( 3, 0.0f );
float value = state.GetValue < float >( 4, 0.0f );
u32 mode = state.GetValue < u32 >( 5, USInterpolate::kSmooth );
float weight = state.GetValue < float >( 6, 1.0f );
MOAI_CHECK_INDEX ( index, self->Size ())
self->SetKey ( index, time, value, mode, weight );
return 0;
}
//================================================================//
// MOAIAnimCurve
//================================================================//
//----------------------------------------------------------------//
bool MOAIAnimCurve::ApplyAttrOp ( u32 attrID, USAttrOp& attrOp ) {
if ( MOAIAnimCurveAttr::Check ( attrID )) {
switch ( UNPACK_ATTR ( attrID )) {
case ATTR_TIME:
this->mTime = attrOp.Op ( this->mTime );
return true;
case ATTR_VALUE:
attrOp.Op ( this->mValue );
return true;
}
}
return false;
}
//----------------------------------------------------------------//
MOAIAnimCurve::MOAIAnimCurve () :
mTime ( 0.0f ),
mValue ( 0.0f ) {
RTTI_SINGLE ( MOAINode )
}
//----------------------------------------------------------------//
MOAIAnimCurve::~MOAIAnimCurve () {
}
//----------------------------------------------------------------//
void MOAIAnimCurve::OnDepNodeUpdate () {
this->mValue = this->GetFloatValue ( this->mTime );
}
//----------------------------------------------------------------//
void MOAIAnimCurve::RegisterLuaClass ( USLuaState& state ) {
state.SetField ( -1, "ATTR_TIME", MOAIAnimCurveAttr::Pack ( ATTR_TIME ));
state.SetField ( -1, "ATTR_VALUE", MOAIAnimCurveAttr::Pack ( ATTR_VALUE ));
}
//----------------------------------------------------------------//
void MOAIAnimCurve::RegisterLuaFuncs ( USLuaState& state ) {
MOAINode::RegisterLuaFuncs ( state );
luaL_Reg regTable [] = {
{ "getLength", _getLength },
{ "reserveKeys", _reserveKeys },
{ "setKey", _setKey },
{ NULL, NULL }
};
luaL_register ( state, 0, regTable );
}
//----------------------------------------------------------------//
STLString MOAIAnimCurve::ToString () {
STLString repr;
PRETTY_PRINT ( repr, mTime );
PRETTY_PRINT ( repr, mValue );
return repr;
}
| [
"[email protected]",
"[email protected]",
"Patrick@agile.(none)"
] | [
[
[
1,
65
],
[
67,
77
],
[
79,
79
],
[
90,
90
],
[
92,
114
],
[
117,
143
]
],
[
[
66,
66
]
],
[
[
78,
78
],
[
80,
89
],
[
91,
91
],
[
115,
116
]
]
] |
f9eec28c17d4d14719a1ccef626487efe136d005 | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /tags/release-2005-10-27/eeschema/libedit_onleftclick.cpp | 230dfdbc468f639aaa57a189a521546a64aa866e | [] | no_license | BackupTheBerlios/kicad-svn | 4b79bc0af39d6e5cb0f07556eb781a83e8a464b9 | 4c97bbde4b1b12ec5616a57c17298c77a9790398 | refs/heads/master | 2021-01-01T19:38:40.000652 | 2006-06-19T20:01:24 | 2006-06-19T20:01:24 | 40,799,911 | 0 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 6,779 | cpp | /*****************************************/
/* EESchema - libedit_onleftclick.cpp */
/*****************************************/
/* Library editor commands created by a mouse left button simple or double click
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "bitmaps.h"
#include "protos.h"
#include "id.h"
/************************************************************************/
void WinEDA_LibeditFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos)
/************************************************************************/
{
LibEDA_BaseStruct* DrawEntry = CurrentDrawItem;
if( CurrentLibEntry == NULL) return;
if ( m_ID_current_state == 0 )
{
if ( DrawEntry && DrawEntry->m_Flags )
{
switch (DrawEntry->m_StructType )
{
case COMPONENT_PIN_DRAW_TYPE:
SaveCopyInUndoList();
PlacePin(DC);
break;
case COMPONENT_FIELD_DRAW_TYPE:
SaveCopyInUndoList();
PlaceField(DC, (LibDrawField *) DrawEntry);
DrawEntry = NULL;
break;
default:
SaveCopyInUndoList();
EndDrawGraphicItem(DC);
break;
}
}
else
{
DrawEntry = LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry,
CurrentUnit, CurrentConvert);
if (DrawEntry == NULL )
{
DrawEntry = LocateDrawItem(GetScreen(), CurrentLibEntry,CurrentUnit,
CurrentConvert,LOCATE_ALL_DRAW_ITEM);
}
if ( DrawEntry ) DrawEntry->Display_Infos_DrawEntry(this);
else
{
EraseMsgBox();
AfficheDoc(this, CurrentLibEntry->m_Doc.GetData(),
CurrentLibEntry->m_KeyWord.GetData());
}
}
}
if ( m_ID_current_state )
{
switch ( m_ID_current_state )
{
case ID_NO_SELECT_BUTT:
break;
case ID_LIBEDIT_PIN_BUTT :
if( CurrentDrawItem == NULL )
{
DrawPanel->m_IgnoreMouseEvents = TRUE;
CreatePin(DC);
InstallPineditFrame(this, wxPoint(-1,-1) );
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
}
else
{
SaveCopyInUndoList();
PlacePin(DC);
}
break;
case ID_LIBEDIT_BODY_LINE_BUTT :
case ID_LIBEDIT_BODY_ARC_BUTT :
case ID_LIBEDIT_BODY_CIRCLE_BUTT :
case ID_LIBEDIT_BODY_RECT_BUTT :
case ID_LIBEDIT_BODY_TEXT_BUTT :
if ( CurrentDrawItem == NULL)
{
CurrentDrawItem = CreateGraphicItem(DC);
}
else
{
if ( CurrentDrawItem->m_Flags & IS_NEW )
GraphicItemBeginDraw(DC);
else
{
SaveCopyInUndoList();
EndDrawGraphicItem(DC);
}
}
break;
case ID_LIBEDIT_DELETE_ITEM_BUTT :
DrawEntry = LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry,
CurrentUnit, CurrentConvert);
if (DrawEntry == NULL )
{
DrawEntry = LocateDrawItem(GetScreen(), CurrentLibEntry,CurrentUnit,
CurrentConvert,LOCATE_ALL_DRAW_ITEM);
}
if ( DrawEntry == NULL )
{
AfficheDoc(this, CurrentLibEntry->m_Doc.GetData(),
CurrentLibEntry->m_KeyWord.GetData());
break;
}
SaveCopyInUndoList();
if ( DrawEntry->m_StructType == COMPONENT_PIN_DRAW_TYPE )
DeletePin(DC, CurrentLibEntry, (LibDrawPin*)DrawEntry);
else
DeleteOneLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry,DrawEntry, TRUE);
DrawEntry = NULL;
m_CurrentScreen->SetModify();
break;
case ID_LIBEDIT_ANCHOR_ITEM_BUTT :
SaveCopyInUndoList();
PlaceAncre();
SetToolID( 0, wxCURSOR_ARROW, "");
break;
default :
DisplayError(this, "WinEDA_LibeditFrame::OnLeftClick error");
SetToolID( 0, wxCURSOR_ARROW, "");
break;
}
}
}
/*************************************************************************/
void WinEDA_LibeditFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos)
/*************************************************************************/
/* Appelé sur un double click:
pour un élément editable (textes, composant):
appel de l'editeur correspondant.
pour une connexion en cours:
termine la connexion
*/
{
wxPoint pos = GetPosition();
LibEDA_BaseStruct* DrawEntry = CurrentDrawItem;
if ( CurrentLibEntry == NULL ) return;
if ( !m_ID_current_state || // Simple localisation des elements
(DrawEntry == NULL) || (DrawEntry->m_Flags == 0) )
{
DrawEntry = LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry,
CurrentUnit, CurrentConvert);
if ( DrawEntry == NULL )
{
DrawEntry = CurrentDrawItem = LocateDrawItem(GetScreen(), CurrentLibEntry,CurrentUnit,
CurrentConvert,LOCATE_ALL_DRAW_ITEM);
}
if ( DrawEntry == NULL )
{
DrawEntry = CurrentDrawItem = (LibEDA_BaseStruct*)
LocateField(CurrentLibEntry);
}
if ( DrawEntry == NULL )
{
wxPoint mpos;
wxGetMousePosition(&mpos.x, &mpos.y);
InstallLibeditFrame(mpos);
}
}
// Si Commande en cours: affichage commande d'annulation
if ( m_ID_current_state )
{
}
else
{
}
if ( DrawEntry ) DrawEntry->Display_Infos_DrawEntry(this);
else return;
CurrentDrawItem = DrawEntry;
DrawPanel->m_IgnoreMouseEvents = TRUE;
switch ( DrawEntry->m_StructType )
{
case COMPONENT_PIN_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 ) // Item localisé et non en edition: placement commande move
{
DrawPanel->m_IgnoreMouseEvents = TRUE;
InstallPineditFrame(this, pos);
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
}
break;
case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_RECT_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 )
{
DrawPanel->m_IgnoreMouseEvents = TRUE;
EditGraphicSymbol(DC, DrawEntry);
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
}
break;
case COMPONENT_LINE_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 )
{
EditGraphicSymbol(DC, DrawEntry);
DrawPanel->MouseToCursorSchema();
}
else if( DrawEntry->m_Flags & IS_NEW )
{
EndDrawGraphicItem(DC);
}
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 )
{
EditSymbolText(DC, DrawEntry);
DrawPanel->MouseToCursorSchema();
}
break;
case COMPONENT_FIELD_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 )
{
}
break;
default:
wxString msg;
msg.Printf(
"WinEDA_LibeditFrame::OnLeftDClick Error: unknown StructType %d",
DrawEntry->m_StructType);
DisplayError(this, msg );
break;
}
DrawPanel->m_IgnoreMouseEvents = FALSE;
}
| [
"bokeoa@244deca0-f506-0410-ab94-f4f3571dea26"
] | [
[
[
1,
273
]
]
] |
c27d03d4d9da5514dad5abcd5a009e40f58e88fa | 1fd622648edad3fc8b54acf381dba2de134a32a1 | /signe.hxx | 8102e3d98edd7850cd82b0dfc5ed7c1176d17206 | [] | no_license | cider-load-test/partsim | ec2423c172381ab27b66731fea02c10596346f3e | cea4f91d7780e8472e18ccc03cad1a010143538a | refs/heads/master | 2021-12-02T06:07:22.246809 | 2008-11-20T22:16:01 | 2008-11-20T22:16:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 199 | hxx | #ifndef SIGNE
# define SIGNE
template <bool _positive>
struct Signe
{
static const int value = 1;
};
template <>
struct Signe<false>
{
static const int value = -1;
};
#endif
| [
"[email protected]"
] | [
[
[
1,
17
]
]
] |
9ebcf80ed48224aa71964ff1dc80c4aabb72005f | 6406ffa37fd4b705e61b79312f0ebe1035228365 | /src/messages/BurstControlPacket.h | 336e4705697863613203006cfc04445a7926f359 | [] | no_license | kitakita/omnetpp_obs | 65904d4e37637706a385476f7c33656c491e2fbd | 19e7c8f0eafcd293d381e733712ecbb2a3564b08 | refs/heads/master | 2021-01-02T12:55:37.328995 | 2011-01-30T10:42:56 | 2011-01-30T10:42:56 | 1,189,202 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,419 | h | //
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
#ifndef BURSTCONTROLPACKET_H_
#define BURSTCONTROLPACKET_H_
#include <omnetpp.h>
#include "BurstControlPacket_m.h"
class BurstControlPacket : public BurstControlPacket_Base
{
protected:
cMessage *burst;
public:
BurstControlPacket(const char *name = NULL, int kind = 0) : BurstControlPacket_Base(name, kind) {}
BurstControlPacket(const BurstControlPacket& other) : BurstControlPacket_Base(other) {}
BurstControlPacket& operator=(const BurstControlPacket& other) { BurstControlPacket_Base::operator=(other); return *this; }
virtual BurstControlPacket *dup() { return new BurstControlPacket(*this); }
cMessage *getBurst() { return burst; };
void setBurst(cMessage *msg) { burst = msg; }
};
#endif /* BURSTCONTROLPACKET_H_ */
| [
"[email protected]"
] | [
[
[
1,
37
]
]
] |
1bb8aeade70eb7360325cf01408a11e95dc065e7 | d115cf7a1b374d857f6b094d4b4ccd8e9b1ac189 | /pygccxml_dev/unittests/data/classes.hpp | a14123eac9bc0aeb0b26231118b86c4745c76eff | [
"BSL-1.0"
] | permissive | gatoatigrado/pyplusplusclone | 30af9065fb6ac3dcce527c79ed5151aade6a742f | a64dc9aeeb718b2f30bd6a5ff8dcd8bfb1cd2ede | refs/heads/master | 2016-09-05T23:32:08.595261 | 2010-05-16T10:53:45 | 2010-05-16T10:53:45 | 700,369 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 354 | hpp | // Copyright 2004-2008 Roman Yakovenko.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef __classes_hpp__
#define __classes_hpp__
struct cls{};
namespace ns{
struct nested_cls{};
}
#endif//__classes_hpp__
| [
"roman_yakovenko@dc5859f9-2512-0410-ae5c-dd123cda1f76"
] | [
[
[
1,
17
]
]
] |
bcc00f680d95d830fbae0da5ec09333ac5b9eb62 | b8c3d2d67e983bd996b76825f174bae1ba5741f2 | /RTMP/utils/gil_2/boost/gil/extension/opencv/opencv_all.hpp | 859b715b529e6923bf2d352d6689cf43decc7eef | [] | no_license | wangscript007/rtmp-cpp | 02172f7a209790afec4c00b8855d7a66b7834f23 | 3ec35590675560ac4fa9557ca7a5917c617d9999 | refs/heads/master | 2021-05-30T04:43:19.321113 | 2008-12-24T20:16:15 | 2008-12-24T20:16:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 971 | hpp | /*
Copyright 2008 Christian Henning
Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
*/
/*************************************************************************************************/
#ifndef BOOST_GIL_EXTENSION_OPENCV_ALL_HPP_INCLUDED
#define BOOST_GIL_EXTENSION_OPENCV_ALL_HPP_INCLUDED
////////////////////////////////////////////////////////////////////////////////////////
/// \file
/// \brief
/// \author Christian Henning \n
///
/// \date 2008 \n
///
////////////////////////////////////////////////////////////////////////////////////////
#include "convert_color.hpp"
#include "convert_scale.hpp"
#include "drawing.hpp"
#include "edge_detection.hpp"
#include "resize.hpp"
#include "smooth.hpp"
#include "text.hpp"
#endif // BOOST_GIL_EXTENSION_OPENCV_UTILITIES_HPP_INCLUDED
| [
"fpelliccioni@71ea4c15-5055-0410-b3ce-cda77bae7b57"
] | [
[
[
1,
30
]
]
] |
0135c2204898342edddf132579e4595e4e06eaf4 | 45229380094a0c2b603616e7505cbdc4d89dfaee | /wavelets/facedetector_src/src/cvLib/basefwt.cpp | 30b200f9306932b33ae6ae293f450bb0e073293c | [] | no_license | xcud/msrds | a71000cc096723272e5ada7229426dee5100406c | 04764859c88f5c36a757dbffc105309a27cd9c4d | refs/heads/master | 2021-01-10T01:19:35.834296 | 2011-11-04T09:26:01 | 2011-11-04T09:26:01 | 45,697,313 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 13,562 | cpp |
#include "stdafx.h"
#include "basefwt.h"
#include "vec1d.h"
///////////////////////////////////constructors/destructors///////////////////////////////////////////////////////////////////
//constructor status 0-not initilized, 1,2-ok after init(), -1,-2,... errors
BaseFWT2D::BaseFWT2D(const wchar_t* fname) : m_status(0),
tH(0), tG(0), H(0), G(0), H2m(0), G2m(0), H2m1(0), G2m1(0),
J(0), TH(0), m_width(0), m_height(0),
spec(0), tspec(0), spec2d(0), tspec2d(0)
{
wcscpy(filter, fname);
FILE* flt = _wfopen(fname, L"rt");
if (flt) {
if ((tH = loadfilter(flt)) == 0) {
m_status = -2;
return;
}
if ((tG = loadfilter(flt)) == 0) {
m_status = -3;
return;
}
if ((H = loadfilter(flt)) == 0) {
m_status = -4;
return;
}
if ((G = loadfilter(flt)) == 0) {
m_status = -5;
return;
}
fclose(flt);
makeHGsynth();
} else
m_status = -1; //filter file failed to open
}
BaseFWT2D::BaseFWT2D(const wchar_t* fname,
const float* tH, unsigned int thL, int thZ,
const float* tG, unsigned int tgL, int tgZ,
const float* H, unsigned int hL, int hZ,
const float* G, unsigned int gL, int gZ) : m_status(0),
tH(0), tG(0), H(0), G(0), H2m(0), G2m(0), H2m1(0), G2m1(0),
J(0), TH(0), m_width(0), m_height(0),
spec(0), tspec(0), spec2d(0), tspec2d(0)
{
wcscpy(filter, fname);
this->tH = new vec1D(thL, -thZ, tH);
this->tG = new vec1D(tgL, -tgZ, tG);
this->H = new vec1D(hL, -hZ, H);
this->G = new vec1D(gL, -gZ, G);
makeHGsynth();
}
BaseFWT2D::~BaseFWT2D()
{
if (tH) delete tH;
if (tG) delete tG;
if (H) delete H;
if (G) delete G;
if (H2m) delete H2m;
if (G2m) delete G2m;
if (H2m1) delete H2m1;
if (G2m1) delete G2m1;
close(); //close spec,tspec,spec2d,tspec2d buffers
}
///////////////////////////////////constructors/destructors///////////////////////////////////////////////////////////////////
//////////////////////////////////init/status functions//////////////////////////////////////////////////////////////////////
const wchar_t* BaseFWT2D::status(int& status) const
{
status = m_status;
switch (m_status) {
default:
case 0:
return 0;
case 1:
case 2:
return L"ready for transforms";
case -1:
return L"failed to open filter file";
case -2:
return L"failed to load tH filter";
case -3:
return L"failed to load tG filter";
case -4:
return L"failed to load H filter";
case -5:
return L"failed to load G filter";
}
}
vec1D* BaseFWT2D::loadfilter(FILE* flt) const
{
int L, Z;
if (fwscanf(flt, L"%d %d", &L, &Z) != 2)
return 0;
vec1D* wf = new vec1D(L, -Z);
for (int i = wf->first(); i <= wf->last(); i++) {
float tmp;
if (fwscanf(flt, L"%*d %f", &tmp) != 1)
return 0;
else
(*wf)(i) = tmp;
}
return wf;
}
void BaseFWT2D::makeHGsynth()
{
int size2m, offset2m;
int size2m1, offset2m1;
size2m = 0;
size2m1 = 0;
//arrange H2m,H2m1
for (int m = H->first(); m <= H->last(); m++) { //count how many odd even coeffs
if (m % 2)
size2m1++;
else
size2m++;
}
offset2m = (H->first() - (H->first() % 2)) / 2;
offset2m1 = (H->first() + (H->first() % 2)) / 2;
H2m = new vec1D(size2m, offset2m);
H2m1 = new vec1D(size2m1, offset2m1);
for (int m = H2m->first(); m <= H2m->last(); m++)
(*H2m)(m) = (*H)(2 * m);
for (int m = H2m1->first(); m <= H2m1->last(); m++)
(*H2m1)(m) = (*H)(2 * m + 1);
size2m = 0;
size2m1 = 0;
//arrange G2m,G2m1
for (int m = G->first(); m <= G->last(); m++) {
if (m % 2)
size2m1++;
else
size2m++;
}
offset2m = (G->first() - (G->first() % 2)) / 2;
offset2m1 = (G->first() + (G->first() % 2)) / 2;
G2m = new vec1D(size2m, offset2m);
G2m1 = new vec1D(size2m1, offset2m1);
for (int m = G2m->first(); m <= G2m->last(); m++)
(*G2m)(m) = (*G)(2 * m);
for (int m = G2m1->first(); m <= G2m1->last(); m++)
(*G2m1)(m) = (*G)(2 * m + 1);
}
void BaseFWT2D::tracefilters(const wchar_t* fname) const
{
FILE* fp = _wfopen(fname, L"wt");
if (fp) {
fwprintf(fp, L"tH\n");
for (int i = tH->first(); i <= tH->last(); i++)
fwprintf(fp, L" %2d %g\n", i, (*tH)(i));
fwprintf(fp, L"\ntG\n");
for (int i = tG->first(); i <= tG->last(); i++)
fwprintf(fp, L" %2d %g\n", i, (*tG)(i));
fwprintf(fp, L"\nH\n");
for (int i = H->first(); i <= H->last(); i++)
fwprintf(fp, L" %2d %g\n", i, (*H)(i));
fwprintf(fp, L"\nG\n");
for (int i = G->first(); i <= G->last(); i++)
fwprintf(fp, L" %2d %g\n", i, (*G)(i));
fwprintf(fp, L"\n\nH2m\n");
for (int i = H2m->first(); i <= H2m->last(); i++)
fwprintf(fp, L" %2d %g\n", 2*i, (*H2m)(i));
fwprintf(fp, L"\nH2m1\n");
for (int i = H2m1->first(); i <= H2m1->last(); i++)
fwprintf(fp, L" %2d %g\n", 2*i + 1, (*H2m1)(i));
fwprintf(fp, L"\nG2m\n");
for (int i = G2m->first(); i <= G2m->last(); i++)
fwprintf(fp, L" %2d %g\n", 2*i, (*G2m)(i));
fwprintf(fp, L"\nG2m1\n");
for (int i = G2m1->first(); i <= G2m1->last(); i++)
fwprintf(fp, L" %2d %g\n", 2*i + 1, (*G2m1)(i));
fclose(fp);
}
}
void BaseFWT2D::init(unsigned int width, unsigned int height)
{
if (width != m_width || height != m_height) {
close();
m_width = width;
m_height = height;
spec = (char*)malloc(2 * width * height * sizeof(char));
tspec = spec + width * height;
spec2d = (char**)malloc(2 * height * sizeof(char*)); //setup rows
for (unsigned int j = 0; j < 2*height; j++)
spec2d[j] = &spec[j*width]; //setup cols
tspec2d = &spec2d[height];
m_status = 1;
}
}
void BaseFWT2D::init(char* data, char* tdata, unsigned int width, unsigned int height)
{
close();
m_width = width;
m_height = height;
spec = data; //data - tdata might be not continuous in memory
tspec = tdata;
spec2d = (char**)malloc(2 * height * sizeof(char *)); //setup rows
for (unsigned int j = 0; j < height; j++)
spec2d[j] = &spec[j*width]; //setup cols
for (unsigned int j = 0; j < height; j++)
spec2d[j+height] = &tspec[j*width]; //setup cols
tspec2d = &spec2d[height];
m_status = 2;
}
void BaseFWT2D::close(void)
{
m_width = 0;
m_height = 0;
if (m_status == 1) {
if (spec != 0) {
free(spec);
spec = 0;
}
}
if (spec2d != 0) {
free(spec2d);
spec2d = 0;
}
m_status = 0;
}
//////////////////////////////////init/status functions//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////transforms/////////////////////////////////////////////////////////////////////
int BaseFWT2D::trans(unsigned int scales, unsigned int th)
{
if (m_status <= 0)
return -1;
J = scales;
TH = th;
unsigned int w = m_width;
unsigned int h = m_height;
for (unsigned int j = 0; j < J; j++) {
transrows(tspec2d, spec2d, w, h);
transcols(spec2d, tspec2d, w, h);
w /= 2;
h /= 2;
TH /= 4;
}
return 0;
}
int BaseFWT2D::trans(const char* data, unsigned int scales, unsigned int th)
{
if (m_status <= 0)
return -1;
mmxmemcpy(spec, data, m_width*m_height); //copy data to spec
return trans(scales, th); //fwt transform
}
int BaseFWT2D::trans(const unsigned char* data, unsigned int scales, unsigned int th)
{
if (m_status <= 0)
return -1;
sub128(spec, data, m_width*m_height); //copy data to spec and correct DC
return trans(scales, th); //fwt transform
}
///////////////////////////////////////////////transforms/////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////synths//////////////////////////////////////////////////////////////////////////
int BaseFWT2D::synth()
{
if (m_status <= 0)
return -1;
unsigned int w = m_width / (unsigned int)pow(2.0f, (float)J);
unsigned int h = m_height / (unsigned int)pow(2.0f, (float)J);
while (J) {
synthcols(tspec2d, spec2d, w, h);
synthrows(spec2d, tspec2d, w, h);
w *= 2;
h *= 2;
J--;
}
return 0;
}
int BaseFWT2D::synth(char* data)
{
int res;
res = synth();
if (res != 0)
return res;
mmxmemcpy(data, spec, m_width*m_height); //copy restored spec to data
return res;
}
int BaseFWT2D::synth(unsigned char* data)
{
int res;
res = synth();
if (res != 0)
return res;
add128(data, spec, m_width*m_height); //copy restored spec to data and correct DC
return res;
}
//////////////////////////////////////////////synths//////////////////////////////////////////////////////////////////////////
//////////////////////////mmx routines////////////////////////////////////////////////////////////////////////////////////////
void BaseFWT2D::mmxmemcpy(char* dest, const char* sour, unsigned int size)
{
//for(int i=0; i<m_width*m_height; i++) //stub
//dest[i] = sour[i];
unsigned int modsize8 = size % 8;
__m64* pdest = (__m64*)dest;
const __m64* psour = (__m64*)sour;
for (unsigned int i = 0; i < size / 8; i++)
*pdest++ = *psour++;
if (modsize8) {
dest = (char*)pdest;
sour = (char*)psour;
for (unsigned int i = 0; i < modsize8; i++)
*dest++ = *sour++;
}
_mm_empty();
}
void BaseFWT2D::sub128(char* dest, const unsigned char* sour, unsigned int size)
{
//for(int i=0; i<m_width*m_height; i++)
// dest[i] = (char)((int)sour[i]-128);
unsigned int modsize8 = size % 8;
__m64 m128;
m128.m64_u64 = 0x8080808080808080;
__m64* pdest = (__m64*)dest;
const __m64* psour = (__m64*)sour;
for (unsigned int i = 0; i < size / 8; i++)
*pdest++ = _mm_sub_pi8(*psour++ , m128);
if (modsize8) {
dest = (char*)pdest;
sour = (unsigned char*)psour;
for (unsigned int i = 0; i < modsize8; i++)
*dest++ = (char)((int) * sour++ - 128);
}
_mm_empty();
}
void BaseFWT2D::add128(unsigned char* dest, const char* sour, unsigned int size)
{
//for(int i=0; i<m_width*m_height; i++)
// data[i] = (unsigned char)((int)spec[i]+128);
unsigned int modsize8 = size % 8;
__m64 m128;
m128.m64_u64 = 0x8080808080808080;
__m64* pdest = (__m64*)dest;
__m64* psour = (__m64*)sour;
for (unsigned int i = 0; i < size / 8; i++)
*pdest++ = _mm_add_pi8(*psour++ , m128);
if (modsize8) {
dest = (unsigned char*)pdest;
sour = (char*)psour;
for (unsigned int i = 0; i < modsize8; i++)
*dest++ = (unsigned char)((int) * sour++ + 128);
}
_mm_empty();
}
| [
"perpet99@cc61708c-8d4c-0410-8fce-b5b73d66a671"
] | [
[
[
1,
421
]
]
] |
f24ad75839200f02ae24a83cd7a1929b5ef26017 | 550e17ad61efc7bea2066db5844663c8b5835e4f | /Source/Base/Field/OSGInt32ToStringMapType.cpp | f4af221296bd54ee9f79a106d306d812f500628b | [] | no_license | danguilliams/OpenSGToolbox | 9287424c66c9c4b38856cf749a311f15d8aac4f0 | 102a9fb02ad1ceeaf5784e6611c2862c4ba84d61 | refs/heads/master | 2021-01-17T23:02:36.528911 | 2010-11-01T16:56:31 | 2010-11-01T16:56:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,034 | cpp | /*---------------------------------------------------------------------------*\
* OpenSG ToolBox Toolbox *
* *
* *
* *
* *
* Authors: David Kabala *
* *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
* License *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Library General Public License as published *
* by the Free Software Foundation, version 2. *
* *
* This library 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 *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
\*---------------------------------------------------------------------------*/
// Source file for new Field type
// This define is only set in this source file. It switches the
// Windows-specific declarations in the header for compiling the Field,
// not for using it.
#define OSG_COMPILEINT32TOSTRINGMAPTYPEINST
// You need this in every OpenSG file
#include "OSGField.h"
#include "OSGSField.h"
#include "OSGSField.ins"
#include "OSGMField.h"
#include "OSGMField.ins"
// The new field type include
#include "OSGInt32ToStringMapType.h"
OSG_BEGIN_NAMESPACE
// This is where the DataType for the new Fieldtype is defined.
// The parameters are the name of the type and the name of the parent type
DataType FieldTraits<Int32ToStringMap>::_type("Int32ToStringMap", "BaseType");
// These macros instantiate the necessary template methods for the fields
OSG_FIELD_DLLEXPORT_DEF1(SField, Int32ToStringMap )
OSG_FIELD_DLLEXPORT_DEF1(MField, Int32ToStringMap )
OSG_END_NAMESPACE
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
35
],
[
37,
37
],
[
43,
50
],
[
52,
53
],
[
56,
58
]
],
[
[
36,
36
],
[
38,
42
],
[
51,
51
],
[
54,
55
]
]
] |
41b0f58392552ee4df059552c418d1786320df2c | 81d3ba636ee63af055c917f13f6ebcb3b7e4717e | /juce/src/gui/components/buttons/juce_Button.cpp | fd5f64f2a9eb0a11d49a94312d96ce78f79924eb | [] | no_license | haibocheng/video_editor | cc68a4f02fc14756c2aa9369a536c8f49fef1334 | 40ab4a33642f70ea1c731f59aa062d82e7120bc7 | refs/heads/master | 2021-01-16T17:55:47.850527 | 2011-03-11T00:42:55 | 2011-03-11T00:42:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,630 | cpp | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-10 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE 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.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
#include "../../../core/juce_StandardHeader.h"
BEGIN_JUCE_NAMESPACE
#include "juce_Button.h"
#include "../keyboard/juce_KeyPressMappingSet.h"
#include "../mouse/juce_MouseInputSource.h"
#include "../../../text/juce_LocalisedStrings.h"
#include "../../../events/juce_Timer.h"
//==============================================================================
class Button::RepeatTimer : public Timer
{
public:
RepeatTimer (Button& owner_) : owner (owner_) {}
void timerCallback() { owner.repeatTimerCallback(); }
private:
Button& owner;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RepeatTimer);
};
//==============================================================================
Button::Button (const String& name)
: Component (name),
text (name),
buttonPressTime (0),
lastRepeatTime (0),
commandManagerToUse (0),
autoRepeatDelay (-1),
autoRepeatSpeed (0),
autoRepeatMinimumDelay (-1),
radioGroupId (0),
commandID (0),
connectedEdgeFlags (0),
buttonState (buttonNormal),
lastToggleState (false),
clickTogglesState (false),
needsToRelease (false),
needsRepainting (false),
isKeyDown (false),
triggerOnMouseDown (false),
generateTooltip (false)
{
setWantsKeyboardFocus (true);
isOn.addListener (this);
}
Button::~Button()
{
isOn.removeListener (this);
if (commandManagerToUse != 0)
commandManagerToUse->removeListener (this);
repeatTimer = 0;
clearShortcuts();
}
//==============================================================================
void Button::setButtonText (const String& newText)
{
if (text != newText)
{
text = newText;
repaint();
}
}
void Button::setTooltip (const String& newTooltip)
{
SettableTooltipClient::setTooltip (newTooltip);
generateTooltip = false;
}
const String Button::getTooltip()
{
if (generateTooltip && commandManagerToUse != 0 && commandID != 0)
{
String tt (commandManagerToUse->getDescriptionOfCommand (commandID));
Array <KeyPress> keyPresses (commandManagerToUse->getKeyMappings()->getKeyPressesAssignedToCommand (commandID));
for (int i = 0; i < keyPresses.size(); ++i)
{
const String key (keyPresses.getReference(i).getTextDescription());
tt << " [";
if (key.length() == 1)
tt << TRANS("shortcut") << ": '" << key << "']";
else
tt << key << ']';
}
return tt;
}
return SettableTooltipClient::getTooltip();
}
void Button::setConnectedEdges (const int connectedEdgeFlags_)
{
if (connectedEdgeFlags != connectedEdgeFlags_)
{
connectedEdgeFlags = connectedEdgeFlags_;
repaint();
}
}
//==============================================================================
void Button::setToggleState (const bool shouldBeOn,
const bool sendChangeNotification)
{
if (shouldBeOn != lastToggleState)
{
if (isOn != shouldBeOn) // this test means that if the value is void rather than explicitly set to
isOn = shouldBeOn; // false, it won't be changed unless the required value is true.
lastToggleState = shouldBeOn;
repaint();
if (sendChangeNotification)
{
WeakReference<Component> deletionWatcher (this);
sendClickMessage (ModifierKeys());
if (deletionWatcher == 0)
return;
}
if (lastToggleState)
turnOffOtherButtonsInGroup (sendChangeNotification);
}
}
void Button::setClickingTogglesState (const bool shouldToggle) throw()
{
clickTogglesState = shouldToggle;
// if you've got clickTogglesState turned on, you shouldn't also connect the button
// up to be a command invoker. Instead, your command handler must flip the state of whatever
// it is that this button represents, and the button will update its state to reflect this
// in the applicationCommandListChanged() method.
jassert (commandManagerToUse == 0 || ! clickTogglesState);
}
bool Button::getClickingTogglesState() const throw()
{
return clickTogglesState;
}
void Button::valueChanged (Value& value)
{
if (value.refersToSameSourceAs (isOn))
setToggleState (isOn.getValue(), true);
}
void Button::setRadioGroupId (const int newGroupId)
{
if (radioGroupId != newGroupId)
{
radioGroupId = newGroupId;
if (lastToggleState)
turnOffOtherButtonsInGroup (true);
}
}
void Button::turnOffOtherButtonsInGroup (const bool sendChangeNotification)
{
Component* const p = getParentComponent();
if (p != 0 && radioGroupId != 0)
{
WeakReference<Component> deletionWatcher (this);
for (int i = p->getNumChildComponents(); --i >= 0;)
{
Component* const c = p->getChildComponent (i);
if (c != this)
{
Button* const b = dynamic_cast <Button*> (c);
if (b != 0 && b->getRadioGroupId() == radioGroupId)
{
b->setToggleState (false, sendChangeNotification);
if (deletionWatcher == 0)
return;
}
}
}
}
}
//==============================================================================
void Button::enablementChanged()
{
updateState();
repaint();
}
Button::ButtonState Button::updateState()
{
return updateState (isMouseOver (true), isMouseButtonDown());
}
Button::ButtonState Button::updateState (const bool over, const bool down)
{
ButtonState newState = buttonNormal;
if (isEnabled() && isVisible() && ! isCurrentlyBlockedByAnotherModalComponent())
{
if ((down && (over || (triggerOnMouseDown && buttonState == buttonDown))) || isKeyDown)
newState = buttonDown;
else if (over)
newState = buttonOver;
}
setState (newState);
return newState;
}
void Button::setState (const ButtonState newState)
{
if (buttonState != newState)
{
buttonState = newState;
repaint();
if (buttonState == buttonDown)
{
buttonPressTime = Time::getApproximateMillisecondCounter();
lastRepeatTime = 0;
}
sendStateMessage();
}
}
bool Button::isDown() const throw()
{
return buttonState == buttonDown;
}
bool Button::isOver() const throw()
{
return buttonState != buttonNormal;
}
void Button::buttonStateChanged()
{
}
uint32 Button::getMillisecondsSinceButtonDown() const throw()
{
const uint32 now = Time::getApproximateMillisecondCounter();
return now > buttonPressTime ? now - buttonPressTime : 0;
}
void Button::setTriggeredOnMouseDown (const bool isTriggeredOnMouseDown) throw()
{
triggerOnMouseDown = isTriggeredOnMouseDown;
}
//==============================================================================
void Button::clicked()
{
}
void Button::clicked (const ModifierKeys& /*modifiers*/)
{
clicked();
}
static const int clickMessageId = 0x2f3f4f99;
void Button::triggerClick()
{
postCommandMessage (clickMessageId);
}
void Button::internalClickCallback (const ModifierKeys& modifiers)
{
if (clickTogglesState)
setToggleState ((radioGroupId != 0) || ! lastToggleState, false);
sendClickMessage (modifiers);
}
void Button::flashButtonState()
{
if (isEnabled())
{
needsToRelease = true;
setState (buttonDown);
getRepeatTimer().startTimer (100);
}
}
void Button::handleCommandMessage (int commandId)
{
if (commandId == clickMessageId)
{
if (isEnabled())
{
flashButtonState();
internalClickCallback (ModifierKeys::getCurrentModifiers());
}
}
else
{
Component::handleCommandMessage (commandId);
}
}
//==============================================================================
void Button::addListener (ButtonListener* const newListener)
{
buttonListeners.add (newListener);
}
void Button::removeListener (ButtonListener* const listener)
{
buttonListeners.remove (listener);
}
void Button::addButtonListener (ButtonListener* l) { addListener (l); }
void Button::removeButtonListener (ButtonListener* l) { removeListener (l); }
void Button::sendClickMessage (const ModifierKeys& modifiers)
{
Component::BailOutChecker checker (this);
if (commandManagerToUse != 0 && commandID != 0)
{
ApplicationCommandTarget::InvocationInfo info (commandID);
info.invocationMethod = ApplicationCommandTarget::InvocationInfo::fromButton;
info.originatingComponent = this;
commandManagerToUse->invoke (info, true);
}
clicked (modifiers);
if (! checker.shouldBailOut())
{
buttonListeners.callChecked (checker, &ButtonListener::buttonClicked, this); // (can't use Button::Listener due to idiotic VC2005 bug)
buttonListeners.callChecked (checker, &ButtonListener::buttonClickedWithMods, this, modifiers); // (can't use Button::Listener due to idiotic VC2005 bug)
}
}
void Button::sendStateMessage()
{
Component::BailOutChecker checker (this);
buttonStateChanged();
if (! checker.shouldBailOut())
buttonListeners.callChecked (checker, &ButtonListener::buttonStateChanged, this);
}
//==============================================================================
void Button::paint (Graphics& g)
{
if (needsToRelease && isEnabled())
{
needsToRelease = false;
needsRepainting = true;
}
paintButton (g, isOver(), isDown());
}
//==============================================================================
void Button::mouseEnter (const MouseEvent&)
{
updateState (true, false);
}
void Button::mouseExit (const MouseEvent&)
{
updateState (false, false);
}
void Button::mouseDown (const MouseEvent& e)
{
updateState (true, true);
if (isDown())
{
if (autoRepeatDelay >= 0)
getRepeatTimer().startTimer (autoRepeatDelay);
if (triggerOnMouseDown)
internalClickCallback (e.mods);
}
}
void Button::mouseUp (const MouseEvent& e)
{
const bool wasDown = isDown();
updateState (isMouseOver(), false);
if (wasDown && isOver() && ! triggerOnMouseDown)
internalClickCallback (e.mods);
}
void Button::mouseDrag (const MouseEvent&)
{
const ButtonState oldState = buttonState;
updateState (isMouseOver(), true);
if (autoRepeatDelay >= 0 && buttonState != oldState && isDown())
getRepeatTimer().startTimer (autoRepeatSpeed);
}
void Button::focusGained (FocusChangeType)
{
updateState();
repaint();
}
void Button::focusLost (FocusChangeType)
{
updateState();
repaint();
}
void Button::visibilityChanged()
{
needsToRelease = false;
updateState();
}
void Button::parentHierarchyChanged()
{
Component* const newKeySource = (shortcuts.size() == 0) ? 0 : getTopLevelComponent();
if (newKeySource != keySource.get())
{
if (keySource != 0)
keySource->removeKeyListener (this);
keySource = newKeySource;
if (keySource != 0)
keySource->addKeyListener (this);
}
}
//==============================================================================
void Button::setCommandToTrigger (ApplicationCommandManager* const commandManagerToUse_,
const int commandID_,
const bool generateTooltip_)
{
commandID = commandID_;
generateTooltip = generateTooltip_;
if (commandManagerToUse != commandManagerToUse_)
{
if (commandManagerToUse != 0)
commandManagerToUse->removeListener (this);
commandManagerToUse = commandManagerToUse_;
if (commandManagerToUse != 0)
commandManagerToUse->addListener (this);
// if you've got clickTogglesState turned on, you shouldn't also connect the button
// up to be a command invoker. Instead, your command handler must flip the state of whatever
// it is that this button represents, and the button will update its state to reflect this
// in the applicationCommandListChanged() method.
jassert (commandManagerToUse == 0 || ! clickTogglesState);
}
if (commandManagerToUse != 0)
applicationCommandListChanged();
else
setEnabled (true);
}
void Button::applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo& info)
{
if (info.commandID == commandID
&& (info.commandFlags & ApplicationCommandInfo::dontTriggerVisualFeedback) == 0)
{
flashButtonState();
}
}
void Button::applicationCommandListChanged()
{
if (commandManagerToUse != 0)
{
ApplicationCommandInfo info (0);
ApplicationCommandTarget* const target = commandManagerToUse->getTargetForCommand (commandID, info);
setEnabled (target != 0 && (info.flags & ApplicationCommandInfo::isDisabled) == 0);
if (target != 0)
setToggleState ((info.flags & ApplicationCommandInfo::isTicked) != 0, false);
}
}
//==============================================================================
void Button::addShortcut (const KeyPress& key)
{
if (key.isValid())
{
jassert (! isRegisteredForShortcut (key)); // already registered!
shortcuts.add (key);
parentHierarchyChanged();
}
}
void Button::clearShortcuts()
{
shortcuts.clear();
parentHierarchyChanged();
}
bool Button::isShortcutPressed() const
{
if (! isCurrentlyBlockedByAnotherModalComponent())
{
for (int i = shortcuts.size(); --i >= 0;)
if (shortcuts.getReference(i).isCurrentlyDown())
return true;
}
return false;
}
bool Button::isRegisteredForShortcut (const KeyPress& key) const
{
for (int i = shortcuts.size(); --i >= 0;)
if (key == shortcuts.getReference(i))
return true;
return false;
}
bool Button::keyStateChanged (const bool, Component*)
{
if (! isEnabled())
return false;
const bool wasDown = isKeyDown;
isKeyDown = isShortcutPressed();
if (autoRepeatDelay >= 0 && (isKeyDown && ! wasDown))
getRepeatTimer().startTimer (autoRepeatDelay);
updateState();
if (isEnabled() && wasDown && ! isKeyDown)
{
internalClickCallback (ModifierKeys::getCurrentModifiers());
// (return immediately - this button may now have been deleted)
return true;
}
return wasDown || isKeyDown;
}
bool Button::keyPressed (const KeyPress&, Component*)
{
// returning true will avoid forwarding events for keys that we're using as shortcuts
return isShortcutPressed();
}
bool Button::keyPressed (const KeyPress& key)
{
if (isEnabled() && key.isKeyCode (KeyPress::returnKey))
{
triggerClick();
return true;
}
return false;
}
//==============================================================================
void Button::setRepeatSpeed (const int initialDelayMillisecs,
const int repeatMillisecs,
const int minimumDelayInMillisecs) throw()
{
autoRepeatDelay = initialDelayMillisecs;
autoRepeatSpeed = repeatMillisecs;
autoRepeatMinimumDelay = jmin (autoRepeatSpeed, minimumDelayInMillisecs);
}
void Button::repeatTimerCallback()
{
if (needsRepainting)
{
getRepeatTimer().stopTimer();
updateState();
needsRepainting = false;
}
else if (autoRepeatSpeed > 0 && (isKeyDown || (updateState() == buttonDown)))
{
int repeatSpeed = autoRepeatSpeed;
if (autoRepeatMinimumDelay >= 0)
{
double timeHeldDown = jmin (1.0, getMillisecondsSinceButtonDown() / 4000.0);
timeHeldDown *= timeHeldDown;
repeatSpeed = repeatSpeed + (int) (timeHeldDown * (autoRepeatMinimumDelay - repeatSpeed));
}
repeatSpeed = jmax (1, repeatSpeed);
const uint32 now = Time::getMillisecondCounter();
// if we've been blocked from repeating often enough, speed up the repeat timer to compensate..
if (lastRepeatTime != 0 && (int) (now - lastRepeatTime) > repeatSpeed * 2)
repeatSpeed = jmax (1, repeatSpeed / 2);
lastRepeatTime = now;
getRepeatTimer().startTimer (repeatSpeed);
internalClickCallback (ModifierKeys::getCurrentModifiers());
}
else if (! needsToRelease)
{
getRepeatTimer().stopTimer();
}
}
Button::RepeatTimer& Button::getRepeatTimer()
{
if (repeatTimer == 0)
repeatTimer = new RepeatTimer (*this);
return *repeatTimer;
}
END_JUCE_NAMESPACE
| [
"[email protected]"
] | [
[
[
1,
674
]
]
] |
afd2f829f6816a1f892e7040543c4f73593236d8 | d67b01b820739ea2d63968389a83c36c4b0ff163 | /UnitTests/QuizBotUnitTest/QuizBotUnitTest/ParticipantManager.cpp | 5a79f8e4af15bfc6362e1fb163e3f1e60a2fd8e8 | [] | no_license | iamukasa/pookas | 114458dc7347c66844ff8cf3023ec75ce4c486b5 | bd5bf9178d2a2a37b3251a07eb3e6afa96f66c67 | refs/heads/master | 2021-01-13T02:08:54.947799 | 2009-11-04T00:52:06 | 2009-11-04T00:52:06 | 35,762,044 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,089 | cpp | #include "ParticipantManager.h"
ParticipantManager::ParticipantManager(void)
{
int topScore = 0;
startingPlayerSID = -1;
}
ParticipantManager::~ParticipantManager(void)
{
}
/**
\fn void ParticipantManager::destroy()
\brief Called when program shutdown
*/
void ParticipantManager::destroy()
{
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
//delete
delete quizUsers.at(i);
}
quizUsers.clear();
}
/**
\fn void ParticipantManager::setUser( int session, PlayerState state )
\brief Adds a user to the quiz.
\param session Session ID of the player to be added
\param state State to set the player to
*/
void ParticipantManager::setUser( int session, PlayerState state )
{
int userIndex = userExists(session);
if ( userIndex != -1 )
{
//std::cout << "Setting user " << session << " state = " << state;
//set the session only
quizUsers.at(userIndex)->setState(state);
}
else
{
QuizParticipant *p = new QuizParticipant(session);
p->setState( state);
quizUsers.push_back(p);
//std::cout << "Added user " << session << " Num = " << quizUsers.size();
}
}
/**
\fn void ParticipantManager::setAllUsers ( PlayerState state )
\brief Sets a state for all users.
\param state State to set the players to
*/
void ParticipantManager::setAllUsers ( PlayerState state )
{
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
quizUsers.at(i)->setState(state);
}
}
/**
\fn void ParticipantManager::removeUser( int session )
\brief Removes a user of a particular session ID.
\param session Session ID of the player
*/
void ParticipantManager::removeUser( int session )
{
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
if ( quizUsers.at(i)->getSessionID() == session )
{
quizUsers.erase(quizUsers.begin()+i, quizUsers.begin()+i+1 );
}
}
std::cout << "Removing \n";
}
/**
\fn void ParticipantManager::removeAllUsers()
\brief Clears the user list
*/
void ParticipantManager::removeAllUsers()
{
quizUsers.clear();
}
/**
\fn void ParticipantManager::removeAllWithState( PlayerState state )
\brief Removes all users with a particular state
\param state The state of the players to remove
*/
void ParticipantManager::removeAllWithState( PlayerState state )
{
std::vector <int> toRemove;
int numRemoved = 0;
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
if ( quizUsers.at(i)->getState() == state )
{
toRemove.push_back(i-numRemoved);
numRemoved += 1;
}
}
for ( unsigned int j = 0; j < toRemove.size(); j++ )
{
int removing = toRemove.at(j);
quizUsers.erase(quizUsers.begin()+removing, quizUsers.begin()+removing+1 );
}
}
/**
\fn int ParticipantManager::userExists( int session )
\brief Check if a player is in the user list
\param session Session ID of the player.
\return The index of the player in the user list. If the player is not in the list, returns -1.
*/
int ParticipantManager::userExists( int session )
{
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
//std::cout << "Searching user" << session << " i= " << quizUsers.at(i)->getSessionID() << std::endl;
if ( quizUsers.at(i)->getSessionID() == session )
return i;
}
return -1;
}
/**
\fn PlayerState ParticipantManager::getState( int session )
\brief Gets the state of a player
\param session Session ID of the player
\return The state of the player
*/
PlayerState ParticipantManager::getState( int session )
{
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
if ( quizUsers.at(i)->getSessionID() == session )
return quizUsers.at(i)->getState();
}
return QUIZPLAYER_INVALID;
}
/**
\fn void ParticipantManager::setState( int session, PlayerState state )
\brief Sets the state of a player
\param session Session ID of the player
\param state The state to set the player to
*/
void ParticipantManager::setState( int session, PlayerState state )
{
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
if ( quizUsers.at(i)->getSessionID() == session )
quizUsers.at(i)->setState( state );
}
}
/**
\fn void ParticipantManager::print()
\brief Prints out the players in the user list.
Debugging purposes.
*/
void ParticipantManager::print()
{
std::cout << "=======================" << std::endl;
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
std::cout << quizUsers.at(i)->getSessionID() << " " << quizUsers.at(i)->getState() << std::endl;
}
std::cout << "=======================" << std::endl;
}
/**
\fn void ParticipantManager::setStartingPlayer( int session )
\brief Sets the first player who started the quiz.
\param session Session ID of the player
*/
void ParticipantManager::setStartingPlayer( int session )
{
startingPlayerSID = session;
}
/**
\fn int ParticipantManager::getStartingPlayer()
\brief Gets the first player who started the quiz.
\return Session ID of the player
*/
int ParticipantManager::getStartingPlayer()
{
return startingPlayerSID;
}
/**
\fn void ParticipantManager::broadcast( std::string message, int r, int g, int b, int bold, int italic )
\brief Broadcasts an ActiveWorlds console message to all players in the user list
\param message Message to broadcast
\param r Defines colour of the message
\param g Defines colour of the message
\param b Defines colour of the message
\param bold Makes the font bold
\param italic Makes the font italic
*/
void ParticipantManager::broadcast( std::string message, int r, int g, int b, int bold, int italic )
{
/*int rc;
std::string msg = "[QuizBot]:\t";
msg += message;
aw_int_set (AW_CONSOLE_RED, r);
aw_int_set (AW_CONSOLE_GREEN, g);
aw_int_set (AW_CONSOLE_BLUE, b);
aw_bool_set (AW_CONSOLE_BOLD, bold);
aw_bool_set (AW_CONSOLE_ITALICS, italic);
aw_string_set (AW_CONSOLE_MESSAGE, msg.c_str());
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
if ( rc = aw_console_message ( quizUsers.at(i)->getSessionID()) )
{
std::cout << "Console message failed (reason "<< rc << ")\n";
}
}*/
}
/**
\fn void ParticipantManager::whisper( int session, std::string message, int r, int g, int b, int bold, int italic )
\brief Whispers a message to a player
\param session Session ID of the player to whisper to
\param message Message to broadcast
\param r Defines colour of the message
\param g Defines colour of the message
\param b Defines colour of the message
\param bold Makes the font bold
\param italic Makes the font italic
*/
void ParticipantManager::whisper( int session, std::string message, int r, int g, int b, int bold, int italic )
{
/*int rc;
std::string msg = "[QuizBot]:\t";
msg += message;
aw_int_set (AW_CONSOLE_RED, r);
aw_int_set (AW_CONSOLE_GREEN, g);
aw_int_set (AW_CONSOLE_BLUE, b);
aw_bool_set (AW_CONSOLE_BOLD, bold);
aw_bool_set (AW_CONSOLE_ITALICS, italic);
aw_string_set (AW_CONSOLE_MESSAGE, msg.c_str());
if ( rc = aw_console_message ( session ) )
{
std::cout << "Console message failed (reason "<< rc << ")\n";
}*/
}
/**
\fn void ParticipantManager::checkAnswers( Vect3D objPos, int radius )
\brief Checks which players answered correctly
\param objPos Position of the tile with the correct answer
\param radius Sphere collision boundary. If the player is within this radius of the tile position, detect as correct.
Checks which players answered correctly and tells the player whether they are right or wrong.
Increments their score accordingly.
*/
void ParticipantManager::checkAnswers( Vect3D objPos, int radius )
{
std::string scoremsg;
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
if ( quizUsers.at(i)->checkCollision( objPos, radius ) )
{
quizUsers.at(i)->addScore();
if ( quizUsers.at(i)->getScore() > topScore )
{
topScore = quizUsers.at(i)->getScore();
}
scoremsg = "You got it right! ";
}
else
{
scoremsg = "Wrong answer, boo. ";
}
scoremsg += "Your score is: ";
char scorestr [2];
_itoa_s(quizUsers.at(i)->getScore(), scorestr, 10);
scoremsg += scorestr;
whisper( quizUsers.at(i)->getSessionID(), scoremsg.c_str(), 100, 0, 100, 0, 0 );
}
}
/**
\fn void ParticipantManager::broadcastTopScores()
\brief Broadcasts the top scores and players who achieved it
*/
void ParticipantManager::broadcastTopScores()
{
std::string top = "The top score is ";
char scorestr [2];
_itoa_s(topScore, scorestr, 10);
top += scorestr;
top += " achieved by";
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
if ( quizUsers.at(i)->getScore() == topScore )
{
top += " ";
top += quizUsers.at(i)->getName();
}
}
top += "!";
broadcast(top.c_str(), 100, 0, 0, 1, 0 );
std::cout << top << std::endl;
}
/**
\fn void ParticipantManager::setPlayerName( int session, std::string name )
\brief Sets the player name
\param session Session ID of the player
\param name Name of the player
*/
void ParticipantManager::setPlayerName( int session, std::string name )
{
//std::cout << "setting player name: " << name << " for session " << session << std::endl;
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
if ( quizUsers.at(i)->getSessionID() == session )
{
quizUsers.at(i)->setName(name);
}
}
}
/**
\fn std::string ParticipantManager::getPlayerName( int session )
\brief Gets the name of the player
\param session Session ID of the player
\return Name of the player
*/
std::string ParticipantManager::getPlayerName( int session )
{
for ( unsigned int i = 0; i < quizUsers.size(); i++ )
{
if ( quizUsers.at(i)->getSessionID() == session )
return quizUsers.at(i)->getName();
}
return NULL;
}
/**
\fn void ParticipantManager::reset()
\brief Resets all variables for the next quiz game.
*/
void ParticipantManager::reset()
{
removeAllUsers();
topScore = 0;
startingPlayerSID = -1;
}
| [
"lab4games@40cc54bc-b367-11de-8ef2-6d788aed22ac"
] | [
[
[
1,
387
]
]
] |
6b5af62d39f24562494b9fa691e4fb8f2d367114 | 974a20e0f85d6ac74c6d7e16be463565c637d135 | /trunk/packages/dCompilerKit/dLexicalGenerator/bin/dLexicalTemplate.cpp | af69cb6b41cd34b8b211a8428dc6dd618b261989 | [] | no_license | Naddiseo/Newton-Dynamics-fork | cb0b8429943b9faca9a83126280aa4f2e6944f7f | 91ac59c9687258c3e653f592c32a57b61dc62fb6 | refs/heads/master | 2021-01-15T13:45:04.651163 | 2011-11-12T04:02:33 | 2011-11-12T04:02:33 | 2,759,246 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,868 | cpp | /* Copyright (c) <2009> <Newton Game Dynamics>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely
*/
//
//Auto generated Lexical Analyzer class: $(className).cpp
//
$(userIncludeCode)
#include "$(className).h"
$(className)::$(className)(const char* const data)
:m_tokenString ("")
,m_data(data)
,m_index(0)
,m_startIndex(0)
,m_lineNumber(0)
{
}
$(className)::~$(className)()
{
}
void $(className)::ReadBalancedExpresion (char open, char close)
{
int count = 1;
while (count) {
int ch = NextChar();
if (ch == '\n') {
m_lineNumber ++;
}
if(ch == open) {
count ++;
} else if (ch == close) {
count --;
} else {
if (ch == '\'') {
ch = NextChar();
if (ch == '\\') {
ch = NextChar();
}
ch = NextChar();
} else if (ch == '\"') {
for (ch = NextChar(); ch != '\"'; ch = NextChar()) {
if (ch == '\\') {
ch = NextChar();
}
}
}
}
}
string tmp (m_tokenString);
GetLexString();
m_tokenString = tmp + m_tokenString;
}
void $(className)::GetLexString ()
{
int length = m_index - m_startIndex;
m_tokenString = string (&m_data[m_startIndex], length);
m_startIndex = m_index;
}
int $(className)::GetNextStateIndex (char symbol, int count, const char* const characterSet) const
{
int i0 = 0;
int i1 = count - 1;
while ((i1 - i0) >= 4) {
int i = (i1 + i0 + 1)>>1;
if (symbol <= characterSet[i]) {
i1 = i;
} else {
i0 = i;
}
}
for (int i = i0; i <= i1; i ++) {
if (symbol == characterSet[i]) {
return i;
}
}
return -1;
}
int $(className)::NextToken ()
{
static short transitionsCount[] = {$(transitionsCount)};
static short transitionsStart[] = {$(transitionsStart)};
static short nextStateSet[] = {$(nextStateList)};
static char nextCharacterSet[] = {$(nextCharaterList)};
m_startIndex = m_index;
int state = 0;
int zeroCount = 2;
char ch = NextChar();
do {
int transCount = transitionsCount[state];
int tranStart = transitionsStart[state];
int nextStateIndex = GetNextStateIndex (ch, transCount, &nextCharacterSet[tranStart]);
if (nextStateIndex >= 0) {
ch = NextChar();
short* const stateArray = &nextStateSet[tranStart];
state = stateArray[nextStateIndex];
} else {
UnGetChar ();
switch (state)
{
$(semanticActionCode)
default:
{
// Lexical error
return -1;
}
}
}
if (!ch) {
zeroCount--;
}
} while (zeroCount);
// Unknown pattern
return -1;
}
| [
"[email protected]@b7a2f1d6-d59d-a8fe-1e9e-8d4888b32692"
] | [
[
[
1,
139
]
]
] |
cb729da0bbfd944af7210a07ebf2c81e911c1fcc | e354a51eef332858855eac4c369024a7af5ff804 | /msgqueue.cpp | 0eab191d898162cd71d1ccfbe4a6386ce2533076 | [] | no_license | cjus/msgCourierLite | 0f9c1e05b71abf820c55f74a913555eec2267bb4 | 9efc1d54737ba47620a03686707b31b1eeb61586 | refs/heads/master | 2020-04-05T22:41:39.141740 | 2010-09-05T18:43:12 | 2010-09-05T18:43:12 | 887,172 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,346 | cpp | /* msgqueue.cpp
Copyright (C) 2004 Carlos Justiniano
[email protected], [email protected], [email protected]
msgqueue.cpp 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 2 of the
License, or (at your option) any later version.
msgqueue.cpp was developed by Carlos Justiniano for use on the
msgCourier project and the ChessBrain Project and is now 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 main.cpp; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 0213e9, USA.
*/
/**
@file msgqueue.cpp
@brief Message Queue
@author Carlos Justiniano
@attention Copyright (C) 2004 Carlos Justiniano, GNU GPL Licence (see source
file header)
cMsgQueue is a threaded singleton class which queues messages for
internal dispatching to message handlers. cMsgQueue offers cMsg's
using its CreateMessage() member function. Message handlers receive
cMsg's for processing and flag the cMsg object as it's
processed. cMsgQueue handles moving the cMsg objects throughout the
msgCourier application and transmits messages to other clients and
servers.
*/
#include <time.h>
#include <string.h>
#include "msgqueue.h"
#include "exception.h"
#include "log.h"
#include "connectionqueue.h"
#include "url.h"
#ifdef _PLATFORM_LINUX
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/dir.h>
#endif //_PLATFORM_LINUX
using namespace std;
#define MAX_MSG_RETRY 10
/**
* cMsgQueue Queue Constructor
* @param iMaxThreads Upper limit on the total threads used to handle message
* processing
*/
cMsgQueue::cMsgQueue(cCommandHandlerFactory *pFactory, cMsgRouterRulesEngine *pRouterRulesEngine)
: m_pCommandHandlerFactory(pFactory)
, m_pRouterRulesEngine(pRouterRulesEngine)
, m_pSysMetrics(0)
{
SetThreadName("cMsgQueue");
}
/**
* cMsgQueue Destructor
*/
cMsgQueue::~cMsgQueue()
{
}
/**
* MsgQueue start
* @return HRC_MSG_QUEUE_OK or throws MEMALLOC
* @throw MEMALLOC
*/
int cMsgQueue::Start()
{
int iRet = HRC_MSG_QUEUE_OK;
cThread::Create();
cThread::Start();
return iRet;
}
/**
* Compliment to cMsgQueue::Start() shuts down thread and performs cleanup.
* @return HRC_MSG_QUEUE_OK
*/
int cMsgQueue::Stop()
{
int iRet = HRC_MSG_QUEUE_OK;
Shutdown();
cThread::Destroy();
return iRet;
}
/**
* Main processing loop which is executed by a thread
* @return HRC_MSG_QUEUE_OK
* @note This is the main work-horse for the cMsgQueue sington object. In this
* function pending cMsg objects are dispatched to cMsgHandler() thread-based
* handlers.
*/
int cMsgQueue::Run()
{
bool msgProcessed;
m_timer.SetInterval(1);
m_timer.Start();
while (ThreadRunning())
{
m_ThreadSync.Lock();
// Process message which are cMsg::MSG_STATE_PENDING
ProcessPendingMessages();
// check if there are any messages in the priority queue
// and if so, process the highest priority message
if (!m_priority_queue.empty())
{
ProcessPriorityQueue();
msgProcessed = true;
}
else
{
msgProcessed = false;
}
// check to see if it's time to flush messages
if (m_timer.IsReady())
{
FlushMessages();
m_timer.Reset();
/*
#ifdef _PLATFORM_LINUX
FileDescriptorWatch();
#endif //_PLATFORM_LINUX
*/
}
m_ThreadSync.Unlock();
if (msgProcessed == false)
YieldSleep();
}
return HRC_MSG_QUEUE_OK;
}
cIMsg *cMsgQueue::CreateMessage()
{
cIMsg *pIMsg = m_msgPool.GetMessage();
MARK_TRAVEL(pIMsg);
return pIMsg;
}
cIMsg *cMsgQueue::CreateMessageReply(cIMsg *pToThisMsg)
{
cAutoThreadSync ThreadSync(&m_CMRThreadSync);
cIMsg *pNewMsg = m_msgPool.GetMessage();
MARK_TRAVEL(pNewMsg);
MARK_TRAVEL(pToThisMsg);
if (pToThisMsg != 0)
{
((cMsg*)pToThisMsg)->SetCloned();
pNewMsg->SetTCPSocketHandle(((cMsg*)pToThisMsg)->GetTCPSocketHandle());
((cMsg*)pNewMsg)->SetKeepAlive(((cMsg*)pToThisMsg)->IsKeepAlive());
if (pToThisMsg->GetConnectionType() == cIMsg::MSG_CT_INTERNAL)
{
pNewMsg->SetConnectionType(cIMsg::MSG_CT_INTERNAL);
}
else if (pToThisMsg->GetConnectionType() == cIMsg::MSG_CT_IB_UDP)
{
pNewMsg->SetConnectionType(cIMsg::MSG_CT_OB_UDP);
}
else if (pToThisMsg->GetConnectionType() == cIMsg::MSG_CT_IB_TCP)
{
pNewMsg->SetConnectionType(cIMsg::MSG_CT_OB_TCP);
}
if (pToThisMsg->GetConnectionType() == cIMsg::MSG_CT_INTERNAL)
{
pNewMsg->SetCommand(pToThisMsg->GetFrom());
}
pNewMsg->SetMsgID(pToThisMsg->GetMsgID());
pNewMsg->SetFormat(cIMsg::MSG_FORMAT_RES);
pNewMsg->SetTo(pToThisMsg->GetFrom());
pNewMsg->SetMsgPriority(pToThisMsg->GetMsgPriority());
if (pToThisMsg->GetConnectionType() == cIMsg::MSG_CT_INTERNAL)
{
pNewMsg->SetReplyAction(cIMsg::MSG_REPLY_ACTION_NONE);
pNewMsg->SetNotifyAction(cIMsg::MSG_NOTIFY_ACTION_NO);
}
else
{
pNewMsg->SetReplyAction(pToThisMsg->GetReplyAction());
pNewMsg->SetNotifyAction(pToThisMsg->GetNotifyAction());
pNewMsg->SetUDPSocketHandle(pToThisMsg->GetUDPSocketHandle());
pNewMsg->SetSourceIP(pToThisMsg->GetSourceIP());
pNewMsg->SetSourcePort(pToThisMsg->GetSourcePort());
}
//pNewMsg->SetProtocolType(cIMsg::MSG_PROTOCOL_MCP);
pNewMsg->SetProtocolType(pToThisMsg->GetProtocolType());
pNewMsg->SetArrivalPort(pToThisMsg->GetArrivalPort());
*((cMsg*)pNewMsg)->GetBench() = *((cMsg*)pToThisMsg)->GetBench();
}
MC_ASSERT(pNewMsg->GetMsgID());
//LOG2("Msg [%s] reply created",pNewMsg->GetMsgID());
return pNewMsg;
}
cIMsg* cMsgQueue::CreateInternalMessage()
{
cMsg *pMsg = (cMsg*)m_msgPool.GetMessage();
MARK_TRAVEL(pMsg);
pMsg->SetConnectionType(cIMsg::MSG_CT_INTERNAL);
pMsg->SetReplyAction(cIMsg::MSG_REPLY_ACTION_NONE);
pMsg->SetNotifyAction(cIMsg::MSG_NOTIFY_ACTION_NO);
return pMsg;
}
int cMsgQueue::PostNotifyMessage(cMsg *pBasedOnThisMsg)
{
cMsg *pMsg = (cMsg*)m_msgPool.GetMessage();
pMsg->SetTCPSocketHandle(pBasedOnThisMsg->GetTCPSocketHandle());
if (pBasedOnThisMsg->GetConnectionType() == cIMsg::MSG_CT_IB_UDP)
pMsg->SetConnectionType(cIMsg::MSG_CT_OB_UDP);
else if (pBasedOnThisMsg->GetConnectionType() == cIMsg::MSG_CT_IB_TCP)
pMsg->SetConnectionType(cIMsg::MSG_CT_OB_TCP);
pMsg->SetMsgID(pBasedOnThisMsg->GetMsgID());
pMsg->SetFormat(cIMsg::MSG_FORMAT_NOTIFY);
pMsg->SetTo(pBasedOnThisMsg->GetFrom());
pMsg->SetMsgPriority(cIMsg::MSG_PRIORITY_HIGHEST + 1000);
pMsg->SetReplyAction(cIMsg::MSG_REPLY_ACTION_NOWAIT);
pMsg->SetProtocolType(cIMsg::MSG_PROTOCOL_MCP);
pMsg->SetNotifyAction(cIMsg::MSG_NOTIFY_ACTION_YES);
*((cMsg*)pMsg)->GetBench() = *((cMsg*)pBasedOnThisMsg)->GetBench();
MARK_TRAVEL(pMsg);
pMsg->DispatchMsg();
return HRC_MSG_QUEUE_OK;
}
int cMsgQueue::Shutdown()
{
cAutoThreadSync ThreadSync(&m_ThreadSync);
return HRC_MSG_QUEUE_OK;
}
int cMsgQueue::FlushMessages()
{
int rc = HRC_MSG_QUEUE_OK;
cIMsg::MSG_STATE msgState;
cMsg *pMsg = 0;
int cnt_tot = 0;
int cnt_inuse = 0;
int cnt_delivered = 0;
int cnt_undelivered = 0;
int cnt_processed = 0;
int cnt_pending = 0;
int currentTime = time(0);
m_msgPool.Lock();
m_msgPool.FlushFreeStack();
pMsg = (cMsg*)m_msgPool.GetHead();
if (pMsg == 0)
{
m_msgPool.Unlock();
return rc;
}
do
{
cnt_tot++;
msgState = pMsg->GetMsgState();
switch (msgState)
{
case cIMsg::MSG_STATE_INACTIVE:
pMsg->SetMsgState(cMsg::MSG_STATE_MARKFORREUSE);
break;
case cIMsg::MSG_STATE_UNDELIVERED:
cnt_undelivered++;
break;
case cIMsg::MSG_STATE_DELIVERED:
cnt_delivered++;
MARK_TRAVEL(pMsg);
pMsg->SetMsgState(cMsg::MSG_STATE_MARKFORREUSE);
break;
case cIMsg::MSG_STATE_PROCESSED:
cnt_processed++;
MARK_TRAVEL(pMsg);
pMsg->SetMsgState(cMsg::MSG_STATE_MARKFORREUSE);
break;
case cIMsg::MSG_STATE_PENDING:
cnt_pending++;
break;
case cIMsg::MSG_STATE_INUSE:
cnt_inuse++;
break;
default:
// cIMsg::MSG_STATE_INACTIVE:
break;
};
if (msgState == cIMsg::MSG_STATE_INACTIVE && (currentTime - pMsg->GetMsgInUseTS()) > 60)
{
m_msgPool.DeleteCurrent();
delete pMsg;
pMsg = 0;
}
else if (pMsg->GetMsgState() == cMsg::MSG_STATE_MARKFORREUSE)
{
m_msgPool.ReturnToPool(pMsg);
}
} while ((pMsg = (cMsg*)m_msgPool.GetNext()) != 0);
//LOG("FreeMsgPool size: %d", m_msgPool.Size());
m_msgPool.Unlock();
//#ifdef _DEBUG
if (cnt_inuse || cnt_pending)
{
LOG(" Flushing: tot(%d) iu(%d) u(%d) d(%d) p(%d) a(%d)",
cnt_tot, cnt_inuse, cnt_undelivered, cnt_delivered, cnt_processed, cnt_pending);
}
//#endif //_DEBUG
//if (cnt_inuse > 32)
// THROW("Forced abort");
return rc;
}
void cMsgQueue::ProcessPendingMessages()
{
cMsg *pMsg;
cIMsg::MSG_STATE msgState;
m_msgPool.Lock();
pMsg = (cMsg*)m_msgPool.GetHead();
if (pMsg == 0)
{
m_msgPool.Unlock();
return;
}
do
{
msgState = pMsg->GetMsgState();
// check if any messages have been placed in a cIMsg::MSG_STATE_PENDING
// state and add them to the priority queue for processing
if (msgState == cMsg::MSG_STATE_PENDING)
{
MARK_TRAVEL(pMsg);
pMsg->SetMsgState(cMsg::MSG_STATE_INUSE);
if (pMsg->GetConnectionType() != cIMsg::MSG_CT_NOTSET)
{
MARK_TRAVEL(pMsg);
m_priority_queue.push(pMsg);
}
else
{
MARK_TRAVEL(pMsg);
MC_ASSERT(0);
}
}
// if message was undelivered and it had a socket to respond to,
// then we need to drop the message because it can no longer communicate
// with the target server
if (msgState == cMsg::MSG_STATE_UNDELIVERED && pMsg->GetTCPSocketHandle() != -1)
{
// remove message from message pool
MARK_TRAVEL(pMsg);
pMsg->SetMsgState(cMsg::MSG_STATE_MARKFORREUSE);
}
// if message was undelivered and it *doesn't have* a socket to respond to
// then there isn't an available handler that can process it. Try to resend
// message at a later time.
if (msgState == cMsg::MSG_STATE_UNDELIVERED && pMsg->GetTCPSocketHandle() == -1)
{
// check whether this message is set for delayed processing
if (pMsg->GetSendRetryCount() != 0)
{
int curtime = time(0);
int lastAttempt = pMsg->GetMsgLastRetryTS();
if ((lastAttempt + pMsg->GetSendRetryDelay()) > curtime)
{
continue;
}
}
int lastAttempt = pMsg->GetMsgLastRetryTS();
if (lastAttempt == 0)
{
pMsg->SetMsgLastRetryTS();
pMsg->SetSendRetryCount(1);
MARK_TRAVEL(pMsg);
pMsg->SetMsgState(cMsg::MSG_STATE_PENDING);
}
else
{
int iRetryCount = pMsg->GetSendRetryCount();
if (iRetryCount > (MAX_MSG_RETRY-1))
{
// too many attempts to resend this message
// mark message for removal from message pool
MARK_TRAVEL(pMsg);
pMsg->SetMsgState(cMsg::MSG_STATE_MARKFORREUSE);
}
else
{
pMsg->SetMsgLastRetryTS();
pMsg->SetSendRetryCount(iRetryCount + 1);
int iRetryDelay = pMsg->GetSendRetryDelay();
pMsg->SetSendRetryDelay(iRetryDelay + iRetryDelay);
MARK_TRAVEL(pMsg);
pMsg->SetMsgState(cMsg::MSG_STATE_PENDING);
}
}
}
} while ((pMsg = (cMsg*)m_msgPool.GetNext()) != 0);
m_msgPool.Unlock();
}
void cMsgQueue::ProcessPriorityQueue()
{
cIMsg *pIMsg = m_priority_queue.top();
m_priority_queue.pop();
MC_ASSERT(pIMsg);
MC_ASSERT(pIMsg->GetMsgID());
MC_ASSERT(pIMsg->GetCommand());
MARK_TRAVEL(pIMsg);
//LOG("ProcessPriorityQueue");
//LOG(" Msg (%d) %p[%s] taken from top of priority queue",
// pIMsg->GetConnectionType(), pIMsg, pIMsg->GetMsgID());
// Check if internal message
if (pIMsg->GetConnectionType() == cIMsg::MSG_CT_INTERNAL)
{
ProcessInternalMessage(pIMsg);
}
else if (pIMsg->GetConnectionType() == cIMsg::MSG_CT_OB_UDP ||
pIMsg->GetConnectionType() == cIMsg::MSG_CT_OB_TCP)
{
ProcessOutboundMessage(pIMsg);
}
else if (pIMsg->GetConnectionType() == cIMsg::MSG_CT_IB_UDP ||
pIMsg->GetConnectionType() == cIMsg::MSG_CT_IB_TCP)
{
ProcessInboundMessage(pIMsg);
}
else
{
// An unidentified connection type message
// should not be on the priority queue!
L
MC_ASSERT(0);
}
}
void cMsgQueue::ProcessInternalMessage(cIMsg *pIMsg)
{
MARK_TRAVEL(pIMsg);
// first search for internal handler
cICommandHandler *pHandler = 0;
pHandler = m_pCommandHandlerFactory->GetCommandHandler(pIMsg->GetCommand());
if (pHandler != 0)
{
m_pSysMetrics->IncMsgDelivered();
pHandler->OnProcess(pIMsg);
return;
}
else if (pHandler == 0)
{
// there is no internal handler, so search for a remote handler
LOG("OOO No internal handler for %s", pIMsg->GetCommand());
/*
cServiceEntry *pService = m_pServiceEngine->QueryServiceFirst(pIMsg->GetCommand());
if (pService != 0)
{
string sTo;
cIMsg *pRemoteMsg = CreateMessage();
MARK_TRAVEL(pRemoteMsg);
pRemoteMsg->SetMsgID(pIMsg->GetMsgID());
pRemoteMsg->SetCommand(pIMsg->GetCommand());
pRemoteMsg->SetConnectionType(cIMsg::MSG_CT_OB_TCP);
sTo = pService->m_pNode->m_MachineName;
sTo += "@";
sTo += pService->m_pNode->m_IPAddress;
sTo += ":3400";
pRemoteMsg->SetTo(sTo.c_str());
pRemoteMsg->SetMsgPriority(cIMsg::MSG_PRIORITY_LOWEST);
pRemoteMsg->SetArrivalPort(3400);
pRemoteMsg->SetProtocolType(cIMsg::MSG_PROTOCOL_MCP);
pRemoteMsg->SetReplyAction(cIMsg::MSG_REPLY_ACTION_NONE);
pRemoteMsg->SetNotifyAction(cIMsg::MSG_NOTIFY_ACTION_NO);
if (pIMsg->GetContentLength() > 0 )
{
pRemoteMsg->SetContentType("application/octet-stream");
pRemoteMsg->SetContentPayload(pIMsg->GetContentPayload(), pIMsg->GetContentLength());
}
pRemoteMsg->DispatchMsg();
MARK_TRAVEL(pIMsg);
pIMsg->MarkProcessed();
return;
}
else
{
//LOG("Warning, internal message can't be routed because a handler can't be located for %s",
// pIMsg->GetCommand());
MARK_TRAVEL(pIMsg);
((cMsg*)pIMsg)->SetMsgState(cMsg::MSG_STATE_UNDELIVERED);
return;
}
*/
((cMsg*)pIMsg)->SetMsgState(cMsg::MSG_STATE_UNDELIVERED);
}
}
void cMsgQueue::ProcessInboundMessage(cIMsg *pIMsg)
{
MARK_TRAVEL(pIMsg);
if (pIMsg->GetNotifyAction() == cMsg::MSG_NOTIFY_ACTION_YES)
{
MARK_TRAVEL(pIMsg);
LOG(" Msg requires a notify response, posting notify to priority queue");
PostNotifyMessage((cMsg*)pIMsg);
// Now remove notify message flag for this message
pIMsg->SetNotifyAction(cIMsg::MSG_NOTIFY_ACTION_NO);
}
cICommandHandler *pHandler = 0;
string Match = "";
// check for message reply
if (strncmp(pIMsg->GetCommand(), "MCP/", 4) == 0)
{
pHandler = m_pCommandHandlerFactory->GetCommandHandler("MC");
m_pSysMetrics->IncMsgDelivered();
pHandler->OnProcess(pIMsg);
return;
}
m_pRouterRulesEngine->Search((cMsg*)pIMsg, Match);
if (Match.length() != 0)
{
//LOG(" Msg was matched against %s and will be processed by that handler", Match.c_str());
pHandler = m_pCommandHandlerFactory->GetCommandHandler(Match.c_str());
MARK_TRAVEL(pIMsg);
}
else
{
//LOG(" Msg was not matched and will be processed by the [%s] handler", pIMsg->GetCommand());
pHandler = m_pCommandHandlerFactory->GetCommandHandler(pIMsg->GetCommand());
MARK_TRAVEL(pIMsg);
}
//if (pHandler == 0)
//{
// // No internal handler found. Search for remote (service) handler
// cServiceEntry *pService = m_pServiceEngine->QueryServiceFirst(pIMsg->GetCommand());
// if (pService != 0)
// {
// // route to MC handler
// pHandler = m_pCommandHandlerFactory->GetCommandHandler("MC");
// ((cMsg*)pIMsg)->SetRemoteHandler(pService);
// m_pSysMetrics->IncMsgDelivered();
// pHandler->OnProcess(pIMsg);
// //LOG("Remote handler located, routing msg = %s", pIMsg->GetContentPayload());
// }
// else
// {
// // route to MC handler
// pHandler = m_pCommandHandlerFactory->GetCommandHandler("MC");
// //LOG("Error, msg [%s] arrived from [%s], but there is no command handler registered.",
// // pIMsg->GetCommand(), pIMsg->GetSourceIP());
// pIMsg->SetCommand("MC.ERROR");
// m_pSysMetrics->IncMsgDelivered();
// pHandler->OnProcess(pIMsg);
// }
//}
//else
//{
MARK_TRAVEL(pIMsg);
m_pSysMetrics->IncMsgDelivered();
pHandler->OnProcess(pIMsg);
//}
}
void cMsgQueue::ProcessOutboundMessage(cIMsg *pIMsg)
{
MARK_TRAVEL(pIMsg);
// if msg's connection type is an outbound UDP or TCP based message
if (pIMsg->GetReplyAction() != cIMsg::MSG_REPLY_ACTION_NONE)
{
m_pConnectionQueue->SendMsg((cMsg*)pIMsg);
}
else
{
pIMsg->MarkProcessed();
}
}
void cMsgQueue::SendToLogger(const char *pCategory, const char *pLogMessage)
{
cAutoThreadSync ThreadSync(&m_ThreadSync);
try
{
if (pCategory == 0 || pLogMessage == 0 ||
strlen(pCategory) == 0 || strlen(pLogMessage) == 0)
return;
string sExpression = "(LOGGER (";
sExpression += pCategory;
sExpression += " \"";
cIMsg *pLogMsg = CreateMessage();
if (pLogMsg == 0)
{
LOG2("Warning, SendToLogger: message is null");
return;
}
MARK_TRAVEL(pLogMsg);
pLogMsg->SetCommand("LOGGER");
pLogMsg->SetContentType("text/s-expression");
pLogMsg->SetConnectionType(cIMsg::MSG_CT_INTERNAL);
pLogMsg->SetMsgPriority(cIMsg::MSG_PRIORITY_LOWEST);
pLogMsg->SetProtocolType(cIMsg::MSG_PROTOCOL_MCP);
pLogMsg->SetReplyAction(cIMsg::MSG_REPLY_ACTION_NONE);
pLogMsg->SetNotifyAction(cIMsg::MSG_NOTIFY_ACTION_NO);
pLogMsg->SetMsgID("0");
string preEncoded, urlEncoded;
preEncoded = pLogMessage;
cURL url;
url.Encode(preEncoded, urlEncoded);
sExpression += urlEncoded;
sExpression += "\"))";
pLogMsg->SetContentPayload(sExpression.c_str(), sExpression.length());
pLogMsg->DispatchMsg();
}
catch (exception const &e)
{
LOGALL(e.what());
}
}
/*
void cMsgQueue::SendToConsole(const char *pText)
{
LOG(pText);
}
*/
#ifdef _PLATFORM_LINUX
void cMsgQueue::FileDescriptorWatch()
{
char path[260];
sprintf(path, "/proc/%d/fd", getpid());
int cnt = 0;
struct direct *DirEntryPtr;
DIR *DirPtr = opendir(path);
while (1)
{
DirEntryPtr = readdir(DirPtr);
if (DirEntryPtr == 0)
break;
if (strcmp(DirEntryPtr->d_name,".") != 0 && strcmp(DirEntryPtr->d_name,"..") != 0)
{
cnt++;
}
}
closedir(DirPtr);
LOG("Total file descriptors in use: %d", cnt-4);
}
#endif //_PLATFORM_LINUX
| [
"[email protected]"
] | [
[
[
1,
706
]
]
] |
f96ad9a42a6e15f879399fe525fe7d505039aec0 | f9351a01f0e2dec478e5b60c6ec6445dcd1421ec | /itl/libs/itl/test/test_interval_set/test_interval_set.cpp | bb3ea87f640f94a1ab40535b407a988ee69fe4e3 | [
"BSL-1.0"
] | permissive | WolfgangSt/itl | e43ed68933f554c952ddfadefef0e466612f542c | 6609324171a96565cabcf755154ed81943f07d36 | refs/heads/master | 2016-09-05T20:35:36.628316 | 2008-11-04T11:44:44 | 2008-11-04T11:44:44 | 327,076 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,401 | cpp | /*----------------------------------------------------------------------------+
Copyright (c) 2008-2008: Joachim Faulhaber
+-----------------------------------------------------------------------------+
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENCE.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
+----------------------------------------------------------------------------*/
#define BOOST_TEST_MODULE itl::interval_set unit test
#include <string>
#include <boost/mpl/list.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/test_case_template.hpp>
// interval instance types
#include "../test_type_lists.hpp"
#include "../test_value_maker.hpp"
#include <boost/itl/interval_set.hpp>
using namespace std;
using namespace boost;
using namespace unit_test;
using namespace boost::itl;
// -----------------------------------------------------------------------------
// test_interval_set_shared are tests that should give identical results for all
// interval_sets: interval_set, separate_interval_set and split_interval_set.
#include "../test_interval_set_shared.hpp"
// Due to limited expressiveness of the testing framework, the testcode in files
// test_interval_set{,_separate,split}_shared.cpp is generated through code
// replication.
#include "test_interval_set_shared.cpp"
| [
"jofaber@6b8beb3d-354a-0410-8f2b-82c74c7fef9a"
] | [
[
[
1,
35
]
]
] |
12ed6195bd77e233b190d06c35c71a0e8dbbf2c5 | af3b3fd56239cddee37913ee4184e2c62b428659 | /unix/thread/Condition.h | b6c75c0cea0e9b7761b78b505389d7174003a767 | [] | no_license | d3v3r4/clearcase-sponge | 7c80405b58c2720777a008e67693869ea835b60e | 699a1ef4874b9b9da2c84072774172d22c1d7369 | refs/heads/master | 2021-01-01T05:32:15.402646 | 2009-06-15T06:39:38 | 2009-06-15T06:39:38 | 41,874,171 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,607 | h | // Condition.h
#ifndef CONDITION_H
#define CONDITION_H
#include <ccsponge.h>
#include <util/Lockable.h>
#include <pthread.h>
/*
* Unix implementation of an event for multithreaded signaling. Wrapper
* around a pthread_cond_t and an associated pthread_mutex_t.
*/
class Condition : public Lockable
{
public:
/*
* Creates the condition and its associated mutex.
*/
Condition();
/*
* Deletes the condition and its associated mutex.
*
* NOTE: Will put the program into a bad state if there are threads
* waiting on the condition.
*/
~Condition();
/*
* Locks the mutex used by this condition. You must lock the mutex in
* order to either wait on the condition, or signal the condition.
*/
void lock();
/*
* Unlocks the mutex used by this event.
*/
void unlock();
/*
* Signals a thread waiting on this condition. This restarts one of the
* threads waiting on this condition.
*/
void signal();
/*
* Signals all threads waiting on this condition. This restarts every
* thread waiting on this condition.
*/
void signalAll();
/*
* Causes the calling thread to wait on the condition until signaled.
*/
void wait();
/*
* Same as wait(), but with a timeout.
*/
uint32 wait(uint32 milliseconds);
private:
Condition(const Condition& other) {}
Condition& operator=(const Condition& other) {}
private:
pthread_cond_t m_cond; // The pthread condition object that this class wraps
pthread_mutex_t m_mutex;// The mutex used by the condition object
};
#endif // CONDITION_H
| [
"scott.conger@2a29f4a4-5970-11de-9a1b-6103e4980ab8"
] | [
[
[
1,
73
]
]
] |
55745d4bcc1c38632686028795f13e55333c8f9b | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Dependencies/Xerces/include/xercesc/com/XMLDOMDocumentFragment.h | 597f8e4ffa234c022d1a4b7a348b9b86fa8db495 | [] | no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,856 | h | /*
* Copyright 1999-2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XMLDOMDocumentFragment.h 191054 2005-06-17 02:56:35Z jberry $
*/
#ifndef ___xmldomdocumentfragment_h___
#define ___xmldomdocumentfragment_h___
#include <xercesc/dom/DOMDocumentFragment.hpp>
#include "IXMLDOMNodeImpl.h"
XERCES_CPP_NAMESPACE_USE
class ATL_NO_VTABLE CXMLDOMDocumentFragment :
public CComObjectRootEx<CComSingleThreadModel>,
public IXMLDOMNodeImpl<IXMLDOMDocumentFragment, &IID_IXMLDOMDocumentFragment>
{
public:
CXMLDOMDocumentFragment()
{}
void FinalRelease()
{
ReleaseOwnerDoc();
}
virtual DOMNode* get_DOMNode() { return documentFragment;}
virtual DOMNodeType get_DOMNodeType() const { return NODE_DOCUMENT_FRAGMENT; }
DECLARE_NOT_AGGREGATABLE(CXMLDOMDocumentFragment)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CXMLDOMDocumentFragment)
COM_INTERFACE_ENTRY(IXMLDOMDocumentFragment)
COM_INTERFACE_ENTRY(IXMLDOMNode)
COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
DOMDocumentFragment* documentFragment;
};
typedef CComObject<CXMLDOMDocumentFragment> CXMLDOMDocumentFragmentObj;
#endif // ___xmldomdocumentfragment_h___ | [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
] | [
[
[
1,
62
]
]
] |
e5c7260a4a7c1b12e5119ffffd2f8868fda791b4 | 1e01b697191a910a872e95ddfce27a91cebc57dd | /ExprScriptFunction.h | 9c4fcf2ae5930b66cab42edf045f3819dd3fe60e | [] | no_license | canercandan/codeworker | 7c9871076af481e98be42bf487a9ec1256040d08 | a68851958b1beef3d40114fd1ceb655f587c49ad | refs/heads/master | 2020-05-31T22:53:56.492569 | 2011-01-29T19:12:59 | 2011-01-29T19:12:59 | 1,306,254 | 7 | 5 | null | null | null | null | IBM852 | C++ | false | false | 3,809 | h | /* "CodeWorker": a scripting language for parsing and generating text.
Copyright (C) 1996-1997, 1999-2002 CÚdric Lemaire
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
To contact the author: [email protected]
*/
#ifndef _ExprScriptFunction_h_
#define _ExprScriptFunction_h_
#include <list>
#include <vector>
#include <map>
#include <string>
#include "ExprScriptExpression.h"
namespace CodeWorker {
class ScpStream;
class DtaScriptVariable;
class GrfFunction;
class GrfBlock;
class ExprScriptFunction;
enum EXPRESSION_TYPE {
UNKNOWN_EXPRTYPE = -1,
VALUE_EXPRTYPE = 0,
NODE_EXPRTYPE = 1,
ITERATOR_EXPRTYPE = 2,
REFERENCE_EXPRTYPE = 3,
SCRIPTFILE_EXPRTYPE = 8, // common script
SCRIPTFILE_PATTERN_EXPRTYPE = 9,
SCRIPTFILE_FREE_EXPRTYPE = 10,
SCRIPTFILE_BNF_EXPRTYPE = 11,
SCRIPTFILE_TRANSLATE_EXPRTYPE = 12,
ARRAY_EXPRTYPE = 16 // for specifying an array type
};
typedef ExprScriptFunction* (*CREATE_FUNCTION)(GrfBlock&);
class DtaFunctionInfo {
public:
CREATE_FUNCTION constructor;
unsigned int* pCounter;
};
class ExprScriptFunction : public ExprScriptExpression {
protected:
std::vector<ExprScriptExpression*> _parameters;
ExprScriptExpression* _pTemplate;
GrfFunction* _pPrototype;
bool _bIsExternal;
public:
ExprScriptFunction(GrfFunction* pPrototype = NULL);
virtual ~ExprScriptFunction();
virtual bool isAFunctionExpression() const { return true; }
virtual bool isAGenerateFunction() const { return false; }
virtual bool isAParseFunction() const { return false; }
void addParameter(ExprScriptExpression* pParameter);
void clearParameters();
const std::vector<ExprScriptExpression*>& getParameters() const { return _parameters; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const;
virtual ExprScriptExpression* getDefaultParameter(unsigned int iIndex) const;
virtual unsigned int getArity() const;
virtual unsigned int getMinArity() const;
virtual const char* getName() const;
inline GrfFunction* getUserBody() const { return _pPrototype; }
inline void setTemplate(ExprScriptExpression* pTemplate) { _pTemplate = pTemplate; }
virtual int getThisPosition() const;
virtual void initializationDone();
virtual std::string getValue(DtaScriptVariable& visibility) const;
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const;
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const;
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const;
virtual std::string toString() const;
static ExprScriptFunction* create(GrfBlock& block, ScpStream& script, const std::string& sFunction, const std::string& sTemplate, bool bGenericKey);
static ExprScriptFunction* createMethod(GrfBlock& block, ScpStream& script, const std::string& sFunction, const std::string& sTemplate, bool bGenericKey);
static std::map<std::string, DtaFunctionInfo>& getFunctionRegister();
static void clearCounters();
};
}
#endif
| [
"cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4"
] | [
[
[
1,
108
]
]
] |
eaeea0dc5b0a3629c99b97113889381de4990833 | 5fb9b06a4bf002fc851502717a020362b7d9d042 | /developertools/GumpEditor/diagram/DiagramEditor/DiagramEntity.h | 8908bf074070596246a5adc05d1c6c7c85383fd4 | [] | no_license | bravesoftdz/iris-svn | 8f30b28773cf55ecf8951b982370854536d78870 | c03438fcf59d9c788f6cb66b6cb9cf7235fbcbd4 | refs/heads/master | 2021-12-05T18:32:54.525624 | 2006-08-21T13:10:54 | 2006-08-21T13:10:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,385 | h | #ifndef _DIAGRAMENTITY_H_
#define _DIAGRAMENTITY_H_
#include "../DiagramPropertyPage.h"
#include "../DiagramPropertySheet.h"
#define CMD_START 100
#define CMD_CUT 100
#define CMD_COPY 101
#define CMD_DUPLICATE 102
#define CMD_PROPERTIES 103
#define CMD_UP 104
#define CMD_DOWN 105
#define CMD_FRONT 106
#define CMD_BOTTOM 107
#define CMD_FREEZE 108
#define CMD_UNFREEZE_ALL 109
#define CMD_HIDE 110
#define CMD_HIDE_UNSEL 111
#define CMD_UNHIDE_ALL 112
#define CMD_CONTROL_LIST 113
#define CMD_SHOW_CODE 114
#define CMD_END 200
#define DEHT_NONE 0
#define DEHT_BODY 1
#define DEHT_TOPLEFT 2
#define DEHT_TOPMIDDLE 3
#define DEHT_TOPRIGHT 4
#define DEHT_BOTTOMLEFT 5
#define DEHT_BOTTOMMIDDLE 6
#define DEHT_BOTTOMRIGHT 7
#define DEHT_LEFTMIDDLE 8
#define DEHT_RIGHTMIDDLE 9
#define round(a) ( int ) ( a + .5 )
class CDiagramEntityContainer;
class CDiagramPropertyPage;
class CDiagramEntity : public CObject
{
friend class CDiagramEntityContainer;
public:
// Creation/initialization
CDiagramEntity();
virtual ~CDiagramEntity();
protected:
virtual void Clear();
public:
virtual CDiagramEntity* Clone();
virtual void Copy( CDiagramEntity* obj );
virtual BOOL FromString( const CString& str );
virtual CString Export( UINT format = 0 ) const;
virtual CString GetString( BOOL bBegin ) const;
virtual CString GetString() const;
virtual CString GetEventHandler() const;
static CDiagramEntity* CreateFromString( const CString& str );
// Object rectangle handling
virtual CRect GetRect() const;
virtual void SetRect( CRect rect );
virtual void SetRect( double left, double top, double right, double bottom );
virtual void MoveRect( double x, double y );
double GetLeft() const;
double GetRight() const;
double GetTop() const;
double GetBottom() const;
virtual void SetLeft( double left );
virtual void SetRight( double right );
virtual void SetTop( double top );
virtual void SetBottom( double bottom );
virtual void SetMinimumSize( CSize minimumSize );
virtual CSize GetMinimumSize() const;
virtual void SetMaximumSize( CSize minimumSize );
virtual CSize GetMaximumSize() const;
virtual void SetConstraints( CSize min, CSize max );
double GetZoom() const;
// Selection handling
virtual void Select( BOOL selected );
virtual BOOL IsSelected() const;
virtual BOOL BodyInRect( CRect rect ) const;
virtual BOOL IsSelectable() const;
virtual void Freeze(BOOL freezed);
virtual BOOL IsFreezed() const;
virtual void SetVisible(BOOL visible);
virtual BOOL IsVisible() const;
// Interaction
virtual int GetHitCode( CPoint point ) const;
virtual BOOL DoMessage( UINT msg, CDiagramEntity* sender, CWnd* from = NULL );
// Auxilliary
virtual void ShowProperties( CWnd* parent, BOOL show = TRUE );
virtual void ShowPopup( CPoint point, CWnd* parent );
// Visuals
virtual void Draw( CDC* dc, CRect rect );
virtual HCURSOR GetCursor( int hit ) const;
virtual void DrawObject( CDC* dc, double zoom );
// Properties
virtual CString GetTitle() const;
virtual void SetTitle( CString title );
virtual CString GetName() const;
virtual void SetName( CString name );
CString GetType() const;
void SetType( CString type );
protected:
// Selection
virtual void DrawSelectionMarkers( CDC* dc, CRect rect ) const;
virtual CRect GetSelectionMarkerRect( UINT marker, CRect rect ) const;
// Visuals
void GetFont( LOGFONT& lf ) const;
// Properties
void SetMarkerSize( CSize markerSize );
CSize GetMarkerSize() const;
void SetZoom( double zoom );
void SetParent( CDiagramEntityContainer* parent );
CDiagramEntityContainer* GetParent() const;
void AddPropertyPage( CDiagramPropertyPage* page);
CDiagramPropertySheet* GetPropertySheet() ;
private:
// Position
double m_left;
double m_right;
double m_top;
double m_bottom;
// Sizes
CSize m_markerSize;
CSize m_minimumSize;
CSize m_maximumSize;
// States
double m_zoom;
BOOL m_selected;
BOOL m_freezed;
BOOL m_visible;
// Data
CString m_type;
CString m_title;
CString m_name;
CDiagramPropertySheet m_propertysheet;
CDiagramEntityContainer* m_parent;
};
#endif // _DIAGRAMENTITY_H_
| [
"sience@a725d9c3-d2eb-0310-b856-fa980ef11a19"
] | [
[
[
1,
179
]
]
] |
3c4bef00fa2ff774b0ac3623b331bba879272bd2 | a42631976da2e576db6c612fcacaf0781e23f8d0 | /Memory.cpp | 70eb043c69d15c888b0babcc1f0250a69a034a66 | [] | no_license | rivaldo/projetopsc | f088a0889c69c196a39c3cfdc9cb91ba0ec59c4d | 0e94d332a437d638b14707cbb029dfb23ce679e5 | refs/heads/master | 2020-12-25T09:38:23.671816 | 2011-06-03T18:46:53 | 2011-06-03T18:46:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 194 | cpp | #include <Memory.h>
void Memory::t_sync_mem() {
if(rst) {
datao = 0x00;
wait();
}
while(1) {
if(write) mem[address] = datai;
else datao = mem[address];
wait();
}
}
| [
"[email protected]"
] | [
[
[
1,
14
]
]
] |
6368888ef54de8c09884b0f0437d892ad839c0bd | d54d8b1bbc9575f3c96853e0c67f17c1ad7ab546 | /hlsdk-2.3-p3/singleplayer/utils/vgui/include/VGUI.h | 0078a27eb0fccb560e047d2d6eee89b45e3f1a92 | [] | no_license | joropito/amxxgroup | 637ee71e250ffd6a7e628f77893caef4c4b1af0a | f948042ee63ebac6ad0332f8a77393322157fa8f | refs/heads/master | 2021-01-10T09:21:31.449489 | 2010-04-11T21:34:27 | 2010-04-11T21:34:27 | 47,087,485 | 1 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 4,450 | h | //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_H
#define VGUI_H
//If you are going to add stuff to the vgui core...
//
//Keep it simple.
//
//Never put code in a header.
//
//The name of the class is the name of the the file
//
//Each class gets its own .cpp file for its definition and a .h for its header. Helper
//classes can be used but only within the .cpp and not referenceable from anywhere else.
//
//Don't add unneeded files. Keep the API clean.
//
//No platform specific code in vgui\lib-src\vgui dir. Code in vgui\lib-src\vgui should
//only include from vgui\include or standard C includes. ie, if I see windows.h included
//anywhere but vgui\lib-src\win32 I will hunt you down and kill you. Don't give me any crap
//that mfc is platform inspecific.
//
//Always use <> and not "" for includes
//
//Use minimum dependencies in headers. Don't include another header if you can get away
//with forward declaring (which is usually the case)
//
//No macros in headers. They are tools of satan. This also means no use of DEFINEs, use enum
//
//Minimize global functions
//
//No global variables.
//
//Panel is getting pretty plump, try and avoid adding junk to it if you can
//TODO: Look and Feel support
// add Panel::setPaintProxy, if _paintProxy exists, it calls _paintProxy->paint
// instead of Panel::paint. Components should implement their painting in a seperate
// plugin class. Perhaps to encourage this, Panel::paint should just go away completely
// The other option is to have Panel have the interface Paintable
// class Paintable
// {
// public:
// virtual void paint()=0;
// };
// Then a component can implement its paint in the class itself and then call
// setPaintProxy(this). If this is the case _paintProxy->paint should always be called
// and never Panel::paint from within paintTraverse
//TODO: Figure out the 'Valve' Look and Feel and implement that instead of a the Java one
//TODO: Determine ownership policy for Borders, Layouts, etc..
//TODO: tooltips support
//TODO: ComboKey (hot key support)
//TODO: add Background.cpp, remove paintBackground from all components
// Panel implements setBackground, Panel::paintBackground calls _background->paintBackground
// similiar to the way Border works.
//TODO: Builtin components should never overide paintBackground, only paint
//TODO: All protected members should be converted to private
//TODO: All member variables should be moved to the top of the class prototype
//TODO: All private methods should be prepended with private
//TODO: Use of word internal in method names is not consistent and confusing
//TODO: Cleanup so bullshit publics are properly named, maybe even figure out
// a naming convention for them
//TODO: Breakup InputSignal into logical pieces
//TODO: Button is in a state of disarray, it should have ButtonModel support
//TODO: get rid of all the stupid strdup laziness, convert to vgui_strdup
//TODO: actually figure out policy on String and implement it consistently
//TODO: implement createLayoutInfo for other Layouts than need it
//TODO: BorderLayout should have option for a null LayoutInfo defaulting to center
//TODO: SurfaceBase should go away, put it in Surface
//TODO: ActionSignals and other Signals should just set a flag when they fire.
// then App can come along later and fire all the signals
//TODO: Change all method naming to starting with a capital letter.
#ifdef _WIN32
# define VGUIAPI __declspec( dllexport )
#else
# define VGUIAPI
#endif
#define null 0L
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
namespace vgui
{
VGUIAPI void vgui_setMalloc(void* (*malloc)(size_t size));
VGUIAPI void vgui_setFree(void (*free)(void* memblock));
VGUIAPI void vgui_strcpy(char* dst,int dstLen,const char* src);
VGUIAPI char* vgui_strdup(const char* src);
VGUIAPI int vgui_printf(const char* format,...);
VGUIAPI int vgui_dprintf(const char* format,...);
VGUIAPI int vgui_dprintf2(const char* format,...);
}
#endif
| [
"joropito@23c7d628-c96c-11de-a380-73d83ba7c083"
] | [
[
[
1,
107
]
]
] |
7cd2c96bc35fbbee02294c7bf2a8c495919b0b93 | c74b0c37ac8e2d3d1a3c0ffaa2b608bc4deff1c6 | /Toolkit/FreyaReflect/Lib/3party/elsa/xml_ast_reader_1defn.gen.cc | 1f77ddc6fa0b5c36ca7784f95e133d540dbd84f5 | [] | no_license | crsib/freya-3d | c33beeb787e572f2faf9528c6f3a1fa3875749c5 | ff1f54b09f7bc0e253053a474f3fe5635dbedde6 | refs/heads/master | 2022-05-21T19:42:30.694778 | 2011-03-11T13:49:00 | 2011-03-11T13:49:00 | 259,894,429 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 115,971 | cc | bool XmlAstReader::kind2kindCat(int kind, KindCategory *kindCat) {
switch(kind) {
default: return false; // don't know this kind
case XTOK_TranslationUnit: *kindCat = KC_Node; break;
case XTOK_TopForm: *kindCat = KC_Node; break;
case XTOK_TF_decl: *kindCat = KC_Node; break;
case XTOK_TF_func: *kindCat = KC_Node; break;
case XTOK_TF_template: *kindCat = KC_Node; break;
case XTOK_TF_explicitInst: *kindCat = KC_Node; break;
case XTOK_TF_linkage: *kindCat = KC_Node; break;
case XTOK_TF_one_linkage: *kindCat = KC_Node; break;
case XTOK_TF_asm: *kindCat = KC_Node; break;
case XTOK_TF_namespaceDefn: *kindCat = KC_Node; break;
case XTOK_TF_namespaceDecl: *kindCat = KC_Node; break;
case XTOK_Function: *kindCat = KC_Node; break;
case XTOK_MemberInit: *kindCat = KC_Node; break;
case XTOK_Declaration: *kindCat = KC_Node; break;
case XTOK_ASTTypeId: *kindCat = KC_Node; break;
case XTOK_PQName: *kindCat = KC_Node; break;
case XTOK_PQ_qualifier: *kindCat = KC_Node; break;
case XTOK_PQ_name: *kindCat = KC_Node; break;
case XTOK_PQ_operator: *kindCat = KC_Node; break;
case XTOK_PQ_template: *kindCat = KC_Node; break;
case XTOK_PQ_variable: *kindCat = KC_Node; break;
case XTOK_TypeSpecifier: *kindCat = KC_Node; break;
case XTOK_TS_name: *kindCat = KC_Node; break;
case XTOK_TS_simple: *kindCat = KC_Node; break;
case XTOK_TS_elaborated: *kindCat = KC_Node; break;
case XTOK_TS_classSpec: *kindCat = KC_Node; break;
case XTOK_TS_enumSpec: *kindCat = KC_Node; break;
case XTOK_TS_type: *kindCat = KC_Node; break;
case XTOK_TS_typeof: *kindCat = KC_Node; break;
case XTOK_BaseClassSpec: *kindCat = KC_Node; break;
case XTOK_Enumerator: *kindCat = KC_Node; break;
case XTOK_MemberList: *kindCat = KC_Node; break;
case XTOK_Member: *kindCat = KC_Node; break;
case XTOK_MR_decl: *kindCat = KC_Node; break;
case XTOK_MR_func: *kindCat = KC_Node; break;
case XTOK_MR_access: *kindCat = KC_Node; break;
case XTOK_MR_usingDecl: *kindCat = KC_Node; break;
case XTOK_MR_template: *kindCat = KC_Node; break;
case XTOK_Declarator: *kindCat = KC_Node; break;
case XTOK_IDeclarator: *kindCat = KC_Node; break;
case XTOK_D_name: *kindCat = KC_Node; break;
case XTOK_D_pointer: *kindCat = KC_Node; break;
case XTOK_D_reference: *kindCat = KC_Node; break;
case XTOK_D_func: *kindCat = KC_Node; break;
case XTOK_D_array: *kindCat = KC_Node; break;
case XTOK_D_bitfield: *kindCat = KC_Node; break;
case XTOK_D_ptrToMember: *kindCat = KC_Node; break;
case XTOK_D_grouping: *kindCat = KC_Node; break;
case XTOK_ExceptionSpec: *kindCat = KC_Node; break;
case XTOK_OperatorName: *kindCat = KC_Node; break;
case XTOK_ON_newDel: *kindCat = KC_Node; break;
case XTOK_ON_operator: *kindCat = KC_Node; break;
case XTOK_ON_conversion: *kindCat = KC_Node; break;
case XTOK_Statement: *kindCat = KC_Node; break;
case XTOK_S_skip: *kindCat = KC_Node; break;
case XTOK_S_label: *kindCat = KC_Node; break;
case XTOK_S_case: *kindCat = KC_Node; break;
case XTOK_S_default: *kindCat = KC_Node; break;
case XTOK_S_expr: *kindCat = KC_Node; break;
case XTOK_S_compound: *kindCat = KC_Node; break;
case XTOK_S_if: *kindCat = KC_Node; break;
case XTOK_S_switch: *kindCat = KC_Node; break;
case XTOK_S_while: *kindCat = KC_Node; break;
case XTOK_S_doWhile: *kindCat = KC_Node; break;
case XTOK_S_for: *kindCat = KC_Node; break;
case XTOK_S_break: *kindCat = KC_Node; break;
case XTOK_S_continue: *kindCat = KC_Node; break;
case XTOK_S_return: *kindCat = KC_Node; break;
case XTOK_S_goto: *kindCat = KC_Node; break;
case XTOK_S_decl: *kindCat = KC_Node; break;
case XTOK_S_try: *kindCat = KC_Node; break;
case XTOK_S_asm: *kindCat = KC_Node; break;
case XTOK_S_namespaceDecl: *kindCat = KC_Node; break;
case XTOK_S_function: *kindCat = KC_Node; break;
case XTOK_S_rangeCase: *kindCat = KC_Node; break;
case XTOK_S_computedGoto: *kindCat = KC_Node; break;
case XTOK_Condition: *kindCat = KC_Node; break;
case XTOK_CN_expr: *kindCat = KC_Node; break;
case XTOK_CN_decl: *kindCat = KC_Node; break;
case XTOK_Handler: *kindCat = KC_Node; break;
case XTOK_Expression: *kindCat = KC_Node; break;
case XTOK_E_boolLit: *kindCat = KC_Node; break;
case XTOK_E_intLit: *kindCat = KC_Node; break;
case XTOK_E_floatLit: *kindCat = KC_Node; break;
case XTOK_E_stringLit: *kindCat = KC_Node; break;
case XTOK_E_charLit: *kindCat = KC_Node; break;
case XTOK_E_this: *kindCat = KC_Node; break;
case XTOK_E_variable: *kindCat = KC_Node; break;
case XTOK_E_funCall: *kindCat = KC_Node; break;
case XTOK_E_constructor: *kindCat = KC_Node; break;
case XTOK_E_fieldAcc: *kindCat = KC_Node; break;
case XTOK_E_sizeof: *kindCat = KC_Node; break;
case XTOK_E_unary: *kindCat = KC_Node; break;
case XTOK_E_effect: *kindCat = KC_Node; break;
case XTOK_E_binary: *kindCat = KC_Node; break;
case XTOK_E_addrOf: *kindCat = KC_Node; break;
case XTOK_E_deref: *kindCat = KC_Node; break;
case XTOK_E_cast: *kindCat = KC_Node; break;
case XTOK_E_cond: *kindCat = KC_Node; break;
case XTOK_E_sizeofType: *kindCat = KC_Node; break;
case XTOK_E_assign: *kindCat = KC_Node; break;
case XTOK_E_new: *kindCat = KC_Node; break;
case XTOK_E_delete: *kindCat = KC_Node; break;
case XTOK_E_throw: *kindCat = KC_Node; break;
case XTOK_E_keywordCast: *kindCat = KC_Node; break;
case XTOK_E_typeidExpr: *kindCat = KC_Node; break;
case XTOK_E_typeidType: *kindCat = KC_Node; break;
case XTOK_E_grouping: *kindCat = KC_Node; break;
case XTOK_E_arrow: *kindCat = KC_Node; break;
case XTOK_E_statement: *kindCat = KC_Node; break;
case XTOK_E_compoundLit: *kindCat = KC_Node; break;
case XTOK_E___builtin_constant_p: *kindCat = KC_Node; break;
case XTOK_E___builtin_va_arg: *kindCat = KC_Node; break;
case XTOK_E_alignofType: *kindCat = KC_Node; break;
case XTOK_E_alignofExpr: *kindCat = KC_Node; break;
case XTOK_E_gnuCond: *kindCat = KC_Node; break;
case XTOK_E_addrOfLabel: *kindCat = KC_Node; break;
case XTOK_FullExpression: *kindCat = KC_Node; break;
case XTOK_ArgExpression: *kindCat = KC_Node; break;
case XTOK_ArgExpressionListOpt: *kindCat = KC_Node; break;
case XTOK_Initializer: *kindCat = KC_Node; break;
case XTOK_IN_expr: *kindCat = KC_Node; break;
case XTOK_IN_compound: *kindCat = KC_Node; break;
case XTOK_IN_ctor: *kindCat = KC_Node; break;
case XTOK_IN_designated: *kindCat = KC_Node; break;
case XTOK_TemplateDeclaration: *kindCat = KC_Node; break;
case XTOK_TD_func: *kindCat = KC_Node; break;
case XTOK_TD_decl: *kindCat = KC_Node; break;
case XTOK_TD_tmember: *kindCat = KC_Node; break;
case XTOK_TemplateParameter: *kindCat = KC_Node; break;
case XTOK_TP_type: *kindCat = KC_Node; break;
case XTOK_TP_nontype: *kindCat = KC_Node; break;
case XTOK_TP_template: *kindCat = KC_Node; break;
case XTOK_TemplateArgument: *kindCat = KC_Node; break;
case XTOK_TA_type: *kindCat = KC_Node; break;
case XTOK_TA_nontype: *kindCat = KC_Node; break;
case XTOK_TA_templateUsed: *kindCat = KC_Node; break;
case XTOK_NamespaceDecl: *kindCat = KC_Node; break;
case XTOK_ND_alias: *kindCat = KC_Node; break;
case XTOK_ND_usingDecl: *kindCat = KC_Node; break;
case XTOK_ND_usingDir: *kindCat = KC_Node; break;
case XTOK_FullExpressionAnnot: *kindCat = KC_Node; break;
case XTOK_ASTTypeof: *kindCat = KC_Node; break;
case XTOK_TS_typeof_expr: *kindCat = KC_Node; break;
case XTOK_TS_typeof_type: *kindCat = KC_Node; break;
case XTOK_Designator: *kindCat = KC_Node; break;
case XTOK_FieldDesignator: *kindCat = KC_Node; break;
case XTOK_SubscriptDesignator: *kindCat = KC_Node; break;
case XTOK_AttributeSpecifierList: *kindCat = KC_Node; break;
case XTOK_AttributeSpecifier: *kindCat = KC_Node; break;
case XTOK_Attribute: *kindCat = KC_Node; break;
case XTOK_AT_empty: *kindCat = KC_Node; break;
case XTOK_AT_word: *kindCat = KC_Node; break;
case XTOK_AT_func: *kindCat = KC_Node; break;
case XTOK_List_TF_namespaceDefn_forms: *kindCat = KC_ASTList; break;
case XTOK_List_TranslationUnit_topForms: *kindCat = KC_ASTList; break;
case XTOK_List_Function_inits: *kindCat = KC_FakeList; break;
case XTOK_List_Function_handlers: *kindCat = KC_FakeList; break;
case XTOK_List_MemberInit_args: *kindCat = KC_FakeList; break;
case XTOK_List_MemberList_list: *kindCat = KC_ASTList; break;
case XTOK_List_Declaration_decllist: *kindCat = KC_FakeList; break;
case XTOK_List_TS_classSpec_bases: *kindCat = KC_FakeList; break;
case XTOK_List_TS_enumSpec_elts: *kindCat = KC_FakeList; break;
case XTOK_List_D_func_params: *kindCat = KC_FakeList; break;
case XTOK_List_D_func_kAndR_params: *kindCat = KC_FakeList; break;
case XTOK_List_S_try_handlers: *kindCat = KC_FakeList; break;
case XTOK_List_ExceptionSpec_types: *kindCat = KC_FakeList; break;
case XTOK_List_S_compound_stmts: *kindCat = KC_ASTList; break;
case XTOK_List_E_funCall_args: *kindCat = KC_FakeList; break;
case XTOK_List_E_constructor_args: *kindCat = KC_FakeList; break;
case XTOK_List_E_new_placementArgs: *kindCat = KC_FakeList; break;
case XTOK_List_ArgExpressionListOpt_list: *kindCat = KC_FakeList; break;
case XTOK_List_IN_compound_inits: *kindCat = KC_ASTList; break;
case XTOK_List_IN_ctor_args: *kindCat = KC_FakeList; break;
case XTOK_List_TP_template_parameters: *kindCat = KC_FakeList; break;
case XTOK_List_IN_designated_designator_list: *kindCat = KC_FakeList; break;
case XTOK_List_FullExpressionAnnot_declarations: *kindCat = KC_ASTList; break;
case XTOK_List_AT_func_args: *kindCat = KC_FakeList; break;
}
return true;
}
void XmlAstReader::registerAttr_TranslationUnit(TranslationUnit *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TranslationUnit");
break;
case XTOK_topForms:
manager->addUnsatLink(new UnsatLink((void*) &(obj->topForms), strValue, XTOK_List_TranslationUnit_topForms, true));
break;
case XTOK_globalScope:
manager->addUnsatLink(new UnsatLink((void*) &(obj->globalScope), strValue,XTOK_Scope, false));
break;
}
}
void XmlAstReader::registerAttr_TF_decl(TF_decl *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TF_decl");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_decl:
manager->addUnsatLink(new UnsatLink((void*) &(obj->decl), strValue,XTOK_Declaration, false));
break;
}
}
void XmlAstReader::registerAttr_TF_func(TF_func *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TF_func");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_f:
manager->addUnsatLink(new UnsatLink((void*) &(obj->f), strValue,XTOK_Function, false));
break;
}
}
void XmlAstReader::registerAttr_TF_template(TF_template *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TF_template");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_td:
manager->addUnsatLink(new UnsatLink((void*) &(obj->td), strValue,XTOK_TemplateDeclaration, false));
break;
}
}
void XmlAstReader::registerAttr_TF_explicitInst(TF_explicitInst *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TF_explicitInst");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_instFlags:
fromXml(obj->instFlags, strValue);
break;
case XTOK_d:
manager->addUnsatLink(new UnsatLink((void*) &(obj->d), strValue,XTOK_Declaration, false));
break;
}
}
void XmlAstReader::registerAttr_TF_linkage(TF_linkage *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TF_linkage");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_linkageType:
obj->linkageType = manager->strTable(strValue);
break;
case XTOK_forms:
manager->addUnsatLink(new UnsatLink((void*) &(obj->forms), strValue,XTOK_TranslationUnit, false));
break;
}
}
void XmlAstReader::registerAttr_TF_one_linkage(TF_one_linkage *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TF_one_linkage");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_linkageType:
obj->linkageType = manager->strTable(strValue);
break;
case XTOK_form:
manager->addUnsatLink(new UnsatLink((void*) &(obj->form), strValue,XTOK_TopForm, false));
break;
}
}
void XmlAstReader::registerAttr_TF_asm(TF_asm *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TF_asm");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_text:
manager->addUnsatLink(new UnsatLink((void*) &(obj->text), strValue,XTOK_E_stringLit, false));
break;
}
}
void XmlAstReader::registerAttr_TF_namespaceDefn(TF_namespaceDefn *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TF_namespaceDefn");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_name:
obj->name = manager->strTable(strValue);
break;
case XTOK_forms:
manager->addUnsatLink(new UnsatLink((void*) &(obj->forms), strValue, XTOK_List_TF_namespaceDefn_forms, true));
break;
}
}
void XmlAstReader::registerAttr_TF_namespaceDecl(TF_namespaceDecl *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TF_namespaceDecl");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_decl:
manager->addUnsatLink(new UnsatLink((void*) &(obj->decl), strValue,XTOK_NamespaceDecl, false));
break;
}
}
void XmlAstReader::registerAttr_Function(Function *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a Function");
break;
case XTOK_dflags:
fromXml(obj->dflags, strValue);
break;
case XTOK_retspec:
manager->addUnsatLink(new UnsatLink((void*) &(obj->retspec), strValue,XTOK_TypeSpecifier, false));
break;
case XTOK_nameAndParams:
manager->addUnsatLink(new UnsatLink((void*) &(obj->nameAndParams), strValue,XTOK_Declarator, false));
break;
case XTOK_inits:
manager->addUnsatLink(new UnsatLink((void*) &(obj->inits), strValue, XTOK_List_Function_inits, true));
break;
case XTOK_body:
manager->addUnsatLink(new UnsatLink((void*) &(obj->body), strValue,XTOK_S_compound, false));
break;
case XTOK_handlers:
manager->addUnsatLink(new UnsatLink((void*) &(obj->handlers), strValue, XTOK_List_Function_handlers, true));
break;
case XTOK_funcType:
manager->addUnsatLink(new UnsatLink((void*) &(obj->funcType), strValue,XTOK_FunctionType, false));
break;
case XTOK_receiver:
manager->addUnsatLink(new UnsatLink((void*) &(obj->receiver), strValue,XTOK_Variable, false));
break;
case XTOK_retVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->retVar), strValue,XTOK_Variable, false));
break;
case XTOK_dtorStatement:
manager->addUnsatLink(new UnsatLink((void*) &(obj->dtorStatement), strValue,XTOK_Statement, false));
break;
case XTOK_implicitlyDefined:
fromXml_bool(obj->implicitlyDefined, strValue);
break;
}
}
void XmlAstReader::registerAttr_MemberInit(MemberInit *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a MemberInit");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
case XTOK_args:
manager->addUnsatLink(new UnsatLink((void*) &(obj->args), strValue, XTOK_List_MemberInit_args, true));
break;
case XTOK_member:
manager->addUnsatLink(new UnsatLink((void*) &(obj->member), strValue,XTOK_Variable, false));
break;
case XTOK_base:
manager->addUnsatLink(new UnsatLink((void*) &(obj->base), strValue,XTOK_CompoundType, false));
break;
case XTOK_ctorVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctorVar), strValue,XTOK_Variable, false));
break;
case XTOK_annot:
manager->addUnsatLink(new UnsatLink((void*) &(obj->annot), strValue,XTOK_FullExpressionAnnot, false));
break;
case XTOK_ctorStatement:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctorStatement), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_Declaration(Declaration *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a Declaration");
break;
case XTOK_dflags:
fromXml(obj->dflags, strValue);
break;
case XTOK_spec:
manager->addUnsatLink(new UnsatLink((void*) &(obj->spec), strValue,XTOK_TypeSpecifier, false));
break;
case XTOK_decllist:
manager->addUnsatLink(new UnsatLink((void*) &(obj->decllist), strValue, XTOK_List_Declaration_decllist, true));
break;
}
}
void XmlAstReader::registerAttr_ASTTypeId(ASTTypeId *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ASTTypeId");
break;
case XTOK_spec:
manager->addUnsatLink(new UnsatLink((void*) &(obj->spec), strValue,XTOK_TypeSpecifier, false));
break;
case XTOK_decl:
manager->addUnsatLink(new UnsatLink((void*) &(obj->decl), strValue,XTOK_Declarator, false));
break;
}
}
void XmlAstReader::registerAttr_PQ_qualifier(PQ_qualifier *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a PQ_qualifier");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_qualifier:
obj->qualifier = manager->strTable(strValue);
break;
case XTOK_templArgs:
manager->addUnsatLink(new UnsatLink((void*) &(obj->templArgs), strValue,XTOK_TemplateArgument, false));
break;
case XTOK_rest:
manager->addUnsatLink(new UnsatLink((void*) &(obj->rest), strValue,XTOK_PQName, false));
break;
case XTOK_qualifierVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->qualifierVar), strValue,XTOK_Variable, false));
break;
case XTOK_sargs:
manager->addUnsatLink(new UnsatLink((void*) &(obj->sargs), strValue,XTOK_List_PQ_qualifier_sargs, true));
break;
}
}
void XmlAstReader::registerAttr_PQ_name(PQ_name *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a PQ_name");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_name:
obj->name = manager->strTable(strValue);
break;
}
}
void XmlAstReader::registerAttr_PQ_operator(PQ_operator *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a PQ_operator");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_o:
manager->addUnsatLink(new UnsatLink((void*) &(obj->o), strValue,XTOK_OperatorName, false));
break;
case XTOK_fakeName:
obj->fakeName = manager->strTable(strValue);
break;
}
}
void XmlAstReader::registerAttr_PQ_template(PQ_template *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a PQ_template");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_name:
obj->name = manager->strTable(strValue);
break;
case XTOK_templArgs:
manager->addUnsatLink(new UnsatLink((void*) &(obj->templArgs), strValue,XTOK_TemplateArgument, false));
break;
case XTOK_sargs:
manager->addUnsatLink(new UnsatLink((void*) &(obj->sargs), strValue,XTOK_List_PQ_template_sargs, true));
break;
}
}
void XmlAstReader::registerAttr_PQ_variable(PQ_variable *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a PQ_variable");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_var:
manager->addUnsatLink(new UnsatLink((void*) &(obj->var), strValue,XTOK_Variable, false));
break;
}
}
void XmlAstReader::registerAttr_TS_name(TS_name *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TS_name");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
case XTOK_typenameUsed:
fromXml_bool(obj->typenameUsed, strValue);
break;
case XTOK_var:
manager->addUnsatLink(new UnsatLink((void*) &(obj->var), strValue,XTOK_Variable, false));
break;
case XTOK_nondependentVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->nondependentVar), strValue,XTOK_Variable, false));
break;
}
}
void XmlAstReader::registerAttr_TS_simple(TS_simple *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TS_simple");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_id:
fromXml(obj->id, strValue);
break;
}
}
void XmlAstReader::registerAttr_TS_elaborated(TS_elaborated *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TS_elaborated");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_keyword:
fromXml(obj->keyword, strValue);
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
case XTOK_atype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->atype), strValue,XTOK_NamedAtomicType, false));
break;
}
}
void XmlAstReader::registerAttr_TS_classSpec(TS_classSpec *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TS_classSpec");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_keyword:
fromXml(obj->keyword, strValue);
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
case XTOK_bases:
manager->addUnsatLink(new UnsatLink((void*) &(obj->bases), strValue, XTOK_List_TS_classSpec_bases, true));
break;
case XTOK_members:
manager->addUnsatLink(new UnsatLink((void*) &(obj->members), strValue,XTOK_MemberList, false));
break;
case XTOK_ctype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctype), strValue,XTOK_CompoundType, false));
break;
}
}
void XmlAstReader::registerAttr_TS_enumSpec(TS_enumSpec *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TS_enumSpec");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_name:
obj->name = manager->strTable(strValue);
break;
case XTOK_elts:
manager->addUnsatLink(new UnsatLink((void*) &(obj->elts), strValue, XTOK_List_TS_enumSpec_elts, true));
break;
case XTOK_etype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->etype), strValue,XTOK_EnumType, false));
break;
}
}
void XmlAstReader::registerAttr_TS_type(TS_type *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TS_type");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
}
}
void XmlAstReader::registerAttr_TS_typeof(TS_typeof *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TS_typeof");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_atype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->atype), strValue,XTOK_ASTTypeof, false));
break;
}
}
void XmlAstReader::registerAttr_BaseClassSpec(BaseClassSpec *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a BaseClassSpec");
break;
case XTOK_isVirtual:
fromXml_bool(obj->isVirtual, strValue);
break;
case XTOK_access:
fromXml(obj->access, strValue);
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_CompoundType, false));
break;
}
}
void XmlAstReader::registerAttr_Enumerator(Enumerator *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a Enumerator");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_name:
obj->name = manager->strTable(strValue);
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
case XTOK_var:
manager->addUnsatLink(new UnsatLink((void*) &(obj->var), strValue,XTOK_Variable, false));
break;
case XTOK_enumValue:
fromXml_int(obj->enumValue, strValue);
break;
}
}
void XmlAstReader::registerAttr_MemberList(MemberList *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a MemberList");
break;
case XTOK_list:
manager->addUnsatLink(new UnsatLink((void*) &(obj->list), strValue, XTOK_List_MemberList_list, true));
break;
}
}
void XmlAstReader::registerAttr_MR_decl(MR_decl *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a MR_decl");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_d:
manager->addUnsatLink(new UnsatLink((void*) &(obj->d), strValue,XTOK_Declaration, false));
break;
}
}
void XmlAstReader::registerAttr_MR_func(MR_func *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a MR_func");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_f:
manager->addUnsatLink(new UnsatLink((void*) &(obj->f), strValue,XTOK_Function, false));
break;
}
}
void XmlAstReader::registerAttr_MR_access(MR_access *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a MR_access");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_k:
fromXml(obj->k, strValue);
break;
}
}
void XmlAstReader::registerAttr_MR_usingDecl(MR_usingDecl *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a MR_usingDecl");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_decl:
manager->addUnsatLink(new UnsatLink((void*) &(obj->decl), strValue,XTOK_ND_usingDecl, false));
break;
}
}
void XmlAstReader::registerAttr_MR_template(MR_template *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a MR_template");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_d:
manager->addUnsatLink(new UnsatLink((void*) &(obj->d), strValue,XTOK_TemplateDeclaration, false));
break;
}
}
void XmlAstReader::registerAttr_Declarator(Declarator *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a Declarator");
break;
case XTOK_decl:
manager->addUnsatLink(new UnsatLink((void*) &(obj->decl), strValue,XTOK_IDeclarator, false));
break;
case XTOK_init:
manager->addUnsatLink(new UnsatLink((void*) &(obj->init), strValue,XTOK_Initializer, false));
break;
case XTOK_var:
manager->addUnsatLink(new UnsatLink((void*) &(obj->var), strValue,XTOK_Variable, false));
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_context:
fromXml(obj->context, strValue);
break;
case XTOK_ctorStatement:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctorStatement), strValue,XTOK_Statement, false));
break;
case XTOK_dtorStatement:
manager->addUnsatLink(new UnsatLink((void*) &(obj->dtorStatement), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_D_name(D_name *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a D_name");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
}
}
void XmlAstReader::registerAttr_D_pointer(D_pointer *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a D_pointer");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_base:
manager->addUnsatLink(new UnsatLink((void*) &(obj->base), strValue,XTOK_IDeclarator, false));
break;
}
}
void XmlAstReader::registerAttr_D_reference(D_reference *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a D_reference");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_base:
manager->addUnsatLink(new UnsatLink((void*) &(obj->base), strValue,XTOK_IDeclarator, false));
break;
}
}
void XmlAstReader::registerAttr_D_func(D_func *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a D_func");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_base:
manager->addUnsatLink(new UnsatLink((void*) &(obj->base), strValue,XTOK_IDeclarator, false));
break;
case XTOK_params:
manager->addUnsatLink(new UnsatLink((void*) &(obj->params), strValue, XTOK_List_D_func_params, true));
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_exnSpec:
manager->addUnsatLink(new UnsatLink((void*) &(obj->exnSpec), strValue,XTOK_ExceptionSpec, false));
break;
case XTOK_kAndR_params:
manager->addUnsatLink(new UnsatLink((void*) &(obj->kAndR_params), strValue, XTOK_List_D_func_kAndR_params, true));
break;
case XTOK_isMember:
fromXml_bool(obj->isMember, strValue);
break;
}
}
void XmlAstReader::registerAttr_D_array(D_array *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a D_array");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_base:
manager->addUnsatLink(new UnsatLink((void*) &(obj->base), strValue,XTOK_IDeclarator, false));
break;
case XTOK_size:
manager->addUnsatLink(new UnsatLink((void*) &(obj->size), strValue,XTOK_Expression, false));
break;
case XTOK_isNewSize:
fromXml_bool(obj->isNewSize, strValue);
break;
}
}
void XmlAstReader::registerAttr_D_bitfield(D_bitfield *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a D_bitfield");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
case XTOK_bits:
manager->addUnsatLink(new UnsatLink((void*) &(obj->bits), strValue,XTOK_Expression, false));
break;
case XTOK_numBits:
fromXml_int(obj->numBits, strValue);
break;
}
}
void XmlAstReader::registerAttr_D_ptrToMember(D_ptrToMember *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a D_ptrToMember");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_nestedName:
manager->addUnsatLink(new UnsatLink((void*) &(obj->nestedName), strValue,XTOK_PQName, false));
break;
case XTOK_cv:
fromXml(obj->cv, strValue);
break;
case XTOK_base:
manager->addUnsatLink(new UnsatLink((void*) &(obj->base), strValue,XTOK_IDeclarator, false));
break;
}
}
void XmlAstReader::registerAttr_D_grouping(D_grouping *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a D_grouping");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_base:
manager->addUnsatLink(new UnsatLink((void*) &(obj->base), strValue,XTOK_IDeclarator, false));
break;
}
}
void XmlAstReader::registerAttr_ExceptionSpec(ExceptionSpec *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ExceptionSpec");
break;
case XTOK_types:
manager->addUnsatLink(new UnsatLink((void*) &(obj->types), strValue, XTOK_List_ExceptionSpec_types, true));
break;
}
}
void XmlAstReader::registerAttr_ON_newDel(ON_newDel *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ON_newDel");
break;
case XTOK_isNew:
fromXml_bool(obj->isNew, strValue);
break;
case XTOK_isArray:
fromXml_bool(obj->isArray, strValue);
break;
}
}
void XmlAstReader::registerAttr_ON_operator(ON_operator *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ON_operator");
break;
case XTOK_op:
fromXml(obj->op, strValue);
break;
}
}
void XmlAstReader::registerAttr_ON_conversion(ON_conversion *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ON_conversion");
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_ASTTypeId, false));
break;
}
}
void XmlAstReader::registerAttr_S_skip(S_skip *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_skip");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
}
}
void XmlAstReader::registerAttr_S_label(S_label *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_label");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_name:
obj->name = manager->strTable(strValue);
break;
case XTOK_s:
manager->addUnsatLink(new UnsatLink((void*) &(obj->s), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_S_case(S_case *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_case");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
case XTOK_s:
manager->addUnsatLink(new UnsatLink((void*) &(obj->s), strValue,XTOK_Statement, false));
break;
case XTOK_labelVal:
fromXml_int(obj->labelVal, strValue);
break;
}
}
void XmlAstReader::registerAttr_S_default(S_default *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_default");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_s:
manager->addUnsatLink(new UnsatLink((void*) &(obj->s), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_S_expr(S_expr *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_expr");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_FullExpression, false));
break;
}
}
void XmlAstReader::registerAttr_S_compound(S_compound *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_compound");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_stmts:
manager->addUnsatLink(new UnsatLink((void*) &(obj->stmts), strValue, XTOK_List_S_compound_stmts, true));
break;
}
}
void XmlAstReader::registerAttr_S_if(S_if *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_if");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_cond:
manager->addUnsatLink(new UnsatLink((void*) &(obj->cond), strValue,XTOK_Condition, false));
break;
case XTOK_thenBranch:
manager->addUnsatLink(new UnsatLink((void*) &(obj->thenBranch), strValue,XTOK_Statement, false));
break;
case XTOK_elseBranch:
manager->addUnsatLink(new UnsatLink((void*) &(obj->elseBranch), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_S_switch(S_switch *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_switch");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_cond:
manager->addUnsatLink(new UnsatLink((void*) &(obj->cond), strValue,XTOK_Condition, false));
break;
case XTOK_branches:
manager->addUnsatLink(new UnsatLink((void*) &(obj->branches), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_S_while(S_while *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_while");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_cond:
manager->addUnsatLink(new UnsatLink((void*) &(obj->cond), strValue,XTOK_Condition, false));
break;
case XTOK_body:
manager->addUnsatLink(new UnsatLink((void*) &(obj->body), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_S_doWhile(S_doWhile *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_doWhile");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_body:
manager->addUnsatLink(new UnsatLink((void*) &(obj->body), strValue,XTOK_Statement, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_FullExpression, false));
break;
}
}
void XmlAstReader::registerAttr_S_for(S_for *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_for");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_init:
manager->addUnsatLink(new UnsatLink((void*) &(obj->init), strValue,XTOK_Statement, false));
break;
case XTOK_cond:
manager->addUnsatLink(new UnsatLink((void*) &(obj->cond), strValue,XTOK_Condition, false));
break;
case XTOK_after:
manager->addUnsatLink(new UnsatLink((void*) &(obj->after), strValue,XTOK_FullExpression, false));
break;
case XTOK_body:
manager->addUnsatLink(new UnsatLink((void*) &(obj->body), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_S_break(S_break *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_break");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
}
}
void XmlAstReader::registerAttr_S_continue(S_continue *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_continue");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
}
}
void XmlAstReader::registerAttr_S_return(S_return *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_return");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_FullExpression, false));
break;
case XTOK_ctorStatement:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctorStatement), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_S_goto(S_goto *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_goto");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_target:
obj->target = manager->strTable(strValue);
break;
}
}
void XmlAstReader::registerAttr_S_decl(S_decl *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_decl");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_decl:
manager->addUnsatLink(new UnsatLink((void*) &(obj->decl), strValue,XTOK_Declaration, false));
break;
}
}
void XmlAstReader::registerAttr_S_try(S_try *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_try");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_body:
manager->addUnsatLink(new UnsatLink((void*) &(obj->body), strValue,XTOK_Statement, false));
break;
case XTOK_handlers:
manager->addUnsatLink(new UnsatLink((void*) &(obj->handlers), strValue, XTOK_List_S_try_handlers, true));
break;
}
}
void XmlAstReader::registerAttr_S_asm(S_asm *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_asm");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_text:
manager->addUnsatLink(new UnsatLink((void*) &(obj->text), strValue,XTOK_E_stringLit, false));
break;
}
}
void XmlAstReader::registerAttr_S_namespaceDecl(S_namespaceDecl *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_namespaceDecl");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_decl:
manager->addUnsatLink(new UnsatLink((void*) &(obj->decl), strValue,XTOK_NamespaceDecl, false));
break;
}
}
void XmlAstReader::registerAttr_S_function(S_function *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_function");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_f:
manager->addUnsatLink(new UnsatLink((void*) &(obj->f), strValue,XTOK_Function, false));
break;
}
}
void XmlAstReader::registerAttr_S_rangeCase(S_rangeCase *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_rangeCase");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_exprLo:
manager->addUnsatLink(new UnsatLink((void*) &(obj->exprLo), strValue,XTOK_Expression, false));
break;
case XTOK_exprHi:
manager->addUnsatLink(new UnsatLink((void*) &(obj->exprHi), strValue,XTOK_Expression, false));
break;
case XTOK_s:
manager->addUnsatLink(new UnsatLink((void*) &(obj->s), strValue,XTOK_Statement, false));
break;
case XTOK_labelValLo:
fromXml_int(obj->labelValLo, strValue);
break;
case XTOK_labelValHi:
fromXml_int(obj->labelValHi, strValue);
break;
}
}
void XmlAstReader::registerAttr_S_computedGoto(S_computedGoto *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a S_computedGoto");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_target:
manager->addUnsatLink(new UnsatLink((void*) &(obj->target), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_CN_expr(CN_expr *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a CN_expr");
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_FullExpression, false));
break;
}
}
void XmlAstReader::registerAttr_CN_decl(CN_decl *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a CN_decl");
break;
case XTOK_typeId:
manager->addUnsatLink(new UnsatLink((void*) &(obj->typeId), strValue,XTOK_ASTTypeId, false));
break;
}
}
void XmlAstReader::registerAttr_Handler(Handler *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a Handler");
break;
case XTOK_typeId:
manager->addUnsatLink(new UnsatLink((void*) &(obj->typeId), strValue,XTOK_ASTTypeId, false));
break;
case XTOK_body:
manager->addUnsatLink(new UnsatLink((void*) &(obj->body), strValue,XTOK_Statement, false));
break;
case XTOK_globalVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->globalVar), strValue,XTOK_Variable, false));
break;
case XTOK_annot:
manager->addUnsatLink(new UnsatLink((void*) &(obj->annot), strValue,XTOK_FullExpressionAnnot, false));
break;
case XTOK_localArg:
manager->addUnsatLink(new UnsatLink((void*) &(obj->localArg), strValue,XTOK_Expression, false));
break;
case XTOK_globalDtorStatement:
manager->addUnsatLink(new UnsatLink((void*) &(obj->globalDtorStatement), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_E_boolLit(E_boolLit *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_boolLit");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_b:
fromXml_bool(obj->b, strValue);
break;
}
}
void XmlAstReader::registerAttr_E_intLit(E_intLit *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_intLit");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_text:
obj->text = manager->strTable(strValue);
break;
case XTOK_i:
fromXml_unsigned_long(obj->i, strValue);
break;
}
}
void XmlAstReader::registerAttr_E_floatLit(E_floatLit *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_floatLit");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_text:
obj->text = manager->strTable(strValue);
break;
case XTOK_d:
fromXml_double(obj->d, strValue);
break;
}
}
void XmlAstReader::registerAttr_E_stringLit(E_stringLit *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_stringLit");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_text:
obj->text = manager->strTable(strValue);
break;
case XTOK_continuation:
manager->addUnsatLink(new UnsatLink((void*) &(obj->continuation), strValue,XTOK_E_stringLit, false));
break;
case XTOK_fullTextNQ:
obj->fullTextNQ = manager->strTable(strValue);
break;
}
}
void XmlAstReader::registerAttr_E_charLit(E_charLit *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_charLit");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_text:
obj->text = manager->strTable(strValue);
break;
case XTOK_c:
fromXml_unsigned_int(obj->c, strValue);
break;
}
}
void XmlAstReader::registerAttr_E_this(E_this *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_this");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_receiver:
manager->addUnsatLink(new UnsatLink((void*) &(obj->receiver), strValue,XTOK_Variable, false));
break;
}
}
void XmlAstReader::registerAttr_E_variable(E_variable *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_variable");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
case XTOK_var:
manager->addUnsatLink(new UnsatLink((void*) &(obj->var), strValue,XTOK_Variable, false));
break;
case XTOK_nondependentVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->nondependentVar), strValue,XTOK_Variable, false));
break;
}
}
void XmlAstReader::registerAttr_E_funCall(E_funCall *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_funCall");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_func:
manager->addUnsatLink(new UnsatLink((void*) &(obj->func), strValue,XTOK_Expression, false));
break;
case XTOK_args:
manager->addUnsatLink(new UnsatLink((void*) &(obj->args), strValue, XTOK_List_E_funCall_args, true));
break;
case XTOK_retObj:
manager->addUnsatLink(new UnsatLink((void*) &(obj->retObj), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_constructor(E_constructor *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_constructor");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_spec:
manager->addUnsatLink(new UnsatLink((void*) &(obj->spec), strValue,XTOK_TypeSpecifier, false));
break;
case XTOK_args:
manager->addUnsatLink(new UnsatLink((void*) &(obj->args), strValue, XTOK_List_E_constructor_args, true));
break;
case XTOK_ctorVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctorVar), strValue,XTOK_Variable, false));
break;
case XTOK_artificial:
fromXml_bool(obj->artificial, strValue);
break;
case XTOK_retObj:
manager->addUnsatLink(new UnsatLink((void*) &(obj->retObj), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_fieldAcc(E_fieldAcc *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_fieldAcc");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_obj:
manager->addUnsatLink(new UnsatLink((void*) &(obj->obj), strValue,XTOK_Expression, false));
break;
case XTOK_fieldName:
manager->addUnsatLink(new UnsatLink((void*) &(obj->fieldName), strValue,XTOK_PQName, false));
break;
case XTOK_field:
manager->addUnsatLink(new UnsatLink((void*) &(obj->field), strValue,XTOK_Variable, false));
break;
}
}
void XmlAstReader::registerAttr_E_sizeof(E_sizeof *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_sizeof");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
case XTOK_size:
fromXml_int(obj->size, strValue);
break;
}
}
void XmlAstReader::registerAttr_E_unary(E_unary *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_unary");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_op:
fromXml(obj->op, strValue);
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_effect(E_effect *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_effect");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_op:
fromXml(obj->op, strValue);
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_binary(E_binary *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_binary");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_e1:
manager->addUnsatLink(new UnsatLink((void*) &(obj->e1), strValue,XTOK_Expression, false));
break;
case XTOK_op:
fromXml(obj->op, strValue);
break;
case XTOK_e2:
manager->addUnsatLink(new UnsatLink((void*) &(obj->e2), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_addrOf(E_addrOf *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_addrOf");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_deref(E_deref *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_deref");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_ptr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ptr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_cast(E_cast *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_cast");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_ctype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctype), strValue,XTOK_ASTTypeId, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
case XTOK_tcheckedType:
fromXml_bool(obj->tcheckedType, strValue);
break;
}
}
void XmlAstReader::registerAttr_E_cond(E_cond *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_cond");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_cond:
manager->addUnsatLink(new UnsatLink((void*) &(obj->cond), strValue,XTOK_Expression, false));
break;
case XTOK_th:
manager->addUnsatLink(new UnsatLink((void*) &(obj->th), strValue,XTOK_Expression, false));
break;
case XTOK_el:
manager->addUnsatLink(new UnsatLink((void*) &(obj->el), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_sizeofType(E_sizeofType *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_sizeofType");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_atype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->atype), strValue,XTOK_ASTTypeId, false));
break;
case XTOK_size:
fromXml_int(obj->size, strValue);
break;
case XTOK_tchecked:
fromXml_bool(obj->tchecked, strValue);
break;
}
}
void XmlAstReader::registerAttr_E_assign(E_assign *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_assign");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_target:
manager->addUnsatLink(new UnsatLink((void*) &(obj->target), strValue,XTOK_Expression, false));
break;
case XTOK_op:
fromXml(obj->op, strValue);
break;
case XTOK_src:
manager->addUnsatLink(new UnsatLink((void*) &(obj->src), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_new(E_new *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_new");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_colonColon:
fromXml_bool(obj->colonColon, strValue);
break;
case XTOK_placementArgs:
manager->addUnsatLink(new UnsatLink((void*) &(obj->placementArgs), strValue, XTOK_List_E_new_placementArgs, true));
break;
case XTOK_atype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->atype), strValue,XTOK_ASTTypeId, false));
break;
case XTOK_ctorArgs:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctorArgs), strValue,XTOK_ArgExpressionListOpt, false));
break;
case XTOK_arraySize:
manager->addUnsatLink(new UnsatLink((void*) &(obj->arraySize), strValue,XTOK_Expression, false));
break;
case XTOK_ctorVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctorVar), strValue,XTOK_Variable, false));
break;
case XTOK_ctorStatement:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctorStatement), strValue,XTOK_Statement, false));
break;
case XTOK_heapVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->heapVar), strValue,XTOK_Variable, false));
break;
}
}
void XmlAstReader::registerAttr_E_delete(E_delete *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_delete");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_colonColon:
fromXml_bool(obj->colonColon, strValue);
break;
case XTOK_array:
fromXml_bool(obj->array, strValue);
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
case XTOK_dtorStatement:
manager->addUnsatLink(new UnsatLink((void*) &(obj->dtorStatement), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_E_throw(E_throw *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_throw");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
case XTOK_globalVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->globalVar), strValue,XTOK_Variable, false));
break;
case XTOK_globalCtorStatement:
manager->addUnsatLink(new UnsatLink((void*) &(obj->globalCtorStatement), strValue,XTOK_Statement, false));
break;
}
}
void XmlAstReader::registerAttr_E_keywordCast(E_keywordCast *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_keywordCast");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_key:
fromXml(obj->key, strValue);
break;
case XTOK_ctype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctype), strValue,XTOK_ASTTypeId, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_typeidExpr(E_typeidExpr *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_typeidExpr");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_typeidType(E_typeidType *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_typeidType");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_ttype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ttype), strValue,XTOK_ASTTypeId, false));
break;
}
}
void XmlAstReader::registerAttr_E_grouping(E_grouping *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_grouping");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_arrow(E_arrow *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_arrow");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_obj:
manager->addUnsatLink(new UnsatLink((void*) &(obj->obj), strValue,XTOK_Expression, false));
break;
case XTOK_fieldName:
manager->addUnsatLink(new UnsatLink((void*) &(obj->fieldName), strValue,XTOK_PQName, false));
break;
}
}
void XmlAstReader::registerAttr_E_statement(E_statement *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_statement");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_s:
manager->addUnsatLink(new UnsatLink((void*) &(obj->s), strValue,XTOK_S_compound, false));
break;
}
}
void XmlAstReader::registerAttr_E_compoundLit(E_compoundLit *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_compoundLit");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_stype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->stype), strValue,XTOK_ASTTypeId, false));
break;
case XTOK_init:
manager->addUnsatLink(new UnsatLink((void*) &(obj->init), strValue,XTOK_IN_compound, false));
break;
}
}
void XmlAstReader::registerAttr_E___builtin_constant_p(E___builtin_constant_p *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E___builtin_constant_p");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E___builtin_va_arg(E___builtin_va_arg *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E___builtin_va_arg");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
case XTOK_atype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->atype), strValue,XTOK_ASTTypeId, false));
break;
}
}
void XmlAstReader::registerAttr_E_alignofType(E_alignofType *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_alignofType");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_atype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->atype), strValue,XTOK_ASTTypeId, false));
break;
case XTOK_alignment:
fromXml_int(obj->alignment, strValue);
break;
}
}
void XmlAstReader::registerAttr_E_alignofExpr(E_alignofExpr *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_alignofExpr");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
case XTOK_alignment:
fromXml_int(obj->alignment, strValue);
break;
}
}
void XmlAstReader::registerAttr_E_gnuCond(E_gnuCond *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_gnuCond");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_cond:
manager->addUnsatLink(new UnsatLink((void*) &(obj->cond), strValue,XTOK_Expression, false));
break;
case XTOK_el:
manager->addUnsatLink(new UnsatLink((void*) &(obj->el), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_E_addrOfLabel(E_addrOfLabel *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a E_addrOfLabel");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_endloc:
fromXml_SourceLoc(obj->endloc, strValue);
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_labelName:
obj->labelName = manager->strTable(strValue);
break;
}
}
void XmlAstReader::registerAttr_FullExpression(FullExpression *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a FullExpression");
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
case XTOK_annot:
manager->addUnsatLink(new UnsatLink((void*) &(obj->annot), strValue,XTOK_FullExpressionAnnot, false));
break;
}
}
void XmlAstReader::registerAttr_ArgExpression(ArgExpression *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ArgExpression");
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_ArgExpressionListOpt(ArgExpressionListOpt *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ArgExpressionListOpt");
break;
case XTOK_list:
manager->addUnsatLink(new UnsatLink((void*) &(obj->list), strValue, XTOK_List_ArgExpressionListOpt_list, true));
break;
}
}
void XmlAstReader::registerAttr_IN_expr(IN_expr *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a IN_expr");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_annot:
manager->addUnsatLink(new UnsatLink((void*) &(obj->annot), strValue,XTOK_FullExpressionAnnot, false));
break;
case XTOK_e:
manager->addUnsatLink(new UnsatLink((void*) &(obj->e), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_IN_compound(IN_compound *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a IN_compound");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_annot:
manager->addUnsatLink(new UnsatLink((void*) &(obj->annot), strValue,XTOK_FullExpressionAnnot, false));
break;
case XTOK_inits:
manager->addUnsatLink(new UnsatLink((void*) &(obj->inits), strValue, XTOK_List_IN_compound_inits, true));
break;
}
}
void XmlAstReader::registerAttr_IN_ctor(IN_ctor *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a IN_ctor");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_annot:
manager->addUnsatLink(new UnsatLink((void*) &(obj->annot), strValue,XTOK_FullExpressionAnnot, false));
break;
case XTOK_args:
manager->addUnsatLink(new UnsatLink((void*) &(obj->args), strValue, XTOK_List_IN_ctor_args, true));
break;
case XTOK_ctorVar:
manager->addUnsatLink(new UnsatLink((void*) &(obj->ctorVar), strValue,XTOK_Variable, false));
break;
case XTOK_was_IN_expr:
fromXml_bool(obj->was_IN_expr, strValue);
break;
}
}
void XmlAstReader::registerAttr_IN_designated(IN_designated *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a IN_designated");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_annot:
manager->addUnsatLink(new UnsatLink((void*) &(obj->annot), strValue,XTOK_FullExpressionAnnot, false));
break;
case XTOK_designator_list:
manager->addUnsatLink(new UnsatLink((void*) &(obj->designator_list), strValue, XTOK_List_IN_designated_designator_list, true));
break;
case XTOK_init:
manager->addUnsatLink(new UnsatLink((void*) &(obj->init), strValue,XTOK_Initializer, false));
break;
}
}
void XmlAstReader::registerAttr_TD_func(TD_func *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TD_func");
break;
case XTOK_params:
manager->addUnsatLink(new UnsatLink((void*) &(obj->params), strValue,XTOK_TemplateParameter, false));
break;
case XTOK_f:
manager->addUnsatLink(new UnsatLink((void*) &(obj->f), strValue,XTOK_Function, false));
break;
}
}
void XmlAstReader::registerAttr_TD_decl(TD_decl *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TD_decl");
break;
case XTOK_params:
manager->addUnsatLink(new UnsatLink((void*) &(obj->params), strValue,XTOK_TemplateParameter, false));
break;
case XTOK_d:
manager->addUnsatLink(new UnsatLink((void*) &(obj->d), strValue,XTOK_Declaration, false));
break;
}
}
void XmlAstReader::registerAttr_TD_tmember(TD_tmember *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TD_tmember");
break;
case XTOK_params:
manager->addUnsatLink(new UnsatLink((void*) &(obj->params), strValue,XTOK_TemplateParameter, false));
break;
case XTOK_d:
manager->addUnsatLink(new UnsatLink((void*) &(obj->d), strValue,XTOK_TemplateDeclaration, false));
break;
}
}
void XmlAstReader::registerAttr_TP_type(TP_type *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TP_type");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_var:
manager->addUnsatLink(new UnsatLink((void*) &(obj->var), strValue,XTOK_Variable, false));
break;
case XTOK_next:
manager->addUnsatLink(new UnsatLink((void*) &(obj->next), strValue,XTOK_TemplateParameter, false));
break;
case XTOK_name:
obj->name = manager->strTable(strValue);
break;
case XTOK_defaultType:
manager->addUnsatLink(new UnsatLink((void*) &(obj->defaultType), strValue,XTOK_ASTTypeId, false));
break;
}
}
void XmlAstReader::registerAttr_TP_nontype(TP_nontype *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TP_nontype");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_var:
manager->addUnsatLink(new UnsatLink((void*) &(obj->var), strValue,XTOK_Variable, false));
break;
case XTOK_next:
manager->addUnsatLink(new UnsatLink((void*) &(obj->next), strValue,XTOK_TemplateParameter, false));
break;
case XTOK_param:
manager->addUnsatLink(new UnsatLink((void*) &(obj->param), strValue,XTOK_ASTTypeId, false));
break;
}
}
void XmlAstReader::registerAttr_TP_template(TP_template *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TP_template");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_var:
manager->addUnsatLink(new UnsatLink((void*) &(obj->var), strValue,XTOK_Variable, false));
break;
case XTOK_next:
manager->addUnsatLink(new UnsatLink((void*) &(obj->next), strValue,XTOK_TemplateParameter, false));
break;
case XTOK_parameters:
manager->addUnsatLink(new UnsatLink((void*) &(obj->parameters), strValue, XTOK_List_TP_template_parameters, true));
break;
case XTOK_name:
obj->name = manager->strTable(strValue);
break;
case XTOK_defaultTemplate:
manager->addUnsatLink(new UnsatLink((void*) &(obj->defaultTemplate), strValue,XTOK_PQName, false));
break;
}
}
void XmlAstReader::registerAttr_TA_type(TA_type *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TA_type");
break;
case XTOK_next:
manager->addUnsatLink(new UnsatLink((void*) &(obj->next), strValue,XTOK_TemplateArgument, false));
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_ASTTypeId, false));
break;
}
}
void XmlAstReader::registerAttr_TA_nontype(TA_nontype *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TA_nontype");
break;
case XTOK_next:
manager->addUnsatLink(new UnsatLink((void*) &(obj->next), strValue,XTOK_TemplateArgument, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_Expression, false));
break;
}
}
void XmlAstReader::registerAttr_TA_templateUsed(TA_templateUsed *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TA_templateUsed");
break;
case XTOK_next:
manager->addUnsatLink(new UnsatLink((void*) &(obj->next), strValue,XTOK_TemplateArgument, false));
break;
}
}
void XmlAstReader::registerAttr_ND_alias(ND_alias *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ND_alias");
break;
case XTOK_alias:
obj->alias = manager->strTable(strValue);
break;
case XTOK_original:
manager->addUnsatLink(new UnsatLink((void*) &(obj->original), strValue,XTOK_PQName, false));
break;
}
}
void XmlAstReader::registerAttr_ND_usingDecl(ND_usingDecl *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ND_usingDecl");
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
}
}
void XmlAstReader::registerAttr_ND_usingDir(ND_usingDir *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a ND_usingDir");
break;
case XTOK_name:
manager->addUnsatLink(new UnsatLink((void*) &(obj->name), strValue,XTOK_PQName, false));
break;
}
}
void XmlAstReader::registerAttr_FullExpressionAnnot(FullExpressionAnnot *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a FullExpressionAnnot");
break;
case XTOK_declarations:
manager->addUnsatLink(new UnsatLink((void*) &(obj->declarations), strValue, XTOK_List_FullExpressionAnnot_declarations, true));
break;
}
}
void XmlAstReader::registerAttr_TS_typeof_expr(TS_typeof_expr *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TS_typeof_expr");
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->expr), strValue,XTOK_FullExpression, false));
break;
}
}
void XmlAstReader::registerAttr_TS_typeof_type(TS_typeof_type *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a TS_typeof_type");
break;
case XTOK_type:
manager->addUnsatLink(new UnsatLink((void*) &(obj->type), strValue,XTOK_Type, false));
break;
case XTOK_atype:
manager->addUnsatLink(new UnsatLink((void*) &(obj->atype), strValue,XTOK_ASTTypeId, false));
break;
}
}
void XmlAstReader::registerAttr_FieldDesignator(FieldDesignator *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a FieldDesignator");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_id:
obj->id = manager->strTable(strValue);
break;
}
}
void XmlAstReader::registerAttr_SubscriptDesignator(SubscriptDesignator *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a SubscriptDesignator");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_idx_expr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->idx_expr), strValue,XTOK_Expression, false));
break;
case XTOK_idx_expr2:
manager->addUnsatLink(new UnsatLink((void*) &(obj->idx_expr2), strValue,XTOK_Expression, false));
break;
case XTOK_idx_computed:
fromXml_int(obj->idx_computed, strValue);
break;
case XTOK_idx_computed2:
fromXml_int(obj->idx_computed2, strValue);
break;
}
}
void XmlAstReader::registerAttr_AttributeSpecifierList(AttributeSpecifierList *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a AttributeSpecifierList");
break;
case XTOK_spec:
manager->addUnsatLink(new UnsatLink((void*) &(obj->spec), strValue,XTOK_AttributeSpecifier, false));
break;
case XTOK_next:
manager->addUnsatLink(new UnsatLink((void*) &(obj->next), strValue,XTOK_AttributeSpecifierList, false));
break;
}
}
void XmlAstReader::registerAttr_AttributeSpecifier(AttributeSpecifier *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a AttributeSpecifier");
break;
case XTOK_attr:
manager->addUnsatLink(new UnsatLink((void*) &(obj->attr), strValue,XTOK_Attribute, false));
break;
case XTOK_next:
manager->addUnsatLink(new UnsatLink((void*) &(obj->next), strValue,XTOK_AttributeSpecifier, false));
break;
}
}
void XmlAstReader::registerAttr_AT_empty(AT_empty *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a AT_empty");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
}
}
void XmlAstReader::registerAttr_AT_word(AT_word *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a AT_word");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_w:
obj->w = manager->strTable(strValue);
break;
}
}
void XmlAstReader::registerAttr_AT_func(AT_func *obj, int attr, char const *strValue) {
switch(attr) {
default:
xmlUserFatalError("illegal attribute for a AT_func");
break;
case XTOK_loc:
fromXml_SourceLoc(obj->loc, strValue);
break;
case XTOK_f:
obj->f = manager->strTable(strValue);
break;
case XTOK_args:
manager->addUnsatLink(new UnsatLink((void*) &(obj->args), strValue, XTOK_List_AT_func_args, true));
break;
}
}
bool XmlAstReader::recordKind(int kind, bool& answer) {
switch(kind) {
default: return false; break;
case XTOK_TranslationUnit: answer = false; return true; break;
case XTOK_TF_decl: answer = false; return true; break;
case XTOK_TF_func: answer = false; return true; break;
case XTOK_TF_template: answer = false; return true; break;
case XTOK_TF_explicitInst: answer = false; return true; break;
case XTOK_TF_linkage: answer = false; return true; break;
case XTOK_TF_one_linkage: answer = false; return true; break;
case XTOK_TF_asm: answer = false; return true; break;
case XTOK_TF_namespaceDefn: answer = false; return true; break;
case XTOK_TF_namespaceDecl: answer = false; return true; break;
case XTOK_Function: answer = false; return true; break;
case XTOK_MemberInit: answer = false; return true; break;
case XTOK_Declaration: answer = false; return true; break;
case XTOK_ASTTypeId: answer = false; return true; break;
case XTOK_PQ_qualifier: answer = false; return true; break;
case XTOK_PQ_name: answer = false; return true; break;
case XTOK_PQ_operator: answer = false; return true; break;
case XTOK_PQ_template: answer = false; return true; break;
case XTOK_PQ_variable: answer = false; return true; break;
case XTOK_TS_name: answer = false; return true; break;
case XTOK_TS_simple: answer = false; return true; break;
case XTOK_TS_elaborated: answer = false; return true; break;
case XTOK_TS_classSpec: answer = false; return true; break;
case XTOK_TS_enumSpec: answer = false; return true; break;
case XTOK_TS_type: answer = false; return true; break;
case XTOK_TS_typeof: answer = false; return true; break;
case XTOK_BaseClassSpec: answer = false; return true; break;
case XTOK_Enumerator: answer = false; return true; break;
case XTOK_MemberList: answer = false; return true; break;
case XTOK_MR_decl: answer = false; return true; break;
case XTOK_MR_func: answer = false; return true; break;
case XTOK_MR_access: answer = false; return true; break;
case XTOK_MR_usingDecl: answer = false; return true; break;
case XTOK_MR_template: answer = false; return true; break;
case XTOK_Declarator: answer = false; return true; break;
case XTOK_D_name: answer = false; return true; break;
case XTOK_D_pointer: answer = false; return true; break;
case XTOK_D_reference: answer = false; return true; break;
case XTOK_D_func: answer = false; return true; break;
case XTOK_D_array: answer = false; return true; break;
case XTOK_D_bitfield: answer = false; return true; break;
case XTOK_D_ptrToMember: answer = false; return true; break;
case XTOK_D_grouping: answer = false; return true; break;
case XTOK_ExceptionSpec: answer = false; return true; break;
case XTOK_ON_newDel: answer = false; return true; break;
case XTOK_ON_operator: answer = false; return true; break;
case XTOK_ON_conversion: answer = false; return true; break;
case XTOK_S_skip: answer = false; return true; break;
case XTOK_S_label: answer = false; return true; break;
case XTOK_S_case: answer = false; return true; break;
case XTOK_S_default: answer = false; return true; break;
case XTOK_S_expr: answer = false; return true; break;
case XTOK_S_compound: answer = false; return true; break;
case XTOK_S_if: answer = false; return true; break;
case XTOK_S_switch: answer = false; return true; break;
case XTOK_S_while: answer = false; return true; break;
case XTOK_S_doWhile: answer = false; return true; break;
case XTOK_S_for: answer = false; return true; break;
case XTOK_S_break: answer = false; return true; break;
case XTOK_S_continue: answer = false; return true; break;
case XTOK_S_return: answer = false; return true; break;
case XTOK_S_goto: answer = false; return true; break;
case XTOK_S_decl: answer = false; return true; break;
case XTOK_S_try: answer = false; return true; break;
case XTOK_S_asm: answer = false; return true; break;
case XTOK_S_namespaceDecl: answer = false; return true; break;
case XTOK_S_function: answer = false; return true; break;
case XTOK_S_rangeCase: answer = false; return true; break;
case XTOK_S_computedGoto: answer = false; return true; break;
case XTOK_CN_expr: answer = false; return true; break;
case XTOK_CN_decl: answer = false; return true; break;
case XTOK_Handler: answer = false; return true; break;
case XTOK_E_boolLit: answer = false; return true; break;
case XTOK_E_intLit: answer = false; return true; break;
case XTOK_E_floatLit: answer = false; return true; break;
case XTOK_E_stringLit: answer = false; return true; break;
case XTOK_E_charLit: answer = false; return true; break;
case XTOK_E_this: answer = false; return true; break;
case XTOK_E_variable: answer = false; return true; break;
case XTOK_E_funCall: answer = false; return true; break;
case XTOK_E_constructor: answer = false; return true; break;
case XTOK_E_fieldAcc: answer = false; return true; break;
case XTOK_E_sizeof: answer = false; return true; break;
case XTOK_E_unary: answer = false; return true; break;
case XTOK_E_effect: answer = false; return true; break;
case XTOK_E_binary: answer = false; return true; break;
case XTOK_E_addrOf: answer = false; return true; break;
case XTOK_E_deref: answer = false; return true; break;
case XTOK_E_cast: answer = false; return true; break;
case XTOK_E_cond: answer = false; return true; break;
case XTOK_E_sizeofType: answer = false; return true; break;
case XTOK_E_assign: answer = false; return true; break;
case XTOK_E_new: answer = false; return true; break;
case XTOK_E_delete: answer = false; return true; break;
case XTOK_E_throw: answer = false; return true; break;
case XTOK_E_keywordCast: answer = false; return true; break;
case XTOK_E_typeidExpr: answer = false; return true; break;
case XTOK_E_typeidType: answer = false; return true; break;
case XTOK_E_grouping: answer = false; return true; break;
case XTOK_E_arrow: answer = false; return true; break;
case XTOK_E_statement: answer = false; return true; break;
case XTOK_E_compoundLit: answer = false; return true; break;
case XTOK_E___builtin_constant_p: answer = false; return true; break;
case XTOK_E___builtin_va_arg: answer = false; return true; break;
case XTOK_E_alignofType: answer = false; return true; break;
case XTOK_E_alignofExpr: answer = false; return true; break;
case XTOK_E_gnuCond: answer = false; return true; break;
case XTOK_E_addrOfLabel: answer = false; return true; break;
case XTOK_FullExpression: answer = false; return true; break;
case XTOK_ArgExpression: answer = false; return true; break;
case XTOK_ArgExpressionListOpt: answer = false; return true; break;
case XTOK_IN_expr: answer = false; return true; break;
case XTOK_IN_compound: answer = false; return true; break;
case XTOK_IN_ctor: answer = false; return true; break;
case XTOK_IN_designated: answer = false; return true; break;
case XTOK_TD_func: answer = false; return true; break;
case XTOK_TD_decl: answer = false; return true; break;
case XTOK_TD_tmember: answer = false; return true; break;
case XTOK_TP_type: answer = false; return true; break;
case XTOK_TP_nontype: answer = false; return true; break;
case XTOK_TP_template: answer = false; return true; break;
case XTOK_TA_type: answer = false; return true; break;
case XTOK_TA_nontype: answer = false; return true; break;
case XTOK_TA_templateUsed: answer = false; return true; break;
case XTOK_ND_alias: answer = false; return true; break;
case XTOK_ND_usingDecl: answer = false; return true; break;
case XTOK_ND_usingDir: answer = false; return true; break;
case XTOK_FullExpressionAnnot: answer = false; return true; break;
case XTOK_TS_typeof_expr: answer = false; return true; break;
case XTOK_TS_typeof_type: answer = false; return true; break;
case XTOK_FieldDesignator: answer = false; return true; break;
case XTOK_SubscriptDesignator: answer = false; return true; break;
case XTOK_AttributeSpecifierList: answer = false; return true; break;
case XTOK_AttributeSpecifier: answer = false; return true; break;
case XTOK_AT_empty: answer = false; return true; break;
case XTOK_AT_word: answer = false; return true; break;
case XTOK_AT_func: answer = false; return true; break;
case XTOK_List_TF_namespaceDefn_forms: answer = false; return true; break;
case XTOK_List_TranslationUnit_topForms: answer = false; return true; break;
case XTOK_List_Function_inits: answer = false; return true; break;
case XTOK_List_Function_handlers: answer = false; return true; break;
case XTOK_List_MemberInit_args: answer = false; return true; break;
case XTOK_List_MemberList_list: answer = false; return true; break;
case XTOK_List_Declaration_decllist: answer = false; return true; break;
case XTOK_List_TS_classSpec_bases: answer = false; return true; break;
case XTOK_List_TS_enumSpec_elts: answer = false; return true; break;
case XTOK_List_D_func_params: answer = false; return true; break;
case XTOK_List_D_func_kAndR_params: answer = false; return true; break;
case XTOK_List_S_try_handlers: answer = false; return true; break;
case XTOK_List_ExceptionSpec_types: answer = false; return true; break;
case XTOK_List_S_compound_stmts: answer = false; return true; break;
case XTOK_List_E_funCall_args: answer = false; return true; break;
case XTOK_List_E_constructor_args: answer = false; return true; break;
case XTOK_List_E_new_placementArgs: answer = false; return true; break;
case XTOK_List_ArgExpressionListOpt_list: answer = false; return true; break;
case XTOK_List_IN_compound_inits: answer = false; return true; break;
case XTOK_List_IN_ctor_args: answer = false; return true; break;
case XTOK_List_TP_template_parameters: answer = false; return true; break;
case XTOK_List_IN_designated_designator_list: answer = false; return true; break;
case XTOK_List_FullExpressionAnnot_declarations: answer = false; return true; break;
case XTOK_List_AT_func_args: answer = false; return true; break;
}
}
bool XmlAstReader::upcastToWantedType(void *obj, int kind, void **target, int targetKind) {
switch(kind) {
default: return false; break;
case XTOK_TranslationUnit:
case XTOK_TF_decl:
case XTOK_TF_func:
case XTOK_TF_template:
case XTOK_TF_explicitInst:
case XTOK_TF_linkage:
case XTOK_TF_one_linkage:
case XTOK_TF_asm:
case XTOK_TF_namespaceDefn:
case XTOK_TF_namespaceDecl:
case XTOK_Function:
case XTOK_MemberInit:
case XTOK_Declaration:
case XTOK_ASTTypeId:
case XTOK_PQ_qualifier:
case XTOK_PQ_name:
case XTOK_PQ_operator:
case XTOK_PQ_template:
case XTOK_PQ_variable:
case XTOK_TS_name:
case XTOK_TS_simple:
case XTOK_TS_elaborated:
case XTOK_TS_classSpec:
case XTOK_TS_enumSpec:
case XTOK_TS_type:
case XTOK_TS_typeof:
case XTOK_BaseClassSpec:
case XTOK_Enumerator:
case XTOK_MemberList:
case XTOK_MR_decl:
case XTOK_MR_func:
case XTOK_MR_access:
case XTOK_MR_usingDecl:
case XTOK_MR_template:
case XTOK_Declarator:
case XTOK_D_name:
case XTOK_D_pointer:
case XTOK_D_reference:
case XTOK_D_func:
case XTOK_D_array:
case XTOK_D_bitfield:
case XTOK_D_ptrToMember:
case XTOK_D_grouping:
case XTOK_ExceptionSpec:
case XTOK_ON_newDel:
case XTOK_ON_operator:
case XTOK_ON_conversion:
case XTOK_S_skip:
case XTOK_S_label:
case XTOK_S_case:
case XTOK_S_default:
case XTOK_S_expr:
case XTOK_S_compound:
case XTOK_S_if:
case XTOK_S_switch:
case XTOK_S_while:
case XTOK_S_doWhile:
case XTOK_S_for:
case XTOK_S_break:
case XTOK_S_continue:
case XTOK_S_return:
case XTOK_S_goto:
case XTOK_S_decl:
case XTOK_S_try:
case XTOK_S_asm:
case XTOK_S_namespaceDecl:
case XTOK_S_function:
case XTOK_S_rangeCase:
case XTOK_S_computedGoto:
case XTOK_CN_expr:
case XTOK_CN_decl:
case XTOK_Handler:
case XTOK_E_boolLit:
case XTOK_E_intLit:
case XTOK_E_floatLit:
case XTOK_E_stringLit:
case XTOK_E_charLit:
case XTOK_E_this:
case XTOK_E_variable:
case XTOK_E_funCall:
case XTOK_E_constructor:
case XTOK_E_fieldAcc:
case XTOK_E_sizeof:
case XTOK_E_unary:
case XTOK_E_effect:
case XTOK_E_binary:
case XTOK_E_addrOf:
case XTOK_E_deref:
case XTOK_E_cast:
case XTOK_E_cond:
case XTOK_E_sizeofType:
case XTOK_E_assign:
case XTOK_E_new:
case XTOK_E_delete:
case XTOK_E_throw:
case XTOK_E_keywordCast:
case XTOK_E_typeidExpr:
case XTOK_E_typeidType:
case XTOK_E_grouping:
case XTOK_E_arrow:
case XTOK_E_statement:
case XTOK_E_compoundLit:
case XTOK_E___builtin_constant_p:
case XTOK_E___builtin_va_arg:
case XTOK_E_alignofType:
case XTOK_E_alignofExpr:
case XTOK_E_gnuCond:
case XTOK_E_addrOfLabel:
case XTOK_FullExpression:
case XTOK_ArgExpression:
case XTOK_ArgExpressionListOpt:
case XTOK_IN_expr:
case XTOK_IN_compound:
case XTOK_IN_ctor:
case XTOK_IN_designated:
case XTOK_TD_func:
case XTOK_TD_decl:
case XTOK_TD_tmember:
case XTOK_TP_type:
case XTOK_TP_nontype:
case XTOK_TP_template:
case XTOK_TA_type:
case XTOK_TA_nontype:
case XTOK_TA_templateUsed:
case XTOK_ND_alias:
case XTOK_ND_usingDecl:
case XTOK_ND_usingDir:
case XTOK_FullExpressionAnnot:
case XTOK_TS_typeof_expr:
case XTOK_TS_typeof_type:
case XTOK_FieldDesignator:
case XTOK_SubscriptDesignator:
case XTOK_AttributeSpecifierList:
case XTOK_AttributeSpecifier:
case XTOK_AT_empty:
case XTOK_AT_word:
case XTOK_AT_func:
case XTOK_List_TF_namespaceDefn_forms:
case XTOK_List_TranslationUnit_topForms:
case XTOK_List_Function_inits:
case XTOK_List_Function_handlers:
case XTOK_List_MemberInit_args:
case XTOK_List_MemberList_list:
case XTOK_List_Declaration_decllist:
case XTOK_List_TS_classSpec_bases:
case XTOK_List_TS_enumSpec_elts:
case XTOK_List_D_func_params:
case XTOK_List_D_func_kAndR_params:
case XTOK_List_S_try_handlers:
case XTOK_List_ExceptionSpec_types:
case XTOK_List_S_compound_stmts:
case XTOK_List_E_funCall_args:
case XTOK_List_E_constructor_args:
case XTOK_List_E_new_placementArgs:
case XTOK_List_ArgExpressionListOpt_list:
case XTOK_List_IN_compound_inits:
case XTOK_List_IN_ctor_args:
case XTOK_List_TP_template_parameters:
case XTOK_List_IN_designated_designator_list:
case XTOK_List_FullExpressionAnnot_declarations:
case XTOK_List_AT_func_args:
xfailure("should never be called"); return true; break;
}
}
bool XmlAstReader::callOpAssignToEmbeddedObj(void *obj, int kind, void *target) {
switch(kind) {
default: return false; break;
case XTOK_TranslationUnit:
case XTOK_TF_decl:
case XTOK_TF_func:
case XTOK_TF_template:
case XTOK_TF_explicitInst:
case XTOK_TF_linkage:
case XTOK_TF_one_linkage:
case XTOK_TF_asm:
case XTOK_TF_namespaceDefn:
case XTOK_TF_namespaceDecl:
case XTOK_Function:
case XTOK_MemberInit:
case XTOK_Declaration:
case XTOK_ASTTypeId:
case XTOK_PQ_qualifier:
case XTOK_PQ_name:
case XTOK_PQ_operator:
case XTOK_PQ_template:
case XTOK_PQ_variable:
case XTOK_TS_name:
case XTOK_TS_simple:
case XTOK_TS_elaborated:
case XTOK_TS_classSpec:
case XTOK_TS_enumSpec:
case XTOK_TS_type:
case XTOK_TS_typeof:
case XTOK_BaseClassSpec:
case XTOK_Enumerator:
case XTOK_MemberList:
case XTOK_MR_decl:
case XTOK_MR_func:
case XTOK_MR_access:
case XTOK_MR_usingDecl:
case XTOK_MR_template:
case XTOK_Declarator:
case XTOK_D_name:
case XTOK_D_pointer:
case XTOK_D_reference:
case XTOK_D_func:
case XTOK_D_array:
case XTOK_D_bitfield:
case XTOK_D_ptrToMember:
case XTOK_D_grouping:
case XTOK_ExceptionSpec:
case XTOK_ON_newDel:
case XTOK_ON_operator:
case XTOK_ON_conversion:
case XTOK_S_skip:
case XTOK_S_label:
case XTOK_S_case:
case XTOK_S_default:
case XTOK_S_expr:
case XTOK_S_compound:
case XTOK_S_if:
case XTOK_S_switch:
case XTOK_S_while:
case XTOK_S_doWhile:
case XTOK_S_for:
case XTOK_S_break:
case XTOK_S_continue:
case XTOK_S_return:
case XTOK_S_goto:
case XTOK_S_decl:
case XTOK_S_try:
case XTOK_S_asm:
case XTOK_S_namespaceDecl:
case XTOK_S_function:
case XTOK_S_rangeCase:
case XTOK_S_computedGoto:
case XTOK_CN_expr:
case XTOK_CN_decl:
case XTOK_Handler:
case XTOK_E_boolLit:
case XTOK_E_intLit:
case XTOK_E_floatLit:
case XTOK_E_stringLit:
case XTOK_E_charLit:
case XTOK_E_this:
case XTOK_E_variable:
case XTOK_E_funCall:
case XTOK_E_constructor:
case XTOK_E_fieldAcc:
case XTOK_E_sizeof:
case XTOK_E_unary:
case XTOK_E_effect:
case XTOK_E_binary:
case XTOK_E_addrOf:
case XTOK_E_deref:
case XTOK_E_cast:
case XTOK_E_cond:
case XTOK_E_sizeofType:
case XTOK_E_assign:
case XTOK_E_new:
case XTOK_E_delete:
case XTOK_E_throw:
case XTOK_E_keywordCast:
case XTOK_E_typeidExpr:
case XTOK_E_typeidType:
case XTOK_E_grouping:
case XTOK_E_arrow:
case XTOK_E_statement:
case XTOK_E_compoundLit:
case XTOK_E___builtin_constant_p:
case XTOK_E___builtin_va_arg:
case XTOK_E_alignofType:
case XTOK_E_alignofExpr:
case XTOK_E_gnuCond:
case XTOK_E_addrOfLabel:
case XTOK_FullExpression:
case XTOK_ArgExpression:
case XTOK_ArgExpressionListOpt:
case XTOK_IN_expr:
case XTOK_IN_compound:
case XTOK_IN_ctor:
case XTOK_IN_designated:
case XTOK_TD_func:
case XTOK_TD_decl:
case XTOK_TD_tmember:
case XTOK_TP_type:
case XTOK_TP_nontype:
case XTOK_TP_template:
case XTOK_TA_type:
case XTOK_TA_nontype:
case XTOK_TA_templateUsed:
case XTOK_ND_alias:
case XTOK_ND_usingDecl:
case XTOK_ND_usingDir:
case XTOK_FullExpressionAnnot:
case XTOK_TS_typeof_expr:
case XTOK_TS_typeof_type:
case XTOK_FieldDesignator:
case XTOK_SubscriptDesignator:
case XTOK_AttributeSpecifierList:
case XTOK_AttributeSpecifier:
case XTOK_AT_empty:
case XTOK_AT_word:
case XTOK_AT_func:
case XTOK_List_TF_namespaceDefn_forms:
case XTOK_List_TranslationUnit_topForms:
case XTOK_List_Function_inits:
case XTOK_List_Function_handlers:
case XTOK_List_MemberInit_args:
case XTOK_List_MemberList_list:
case XTOK_List_Declaration_decllist:
case XTOK_List_TS_classSpec_bases:
case XTOK_List_TS_enumSpec_elts:
case XTOK_List_D_func_params:
case XTOK_List_D_func_kAndR_params:
case XTOK_List_S_try_handlers:
case XTOK_List_ExceptionSpec_types:
case XTOK_List_S_compound_stmts:
case XTOK_List_E_funCall_args:
case XTOK_List_E_constructor_args:
case XTOK_List_E_new_placementArgs:
case XTOK_List_ArgExpressionListOpt_list:
case XTOK_List_IN_compound_inits:
case XTOK_List_IN_ctor_args:
case XTOK_List_TP_template_parameters:
case XTOK_List_IN_designated_designator_list:
case XTOK_List_FullExpressionAnnot_declarations:
case XTOK_List_AT_func_args:
xfailure("should never be called"); return true; break;
}
}
bool XmlAstReader::prependToFakeList(void *&list, void *obj, int listKind) {
switch(listKind) {
default: return false; // we did not find a matching tag
case XTOK_List_Function_inits: {
prependToFakeList0<MemberInit>(list, obj);
break;
}
case XTOK_List_Function_handlers: {
prependToFakeList0<Handler>(list, obj);
break;
}
case XTOK_List_MemberInit_args: {
prependToFakeList0<ArgExpression>(list, obj);
break;
}
case XTOK_List_Declaration_decllist: {
prependToFakeList0<Declarator>(list, obj);
break;
}
case XTOK_List_TS_classSpec_bases: {
prependToFakeList0<BaseClassSpec>(list, obj);
break;
}
case XTOK_List_TS_enumSpec_elts: {
prependToFakeList0<Enumerator>(list, obj);
break;
}
case XTOK_List_D_func_params: {
prependToFakeList0<ASTTypeId>(list, obj);
break;
}
case XTOK_List_D_func_kAndR_params: {
prependToFakeList0<PQ_name>(list, obj);
break;
}
case XTOK_List_S_try_handlers: {
prependToFakeList0<Handler>(list, obj);
break;
}
case XTOK_List_ExceptionSpec_types: {
prependToFakeList0<ASTTypeId>(list, obj);
break;
}
case XTOK_List_E_funCall_args: {
prependToFakeList0<ArgExpression>(list, obj);
break;
}
case XTOK_List_E_constructor_args: {
prependToFakeList0<ArgExpression>(list, obj);
break;
}
case XTOK_List_E_new_placementArgs: {
prependToFakeList0<ArgExpression>(list, obj);
break;
}
case XTOK_List_ArgExpressionListOpt_list: {
prependToFakeList0<ArgExpression>(list, obj);
break;
}
case XTOK_List_IN_ctor_args: {
prependToFakeList0<ArgExpression>(list, obj);
break;
}
case XTOK_List_TP_template_parameters: {
prependToFakeList0<TemplateParameter>(list, obj);
break;
}
case XTOK_List_IN_designated_designator_list: {
prependToFakeList0<Designator>(list, obj);
break;
}
case XTOK_List_AT_func_args: {
prependToFakeList0<ArgExpression>(list, obj);
break;
}
}
return true;
}
bool XmlAstReader::reverseFakeList(void *&list, int listKind) {
switch(listKind) {
default: return false; // we did not find a matching tag
case XTOK_List_Function_inits: {
reverseFakeList0<MemberInit>(list);
break;
}
case XTOK_List_Function_handlers: {
reverseFakeList0<Handler>(list);
break;
}
case XTOK_List_MemberInit_args: {
reverseFakeList0<ArgExpression>(list);
break;
}
case XTOK_List_Declaration_decllist: {
reverseFakeList0<Declarator>(list);
break;
}
case XTOK_List_TS_classSpec_bases: {
reverseFakeList0<BaseClassSpec>(list);
break;
}
case XTOK_List_TS_enumSpec_elts: {
reverseFakeList0<Enumerator>(list);
break;
}
case XTOK_List_D_func_params: {
reverseFakeList0<ASTTypeId>(list);
break;
}
case XTOK_List_D_func_kAndR_params: {
reverseFakeList0<PQ_name>(list);
break;
}
case XTOK_List_S_try_handlers: {
reverseFakeList0<Handler>(list);
break;
}
case XTOK_List_ExceptionSpec_types: {
reverseFakeList0<ASTTypeId>(list);
break;
}
case XTOK_List_E_funCall_args: {
reverseFakeList0<ArgExpression>(list);
break;
}
case XTOK_List_E_constructor_args: {
reverseFakeList0<ArgExpression>(list);
break;
}
case XTOK_List_E_new_placementArgs: {
reverseFakeList0<ArgExpression>(list);
break;
}
case XTOK_List_ArgExpressionListOpt_list: {
reverseFakeList0<ArgExpression>(list);
break;
}
case XTOK_List_IN_ctor_args: {
reverseFakeList0<ArgExpression>(list);
break;
}
case XTOK_List_TP_template_parameters: {
reverseFakeList0<TemplateParameter>(list);
break;
}
case XTOK_List_IN_designated_designator_list: {
reverseFakeList0<Designator>(list);
break;
}
case XTOK_List_AT_func_args: {
reverseFakeList0<ArgExpression>(list);
break;
}
}
return true;
}
| [
"crsib@localhost"
] | [
[
[
1,
3481
]
]
] |
5e2d97a3dc1b12ebc80488e0fc3e392d3775ccde | 967868cbef4914f2bade9ef8f6c300eb5d14bc57 | /Security/NtlmAuth.hpp | abfd3b19c5b804fceddda150f90ac9e0bfd3e7a4 | [] | no_license | saminigod/baseclasses-001 | 159c80d40f69954797f1c695682074b469027ac6 | 381c27f72583e0401e59eb19260c70ee68f9a64c | refs/heads/master | 2023-04-29T13:34:02.754963 | 2009-10-29T11:22:46 | 2009-10-29T11:22:46 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 735 | hpp | /*
© Vestris Inc., Geneva Switzerland
http://www.vestris.com, 1998, All Rights Reserved
__________________________________________________
written by Daniel Doubrovkine - [email protected]
*/
#ifndef BASECLASSES_NTLM_AUTHENTICATION_HPP
#define BASECLASSES_NTLM_AUTHENTICATION_HPP
#include <platform/include.hpp>
#ifdef _WIN32
#include "Authentication.hpp"
#include "SspiAuth.hpp"
class CNtlmAuthenticator : public CSspiAuthenticator {
public:
CNtlmAuthenticator(void);
virtual ~CNtlmAuthenticator(void);
};
class CNegotiateAuthenticator : public CSspiAuthenticator {
public:
CNegotiateAuthenticator(void);
virtual ~CNegotiateAuthenticator(void);
};
#endif
#endif
| [
"[email protected]"
] | [
[
[
1,
35
]
]
] |
8d9e24ff8a53bebd0452e1bcb3c11c2f907a1740 | 35231241243cb13bd3187983d224e827bb693df3 | /branches/umptesting/cpreview/filexor.cpp | 5abfd0536178f10f0b06ffa4b56dbfca412faa91 | [] | no_license | casaretto/cgpsmapper | b597aa2775cc112bf98732b182a9bc798c3dd967 | 76d90513514188ef82f4d869fc23781d6253f0ba | refs/heads/master | 2021-05-15T01:42:47.532459 | 2011-06-25T23:16:34 | 2011-06-25T23:16:34 | 1,943,334 | 2 | 2 | null | 2019-06-11T00:26:40 | 2011-06-23T18:31:36 | C++ | UTF-8 | C++ | false | false | 8,496 | cpp | /*
Created by: cgpsmapper
This is open source software. Source code is under the GNU General Public License version 3.0 (GPLv3) license.
Permission to modify the code and to distribute modified code is granted,
provided the above notices are retained, and a notice that the code was
modified is included with the above copyright notice.
*/
#include "filexor.h"
#include "utils.h"
#include <string.h>
/*
=======================================================================================================================
=======================================================================================================================
*/
xor_fstream::xor_fstream(const char *file_name, const char *mode) {
this->file_name = file_name;
stream = fopen(file_name, mode);
headerOffset = 0;
if(!stream) {
error = true;
return;
}
error = false;
m_mask = 0;
line_no = 0;
seekg(0, SEEK_END);
file_size = tellg();
seekg(0, SEEK_SET);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
xor_fstream::~xor_fstream(void) {
if(stream > 0)
fclose(stream);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void xor_fstream::seekg(long offset, int whence) {
if(whence == SEEK_SET)
offset += headerOffset;
fseek(stream, offset, whence);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
long xor_fstream::tellg(void) {
long t_ret = ftell(stream);
t_ret -= headerOffset;
return t_ret;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
int xor_fstream::Read(void *Buffer, int Count) {
int size, t_licznik = 0;
memset(Buffer,0,Count);
try
{
size = static_cast<int>(fread(((char *) Buffer), 1, Count, stream));
if(m_mask && size) {
while(t_licznik < size) {
((unsigned char *) Buffer)[t_licznik] = ((unsigned char *) Buffer)[t_licznik] ^ m_mask;
t_licznik++;
}
}
}
catch (...) {
throw runtime_error("Error reading file.");
}
return size;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
int xor_fstream::Write(const void *Buffer, int Count) {
unsigned char znak;
int t_licznik = 0;
while(t_licznik < Count) {
znak = ((unsigned char *) Buffer)[t_licznik] ^ m_mask;
fwrite(&znak, 1, 1, stream); // write(&znak,1);
t_licznik++;
}
return Count;
}
int xor_fstream::WriteInt(int value, int Count) {
return Write(&value,Count);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void xor_fstream::FillWrite(unsigned char value, int Count) {
unsigned char bufor[1];
bufor[0] = value ^ m_mask;
while(Count) {
fwrite(bufor, 1, 1, stream); // write(bufor,1);
Count--;
}
}
/*
=======================================================================================================================
=======================================================================================================================
*/
int xor_fstream::SearchKey(string master_key, string &value, string terminator) {
string key;
int t_file_pos = tellg();
int t_line_pos = this->line_no;
int t_read = ReadInput(key, value);
while(t_read != 0 && key.find(terminator) > 0) {
if(master_key == key) {
seekg(t_file_pos, SEEK_SET);
this->line_no = t_line_pos;
return 2;
}
t_read = ReadInput(key, value);
}
this->line_no = t_line_pos;
seekg(t_file_pos, SEEK_SET);
return 0;
}
bool xor_fstream::SeekLine(int line) {
int t_line = 0;
char znak;
seekg(0,SEEK_SET);
while( t_line < line ) {
if( !Read(&znak,1) ) return false;
if( znak == '\n' ) t_line++;
}
return true;
}
//
// =======================================================================================================================
// czytanie z pliku TXT wejsciowego 0 - blad czytania 1 - [key] 2 - key = value 3 - nieznany string - komentarz 4 -
// key = NULL 5 - nieznany string - bez ';'
// =======================================================================================================================
//
int xor_fstream::ReadInput(string &key, string &value) {
key = /* upper_case( */ ReadLine(); // );
if(tellg() >= file_size)
return 0;
if( key.size() == 0 )
return 3;
if(key[0] == '[') {
if(key.find(']'))
key = key.substr(0, key.find(']') + 1);
key = upper_case(key);
return 1;
}
if(key[0] == ';')
return 3;
if(key.find("=") < key.length()) {
value = key.substr(key.find("=") + 1, key.length() - 1 - key.find("="));
key = key.substr(0, key.find("="));
key = upper_case(key);
if(value.length() == 0)
return 4;
return 2;
}
return 5;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
string xor_fstream::ReadLine(char terminator) {
char znak;
string t_ret_line;
t_ret_line.reserve(10000);
line_no++;
if(!Read(&znak, 1))
return t_ret_line;
while(znak != terminator) {
if(znak != '\r' && znak != '\n')
t_ret_line = t_ret_line + znak;
if(!Read(&znak, 1))
return t_ret_line;
}
return t_ret_line;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
string xor_fstream::ReadLine(void) {
string t_ret;
line_no++;
if( fgets(m_buffer,BUFFER_MAX-1,stream) ) {
while( m_buffer[strlen(m_buffer)-1] != '\n' && m_buffer[strlen(m_buffer)-1] != '\r' ) {
t_ret += m_buffer;
if( fgets(m_buffer,BUFFER_MAX-1,stream) == NULL)
break;
}
if( strlen(m_buffer) > 0 && (m_buffer[strlen(m_buffer)-1] == '\n' || m_buffer[strlen(m_buffer)-1] == '\r') )
m_buffer[strlen(m_buffer)-1] = 0;
if( strlen(m_buffer) > 0 && (m_buffer[strlen(m_buffer)-1] == '\n' || m_buffer[strlen(m_buffer)-1] == '\r') )
m_buffer[strlen(m_buffer)-1] = 0;
t_ret += m_buffer;
}
/*
if(!Read(&znak, 1))
return t_ret;
while(znak != '\n') {
if(znak != '\r' && znak != '\n')
t_ret = t_ret + znak;
if(!Read(&znak, 1))
return t_ret;
}
*/
return t_ret;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
string xor_fstream::ReadString(void) {
char znak;
string t_ret;
if(!Read(&znak, 1))
return t_ret;
while(znak) {
t_ret = t_ret + znak;
if(!Read(&znak, 1))
return t_ret;
}
return t_ret;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void xor_fstream::WriteString(string text) {
char znak;
int t_pos = 0;
while(t_pos < (int) text.length()) {
znak = text[t_pos];
Write(&znak, 1);
t_pos++;
}
FillWrite(0, 1);
}
| [
"marrud@ad713ecf-6e55-4363-b790-59b81426eeec"
] | [
[
[
1,
297
]
]
] |
3ff56fd083c679be6f9a30a8f949220777278632 | df5277b77ad258cc5d3da348b5986294b055a2be | /ChatServer/Server/ServerRoutines.hpp | f04e9bbe8f7fef2fcdf1ad5c34295717efb84187 | [] | no_license | beentaken/cs260-last2 | 147eaeb1ab15d03c57ad7fdc5db2d4e0824c0c22 | 61b2f84d565cc94a0283cc14c40fb52189ec1ba5 | refs/heads/master | 2021-03-20T16:27:10.552333 | 2010-04-26T00:47:13 | 2010-04-26T00:47:13 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 3,560 | hpp | /**************************************************************************************************/
/*!
@file ServerRoutines.hpp
@author Robert Onulak
@author Justin Keane
@par email: robert.onulak@@digipen.edu
@par email: justin.keane@@digipen.edu
@par Course: CS260
@par Assignment #3
----------------------------------------------------------------------------------------------------
@attention © Copyright 2010: DigiPen Institute of Technology (USA). All Rights Reserved.
*/
/**************************************************************************************************/
#ifndef SERVER_ROUTINES_H
#define SERVER_ROUTINES_H
#include "NetworkingLibrary/ChatProtocol.hpp"
#include "WindowsLibrary/Threading.hpp"
#include "WindowsLibrary/Timer.hpp"
#include "WindowsLibrary/CommandCenter.hpp"
#include <queue>
typedef std::string ClientNick; ///< Nickname.
typedef unsigned ClientIDTag; ///< ID of client.
const double TIMEOUT_REQ_NAME = 5.0; ///< Max time to wait for a name request
const double TIMEOUT_REQ_DATA = 5.0; ///< Max time to wait for a data request
class HostRoutine; ///< Forward declaration.
class ClientRoutine : public RoutineObject
{
typedef std::queue<Command> CommandQueue;
Mutex mutex;
CommandQueue commands; ///< A queue of commands to be processed.
ClientIDTag idtag; ///< ID tag for reference later.
ClientNick name; ///< Nickname of the client.
NAPI::TCPSOCKET socket; ///< Handle to a socket.
HostRoutine *host; ///< Pointer to the host.
bool running; ///< Whether or not a session is running.
void ProcessCommands();
public:
ClientRoutine(ClientIDTag tag, NAPI::TCPSOCKET contact, HostRoutine *hr)
: socket(contact), running(false), host(hr) {;}
~ClientRoutine() { EndSession(); }
ClientIDTag GetID() const { return idtag; }
ClientNick GetNick() const { return name; }
void BeginSession() { thread_.Resume(); }
void SendFileTransferInfo( const FileTransferInfo *info );
void EndSession() { Kill(); }
void AddCommand(Command cmd); ///< Used to inform client of things while in thread.
protected:
virtual void InitializeThread( void );
virtual void Run( void );
virtual void ExitThread( void ) throw();
virtual void FlushThread( void );
};
class HostRoutine : public RoutineObject
{
friend class ClientRoutine;
static ClientIDTag idBase; ///< source of client ID's
typedef std::map<ClientNick, ClientRoutine*> ActiveUserMap;
typedef std::map<ClientIDTag, ClientRoutine*> ClientRoutineMap;
Mutex mutex;
ActiveUserMap activeUsers; ///< Map of active user's Nicknames corresponding to IDTags.
ClientRoutineMap pendingUsers; ///< The clients themselves.
ClientRoutineMap inactiveUsers; ///< Clients that have left or failed to connect.
NAPI::TCPSOCKET listener;
Event quit_;
unsigned port;
bool hosting;
bool SetUserActive(ClientIDTag id);
bool SetUserInactive(ClientRoutine *client);
public:
HostRoutine(unsigned port_) : listener(0), port(port_), hosting(false) {;}
~HostRoutine() { Quit(); }
void DistributeMessage(Command cmd);
void ProcessFileTransferRequest( const void *info_ );
void UpdateUserList(const std::string &name);
void Host() { thread_.Resume(); }
void Quit() { thread_.Terminate(); }
protected:
virtual void InitializeThread( void );
virtual void Run( void );
virtual void ExitThread( void ) throw();
virtual void FlushThread( void );
};
#endif
| [
"rziugy@af704e40-745a-32bd-e5ce-d8b418a3b9ef",
"ProstheticMind43@af704e40-745a-32bd-e5ce-d8b418a3b9ef"
] | [
[
[
1,
15
]
],
[
[
16,
102
]
]
] |
a89e080e6cb539762ebd628533443393c9f63c01 | 71c8e50508c636ca36dfc42b0e5fffd5910e09fa | /Error.h | d85350855e8b3fbc375a3e133b8c025408cccd4c | [] | no_license | NIA/D3DSkinning | ea6495b4cd792b8fe28e16c15a318bbe71cd5235 | ede8f34154265075fae71bd496cd50b71653e0a2 | refs/heads/master | 2021-01-19T22:13:42.575728 | 2009-10-29T08:25:19 | 2009-10-29T08:25:19 | 344,934 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,143 | h | #pragma once
#include <exception>
#include <tchar.h>
class RuntimeError : public std::exception
{
private:
const TCHAR * msg;
public:
RuntimeError(const TCHAR *msg) : msg(msg) {}
const TCHAR *message() const { return msg; }
};
class WindowInitError : public RuntimeError
{
public:
WindowInitError() : RuntimeError( _T("Error while creating window") ) {}
};
class D3DInitError : public RuntimeError
{
public:
D3DInitError() : RuntimeError( _T("Error while initializing D3D device") ) {}
};
class VertexDeclarationInitError : public RuntimeError
{
public:
VertexDeclarationInitError() : RuntimeError( _T("Error while creating vertex declaration") ) {}
};
class VertexShaderAssemblyError : public RuntimeError
{
public:
VertexShaderAssemblyError() : RuntimeError( _T("Error while assembling vertex shader") ) {}
};
class VertexShaderInitError : public RuntimeError
{
public:
VertexShaderInitError() : RuntimeError( _T("Error while creating vertex shader") ) {}
};
class VertexBufferInitError : public RuntimeError
{
public:
VertexBufferInitError() : RuntimeError( _T("Error while creating vertex buffer") ) {}
};
class IndexBufferInitError : public RuntimeError
{
public:
IndexBufferInitError() : RuntimeError( _T("Error while creating index buffer") ) {}
};
class VertexBufferFillError : public RuntimeError
{
public:
VertexBufferFillError() : RuntimeError( _T("Error while filling vertex buffer") ) {}
};
class IndexBufferFillError : public RuntimeError
{
public:
IndexBufferFillError() : RuntimeError( _T("Error while filling index buffer") ) {}
};
class RenderError : public RuntimeError
{
public:
RenderError() : RuntimeError( _T("Error while rendering scene") ) {}
};
class RenderStateError : public RuntimeError
{
public:
RenderStateError() : RuntimeError( _T("Error while setting render state") ) {}
};
inline void check_render( HRESULT res )
{
if( FAILED(res) )
throw RenderError();
}
inline void check_state( HRESULT res )
{
if( FAILED(res) )
throw RenderStateError();
}
| [
"[email protected]"
] | [
[
[
1,
80
]
]
] |
3d9277556e8ce9bc0b456b0eb15b5d9303e86d66 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/_Common/Graphic3D.cpp | 56d010cbf2f62653dd41fd46297bc0c697ee675e | [] | no_license | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UHC | C++ | false | false | 4,859 | cpp | #include "stdafx.h"
#include "Graphic3D.h"
CGraphic3D g_Grp3D;
//
//
//
void CGraphic3D :: Init( void )
{
int i;
m_pd3dDevice = NULL;
memset( m_aVertex, 0, sizeof(FVF_3DVERTEX) * MAX_3DVERTEX );
for( i = 0; i < MAX_3DVERTEX; i ++ )
{
m_aVertex[i].vPos = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
m_aVertex[i].dwColor = 0xffffffff;
}
}
void CGraphic3D :: Destroy( void )
{
Init();
}
void CGraphic3D :: RenderPoint( D3DXVECTOR3 &v, DWORD dwColor )
{
FVF_3DVERTEX aList[1];
aList[0].vPos = v;
aList[0].dwColor = dwColor;
m_pd3dDevice->SetFVF( D3DFVF_3DVERTEX );
m_pd3dDevice->DrawPrimitiveUP( D3DPT_POINTLIST, 1, aList, sizeof(FVF_3DVERTEX) );
}
void CGraphic3D :: Render3DLine( D3DXVECTOR3 &vOrig, D3DXVECTOR3 &vTar, DWORD dwColor )
{
FVF_3DVERTEX aList[2];
aList[0].vPos = vOrig;
aList[1].vPos = vTar;
aList[0].dwColor = dwColor;
aList[1].dwColor = dwColor;
m_pd3dDevice->SetFVF( D3DFVF_3DVERTEX );
m_pd3dDevice->DrawPrimitiveUP( D3DPT_LINELIST, 1, aList, sizeof(FVF_3DVERTEX) );
}
//
// vList : 삼각형 3점의 시작포인터. vList[0], [1], [2]
void CGraphic3D :: Render3DTri( D3DXVECTOR3 *vList, DWORD dwColor, BOOL bShowNormal )
{
FVF_3DVERTEX aList[3];
aList[0].vPos = vList[0]; aList[0].dwColor = dwColor;
aList[1].vPos = vList[1]; aList[1].dwColor = dwColor;
aList[2].vPos = vList[2]; aList[2].dwColor = dwColor;
m_pd3dDevice->SetFVF( D3DFVF_3DVERTEX );
m_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 1, aList, sizeof(FVF_3DVERTEX) );
if( bShowNormal )
{
D3DXVECTOR3 vPos, v1, v2;
vPos = (vList[0] + vList[1] + vList[2]) / 3;
v1 = vList[1] - vList[0]; // 노말 계산 시작.
v2 = vList[2] - vList[0];
D3DXVec3Cross( &v1, &v1, &v2 ); // 바닥의 노말 계산.
D3DXVec3Normalize( &v1, &v1 ); // 단위벡터로 변환
v1 += vPos;
Render3DLine( vPos, v1, COL_WHITE );
}
}
void CGraphic3D :: RenderAABB( D3DXVECTOR3 &vMin, D3DXVECTOR3 &vMax, DWORD dwColor )
{
FVF_3DVERTEX aList[24];
D3DXVECTOR3 vAABB[8];
vAABB[0].x = vMin.x;
vAABB[0].y = vMax.y;
vAABB[0].z = vMin.z;
vAABB[1].x = vMax.x;
vAABB[1].y = vMax.y;
vAABB[1].z = vMin.z;
vAABB[2].x = vMax.x;
vAABB[2].y = vMax.y;
vAABB[2].z = vMax.z;
vAABB[3].x = vMin.x;
vAABB[3].y = vMax.y;
vAABB[3].z = vMax.z;
vAABB[4].x = vMin.x;
vAABB[4].y = vMin.y;
vAABB[4].z = vMin.z;
vAABB[5].x = vMax.x;
vAABB[5].y = vMin.y;
vAABB[5].z = vMin.z;
vAABB[6].x = vMax.x;
vAABB[6].y = vMin.y;
vAABB[6].z = vMax.z;
vAABB[7].x = vMin.x;
vAABB[7].y = vMin.y;
vAABB[7].z = vMax.z;
aList[0].vPos = vAABB[0];
aList[1].vPos = vAABB[1];
aList[2].vPos = vAABB[1];
aList[3].vPos = vAABB[2];
aList[4].vPos = vAABB[2];
aList[5].vPos = vAABB[3];
aList[6].vPos = vAABB[3];
aList[7].vPos = vAABB[0];
aList[8].vPos = vAABB[4];
aList[9].vPos = vAABB[5];
aList[10].vPos = vAABB[5];
aList[11].vPos = vAABB[6];
aList[12].vPos = vAABB[6];
aList[13].vPos = vAABB[7];
aList[14].vPos = vAABB[7];
aList[15].vPos = vAABB[4];
aList[16].vPos = vAABB[0];
aList[17].vPos = vAABB[4];
aList[18].vPos = vAABB[1];
aList[19].vPos = vAABB[5];
aList[20].vPos = vAABB[2];
aList[21].vPos = vAABB[6];
aList[22].vPos = vAABB[3];
aList[23].vPos = vAABB[7];
int i; for( i = 0; i < 24; i ++ )
aList[i].dwColor = dwColor;
m_pd3dDevice->SetFVF( D3DFVF_3DVERTEX );
m_pd3dDevice->DrawPrimitiveUP( D3DPT_LINELIST, 12, aList, sizeof(FVF_3DVERTEX) );
}
//
// 3차원 공간상에 Y=0인 그리드를 만든다
//
void CGraphic3D :: RenderGrid( DWORD dwColor )
{
FVF_3DVERTEX *aList = m_aVertex;
int i;
int nCnt = 0;
// 세로선
for( i = 0; i < 21; i ++ )
{
aList[ nCnt ].vPos.x = (float)(-10 + i * 1); // 시작
aList[ nCnt ].vPos.z = (float)10;
aList[ nCnt ].vPos.y = 0;
aList[ nCnt ].dwColor = dwColor;
nCnt ++;
aList[ nCnt ].vPos.x = (float)(-10 + i * 1); // 끝
aList[ nCnt ].vPos.z = (float)-10;
aList[ nCnt ].vPos.y = 0;
aList[ nCnt ].dwColor = dwColor;
nCnt ++;
}
// 가로선
for( i = 0; i < 21; i ++ )
{
aList[ nCnt ].vPos.x = (float)-10; // 시작
aList[ nCnt ].vPos.z = (float)(-10 + i * 1);
aList[ nCnt ].vPos.y = 0;
aList[ nCnt ].dwColor = dwColor;
nCnt ++;
aList[ nCnt ].vPos.x = (float)10; // 끝
aList[ nCnt ].vPos.z = (float)(-10 + i * 1);
aList[ nCnt ].vPos.y = 0;
aList[ nCnt ].dwColor = dwColor;
nCnt ++;
}
m_pd3dDevice->SetFVF( D3DFVF_3DVERTEX );
int nShare = nCnt / 64;
int nRest = nCnt % 64;
for( i = 0; i < nShare; i ++ )
m_pd3dDevice->DrawPrimitiveUP( D3DPT_LINELIST, 64, aList + (i * 64), sizeof(FVF_3DVERTEX) );
if( nRest )
m_pd3dDevice->DrawPrimitiveUP( D3DPT_LINELIST, nRest, aList + (nShare * 64), sizeof(FVF_3DVERTEX) );
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] | [
[
[
1,
202
]
]
] |
32214d68e666301e1e9b10bec4fe920346938c9c | 59ce53af7ad5a1f9b12a69aadbfc7abc4c4bfc02 | /publish/skinctrlex/skinheaderctrl.h | c3ad6239c293c9e46358f3ea599c650cae74e109 | [] | no_license | fingomajom/skinengine | 444a89955046a6f2c7be49012ff501dc465f019e | 6bb26a46a7edac88b613ea9a124abeb8a1694868 | refs/heads/master | 2021-01-10T11:30:51.541442 | 2008-07-30T07:13:11 | 2008-07-30T07:13:11 | 47,892,418 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 9,760 | h | ///////////////////////////////////////////////////////////////
//
// Filename: skinheaderctrl.h
// Creator: 冰峰 & lichenglin
// Date: 2008-7-24 15:24
// Comment:
//
///////////////////////////////////////////////////////////////
#ifndef _skinheaderctrl_h_
#define _skinheaderctrl_h_
#include "../ksguicommon/drawer/KFormatDrawer.h"
namespace KSGUI{
//////////////////////////////////////////////////////////////////////////
// Header Ctrl 扩展风格
#define HDS_CT_DRAWFRAME 0x00000001
#define HDS_CT_FIXWIDTH 0x00000002
#define HDS_CT_TEXT_TRANSPARENT 0x00000004
//////////////////////////////////////////////////////////////////////////
// 自绘Header Ctrl
template<class T>
class CSkinHeaderCtrlExImpl : public SkinWindowImpl<T, CHeaderCtrl>
{
public:
typedef SkinWindowImpl<T, CHeaderCtrl> _Base;
typedef CSkinHeaderCtrlExImpl _Self;
private:
typedef std::vector<KSingleLineHTMLControl*> _Container;
typedef _Container::iterator _Iter;
_Container m_Container;
UINT m_nCustomStyle; //自定义样式
int m_nHeight; //高度
COLORREF m_rGridLine; //网格线颜色
COLORREF m_rBkColor;
//////////////////////////////////////////////////////////////////////////
// Init
public:
CSkinHeaderCtrlExImpl()
{
m_nCustomStyle = 0;
m_rGridLine = RGB(128, 128, 128);
m_rBkColor = RGB(255, 255, 255);
m_nHeight = 30;
}
~CSkinHeaderCtrlExImpl()
{
}
BOOL SubclassWindow(HWND hWnd)
{
ATLASSERT(m_hWnd == NULL);
ATLASSERT(::IsWindow(hWnd));
BOOL bRet = _Base::SubclassWindow(hWnd);
if(bRet)
_Init();
return bRet;
}
//////////////////////////////////////////////////////////////////////////
// 导出函数
public:
void SetHeight(int nHeight)
{
m_nHeight = nHeight;
CRect rc;
GetClientRect(&rc);
SetWindowPos(NULL, 0, 0, rc.Width(), nHeight, SWP_NOMOVE);
}
void SetGridLineColor(COLORREF rColor)
{
m_rGridLine = rColor;
}
void SetBkColor(COLORREF rColor)
{
m_rBkColor = rColor;
}
void SetCustomStyle(UINT nStyle)
{
m_nCustomStyle = nStyle;
}
BOOL SetRichText(int nItem, LPCTSTR szRichText, int nWidth = - 1, int nIndent = 0, int nAlignType = AT_LEFT)
{
if (nItem >= (int)m_Container.size())
{
_InsertTakePlaceItem(GetItemCount(), nItem);
m_Container.resize(nItem + 1);
}
if (m_Container[nItem] == 0)
m_Container[nItem] = new KSingleLineHTMLControl;
// Setting
if (nWidth != -1)
SetWidth(nItem, nWidth);
KSingleLineHTMLControl *pDrawer = m_Container[nItem];
pDrawer->SetIndent(nIndent);
pDrawer->SetAlignStyle(nAlignType);
pDrawer->SetPageSize(nWidth, m_nHeight);
return pDrawer->SetRichText(szRichText);
}
BOOL SetWidth(int nItem, int nWidth)
{
ASSERT(nItem < (int)m_Container.size());
if (nItem < (int)m_Container.size())
{
m_Container[nItem]->SetPageSize(nWidth);
}
//
HDITEM hditem = { 0 };
hditem.mask = HDI_WIDTH;
hditem.cxy = nWidth;
return _Base::SetItem(nItem, &hditem);
}
//////////////////////////////////////////////////////////////////////////
// 消息
public:
BEGIN_MSG_MAP(CSkinHeaderCtrlExImpl<T>)
MESSAGE_HANDLER(WM_CREATE , OnCreate)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(HDM_LAYOUT, OnLayOut)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
//
REFLECTED_NOTIFY_CODE_HANDLER(HDN_BEGINTRACK, OnBeginTrack) //当它作为ListView的标头时,是收不到此消息的
REFLECTED_NOTIFY_CODE_HANDLER(HDN_ITEMCHANGINGW, OnColumnWidthChange)
REFLECTED_NOTIFY_CODE_HANDLER(HDN_ITEMCHANGINGA, OnColumnWidthChange)
REFLECTED_NOTIFY_CODE_HANDLER(HDN_BEGINTRACK, OnBeginChangeColumnWidth)
REFLECTED_NOTIFY_CODE_HANDLER(HDN_ENDTRACK, OnEndChangeColumnWidth)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bHandled = FALSE;
_Init();
return 1L;
}
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
//放掉数据
for (int i = (int)m_Container.size() - 1; i >= 0; --i)
{
ASSERT(m_Container[i]);
if (m_Container[i])
delete m_Container[i];
}
m_Container.clear();
bHandled = FALSE;
return 1L;
}
LRESULT OnLayOut(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
LPHDLAYOUT pLayout = (LPHDLAYOUT)lParam;
pLayout->pwpos->hwnd = m_hWnd;
pLayout->pwpos->hwndInsertAfter = NULL;
pLayout->pwpos->flags = SWP_FRAMECHANGED;
pLayout->pwpos->x = pLayout->prc->left;
pLayout->pwpos->y = 0;
pLayout->pwpos->cx = pLayout->prc->right - pLayout->prc->left;
pLayout->pwpos->cy = m_nHeight;
pLayout->prc->top = m_nHeight;
return 1L;
};
LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
CPaintDC dc(m_hWnd);
HFONT hFont = _Base::GetFont();
HFONT hOldFont = dc.SelectFont(hFont);
int nColumns = GetItemCount();
for (int i = 0; i < nColumns; ++i)
{
_DrawItem(dc.m_hDC, i);
}
dc.SelectFont(hOldFont);
// Draw Frame
if (m_nCustomStyle & HDS_CT_DRAWFRAME)
{
HBRUSH brush = (HBRUSH)GetStockObject(NULL_BRUSH);
HBRUSH oldBrush = dc.SelectBrush(brush);
CPen pen;
pen.CreatePen(PS_SOLID, 1, m_rGridLine);
HPEN oldPen = dc.SelectPen(pen);
CRect rc;
GetClientRect(&rc);
dc.Rectangle(&rc);
dc.SelectPen(oldPen);
dc.SelectBrush(oldBrush);
}
return 0;
}
LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
GetParent().Invalidate();
bHandled = FALSE;
return 0;
}
LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (m_nCustomStyle & HDS_CT_FIXWIDTH)
return TRUE;
bHandled = FALSE;
return 0;
}
LRESULT OnBeginTrack(int /*wParam*/, LPNMHDR /*lParam*/, BOOL& bHandled)
{
if (m_nCustomStyle & HDS_CT_FIXWIDTH)
return 1L; //禁止用户拖动标头
return 0L;
};
LRESULT OnColumnWidthChange(int /*wParam*/, LPNMHDR lParam, BOOL& bHandled)
{
return 0;
NMHEADER *pItem = (NMHEADER*)lParam;
int nItem = pItem->iItem;
int nCount = _Base::GetItemCount();
CRect rc, rcTemp;
_Base::GetClientRect(&rc);
int nSpace = 0;
for (int i = 0; i <= nItem; ++i)
{
_Base::GetItemRect(i, &rcTemp);
nSpace += rcTemp.Width();
}
nSpace += 20 * (nCount - nItem - 1);
if (nSpace > rc.Width())
{
return TRUE;
}
return FALSE;
}
LRESULT OnBeginChangeColumnWidth(int /*wParam*/, LPNMHDR lParam, BOOL& bHandled)
{
return 0;
}
LRESULT OnEndChangeColumnWidth(int /*wParam*/, LPNMHDR lParam, BOOL& bHandled)
{
bHandled = FALSE;
return 0;
NMHEADER *pItem = (NMHEADER*)lParam;
int nItem = pItem->iItem;
int nCount = _Base::GetItemCount();
CRect rc, rcTemp;
_Base::GetClientRect(&rc);
rc.right -= 15;
int nSpace = 0;
for (int i = 0; i < nCount; ++i)
{
_Base::GetItemRect(i, &rcTemp);
nSpace += rcTemp.Width();
}
nSpace = nSpace - rc.Width(); // 多出的Space
if (nCount - nItem - 1 == 0)
return 0;
int nvSpace = nSpace / (nCount - nItem - 1); // 后面项平均每项要减少的Sapce
for (int i = nItem + 1; i < nCount; ++i)
{
_Base::GetItemRect(i, &rcTemp);
// if (i < nCount - 1)
SetWidth(i, rcTemp.Width() - nvSpace);
// else
// SetWidth(i, rcTemp.Width() - nvSpace + 15);
// nSpace -= nvSpace;
}
return 0;
}
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
int nColumns = GetItemCount();
CDCHandle dc(lpDrawItemStruct->hDC);
int nDC = dc.SaveDC();
CRect rc;
for (int i = 0; i < nColumns; ++i)
{
_DrawItem(lpDrawItemStruct->hDC, lpDrawItemStruct->itemID);
}
dc.RestoreDC(nDC);
return;
}
void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
return;
}
void DeleteItem(LPDELETEITEMSTRUCT /*lpDeleteItemStruct*/)
{
return;
}
//////////////////////////////////////////////////////////////////////////
// Helper
private:
void _Init()
{
ModifyStyle(0, HDS_FLAT);
}
inline void _DrawItem(HDC hdc, int nItem)
{
CDCHandle dc(hdc);
CRect rc;
GetItemRect(nItem, &rc);
// Draw Bk
CPen pen;
pen.CreatePen(PS_SOLID, 1, m_rGridLine);
HPEN oldPen = dc.SelectPen(pen);
dc.FillSolidRect(rc.left, rc.top, rc.right, rc.bottom, m_rBkColor);
if (nItem > 0)
_DrawLine(dc, rc.left, rc.top, rc.left, rc.bottom);
_DrawLine(dc, rc.right, rc.top, rc.right, rc.bottom);
_DrawLine(dc, rc.left, rc.bottom - 1, rc.right, rc.bottom - 1);
ASSERT(nItem < (int)m_Container.size());
if (nItem < (int)m_Container.size())
{
int bm = dc.GetBkMode();
if (m_nCustomStyle & HDS_CT_TEXT_TRANSPARENT)
dc.SetBkMode(TRANSPARENT);
m_Container[nItem]->Draw(dc, &rc);
dc.SetBkMode(bm);
}
dc.SelectPen(oldPen);
return;
}
inline void _DrawLine(CDCHandle &dc, int x1, int y1, int x2, int y2)
{
dc.MoveTo(x1, y1);
dc.LineTo(x2, y2);
}
inline void _InsertTakePlaceItem(int nStart, int nEnd)
{
HDITEM hditem = { 0 };
hditem.pszText = _T("");
hditem.cchTextMax = 0;
hditem.mask = HDI_TEXT;
for (int i = nStart; i <= nEnd; ++i)
{
AddItem(&hditem);
}
}
};
class CSkinHeaderCtrlEx : public CSkinHeaderCtrlExImpl<CSkinHeaderCtrlEx>
{
};
}
#endif // _skinheaderctrl_h_ | [
"[email protected]"
] | [
[
[
1,
422
]
]
] |
48c42cb0b7ee2df95159fac0c7139b4f9a48bb3e | be2e23022d2eadb59a3ac3932180a1d9c9dee9c2 | /GameServer/MapGroupKernel/Network/MsgWalk.cpp | f5105aa239a177ca78984ecb90660491906ae544 | [] | no_license | cronoszeu/revresyksgpr | 78fa60d375718ef789042c452cca1c77c8fa098e | 5a8f637e78f7d9e3e52acdd7abee63404de27e78 | refs/heads/master | 2020-04-16T17:33:10.793895 | 2010-06-16T12:52:45 | 2010-06-16T12:52:45 | 35,539,807 | 0 | 2 | null | null | null | null | GB18030 | C++ | false | false | 4,326 | cpp | #include "AllMsg.h"
#include "mapgroup.h"
#include "transformation.h"
#include "I_Role.h"
void CMsgWalk::Process(CMapGroup& mapGroup, SOCKET_ID idSocket, OBJID idNpc)
{
DEBUG_TRY
#ifdef _MSGDEBUG
::LogMsg("Process CMsgWalk, idUser:%u, data:%u",
m_idUser,
m_dwData);
#endif
// get obj
IRole* pRole = mapGroup.GetRoleManager()->QueryRole(idSocket, idNpc, m_idUser);
if(!pRole)
{
if(idSocket != SOCKET_NONE)//!this->IsNpcMsg()
LOGERROR("CMsgWalk消息没有找到玩家,SOCKET_ID[%u],NPC_ID[%u]", idSocket, idNpc);
return ;
}
//xxxCHECK(pRole->GetID() == m_idUser);
int nDir = m_ucDir%8;
int nNewX = pRole->GetPosX()+_DELTA_X[nDir];
int nNewY = pRole->GetPosY()+_DELTA_Y[nDir];
CUser* pUser = NULL;
if(pRole->QueryObj(OBJ_USER, IPP_OF(pUser)))
{
if(!pRole->IsAlive() && !pUser->IsGhost())
{
pRole->SendSysMsg(STR_DIE);
return ;
}
if (pUser->QueryTransformation() && !pUser->QueryTransformation()->IsMoveEnable()) // BUG: 刚变时,客户端还没禁跳
{
pUser->SendSysMsg(STR_YOUR_CANNOT_WALK);
pUser->KickBack();
//UserManager()->KickOutSocket(m_idSocket, "不能走!");
return;
}
if (pUser->QueryStatus(STATUS_LOCK) || pUser->QueryStatus(STATUS_FREEZE)
|| pRole->QueryStatus(STATUS_FAINT))
{
pUser->KickBack();
#ifdef ZLONG_DEBUG
pUser->SendSysMsg("Debug: 不可移动。");
#endif
return;
}
if (pUser->QueryMagic() && pUser->QueryMagic()->IsInLaunch())
{
pUser->KickBack();
#ifdef ZLONG_DEBUG
pUser->SendSysMsg("Debug: 魔法施展中,踢回。");
#endif
return;
}
if (pUser->QueryMagic() && pUser->QueryMagic()->IsIntone())
{
pUser->QueryMagic()->AbortMagic();
}
if(pUser->IsAlive() && !pUser->GetMap()->IsMoveEnable(nNewX, nNewY))
{
pUser->KickBack();
#ifdef LOCAL_DEBUG
pUser->SendSysMsg("阻挡:(%d,%d)", nNewX, nNewY);
#endif
return;
}
// 跑步模式的阻挡判断
if (m_ucMode >= MOVEMODE_RUN_DIR0 && m_ucMode <= MOVEMODE_RUN_DIR7)
{
nNewX += _DELTA_X[m_ucMode - MOVEMODE_RUN_DIR0];
nNewY += _DELTA_Y[m_ucMode - MOVEMODE_RUN_DIR0];
if(pUser->IsAlive() && !pUser->GetMap()->IsMoveEnable(nNewX, nNewY))
{
pUser->KickBack();
#ifdef LOCAL_DEBUG
pUser->SendSysMsg("阻挡:(%d,%d)", nNewX, nNewY);
#endif
return;
}
}
}
else
{
if(!pRole->IsAlive())
return ;
CMonster* pMonster = NULL;
if (pRole->QueryObj(OBJ_MONSTER, IPP_OF(pMonster)))
{
if (!pRole->GetMap())
return ;
if (!pRole->GetMap()->IsMoveEnable(nNewX, nNewY))
{
pMonster->KickBack();
#ifdef LOCAL_DEBUG
::LogSave("Kick back monster from (%d, %d) [ID=%u].", nNewX, nNewY, pMonster->GetID());
#endif
return;
}
if (m_ucMode >= MOVEMODE_RUN_DIR0 && m_ucMode <= MOVEMODE_RUN_DIR7)
{
nNewX += _DELTA_X[m_ucMode - MOVEMODE_RUN_DIR0];
nNewY += _DELTA_Y[m_ucMode - MOVEMODE_RUN_DIR0];
if (!pRole->GetMap()->IsMoveEnable(nNewX, nNewY))
{
pMonster->KickBack();
#ifdef LOCAL_DEBUG
::LogSave("Kick back monster from (%d, %d) [ID=%u].", nNewX, nNewY, pMonster->GetID());
#endif
return;
}
}
}
}
DEBUG_TRY
// stop fight
if(m_ucMode != MOVEMODE_SHIFT)
pRole->ProcessOnMove(m_ucMode);
DEBUG_CATCH("ProcessOnMove")
// fill id
DEBUG_TRY
//*
// pRole->BroadcastRoomMsg(this, EXCLUDE_SELF);
{
MsgWalkEx msg;
IF_OK(msg.Create(m_idUser, m_ucDir, m_ucMode, nNewX, nNewY))
{
// pRole->SendMsg(&msg);
pRole->BroadcastRoomMsg(&msg, INCLUDE_SELF);
}
}
//*/
/*else
pRole->SendMsg(this);
//*/
bool bRunMode = (m_ucMode >= MOVEMODE_RUN_DIR0 && m_ucMode <= MOVEMODE_RUN_DIR7);
pRole->MoveToward(nDir, !bRunMode); // return true: 是n步模数
// 如果是,跑步模式,移动第二步
if (bRunMode)
pRole->MoveToward(m_ucMode - MOVEMODE_RUN_DIR0);
DEBUG_CATCH("MoveToward")
#ifdef PALED_DEBUG_X
MSGBUF szMsg;
if(IsNpcID(pRole->GetID()))
sprintf(szMsg, "%s%06dWALK: (%d,%d)", pRole->GetName(), pRole->GetID(), pRole->GetPosX(), pRole->GetPosY());
else
sprintf(szMsg, "%sWALK: (%d,%d)", pRole->GetName(), pRole->GetPosX(), pRole->GetPosY());
//LOGWARNING(szMsg);
DebugSave(szMsg);
#endif
DEBUG_CATCH("CMsgWalk::Process")
}
| [
"rpgsky.com@cc92e6ba-efcf-11de-bf31-4dec8810c1c1"
] | [
[
[
1,
164
]
]
] |
bd479275bd39f590faa9fba06eee9e0ec136fefb | be3d7c318d79cd33d306aba58a1159147cac91fd | /modules/hyperfun/src/hfpolymesh.h | 95acaad6aa50978919c5be3ce29e740690088526 | [] | no_license | knicos/Cadence | 827149b53bb3e92fe532b0ad4234b7d0de11ca43 | 7e1e1cf1bae664f77afce63407b61c7b2b0a4fff | refs/heads/master | 2020-05-29T13:19:07.595099 | 2011-10-31T13:05:48 | 2011-10-31T13:05:48 | 1,238,039 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,283 | h | /*==============================================================================
Copyright 1999 Eric Fausett
Copyright 2003-2004 Pierre-Alain Fayolle, Benjamin Schmitt
Copyright 2007-2008 Oleg Fryazinov, Denis Kravtsov
This Work or file is part of the greater total Work, software or group of
files named HyperFun Polygonizer.
The implemented polygonization algorithm is described in
Pasko A.A., Pilyugin V.V., Pokrovskiy V.N.
"Geometric modeling in the analysis of trivariate functions",
Communications of Joint Insititute of Nuclear Research, P10-86-310,
Dubna, Russia, 1986 (in Russian).
Pasko A.A., Pilyugin V.V., Pokrovskiy V.N.
"Geometric modeling in the analysis of trivariate functions",
Computers and Graphics, vol.12, Nos.3/4, 1988, pp.457-465.
HyperFun Polygonizer can be redistributed and/or modified under the terms
of the CGPL, The Common Good Public License as published by and at CGPL.org
(http://CGPL.org). It is released under version 1.0 Beta of the License
until the 1.0 version is released after which either version 1.0 of the
License, or (at your option) any later version can be applied.
THIS WORK, OR SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED (See the
CGPL, The Common Good Public License for more information.)
You should have received a copy of the CGPL along with HyperFun Polygonizer;
if not, see - http://CGPL.org to get a copy of the License.
==============================================================================*/
// HFPolyMesh.h: interface for the HFPolyMesh class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(HFPolyMesh_H)
#define HFPolyMesh_H
#pragma warning( disable : 4786 )
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <cmath>
#include "hfinterpreter.h"
#include "hftimer.h"
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define F1_0 0 // 0000000000000000
#define F1_1 1 // 0000000000000001
#define F1_2 2 // 0000000000000010
#define F1_4 3 // 0000000000000011
#define F2_0 0 // 0000000000000000
#define F2_1 4 // 0000000000000100
#define F2_2 8 // 0000000000001000
#define F2_4 12 // 0000000000001100
#define F3_0 0 // 0000000000000000
#define F3_1 16 // 0000000000010000
#define F3_2 32 // 0000000000100000
#define F3_4 48 // 0000000000110000
#define F4_0 0 // 0000000000000000
#define F4_1 64 // 0000000001000000
#define F4_2 128 // 0000000010000000
#define F4_4 192 // 0000000011000000
#define F5_0 0 // 0000000000000000
#define F5_1 256 // 0000000100000000
#define F5_2 512 // 0000001000000000
#define F5_4 768 // 0000001100000000
#define F6_0 0 // 0000000000000000
#define F6_1 1024 // 0000010000000000
#define F6_2 2048 // 0000100000000000
#define F6_4 3072 // 0000110000000000
#define NONE 0 // 0000000000000000
#define One 1 // 0000000000000001
#define TWO 2 // 0000000000000010
#define FOUR 3 // 0000000000000011
const int Face2Vert[6][4]={ {0,1,2,3}, {0,9,4,8}, {3,11,7,8}, {4,5,6,7}, {2,10,6,11}, {1,10,5,9} };
//{{0,1,2,3}, {3,11,7,8}, {4,5,6,7}, {1,10,5,9}, {0,9,4,8}, {2,10,6,11}};
const std::vector<double> EMPTYVD(0);
const std::vector<unsigned int> EMPTYVI(0);
#define EPS (double)0.00001
#define NORMDELTMULT (double)0.001
//#define pol_eps 0.001
struct HFPError{ std::string error;
HFPError(std::string e){ error=e; }
};
class HFPolyMesh{
public:
//********** PUBLIC METHODS **********
//HFPolyMesh can throw HFPError
HFPolyMesh(HFInterpreter& interp);
virtual ~HFPolyMesh();
void Calc();
int VertexNum();
int TriangleNum();
void Timer(bool t);
bool Timer();
void Normals(bool s);
bool Normals();
void SearchPercent(double p);
double SearchPercent();
void Search(bool s);
bool Search();
void Reduce(bool r);
bool Reduce();
void IsoValue(double isov);
double IsoValue();
void MinMax(std::vector<double> mm);
std::vector<double> MinMax();
void Grid(std::vector<int> g);
std::vector<int> Grid();
void DimMap(std::vector<int> dm);
std::vector<int> DimMap();
void Constants(std::vector<double> con);
std::vector<double> Constants();
void Parameters(std::vector<double> par);
std::vector<double> Parameters();
void Refine(bool);
bool Refine();
void GeneralRefinement();
void CalcVNormal(double x, double y, double z, double& nx, double& ny, double& nz);
class TriData{
public:
TriData();
~TriData();
//Initilization
/*********ADDED FOR ATTRIBUTES*/
/*----Added for refinement---*/
void ReplaceVertex(int, std::vector<double>,double,double *);
void setAttributes(int, double *);
//void guessSize(int tNum, int );
void guessSize(int tNum, int VNum,int );
//Data Creation
int pushBackVertex(double* x, double fvalue,double *S);
int pushBackTriangle(int v[3]);
//Data Modification
void initVNormal();
void initTNormal();
/**Modified by schmitt :03 May 2001
/**Call inside the hfpolymesh class.
/**No need to use a double *, and copy it into a vector data type*/
void setVNormal(int , std::vector<double>);
void setTNormal(int , std::vector<double>);
std::vector<double> calcTNormal(int);
void setFunctVal(int v, double fvalue);
void deleteEdge(int e);
void refresh();
void ccwTriangles(); //Requires Normals
//Data Retrival
int getNumV();
int getNumT();
std::vector<double> getVertex(int v);
double getVertex(int v, int x);
std::vector<double> getVNormal(int v);
double getVNormal(int v, int x);
double getTNormal(int v, int x);
double getFunctVal(int v);
std::vector<int> getTriangle(int t);
int getTriangle(int t, int vnum);//vnum is 0, 1, or 2 only
/*****ADDED FOR ATTRIBUTES***********/
std::vector<double> getAttributes(int v);
double getAttributes(int v, int x);
double getVal(int);
private:
//Vertex Data
std::vector<std::vector<double> > itsVCoordinates;//Size 3
std::vector<std::vector<int> > itsVEdges;//Size Variable
std::vector<bool> itsVBad;
std::vector<double> itsVFVal;
std::vector<std::vector<double> > itsVNormal;//Size 3
//Edge Data
std::vector<std::vector<int> > itsEVertices;//Size 2
std::vector<std::vector<int> > itsETriangles;//Size 2
std::vector<bool> itsEBad;
std::vector<double> itsELength;
//Triangle Data
std::vector<std::vector<int> > itsTEdges;//Size 3
std::vector<std::vector<double> > itsTNormal; //Size 3
std::vector<bool> itsTBad;
std::vector<bool> itsTRev;
/*****ADDED FOR ATTRIBUTES */
//Attributes Data
std::vector<std::vector<double> > itsSAttributes;//Size itsSSize
int itsSSize;
int itsVBadCount;
int itsEBadCount;
int itsTBadCount;
std::vector<int> itsOpenEdges;
template <typename T>
inline void fillVector(const T* d, int size, std::vector<T>& ret) const;
double edgeLength(int v1, int v2);
void refreshTriangles();
void refreshEdges();
void refreshVerticies();
};
TriData itsData;
private:
//********** PRIVATE METHODS **********
void TimerStart(std::string tString);
void TimerStop();
void FillMatrix();
void FillVertices();
void CreateTriangles();
void CreateVNormals();
void CreateTNormals();
/* ADDED FOR ATTRIBUTES REFINEMENT*/
void Refinement();
int FindPositiveValue1(std::vector<double> *, std::vector<double>, std::vector<double>,std::vector<double> );
int FindPositiveValue2(std::vector<double> *vertex,std::vector<double> step,std::vector< std::vector<double> > cube,std::vector<double>);
void CalcVNormal(int i,std::vector<double> *norm);
/***************************************/
double VertEst(const double& left, const double& right, const double& delta);
double EdgeSearch(int leftI, int leftJ, int leftK, const int& select, const double lp[3], double* centerPos);
double CalcVal(const double pos[3]);
void VertCalc(int i, int j, int k, int select, const double lNodePos[3]);
void StoreCell(int i, int j, int k, int select);
void GraphBuildCase2(const int* Edge, int* I[12]);
void GraphBuildCase4(double V,double A1, double A2, const int* Edge);
void TraceGraph(int* I[12]);
void FillIndex(int i, int j, int k, int* I[12]);
void AddFace1ToCell(int li, int lj, int lk);
void AddFace2ToCell(int li, int lj, int lk);
void AddFace3ToCell(int li, int lj, int lk);
void AddFace4ToCell(int li, int lj, int lk);
void AddFace5ToCell(int li, int lj, int lk);
void AddFace6ToCell(int li, int lj, int lk);
//********** PRIVATE MEMBERS **********
bool itsSearch;
double itsSearchPer;
bool itsReduce;
bool itsNormals;
bool itsNormalDisplay;
bool itsTimer;
HFInterpreter& itsInterpreter;
double itsS0; //*** Iso Value for Surface ***
short itsXMap, itsYMap, itsZMap;//*** Its X,Y,Z Mapping
double itsBBMax[3], itsBBMin[3];//*** Bounding Box Definition ***
int itsGridSize[3]; //*** Grid Size Definition ***
std::vector<double> itsSendingX;
HFTimer itsT;
double itsEPS; //*** Epsilon Value ***
double itsDelta[3]; //*** Delta Values ***
std::vector<double> itsNormDelt;
double itsMinEdgeLen;
int itsFirstTriangleInSlice;
std::vector < std::vector < std::vector < int > > > DupVert;
std::vector< std::vector < std::vector <double> > > itsValGrid; //*** 3D Grid Holding Function Value Points ***
std::vector< std::vector < std::vector <bool> > > itsBoolGrid; //*** 3D Grid Holding Boolean for Inside/Outside Description of Grid Points ***
std::vector< std::vector< std::vector < std::vector <int> > > > itsVertGrid;//*** 3D Grids Holding Integer Vertex indeces ***
std::vector< std::vector < std::vector <int> > > itsCellGrid; //*** 3D Grid Holding bitmap Style Info about Cell Faces ***
std::vector< std::vector <int> > itsConnect; //*** Conectivity Graph ***
/*****ADDED FOR ATTRIBUTES */
double * itsSAttributesM;
int itsSSize;
bool itsRefinement;
};
#endif // !defined(HFPolyMesh_H)
| [
"nick@viglab-14.(none)"
] | [
[
[
1,
330
]
]
] |
cff8feda223440eb677f31bf288b00ec83e6f9bc | fbe2cbeb947664ba278ba30ce713810676a2c412 | /iptv_root/iptv_wboard/src/WBoardFrame.cpp | 8886ff7ca7cb23c73fef0321ed5289c8cc46e590 | [] | no_license | abhipr1/multitv | 0b3b863bfb61b83c30053b15688b070d4149ca0b | 6a93bf9122ddbcc1971dead3ab3be8faea5e53d8 | refs/heads/master | 2020-12-24T15:13:44.511555 | 2009-06-04T17:11:02 | 2009-06-04T17:11:02 | 41,107,043 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 101,791 | cpp | // For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#include "wx/colordlg.h"
#include "wx/fontdlg.h"
#include "wx/printdlg.h"
#include "wx/filename.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "Images.h"
#include "WBoardFrame.h"
/*!
* CWBFrame type definition
*/
IMPLEMENT_CLASS( CWBFrame, wxFrame )
/*!
* CWBFrame event table definition
*/
BEGIN_EVENT_TABLE( CWBFrame, wxFrame )
////@begin CWBFrame event table entries
EVT_CLOSE( CWBFrame::OnCloseWindow )
EVT_MENU( IDM_WB_NEW, CWBFrame::OnMWbNewClick )
EVT_MENU( IDM_WB_SAVE, CWBFrame::OnMWbSaveClick )
EVT_MENU( IDM_WB_PRINT, CWBFrame::OnWbPrintClick )
EVT_MENU( IDM_WB_PAGE_SETUP, CWBFrame::OnWbPageSetupClick )
EVT_MENU( IDM_WB_CLOSE, CWBFrame::OnMWbCloseClick )
EVT_MENU( IDM_WB_UNDO, CWBFrame::OnMWbUndoClick )
EVT_MENU( IDM_WB_CUT, CWBFrame::OnMWbCutClick )
EVT_MENU( IDM_WB_IMG_STOP, CWBFrame::OnMWbImgStopClick )
EVT_MENU( IDM_WB_HELP_TOPICS, CWBFrame::OnMWbHelpTopicsClick )
EVT_MENU( IDM_WB_ABOUT, CWBFrame::OnMWbAboutClick )
////@end CWBFrame event table entries
END_EVENT_TABLE()
/*!
* CWBFrame constructors
*/
CWBFrame::CWBFrame()
{
Init();
}
CWBFrame::CWBFrame( wxWindow* parent, IWBProcess* pProcess, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
Init();
Create( parent, pProcess, id, caption, pos, size, style );
}
/*!
* WBoardFrame creator
*/
bool CWBFrame::Create( wxWindow* parent, IWBProcess* pProcess, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin CWBFrame creation
wxFrame::Create( parent, id, caption, pos, size, style );
CreateControls();
if (m_pwbMain && pProcess)
{
SetProcessPtr(pProcess);
m_pwbMain->SetProcessObj(pProcess);
}
SetIcon(GetIconResource(wxT("../resource/wb_app_ico.xpm")));
CentreOnScreen();
////@end CWBFrame creation
return true;
}
/*!
* CWBFrame destructor
*/
CWBFrame::~CWBFrame()
{
////@begin CWBFrame destruction
////@end CWBFrame destruction
}
/*!
* Member initialisation
*/
void CWBFrame::Init()
{
////@begin CWBFrame member initialisation
m_pwbMain = NULL;
////@end CWBFrame member initialisation
}
/*!
* Control creation for WBoardFrame
*/
void CWBFrame::CreateControls()
{
////@begin CWBFrame content construction
CWBFrame* itemFrame1 = this;
#if wxUSE_MENUS
m_pMenuBar = new wxMenuBar;
m_pMenuFile = new wxMenu;
m_pMenuFile->Append(IDM_WB_NEW, _("New"), _T(""), wxITEM_NORMAL);
m_pMenuFile->Append(IDM_WB_SAVE, _("Save"), _T(""), wxITEM_NORMAL);
m_pMenuFile->Append(IDM_WB_PRINT, _("Print"), _T(""), wxITEM_NORMAL);
m_pMenuFile->Append(IDM_WB_PAGE_SETUP, _("Page setup"), _T(""), wxITEM_NORMAL);
m_pMenuFile->AppendSeparator();
m_pMenuFile->Append(IDM_WB_CLOSE, _("Close"), _T(""), wxITEM_NORMAL);
m_pMenuBar->Append(m_pMenuFile, _("File"));
m_pMenuEdit = new wxMenu;
m_pMenuEdit->Append(IDM_WB_UNDO, _("Undo"), _T(""), wxITEM_NORMAL);
m_pMenuEdit->AppendSeparator();
m_pMenuEdit->Append(IDM_WB_CUT, _("Cut"), _T(""), wxITEM_NORMAL);
m_pMenuBar->Append(m_pMenuEdit, _("Edit"));
m_pMenuCtrl = new wxMenu;
m_pMenuCtrl->Append(IDM_WB_IMG_STOP, _("Stop image send"), _T(""), wxITEM_NORMAL);
m_pMenuBar->Append(m_pMenuCtrl, _("Control"));
m_pMenuHelp = new wxMenu;
m_pMenuHelp->Append(IDM_WB_HELP_TOPICS, _("Help Topics"), _T(""), wxITEM_NORMAL);
m_pMenuHelp->AppendSeparator();
m_pMenuHelp->Append(IDM_WB_ABOUT, _("About"), _T(""), wxITEM_NORMAL);
m_pMenuBar->Append(m_pMenuHelp, _("Help"));
itemFrame1->SetMenuBar(m_pMenuBar);
#endif // wxUSE_MENUS
m_pwbMain = new CWBMain( itemFrame1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
m_pwbMain->SetBackgroundColour(wxColour(192, 192, 192));
////@end CWBFrame content construction
}
/*!
* Should we show tooltips?
*/
bool CWBFrame::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap CWBFrame::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin CWBFrame bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end CWBFrame bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon CWBFrame::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin CWBFrame icon retrieval
if (name == _T("../resource/wb_app_ico.xpm"))
{
wxIcon icon(wb_app_ico);
return icon;
}
return wxNullIcon;
////@end CWBFrame icon retrieval
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_NEW
*/
void CWBFrame::OnMWbNewClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarNewClick();
else
event.Skip();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_SAVE
*/
void CWBFrame::OnMWbSaveClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarSaveClick();
else
event.Skip();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_PRINT
*/
void CWBFrame::OnWbPrintClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarPrintClick();
else
event.Skip();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_WB_PAGE_SETUP
*/
void CWBFrame::OnWbPageSetupClick(wxCommandEvent& event)
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarPageSetupClick();
else
event.Skip();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_CLOSE
*/
void CWBFrame::OnMWbCloseClick( wxCommandEvent& event )
{
Close();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_UNDO
*/
void CWBFrame::OnMWbUndoClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarUndoClick();
else
event.Skip();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_CUT
*/
void CWBFrame::OnMWbCutClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarCutClick();
else
event.Skip();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_IMG_STOP
*/
void CWBFrame::OnMWbImgStopClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarImageStopClick();
else
event.Skip();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_HELP_TOPICS
*/
void CWBFrame::OnMWbHelpTopicsClick( wxCommandEvent& event )
{
event.Skip();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for IDM_WB_ABOUT
*/
void CWBFrame::OnMWbAboutClick( wxCommandEvent& event )
{
wxMessageBox(wxString::Format(
_T("%s %d.%d.%d Release %d\n")
_T("\n")
_T("Copyright(C) 2008 VAT Tecnologia da Informacao S/A\n"),
_("Version"),
3, 11, 7, 20
),
_("About White Board"),
wxOK | wxICON_INFORMATION,
this);
}
/*!
* wxEVT_CLOSE_WINDOW event handler for ID_WBOARDFRAME
*/
void CWBFrame::OnCloseWindow( wxCloseEvent& event )
{
if (event.CanVeto())
{
if (GetProcessPtr())
GetProcessPtr()->OnWindowClose();
event.Veto(true);
return;
}
event.Skip();
}
IWBInterface* CWBFrame::GetInterfacePtr()
{
IWBInterface* ret = NULL;
if (m_pwbMain)
ret = m_pwbMain->GetInterfacePtr();
return ret;
}
bool CWBFrame::Resize (RcPos* pRc)
{
bool ret;
//RcPos rc;
//int width, height;
ret = false;
/*
if (m_pwbFrame)
{
GetClientRect (lpWBWin->GetParent(), &rc);
width = rc.right - rc.left;
height = rc.bottom - rc.top;
lpWBWin->SetDimension (width, height);
// Não utilizo mais esta função por causa do botão de full screen
// lpWBWin->BringToTop ();
}
*/
return (ret);
}
void CWBFrame::ShowWnd (bool bOp)
{
Show(bOp);
if (bOp)
Raise();
}
void CWBFrame::EnableWnd (bool bOp)
{
if (m_pMenuFile)
m_pMenuFile->Enable(IDM_WB_NEW, bOp);
if (m_pMenuEdit)
{
m_pMenuEdit->Enable(IDM_WB_UNDO, bOp);
m_pMenuEdit->Enable(IDM_WB_CUT, bOp);
}
if (m_pMenuCtrl)
m_pMenuCtrl->Enable(IDM_WB_IMG_STOP, bOp);
if (m_pwbMain)
m_pwbMain->Enable(bOp);
}
void CWBFrame::EnableImgCtrl( bool bOp )
{
if (m_pwbMain)
m_pwbMain->ToolBoxItemEnable(ID_WB_IMG, bOp);
}
void CWBFrame::EnableImgStop( bool bOp )
{
if (m_pMenuCtrl)
m_pMenuCtrl->Enable(IDM_WB_IMG_STOP, bOp);
if (m_pwbMain)
m_pwbMain->MenuBarImageStopEnable(bOp);
}
/*!
* CWBMenuBar type definition
*/
IMPLEMENT_DYNAMIC_CLASS( CWBMenuBar, wxPanel )
/*!
* CWBMenuBar event table definition
*/
BEGIN_EVENT_TABLE( CWBMenuBar, wxPanel )
////@begin CWBMenuBar event table entries
EVT_BUTTON( ID_WB_NEW, CWBMenuBar::OnWbNewClick )
EVT_BUTTON( ID_WB_SAVE, CWBMenuBar::OnWbSaveClick )
EVT_BUTTON( ID_WB_PRINT, CWBMenuBar::OnWbPrintClick )
EVT_BUTTON( ID_WB_CUT, CWBMenuBar::OnWbCutClick )
EVT_BUTTON( ID_WB_UNDO, CWBMenuBar::OnWbUndoClick )
EVT_BUTTON( ID_WB_FTPSTOP, CWBMenuBar::OnWbFtpstopClick )
////@end CWBMenuBar event table entries
END_EVENT_TABLE()
/*!
* CWBMenuBar constructors
*/
CWBMenuBar::CWBMenuBar()
{
Init();
}
CWBMenuBar::CWBMenuBar(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
Init();
Create(parent, id, pos, size, style);
}
/*!
* CWBMenuBar creator
*/
bool CWBMenuBar::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
////@begin CWBMenuBar creation
wxPanel::Create(parent, id, pos, size, style);
CreateControls();
////@end CWBMenuBar creation
return true;
}
/*!
* CWBMenuBar destructor
*/
CWBMenuBar::~CWBMenuBar()
{
////@begin CWBMenuBar destruction
////@end CWBMenuBar destruction
}
/*!
* Member initialisation
*/
void CWBMenuBar::Init()
{
////@begin CWBMenuBar member initialisation
m_mbNew = NULL;
m_mbSave = NULL;
m_mbPrint = NULL;
m_mbCut = NULL;
m_mbUndo = NULL;
m_mbImgStop = NULL;
////@end CWBMenuBar member initialisation
}
/*!
* Control creation for CWBMenuBar
*/
void CWBMenuBar::CreateControls()
{
////@begin CWBMenuBar content construction
CWBMenuBar* itemPanel18 = this;
this->SetBackgroundColour(wxColour(192, 192, 192));
m_mbNew = new wxBitmapButton( itemPanel18, ID_WB_NEW, itemPanel18->GetBitmapResource(wxT("../resource/wb_new_n.xpm")), wxPoint(2, 2), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_mbNewBitmapSel(itemPanel18->GetBitmapResource(wxT("../resource/wb_new_p.xpm")));
m_mbNew->SetBitmapSelected(m_mbNewBitmapSel);
wxBitmap m_mbNewBitmapHover(itemPanel18->GetBitmapResource(wxT("../resource/wb_new_h.xpm")));
m_mbNew->SetBitmapHover(m_mbNewBitmapHover);
if (CWBMenuBar::ShowToolTips())
m_mbNew->SetToolTip(_("New"));
m_mbSave = new wxBitmapButton( itemPanel18, ID_WB_SAVE, itemPanel18->GetBitmapResource(wxT("../resource/wb_sav_n.xpm")), wxPoint(32, 2), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_mbSaveBitmapSel(itemPanel18->GetBitmapResource(wxT("../resource/wb_sav_p.xpm")));
m_mbSave->SetBitmapSelected(m_mbSaveBitmapSel);
wxBitmap m_mbSaveBitmapHover(itemPanel18->GetBitmapResource(wxT("../resource/wb_sav_h.xpm")));
m_mbSave->SetBitmapHover(m_mbSaveBitmapHover);
if (CWBMenuBar::ShowToolTips())
m_mbSave->SetToolTip(_("Save"));
m_mbPrint = new wxBitmapButton( itemPanel18, ID_WB_PRINT, itemPanel18->GetBitmapResource(wxT("../resource/wb_prt_n.xpm")), wxPoint(62, 2), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_mbPrintBitmapSel(itemPanel18->GetBitmapResource(wxT("../resource/wb_prt_p.xpm")));
m_mbPrint->SetBitmapSelected(m_mbPrintBitmapSel);
wxBitmap m_mbPrintBitmapHover(itemPanel18->GetBitmapResource(wxT("../resource/wb_prt_h.xpm")));
m_mbPrint->SetBitmapHover(m_mbPrintBitmapHover);
if (CWBMenuBar::ShowToolTips())
m_mbPrint->SetToolTip(_("Print"));
m_mbCut = new wxBitmapButton( itemPanel18, ID_WB_CUT, itemPanel18->GetBitmapResource(wxT("../resource/wb_cut_n.xpm")), wxPoint(92, 2), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_mbCutBitmapSel(itemPanel18->GetBitmapResource(wxT("../resource/wb_cut_p.xpm")));
m_mbCut->SetBitmapSelected(m_mbCutBitmapSel);
wxBitmap m_mbCutBitmapHover(itemPanel18->GetBitmapResource(wxT("../resource/wb_cut_h.xpm")));
m_mbCut->SetBitmapHover(m_mbCutBitmapHover);
if (CWBMenuBar::ShowToolTips())
m_mbCut->SetToolTip(_("Cut"));
m_mbUndo = new wxBitmapButton( itemPanel18, ID_WB_UNDO, itemPanel18->GetBitmapResource(wxT("../resource/wb_und_n.xpm")), wxPoint(122, 2), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_mbUndoBitmapSel(itemPanel18->GetBitmapResource(wxT("../resource/wb_und_p.xpm")));
m_mbUndo->SetBitmapSelected(m_mbUndoBitmapSel);
wxBitmap m_mbUndoBitmapHover(itemPanel18->GetBitmapResource(wxT("../resource/wb_und_h.xpm")));
m_mbUndo->SetBitmapHover(m_mbUndoBitmapHover);
if (CWBMenuBar::ShowToolTips())
m_mbUndo->SetToolTip(_("Undo"));
m_mbImgStop = new wxBitmapButton( itemPanel18, ID_WB_FTPSTOP, itemPanel18->GetBitmapResource(wxT("../resource/wb_ims_n.xpm")), wxPoint(152, 2), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_mbImgStopBitmapSel(itemPanel18->GetBitmapResource(wxT("../resource/wb_ims_p.xpm")));
m_mbImgStop->SetBitmapSelected(m_mbImgStopBitmapSel);
wxBitmap m_mbImgStopBitmapDisabled(itemPanel18->GetBitmapResource(wxT("../resource/wb_ims_x.xpm")));
m_mbImgStop->SetBitmapDisabled(m_mbImgStopBitmapDisabled);
wxBitmap m_mbImgStopBitmapHover(itemPanel18->GetBitmapResource(wxT("../resource/wb_ims_h.xpm")));
m_mbImgStop->SetBitmapHover(m_mbImgStopBitmapHover);
if (CWBMenuBar::ShowToolTips())
m_mbImgStop->SetToolTip(_("Stop image send"));
////@end CWBMenuBar content construction
}
/*!
* Should we show tooltips?
*/
bool CWBMenuBar::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap CWBMenuBar::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin CWBMenuBar bitmap retrieval
if (name == _T("../resource/wb_new_n.xpm"))
{
wxBitmap bitmap(wb_new_n);
return bitmap;
}
else if (name == _T("../resource/wb_new_p.xpm"))
{
wxBitmap bitmap(wb_new_p);
return bitmap;
}
else if (name == _T("../resource/wb_new_h.xpm"))
{
wxBitmap bitmap(wb_new_h);
return bitmap;
}
else if (name == _T("../resource/wb_sav_n.xpm"))
{
wxBitmap bitmap(wb_sav_n);
return bitmap;
}
else if (name == _T("../resource/wb_sav_p.xpm"))
{
wxBitmap bitmap(wb_sav_p);
return bitmap;
}
else if (name == _T("../resource/wb_sav_h.xpm"))
{
wxBitmap bitmap(wb_sav_h);
return bitmap;
}
else if (name == _T("../resource/wb_prt_n.xpm"))
{
wxBitmap bitmap(wb_prt_n);
return bitmap;
}
else if (name == _T("../resource/wb_prt_p.xpm"))
{
wxBitmap bitmap(wb_prt_p);
return bitmap;
}
else if (name == _T("../resource/wb_prt_h.xpm"))
{
wxBitmap bitmap(wb_prt_h);
return bitmap;
}
else if (name == _T("../resource/wb_cut_n.xpm"))
{
wxBitmap bitmap(wb_cut_n);
return bitmap;
}
else if (name == _T("../resource/wb_cut_p.xpm"))
{
wxBitmap bitmap(wb_cut_p);
return bitmap;
}
else if (name == _T("../resource/wb_cut_h.xpm"))
{
wxBitmap bitmap(wb_cut_h);
return bitmap;
}
else if (name == _T("../resource/wb_und_n.xpm"))
{
wxBitmap bitmap(wb_und_n);
return bitmap;
}
else if (name == _T("../resource/wb_und_p.xpm"))
{
wxBitmap bitmap(wb_und_p);
return bitmap;
}
else if (name == _T("../resource/wb_und_h.xpm"))
{
wxBitmap bitmap(wb_und_h);
return bitmap;
}
else if (name == _T("../resource/wb_ims_n.xpm"))
{
wxBitmap bitmap(wb_ims_n);
return bitmap;
}
else if (name == _T("../resource/wb_ims_p.xpm"))
{
wxBitmap bitmap(wb_ims_p);
return bitmap;
}
else if (name == _T("../resource/wb_ims_x.xpm"))
{
wxBitmap bitmap(wb_ims_x);
return bitmap;
}
else if (name == _T("../resource/wb_ims_h.xpm"))
{
wxBitmap bitmap(wb_ims_h);
return bitmap;
}
return wxNullBitmap;
////@end CWBMenuBar bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon CWBMenuBar::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin CWBMenuBar icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end CWBMenuBar icon retrieval
}
void CWBMenuBar::ImgStopEnable( bool bOp)
{
if (m_mbImgStop)
m_mbImgStop->Enable(bOp);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_NEW
*/
void CWBMenuBar::OnWbNewClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarNewClick();
event.Skip();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SAVE
*/
void CWBMenuBar::OnWbSaveClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarSaveClick();
event.Skip();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PRINT
*/
void CWBMenuBar::OnWbPrintClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarPrintClick();
event.Skip();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CUT
*/
void CWBMenuBar::OnWbCutClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarCutClick();
event.Skip();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_UNDO
*/
void CWBMenuBar::OnWbUndoClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarUndoClick();
event.Skip();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_FTPSTOP
*/
void CWBMenuBar::OnWbFtpstopClick( wxCommandEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnMenuBarImageStopClick();
event.Skip();
}
/*!
* CWBToolBox type definition
*/
IMPLEMENT_DYNAMIC_CLASS( CWBToolBox, wxPanel )
/*!
* CWBToolBox event table definition
*/
BEGIN_EVENT_TABLE( CWBToolBox, wxPanel )
////@begin CWBToolBox event table entries
EVT_BUTTON( ID_WB_POS, CWBToolBox::OnWbPosClick )
EVT_BUTTON( ID_WB_DEL, CWBToolBox::OnWbDelClick )
EVT_BUTTON( ID_WB_TXT, CWBToolBox::OnWbTxtClick )
EVT_BUTTON( ID_WB_MRK, CWBToolBox::OnWbMrkClick )
EVT_BUTTON( ID_WB_PTR, CWBToolBox::OnWbPtrClick )
EVT_BUTTON( ID_WB_IMG, CWBToolBox::OnWbImgClick )
EVT_BUTTON( ID_WB_PEN, CWBToolBox::OnWbPenClick )
EVT_BUTTON( ID_WB_LIN, CWBToolBox::OnWbLinClick )
EVT_BUTTON( ID_WB_SQR, CWBToolBox::OnWbSqrClick )
EVT_BUTTON( ID_WB_SQF, CWBToolBox::OnWbSqfClick )
EVT_BUTTON( ID_WB_CRC, CWBToolBox::OnWbCrcClick )
EVT_BUTTON( ID_WB_CRF, CWBToolBox::OnWbCrfClick )
EVT_BUTTON( ID_WB_LINE1, CWBToolBox::OnWbLine1Click )
EVT_BUTTON( ID_WB_LINE2, CWBToolBox::OnWbLine2Click )
EVT_BUTTON( ID_WB_LINE3, CWBToolBox::OnWbLine3Click )
EVT_BUTTON( ID_WB_LINE4, CWBToolBox::OnWbLine4Click )
EVT_BUTTON( ID_WB_COLOR_SEL, CWBToolBox::OnWbColorSelClick )
EVT_BUTTON( ID_WB_FONT_SEL, CWBToolBox::OnWbFontSelClick )
////@end CWBToolBox event table entries
END_EVENT_TABLE()
/*!
* CWBToolBox constructors
*/
CWBToolBox::CWBToolBox()
{
Init();
}
CWBToolBox::CWBToolBox(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
Init();
Create(parent, id, pos, size, style);
}
/*!
* CWBMenuBar creator
*/
bool CWBToolBox::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
////@begin CWBToolBox creation
wxPanel::Create(parent, id, pos, size, style);
CreateControls();
////@end CWBToolBox creation
return true;
}
/*!
* CWBToolBox destructor
*/
CWBToolBox::~CWBToolBox()
{
////@begin CWBToolBox destruction
////@end CWBToolBox destruction
}
/*!
* Member initialisation
*/
void CWBToolBox::Init()
{
////@begin CWBToolBox member initialisation
m_tbPos = NULL;
m_tbDel = NULL;
m_tbTxt = NULL;
m_tbMRK = NULL;
m_tbPtr = NULL;
m_tbImg = NULL;
m_tbPen = NULL;
m_tbLin = NULL;
m_tbSqr = NULL;
m_tbSqf = NULL;
m_tbCrc = NULL;
m_tbCrf = NULL;
m_tbPSize1 = NULL;
m_tbPSize2 = NULL;
m_tbPSize3 = NULL;
m_tbPSize4 = NULL;
m_tbColor = NULL;
m_tbColorSel = NULL;
m_tbFont = NULL;
m_tbFontLen = NULL;
m_tbFontSel = NULL;
m_tbPSBox = NULL;
////@end CWBToolBox member initialisation
m_CurItemId = -1;
m_CurPenSize = -1;
}
/*!
* Control creation for CWBMenuBar
*/
void CWBToolBox::CreateControls()
{
////@begin CWBToolBox content construction
CWBToolBox* itemPanel25 = this;
this->SetBackgroundColour(wxColour(192, 192, 192));
m_tbPosBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_pos_n.xpm"));
m_tbPosBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_pos_s.xpm"));
m_tbPos = new wxBitmapButton( itemPanel25, ID_WB_POS, m_tbPosBitmap, wxPoint(4, 0), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbPosBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_pos_p.xpm")));
m_tbPos->SetBitmapSelected(m_tbPosBitmapPressed);
wxBitmap m_tbPosBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_pos_h.xpm")));
m_tbPos->SetBitmapHover(m_tbPosBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbPos->SetToolTip(_("Position"));
m_tbDelBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_del_n.xpm"));
m_tbDelBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_del_s.xpm"));
m_tbDel = new wxBitmapButton( itemPanel25, ID_WB_DEL, m_tbDelBitmap, wxPoint(33, 0), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbDelBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_del_p.xpm")));
m_tbDel->SetBitmapSelected(m_tbDelBitmapPressed);
wxBitmap m_tbDelBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_del_h.xpm")));
m_tbDel->SetBitmapHover(m_tbDelBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbDel->SetToolTip(_("Eraser"));
m_tbTxtBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_txt_n.xpm"));
m_tbTxtBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_txt_s.xpm"));
m_tbTxt = new wxBitmapButton( itemPanel25, ID_WB_TXT, m_tbTxtBitmap, wxPoint(4, 25), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbTxtBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_txt_p.xpm")));
m_tbTxt->SetBitmapSelected(m_tbTxtBitmapPressed);
wxBitmap m_tbTxtBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_txt_h.xpm")));
m_tbTxt->SetBitmapHover(m_tbTxtBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbTxt->SetToolTip(_("Text"));
m_tbMRKBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_mrk_n.xpm"));
m_tbMRKBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_mrk_s.xpm"));
m_tbMRK = new wxBitmapButton( itemPanel25, ID_WB_MRK, m_tbMRKBitmap, wxPoint(33, 25), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbMRKBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_mrk_p.xpm")));
m_tbMRK->SetBitmapSelected(m_tbMRKBitmapPressed);
wxBitmap m_tbMRKBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_mrk_h.xpm")));
m_tbMRK->SetBitmapHover(m_tbMRKBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbMRK->SetToolTip(_("Marker"));
m_tbPtrBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_ptr_n.xpm"));
m_tbPtrBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_ptr_s.xpm"));
m_tbPtr = new wxBitmapButton( itemPanel25, ID_WB_PTR, m_tbPtrBitmap, wxPoint(4, 50), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbPtrBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_ptr_p.xpm")));
m_tbPtr->SetBitmapSelected(m_tbPtrBitmapPressed);
wxBitmap m_tbPtrBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_ptr_h.xpm")));
m_tbPtr->SetBitmapHover(m_tbPtrBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbPtr->SetToolTip(_("Pointer"));
m_tbImgBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_img_n.xpm"));
m_tbImgBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_img_s.xpm"));
m_tbImg = new wxBitmapButton( itemPanel25, ID_WB_IMG, m_tbImgBitmap, wxPoint(33, 50), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbImgBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_img_p.xpm")));
m_tbImg->SetBitmapSelected(m_tbImgBitmapPressed);
wxBitmap m_tbImgBitmapDisabled(itemPanel25->GetBitmapResource(wxT("../resource/wb_img_x.xpm")));
m_tbImg->SetBitmapDisabled(m_tbImgBitmapDisabled);
wxBitmap m_tbImgBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_img_h.xpm")));
m_tbImg->SetBitmapHover(m_tbImgBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbImg->SetToolTip(_("Image"));
m_tbPenBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_pen_n.xpm"));
m_tbPenBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_pen_s.xpm"));
m_tbPen = new wxBitmapButton( itemPanel25, ID_WB_PEN, m_tbPenBitmap, wxPoint(4, 75), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbPenBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_pen_p.xpm")));
m_tbPen->SetBitmapSelected(m_tbPenBitmapPressed);
wxBitmap m_tbPenBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_pen_h.xpm")));
m_tbPen->SetBitmapHover(m_tbPenBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbPen->SetToolTip(_("Pen"));
m_tbLinBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_lin_n.xpm"));
m_tbLinBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_lin_s.xpm"));
m_tbLin = new wxBitmapButton( itemPanel25, ID_WB_LIN, m_tbLinBitmap, wxPoint(33, 75), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbLinBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_lin_p.xpm")));
m_tbLin->SetBitmapSelected(m_tbLinBitmapPressed);
wxBitmap m_tbLinBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_lin_h.xpm")));
m_tbLin->SetBitmapHover(m_tbLinBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbLin->SetToolTip(_("Line"));
m_tbSqrBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_sqr_n.xpm"));
m_tbSqrBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_sqr_s.xpm"));
m_tbSqr = new wxBitmapButton( itemPanel25, ID_WB_SQR, m_tbSqrBitmap, wxPoint(4, 100), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbSqrBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_sqr_p.xpm")));
m_tbSqr->SetBitmapSelected(m_tbSqrBitmapPressed);
wxBitmap m_tbSqrBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_sqr_h.xpm")));
m_tbSqr->SetBitmapHover(m_tbSqrBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbSqr->SetToolTip(_("Rectangle"));
m_tbSqfBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_sqf_n.xpm"));
m_tbSqfBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_sqf_s.xpm"));
m_tbSqf = new wxBitmapButton( itemPanel25, ID_WB_SQF, m_tbSqfBitmap, wxPoint(33, 100), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbSqfBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_sqf_p.xpm")));
m_tbSqf->SetBitmapSelected(m_tbSqfBitmapPressed);
wxBitmap m_tbSqfBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_sqf_h.xpm")));
m_tbSqf->SetBitmapHover(m_tbSqfBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbSqf->SetToolTip(_("Full Rectangle"));
m_tbCrcBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_crc_n.xpm"));
m_tbCrcBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_crc_s.xpm"));
m_tbCrc = new wxBitmapButton( itemPanel25, ID_WB_CRC, m_tbCrcBitmap, wxPoint(4, 125), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbCrcBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_crc_p.xpm")));
m_tbCrc->SetBitmapSelected(m_tbCrcBitmapPressed);
wxBitmap m_tbCrcBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_crc_h.xpm")));
m_tbCrc->SetBitmapHover(m_tbCrcBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbCrc->SetToolTip(_("Ellipse"));
m_tbCrfBitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_crf_n.xpm"));
m_tbCrfBitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_crf_s.xpm"));
m_tbCrf = new wxBitmapButton( itemPanel25, ID_WB_CRF, m_tbCrfBitmap, wxPoint(33, 125), wxSize(29, 23), wxBU_AUTODRAW );
wxBitmap m_tbCrfBitmapPressed(itemPanel25->GetBitmapResource(wxT("../resource/wb_crf_p.xpm")));
m_tbCrf->SetBitmapSelected(m_tbCrfBitmapPressed);
wxBitmap m_tbCrfBitmapHover(itemPanel25->GetBitmapResource(wxT("../resource/wb_crf_h.xpm")));
m_tbCrf->SetBitmapHover(m_tbCrfBitmapHover);
if (CWBToolBox::ShowToolTips())
m_tbCrf->SetToolTip(_("Full Ellipse"));
m_tbPSBox = new wxStaticBox( itemPanel25, wxID_STATIC, _T(""), wxPoint(2, 159), wxSize(57, 62), wxSIMPLE_BORDER );
m_tbPSize1Bitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_ps1_n.xpm"));
m_tbPSize1BitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_ps1_s.xpm"));
m_tbPSize1 = new wxBitmapButton( itemPanel25, ID_WB_LINE1, m_tbPSize1Bitmap, wxPoint(3, 160), wxSize(55, 15), wxBU_AUTODRAW );
m_tbPSize1->SetBitmapSelected(m_tbPSize1BitmapSel);
m_tbPSize2Bitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_ps2_n.xpm"));
m_tbPSize2BitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_ps2_s.xpm"));
m_tbPSize2 = new wxBitmapButton( itemPanel25, ID_WB_LINE2, m_tbPSize2Bitmap, wxPoint(3, 175), wxSize(55, 15), wxBU_AUTODRAW );
m_tbPSize2->SetBitmapSelected(m_tbPSize2BitmapSel);
m_tbPSize3Bitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_ps3_n.xpm"));
m_tbPSize3BitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_ps3_s.xpm"));
m_tbPSize3 = new wxBitmapButton( itemPanel25, ID_WB_LINE3, m_tbPSize3Bitmap, wxPoint(3, 190), wxSize(55, 15), wxBU_AUTODRAW );
m_tbPSize3->SetBitmapSelected(m_tbPSize3BitmapSel);
m_tbPSize4Bitmap = itemPanel25->GetBitmapResource(wxT("../resource/wb_ps4_n.xpm"));
m_tbPSize4BitmapSel = itemPanel25->GetBitmapResource(wxT("../resource/wb_ps4_s.xpm"));
m_tbPSize4 = new wxBitmapButton( itemPanel25, ID_WB_LINE4, m_tbPSize4Bitmap, wxPoint(3, 205), wxSize(55, 15), wxBU_AUTODRAW );
m_tbPSize4->SetBitmapSelected(m_tbPSize4BitmapSel);
m_tbColor = new wxStaticText( itemPanel25, ID_WB_COLOR, _T(""), wxPoint(3, 262), wxSize(57, 20), wxALIGN_CENTRE|wxST_NO_AUTORESIZE|wxSIMPLE_BORDER );
m_tbColor->SetBackgroundColour(wxColour(255, 255, 255));
m_tbColorSel = new wxButton( itemPanel25, ID_WB_COLOR_SEL, _("Color"), wxPoint(2, 285), wxSize(59, 24), 0 );
m_tbColorSel->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma")));
m_tbFont = new wxStaticText( itemPanel25, ID_WB_FONT, _("AB"), wxPoint(3, 330), wxSize(33, 22), wxALIGN_LEFT|wxST_NO_AUTORESIZE|wxSIMPLE_BORDER );
m_tbFont->SetBackgroundColour(wxColour(255, 255, 255));
m_tbFontLen = new wxStaticText( itemPanel25, ID_WB_FONT_LEN, _("0"), wxPoint(38, 330), wxSize(22, 22), wxALIGN_RIGHT|wxST_NO_AUTORESIZE|wxSIMPLE_BORDER );
m_tbFontLen->SetBackgroundColour(wxColour(255, 255, 255));
m_tbFontSel = new wxButton( itemPanel25, ID_WB_FONT_SEL, _("Font"), wxPoint(2, 355), wxSize(59, 24), 0 );
m_tbFontSel->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma")));
////@end CWBToolBox content construction
}
/*!
* Should we show tooltips?
*/
bool CWBToolBox::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap CWBToolBox::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin CWBToolBox bitmap retrieval
if (name == _T("../resource/wb_pos_n.xpm"))
{
wxBitmap bitmap(wb_pos_n);
return bitmap;
}
else if (name == _T("../resource/wb_pos_p.xpm"))
{
wxBitmap bitmap(wb_pos_p);
return bitmap;
}
else if (name == _T("../resource/wb_pos_h.xpm"))
{
wxBitmap bitmap(wb_pos_h);
return bitmap;
}
else if (name == _T("../resource/wb_pos_s.xpm"))
{
wxBitmap bitmap(wb_pos_s);
return bitmap;
}
else if (name == _T("../resource/wb_del_n.xpm"))
{
wxBitmap bitmap(wb_del_n);
return bitmap;
}
else if (name == _T("../resource/wb_del_p.xpm"))
{
wxBitmap bitmap(wb_del_p);
return bitmap;
}
else if (name == _T("../resource/wb_del_h.xpm"))
{
wxBitmap bitmap(wb_del_h);
return bitmap;
}
else if (name == _T("../resource/wb_del_s.xpm"))
{
wxBitmap bitmap(wb_del_s);
return bitmap;
}
else if (name == _T("../resource/wb_txt_n.xpm"))
{
wxBitmap bitmap(wb_txt_n);
return bitmap;
}
else if (name == _T("../resource/wb_txt_p.xpm"))
{
wxBitmap bitmap(wb_txt_p);
return bitmap;
}
else if (name == _T("../resource/wb_txt_h.xpm"))
{
wxBitmap bitmap(wb_txt_h);
return bitmap;
}
else if (name == _T("../resource/wb_txt_s.xpm"))
{
wxBitmap bitmap(wb_txt_s);
return bitmap;
}
else if (name == _T("../resource/wb_mrk_n.xpm"))
{
wxBitmap bitmap(wb_mrk_n);
return bitmap;
}
else if (name == _T("../resource/wb_mrk_p.xpm"))
{
wxBitmap bitmap(wb_mrk_p);
return bitmap;
}
else if (name == _T("../resource/wb_mrk_h.xpm"))
{
wxBitmap bitmap(wb_mrk_h);
return bitmap;
}
else if (name == _T("../resource/wb_mrk_s.xpm"))
{
wxBitmap bitmap(wb_mrk_s);
return bitmap;
}
else if (name == _T("../resource/wb_ptr_n.xpm"))
{
wxBitmap bitmap(wb_ptr_n);
return bitmap;
}
else if (name == _T("../resource/wb_ptr_p.xpm"))
{
wxBitmap bitmap(wb_ptr_p);
return bitmap;
}
else if (name == _T("../resource/wb_ptr_h.xpm"))
{
wxBitmap bitmap(wb_ptr_h);
return bitmap;
}
else if (name == _T("../resource/wb_ptr_s.xpm"))
{
wxBitmap bitmap(wb_ptr_s);
return bitmap;
}
else if (name == _T("../resource/wb_img_n.xpm"))
{
wxBitmap bitmap(wb_img_n);
return bitmap;
}
else if (name == _T("../resource/wb_img_p.xpm"))
{
wxBitmap bitmap(wb_img_p);
return bitmap;
}
else if (name == _T("../resource/wb_img_x.xpm"))
{
wxBitmap bitmap(wb_img_x);
return bitmap;
}
else if (name == _T("../resource/wb_img_h.xpm"))
{
wxBitmap bitmap(wb_img_h);
return bitmap;
}
else if (name == _T("../resource/wb_img_s.xpm"))
{
wxBitmap bitmap(wb_img_s);
return bitmap;
}
else if (name == _T("../resource/wb_pen_n.xpm"))
{
wxBitmap bitmap(wb_pen_n);
return bitmap;
}
else if (name == _T("../resource/wb_pen_p.xpm"))
{
wxBitmap bitmap(wb_pen_p);
return bitmap;
}
else if (name == _T("../resource/wb_pen_h.xpm"))
{
wxBitmap bitmap(wb_pen_h);
return bitmap;
}
else if (name == _T("../resource/wb_pen_s.xpm"))
{
wxBitmap bitmap(wb_pen_s);
return bitmap;
}
else if (name == _T("../resource/wb_lin_n.xpm"))
{
wxBitmap bitmap(wb_lin_n);
return bitmap;
}
else if (name == _T("../resource/wb_lin_p.xpm"))
{
wxBitmap bitmap(wb_lin_p);
return bitmap;
}
else if (name == _T("../resource/wb_lin_h.xpm"))
{
wxBitmap bitmap(wb_lin_h);
return bitmap;
}
else if (name == _T("../resource/wb_lin_s.xpm"))
{
wxBitmap bitmap(wb_lin_s);
return bitmap;
}
else if (name == _T("../resource/wb_sqr_n.xpm"))
{
wxBitmap bitmap(wb_sqr_n);
return bitmap;
}
else if (name == _T("../resource/wb_sqr_p.xpm"))
{
wxBitmap bitmap(wb_sqr_p);
return bitmap;
}
else if (name == _T("../resource/wb_sqr_h.xpm"))
{
wxBitmap bitmap(wb_sqr_h);
return bitmap;
}
else if (name == _T("../resource/wb_sqr_s.xpm"))
{
wxBitmap bitmap(wb_sqr_s);
return bitmap;
}
else if (name == _T("../resource/wb_sqf_n.xpm"))
{
wxBitmap bitmap(wb_sqf_n);
return bitmap;
}
else if (name == _T("../resource/wb_sqf_p.xpm"))
{
wxBitmap bitmap(wb_sqf_p);
return bitmap;
}
else if (name == _T("../resource/wb_sqf_h.xpm"))
{
wxBitmap bitmap(wb_sqf_h);
return bitmap;
}
else if (name == _T("../resource/wb_sqf_s.xpm"))
{
wxBitmap bitmap(wb_sqf_s);
return bitmap;
}
else if (name == _T("../resource/wb_crc_n.xpm"))
{
wxBitmap bitmap(wb_crc_n);
return bitmap;
}
else if (name == _T("../resource/wb_crc_p.xpm"))
{
wxBitmap bitmap(wb_crc_p);
return bitmap;
}
else if (name == _T("../resource/wb_crc_h.xpm"))
{
wxBitmap bitmap(wb_crc_h);
return bitmap;
}
else if (name == _T("../resource/wb_crc_s.xpm"))
{
wxBitmap bitmap(wb_crc_s);
return bitmap;
}
else if (name == _T("../resource/wb_crf_n.xpm"))
{
wxBitmap bitmap(wb_crf_n);
return bitmap;
}
else if (name == _T("../resource/wb_crf_p.xpm"))
{
wxBitmap bitmap(wb_crf_p);
return bitmap;
}
else if (name == _T("../resource/wb_crf_h.xpm"))
{
wxBitmap bitmap(wb_crf_h);
return bitmap;
}
else if (name == _T("../resource/wb_crf_s.xpm"))
{
wxBitmap bitmap(wb_crf_s);
return bitmap;
}
else if (name == _T("../resource/wb_ps1_n.xpm"))
{
wxBitmap bitmap(wb_ps1_n);
return bitmap;
}
else if (name == _T("../resource/wb_ps1_s.xpm"))
{
wxBitmap bitmap(wb_ps1_s);
return bitmap;
}
else if (name == _T("../resource/wb_ps2_n.xpm"))
{
wxBitmap bitmap(wb_ps2_n);
return bitmap;
}
else if (name == _T("../resource/wb_ps2_s.xpm"))
{
wxBitmap bitmap(wb_ps2_s);
return bitmap;
}
else if (name == _T("../resource/wb_ps3_n.xpm"))
{
wxBitmap bitmap(wb_ps3_n);
return bitmap;
}
else if (name == _T("../resource/wb_ps3_s.xpm"))
{
wxBitmap bitmap(wb_ps3_s);
return bitmap;
}
else if (name == _T("../resource/wb_ps4_n.xpm"))
{
wxBitmap bitmap(wb_ps4_n);
return bitmap;
}
else if (name == _T("../resource/wb_ps4_s.xpm"))
{
wxBitmap bitmap(wb_ps4_s);
return bitmap;
}
return wxNullBitmap;
////@end CWBToolBox bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon CWBToolBox::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin CWBToolBox icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end CWBToolBox icon retrieval
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_POS
*/
void CWBToolBox::OnWbPosClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CUR in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_POS );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CUR in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_DEL
*/
void CWBToolBox::OnWbDelClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_DEL in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_DEL );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_DEL in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_TXT
*/
void CWBToolBox::OnWbTxtClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_TXT in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_TXT );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_TXT in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_MRK
*/
void CWBToolBox::OnWbMrkClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_MRK in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_MRK );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_MRK in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PTR
*/
void CWBToolBox::OnWbPtrClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PTR in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_PTR );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PTR in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_IMG
*/
void CWBToolBox::OnWbImgClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_IMG in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_IMG );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_IMG in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PEN
*/
void CWBToolBox::OnWbPenClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PEN in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_PEN );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_PEN in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LIN
*/
void CWBToolBox::OnWbLinClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LIN in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_LIN );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LIN in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SQR
*/
void CWBToolBox::OnWbSqrClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SQR in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_SQR );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SQR in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SQF
*/
void CWBToolBox::OnWbSqfClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SQF in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_SQF );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_SQF in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CRC
*/
void CWBToolBox::OnWbCrcClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CRC in WBoardFrame.
// Before editing this code, remove the block markers.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_CRC );
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CRC in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CRF
*/
void CWBToolBox::OnWbCrfClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CRF in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxItemClick( ID_WB_CRF );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_CRF in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE1
*/
void CWBToolBox::OnWbLine1Click( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE1 in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxPenSizeClick( ID_WB_LINE1 );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE1 in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE2
*/
void CWBToolBox::OnWbLine2Click( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE2 in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxPenSizeClick( ID_WB_LINE2 );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE2 in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE3
*/
void CWBToolBox::OnWbLine3Click( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE3 in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxPenSizeClick( ID_WB_LINE3 );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE3 in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE4
*/
void CWBToolBox::OnWbLine4Click( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE4 in WBoardFrame.
if ( GetProcessPtr() )
GetProcessPtr()->OnToolBoxPenSizeClick( ID_WB_LINE4 );
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_LINE4 in WBoardFrame.
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_COLOR_SEL
*/
void CWBToolBox::OnWbColorSelClick( wxCommandEvent& event )
{
wxColourData clData;
wxColourDialog clDlg;
clData.SetColour(m_Colour);
if (clDlg.Create(this, &clData))
{
clDlg.Centre();
if (clDlg.ShowModal() == wxID_OK)
{
wxColour colour = clDlg.GetColourData().GetColour();
if (GetProcessPtr())
{
ColorDef sel;
sel.SetAttr(colour.Red(), colour.Green(), colour.Blue());
GetProcessPtr()->OnToolBoxColorClick(sel);
}
}
}
event.Skip();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_WB_FONT_SEL
*/
void CWBToolBox::OnWbFontSelClick( wxCommandEvent& event )
{
wxFontData fnData;
wxFontDialog fnDlg;
fnData.SetInitialFont(m_Font);
fnData.SetColour(m_Colour);
if (fnDlg.Create(this, fnData))
{
fnDlg.Centre();
if (fnDlg.ShowModal() == wxID_OK)
{
wxFont font = fnDlg.GetFontData().GetChosenFont();
wxColour colour = fnDlg.GetFontData().GetColour();
if (GetProcessPtr())
{
if (font != m_Font)
{
FontDef sel;
wxString name;
WB_BYTE effect;
sel.Clear();
effect = 0;
if (font.GetUnderlined())
effect |= FD_UNDERLINE;
if (font.GetStyle() == wxFONTSTYLE_ITALIC)
effect |= FD_ITALIC;
if (font.GetWeight() == wxFONTWEIGHT_BOLD)
effect |= FD_BOLD;
name = font.GetFaceName();
sel.SetAttr(name.char_str(), font.GetPointSize(), effect);
GetProcessPtr()->OnToolBoxFontClick(sel);
}
if (colour != m_Colour)
{
ColorDef sel;
sel.SetAttr(colour.Red(), colour.Green(), colour.Blue());
GetProcessPtr()->OnToolBoxColorClick(sel);
}
}
}
}
event.Skip();
}
void CWBToolBox::SelectItem(int nId)
{
switch (m_CurItemId)
{
case ID_WB_POS:
m_tbPos->SetBitmapLabel(m_tbPosBitmap);
break;
case ID_WB_DEL:
m_tbDel->SetBitmapLabel(m_tbDelBitmap);
break;
case ID_WB_TXT:
m_tbTxt->SetBitmapLabel(m_tbTxtBitmap);
break;
case ID_WB_MRK:
m_tbMRK->SetBitmapLabel(m_tbMRKBitmap);
break;
case ID_WB_PTR:
m_tbPtr->SetBitmapLabel(m_tbPtrBitmap);
break;
case ID_WB_IMG:
m_tbImg->SetBitmapLabel(m_tbImgBitmap);
break;
case ID_WB_PEN:
m_tbPen->SetBitmapLabel(m_tbPenBitmap);
break;
case ID_WB_LIN:
m_tbLin->SetBitmapLabel(m_tbLinBitmap);
break;
case ID_WB_SQR:
m_tbSqr->SetBitmapLabel(m_tbSqrBitmap);
break;
case ID_WB_SQF:
m_tbSqf->SetBitmapLabel(m_tbSqfBitmap);
break;
case ID_WB_CRC:
m_tbCrc->SetBitmapLabel(m_tbCrcBitmap);
break;
case ID_WB_CRF:
m_tbCrf->SetBitmapLabel(m_tbCrfBitmap);
break;
}
switch (nId)
{
case ID_WB_POS:
m_tbPos->SetBitmapLabel(m_tbPosBitmapSel);
break;
case ID_WB_DEL:
m_tbDel->SetBitmapLabel(m_tbDelBitmapSel);
break;
case ID_WB_TXT:
m_tbTxt->SetBitmapLabel(m_tbTxtBitmapSel);
break;
case ID_WB_MRK:
m_tbMRK->SetBitmapLabel(m_tbMRKBitmapSel);
break;
case ID_WB_PTR:
m_tbPtr->SetBitmapLabel(m_tbPtrBitmapSel);
break;
case ID_WB_IMG:
m_tbImg->SetBitmapLabel(m_tbImgBitmapSel);
break;
case ID_WB_PEN:
m_tbPen->SetBitmapLabel(m_tbPenBitmapSel);
break;
case ID_WB_LIN:
m_tbLin->SetBitmapLabel(m_tbLinBitmapSel);
break;
case ID_WB_SQR:
m_tbSqr->SetBitmapLabel(m_tbSqrBitmapSel);
break;
case ID_WB_SQF:
m_tbSqf->SetBitmapLabel(m_tbSqfBitmapSel);
break;
case ID_WB_CRC:
m_tbCrc->SetBitmapLabel(m_tbCrcBitmapSel);
break;
case ID_WB_CRF:
m_tbCrf->SetBitmapLabel(m_tbCrfBitmapSel);
break;
}
m_CurItemId = nId;
}
void CWBToolBox::EnableItem(int nId, bool bOp)
{
if (m_CurItemId == nId)
{
if (GetProcessPtr())
GetProcessPtr()->OnToolBoxItemClick(ID_WB_POS);
}
switch (nId)
{
case ID_WB_POS:
m_tbPos->Enable(bOp);
break;
case ID_WB_DEL:
m_tbDel->Enable(bOp);
break;
case ID_WB_TXT:
m_tbTxt->Enable(bOp);
break;
case ID_WB_MRK:
m_tbMRK->Enable(bOp);
break;
case ID_WB_PTR:
m_tbPtr->Enable(bOp);
break;
case ID_WB_IMG:
m_tbImg->Enable(bOp);
break;
case ID_WB_PEN:
m_tbPen->Enable(bOp);
break;
case ID_WB_LIN:
m_tbLin->Enable(bOp);
break;
case ID_WB_SQR:
m_tbSqr->Enable(bOp);
break;
case ID_WB_SQF:
m_tbSqf->Enable(bOp);
break;
case ID_WB_CRC:
m_tbCrc->Enable(bOp);
break;
case ID_WB_CRF:
m_tbCrf->Enable(bOp);
break;
}
}
void CWBToolBox::SelectPenSize(int nId)
{
switch (m_CurPenSize)
{
case ID_WB_LINE1:
m_tbPSize1->SetBitmapLabel(m_tbPSize1Bitmap);
break;
case ID_WB_LINE2:
m_tbPSize2->SetBitmapLabel(m_tbPSize2Bitmap);
break;
case ID_WB_LINE3:
m_tbPSize3->SetBitmapLabel(m_tbPSize3Bitmap);
break;
case ID_WB_LINE4:
m_tbPSize4->SetBitmapLabel(m_tbPSize4Bitmap);
break;
}
switch (nId)
{
case ID_WB_LINE1:
m_tbPSize1->SetBitmapLabel(m_tbPSize1BitmapSel);
break;
case ID_WB_LINE2:
m_tbPSize2->SetBitmapLabel(m_tbPSize2BitmapSel);
break;
case ID_WB_LINE3:
m_tbPSize3->SetBitmapLabel(m_tbPSize3BitmapSel);
break;
case ID_WB_LINE4:
m_tbPSize4->SetBitmapLabel(m_tbPSize4BitmapSel);
break;
}
m_CurPenSize = nId;
}
void CWBToolBox::SelectColour(wxColour& colour)
{
m_Colour = colour;
if (m_tbColor)
{
m_tbColor->SetBackgroundColour(m_Colour);
m_tbColor->Refresh();
}
}
void CWBToolBox::SelectFont(wxFont& font)
{
m_Font = font;
if (m_tbFont)
{
wxFont fnName = m_Font;
fnName.SetPointSize(FONT_SIZE_DEF);
m_tbFont->SetFont(fnName);
m_tbFont->SetLabel(wxT("AB"));
}
if (m_tbFontLen)
{
wxFont fnSize = m_tbFontLen->GetFont();
fnSize.SetPointSize(FONT_SIZE_DEF);
m_tbFontLen->SetFont(fnSize);
wxString len;
len.Printf(wxT("%d"), m_Font.GetPointSize());
m_tbFontLen->SetLabel(len);
}
}
/*!
* CWBMain type definition
*/
IMPLEMENT_DYNAMIC_CLASS( CWBMain, wxPanel )
/*!
* CWBMain event table definition
*/
BEGIN_EVENT_TABLE( CWBMain, wxPanel )
////@begin CWBMain event table entries
////@end CWBMain event table entries
END_EVENT_TABLE()
/*!
* CWBMain constructors
*/
CWBMain::CWBMain()
{
Init();
}
CWBMain::CWBMain(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
Init();
Create(parent, id, pos, size, style);
}
/*!
* CWBMain creator
*/
bool CWBMain::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
////@begin CWBMain creation
wxPanel::Create(parent, id, pos, size, style);
CreateControls();
if (GetSizer())
GetSizer()->Fit(this);
////@end CWBMain creation
return true;
}
/*!
* CWBMain destructor
*/
CWBMain::~CWBMain()
{
////@begin CWBMain destruction
if (GetProcessPtr())
{
GetProcessPtr()->OnWindowDestroy();
}
////@end CWBMain destruction
}
/*!
* Member initialisation
*/
void CWBMain::Init()
{
////@begin CWBMain member initialisation
SetProcessPtr(NULL);
m_pwbToolBox = NULL;
m_pwbMenuBar = NULL;
m_pwbScreen = NULL;
m_pwbEdit = NULL;
m_MainSizer = NULL;
////@end CWBMain member initialisation
}
/*!
* Control creation for CWBMain
*/
void CWBMain::CreateControls()
{
////@begin CWBMain content construction
CWBMain* itemPanel15 = this;
this->SetBackgroundColour(wxColour(192, 192, 192));
m_MainSizer = new wxFlexGridSizer(1, 2, 0, 0);
m_MainSizer->AddGrowableRow(1);
m_MainSizer->AddGrowableCol(1);
itemPanel15->SetSizer(m_MainSizer);
m_MainSizer->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_pwbMenuBar = new CWBMenuBar( itemPanel15, wxID_ANY, wxPoint(70, 0), wxSize(600, 40), wxNO_BORDER|wxTAB_TRAVERSAL );
m_pwbMenuBar->SetBackgroundColour(wxColour(192, 192, 192));
m_pwbMenuBar->SetProcessPtr(NULL);
m_MainSizer->Add(m_pwbMenuBar, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
m_pwbToolBox = new CWBToolBox( itemPanel15, wxID_ANY, wxPoint(0, 40), wxSize(70, 400), wxNO_BORDER|wxTAB_TRAVERSAL );
m_pwbToolBox->SetBackgroundColour(wxColour(192, 192, 192));
m_pwbToolBox->SetProcessPtr(NULL);
m_MainSizer->Add(m_pwbToolBox, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_pwbScreen = new CWBScreen( itemPanel15, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL|wxALWAYS_SHOW_SB );
m_pwbScreen->SetBackgroundColour(wxColour(192, 192, 192));
m_pwbEdit = m_pwbScreen->GetWBEdit();
m_pwbEdit->SetProcessPtr(NULL);
m_MainSizer->Add(m_pwbScreen, 0, wxGROW|wxGROW|wxALL, 0);
////@end CWBMain content construction
}
/*!
* Should we show tooltips?
*/
bool CWBMain::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap CWBMain::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin CWBMain bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end CWBMain bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon CWBMain::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin CWBMain icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end CWBMain icon retrieval
}
void CWBMain::SetProcessObj(IWBProcess* pProcess)
{
if (pProcess && GetHandle())
{
pProcess->OnWindowCreate( GetInterfacePtr() );
}
SetProcessPtr(pProcess);
if (m_pwbToolBox)
m_pwbToolBox->SetProcessPtr(pProcess);
if (m_pwbMenuBar)
m_pwbMenuBar->SetProcessPtr(pProcess);
if (m_pwbScreen)
m_pwbScreen->SetProcessPtr(pProcess);
if (m_pwbEdit)
m_pwbEdit->SetProcessPtr(pProcess);
}
IWBInterface* CWBMain::GetInterfacePtr()
{
return (IWBInterface*) this;
}
void CWBMain::ToolBoxItemSel( int nId )
{
if ( m_pwbToolBox )
m_pwbToolBox->SelectItem(nId);
if ( m_pwbEdit )
m_pwbEdit->SetControl(nId);
}
void CWBMain::ToolBoxItemEnable( int nId, bool bOp)
{
if ( m_pwbToolBox )
m_pwbToolBox->EnableItem(nId, bOp);
}
void CWBMain::ToolBoxPenSizeSel( int nId )
{
if ( m_pwbToolBox )
m_pwbToolBox->SelectPenSize(nId);
if ( m_pwbEdit )
m_pwbEdit->SetPenSize(nId);
}
void CWBMain::ToolBoxColorSel( ColorDef& color )
{
wxColor clSel(color.cdRed, color.cdGreen, color.cdBlue);;
if ( m_pwbToolBox )
m_pwbToolBox->SelectColour(clSel);
if ( m_pwbEdit )
m_pwbEdit->SetFrgColour(clSel);
}
void CWBMain::ToolBoxFontSel( FontDef& font )
{
wxFont fnSel;
if ( font.fdName[0] != '\0' )
{
wxString name = wxString::FromAscii(font.fdName);
fnSel.SetFaceName(name);
fnSel.SetPointSize(font.fdSize);
if (font.fdEffect & FD_UNDERLINE)
fnSel.SetUnderlined(true);
if (font.fdEffect & FD_ITALIC)
fnSel.SetStyle(wxFONTSTYLE_ITALIC);
if (font.fdEffect & FD_BOLD)
fnSel.SetWeight(wxFONTWEIGHT_BOLD);
}
else
{
fnSel = GetFont();
fnSel.SetPointSize(FONT_SIZE_DEF);
}
if ( m_pwbToolBox )
m_pwbToolBox->SelectFont(fnSel);
if ( m_pwbEdit )
m_pwbEdit->SetTxtFont(fnSel);
}
bool CWBMain::MenuBarNewExec( bool bChanged, bool bRepaint )
{
bool ret = false;
if ( m_pwbEdit )
ret = m_pwbEdit->NewExec(bChanged, bRepaint);
return ret;
}
void CWBMain::MenuBarSaveExec( )
{
if ( m_pwbEdit )
m_pwbEdit->SaveExec();
}
void CWBMain::MenuBarPrintExec( )
{
if ( m_pwbEdit )
m_pwbEdit->PrintExec();
}
void CWBMain::MenuBarPageSetup( )
{
if ( m_pwbEdit )
m_pwbEdit->PageSetup();
}
void CWBMain::MenuBarCutExec( )
{
if ( m_pwbEdit )
m_pwbEdit->CutExec();
}
void CWBMain::MenuBarUndoExec( )
{
}
void CWBMain::MenuBarImageStopExec( )
{
}
void CWBMain::MenuBarImageStopEnable( bool bOp )
{
if ( m_pwbMenuBar )
m_pwbMenuBar->ImgStopEnable(bOp);
}
void CWBMain::EdtSelArea( PtPos& pt1, PtPos& pt2 )
{
if ( m_pwbEdit )
m_pwbEdit->SelArea(pt1, pt2);
}
void CWBMain::EdtSelRect( PtPos& pt1, PtPos& pt2 )
{
if ( m_pwbEdit )
m_pwbEdit->SelRect(pt1, pt2);
}
void CWBMain::EdtSelEllipse( PtPos& pt1, PtPos& pt2 )
{
if ( m_pwbEdit )
m_pwbEdit->SelEllipse(pt1, pt2);
}
void CWBMain::EdtSelLine( PtPos& pt1, PtPos& pt2 )
{
if ( m_pwbEdit )
m_pwbEdit->SelLine(pt1, pt2);
}
void CWBMain::EdtDrawArea( PtPos& pt1, PtPos& pt2 )
{
if ( m_pwbEdit )
m_pwbEdit->DrawArea(pt1, pt2);
}
void CWBMain::EdtKillArea( )
{
if ( m_pwbEdit )
m_pwbEdit->KillArea();
}
void CWBMain::EdtRepaint( )
{
if ( m_pwbEdit )
m_pwbEdit->Repaint();
}
void CWBMain::ScrScrollWindow( int dx, int dy )
{
if (m_pwbScreen)
{
m_pwbScreen->ScrollWnd(dx, dy);
}
}
void CWBMain::ScrSetScrollPos(int posx, int posy)
{
if (m_pwbEdit)
{
m_pwbEdit->SetScrollPos(posx, posy);
}
}
void CWBMain::CtlDrawRect( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bFull, WB_BYTE flags )
{
if ( m_pwbEdit )
m_pwbEdit->DrawRect(pt1, pt2, nLin, color, bFull, flags);
}
void CWBMain::CtlDrawEllipse( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bFull, WB_BYTE flags )
{
if ( m_pwbEdit )
m_pwbEdit->DrawEllipse(pt1, pt2, nLin, color, bFull, flags);
}
void CWBMain::CtlDrawLine(PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bMask, WB_BYTE flags )
{
if ( m_pwbEdit )
m_pwbEdit->DrawLine(pt1, pt2, nLin, color, bMask, flags);
}
void CWBMain::CtlDrawIndicator( PtPos& pt, WB_BYTE flags )
{
if ( m_pwbEdit )
m_pwbEdit->DrawIndicator(pt, flags);
}
void CWBMain::CtlDrawImage( WB_PCSTR szFile, PtPos& pt1, PtPos& pt2, WB_BYTE flags )
{
if ( m_pwbEdit )
m_pwbEdit->DrawImage(szFile, pt1, pt2, flags);
}
void CWBMain::CtlDrawTxt( WB_PCSTR szText, PtPos& pt1, PtPos& pt2, FontDef& font, ColorDef& color, WB_BYTE flags )
{
if ( m_pwbEdit )
m_pwbEdit->DrawTxt(szText, pt1, pt2, font, color, flags);
}
void CWBMain::CtlEditTxt( PtPos& pt1, PtPos& pt2, FontDef& font, ColorDef& color )
{
if ( m_pwbEdit )
m_pwbEdit->EditTxt(pt1, pt2, font, color);
}
void CWBMain::CtlGetTxt( WB_PSTR szText )
{
if ( m_pwbEdit )
m_pwbEdit->GetTxt(szText);
}
/*!
* CWBScreen type definition
*/
IMPLEMENT_DYNAMIC_CLASS( CWBScreen, wxScrolledWindow )
/*!
* CWBScreen event table definition
*/
BEGIN_EVENT_TABLE( CWBScreen, wxScrolledWindow )
////@begin CWBScreen event table entries
EVT_SCROLLWIN_LINEUP( CWBScreen::OnScrLineUp )
EVT_SCROLLWIN_LINEDOWN( CWBScreen::OnScrLineDown )
EVT_SCROLLWIN_PAGEUP( CWBScreen::OnScrPageUp )
EVT_SCROLLWIN_PAGEDOWN( CWBScreen::OnScrPageDown )
EVT_SCROLLWIN_THUMBRELEASE( CWBScreen::OnScrThumbRelease )
EVT_SIZE( CWBScreen::OnSize )
EVT_PAINT( CWBScreen::OnPaint )
////@end CWBScreen event table entries
END_EVENT_TABLE()
/*!
* CWBScreen constructors
*/
CWBScreen::CWBScreen()
{
Init();
}
CWBScreen::CWBScreen(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
Init();
Create(parent, id, pos, size, style);
}
/*!
* CWBScreen creator
*/
bool CWBScreen::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
////@begin CWBScreen creation
wxScrolledWindow::Create(parent, id, pos, size, style);
CreateControls();
////@end CWBScreen creation
return true;
}
/*!
* CWBScreen destructor
*/
CWBScreen::~CWBScreen()
{
////@begin CWBScreen destruction
////@end CWBScreen destruction
}
/*!
* Member initialisation
*/
void CWBScreen::Init()
{
////@begin CWBScreen member initialisation
m_pwbEdit = NULL;
m_EditSizer = NULL;
m_bIsScrolled = false;
////@end CWBScreen member initialisation
}
/*!
* Control creation for CWBScreen
*/
void CWBScreen::CreateControls()
{
////@begin CWBScreen content construction
CWBScreen* itemScrolledWindow48 = this;
this->SetBackgroundColour(wxColour(192, 192, 192));
this->SetScrollbars(1, 1, 0, 0);
m_EditSizer = new wxGridSizer(1, 1, 0, 0);
itemScrolledWindow48->SetSizer(m_EditSizer);
m_pwbEdit = new CWBEdit( itemScrolledWindow48, IDW_WB_EDIT, wxPoint(0, 0), wxSize(A4_WIDTH, A4_HEIGHT), wxSIMPLE_BORDER|wxTAB_TRAVERSAL );
m_pwbEdit->SetBackgroundColour(wxColour(255, 255, 255));
m_pwbEdit->SetControl(ID_WB_POS);
m_EditSizer->Add(m_pwbEdit, 0, wxALIGN_LEFT|wxALIGN_TOP|wxALL, 0);
this->SetMinSize(wxSize(100, 100));
////@end CWBScreen content construction
}
/*!
* Should we show tooltips?
*/
bool CWBScreen::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap CWBScreen::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin CWBScreen bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end CWBScreen bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon CWBScreen::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin CWBScreen icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end CWBScreen icon retrieval
}
void CWBScreen::OnScrLineUp( wxScrollWinEvent& event )
{
AdjScrollPos();
event.Skip();
}
void CWBScreen::OnScrLineDown( wxScrollWinEvent& event )
{
AdjScrollPos();
event.Skip();
}
void CWBScreen::OnScrPageUp( wxScrollWinEvent& event )
{
AdjScrollPos();
event.Skip();
}
void CWBScreen::OnScrPageDown( wxScrollWinEvent& event )
{
AdjScrollPos();
event.Skip();
}
void CWBScreen::OnScrThumbRelease( wxScrollWinEvent& event )
{
AdjScrollPos();
event.Skip();
}
void CWBScreen::OnSize( wxSizeEvent& event )
{
if ( m_bIsScrolled )
{
AdjScrollPos();
Refresh();
}
event.Skip();
}
void CWBScreen::OnPaint( wxPaintEvent& event )
{
wxPaintDC dc(this);
}
void CWBScreen::ScrollWnd(int dx, int dy)
{
int X, Y, nx, ny;
GetScrollPixelsPerUnit(&nx, &ny);
X = (nx > 0) ? (dx / nx) : dx;
Y = (ny > 0) ? (dy / ny) : dx;
Scroll(X, Y);
}
void CWBScreen::AdjScrollPos()
{
if ( GetProcessPtr() )
{
int X, Y, nx, ny;
GetViewStart(&X, &Y);
GetScrollPixelsPerUnit(&nx, &ny);
if (X > 0 || Y > 0)
m_bIsScrolled = true;
else
m_bIsScrolled = false;
GetProcessPtr()->OnScreenSetScrollPos(X*nx, Y*ny);
}
}
/*!
* CWBEdit type definition
*/
IMPLEMENT_DYNAMIC_CLASS( CWBEdit, wxPanel )
/*!
* CWBEdit event table definition
*/
BEGIN_EVENT_TABLE( CWBEdit, wxPanel )
////@begin CWBEdit event table entries
EVT_LEFT_DOWN( CWBEdit::OnLeftDown )
EVT_LEFT_UP( CWBEdit::OnLeftUp )
EVT_MOTION( CWBEdit::OnMotion )
EVT_PAINT( CWBEdit::OnPaint )
EVT_SET_FOCUS( CWBEdit::OnSetFocus )
EVT_TEXT(ID_WB_EDIT_TEXT, CWBEdit::OnCtlTextUpdated)
////@end CWBEdit event table entries
END_EVENT_TABLE()
/*!
* CWBEdit constructors
*/
CWBEdit::CWBEdit()
{
Init();
}
CWBEdit::CWBEdit(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
Init();
Create(parent, id, pos, size, style);
}
/*!
* CWBEdit creator
*/
bool CWBEdit::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
////@begin CWBEdit creation
wxPanel::Create(parent, id, pos, size, style);
CreateControls();
////@end CWBEdit creation
return true;
}
/*!
* CWBEdit destructor
*/
CWBEdit::~CWBEdit()
{
////@begin CWBEdit destruction
if (m_printData)
delete m_printData;
if (m_pageSetupData)
delete m_pageSetupData;
////@end CWBEdit destruction
}
/*!
* Member initialisation
*/
void CWBEdit::Init()
{
////@begin CWBEdit member initialisation
m_scrPosX = 0;
m_scrPosY = 0;
m_bAreaSelected = false;
m_pText = NULL;
////@end CWBEdit member initialisation
}
/*!
* Control creation for CWBEdit
*/
void CWBEdit::CreateControls()
{
////@begin CWBEdit content construction
this->SetBackgroundColour(wxColour(255, 255, 255));
m_curPos = GetCursorResource(wxT("../resource/wb_pos_cur.xpm"));
m_curDel = GetCursorResource(wxT("../resource/wb_del_cur.xpm"));
m_curTxt = GetCursorResource(wxT("../resource/wb_txt_cur.xpm"));
m_curMRK = GetCursorResource(wxT("../resource/wb_mrk_cur.xpm"));
m_curPtr = GetCursorResource(wxT("../resource/wb_ptr_cur.xpm"));
m_curImg = GetCursorResource(wxT("../resource/wb_img_cur.xpm"));
m_curPen = GetCursorResource(wxT("../resource/wb_pen_cur.xpm"));
m_curLin = GetCursorResource(wxT("../resource/wb_lin_cur.xpm"));
m_curSqr = GetCursorResource(wxT("../resource/wb_sqr_cur.xpm"));
m_curSqf = GetCursorResource(wxT("../resource/wb_sqf_cur.xpm"));
m_curCrc = GetCursorResource(wxT("../resource/wb_crc_cur.xpm"));
m_curCrf = GetCursorResource(wxT("../resource/wb_crf_cur.xpm"));
////@end CWBEdit content construction
m_bmpPtr = wxBitmap(wb_ptr_ico);
wxMask* pmask = new wxMask(m_bmpPtr, *wxGREEN);
m_bmpPtr.SetMask(pmask);
m_bmpEdit.Create(A4_WIDTH, A4_HEIGHT);
m_printData = new wxPrintData;
if (m_printData)
{
m_pageSetupData = new wxPageSetupDialogData;
if (m_pageSetupData)
(*m_pageSetupData) = *m_printData;
}
else
{
m_pageSetupData = NULL;
}
wxInitAllImageHandlers();
NewExec(false, true);
}
void CWBEdit::SetControl(int nId)
{
switch (nId)
{
case ID_WB_POS:
m_Cursor = m_curPos;
break;
case ID_WB_DEL:
m_Cursor = m_curDel;
break;
case ID_WB_TXT:
m_Cursor = m_curTxt;
break;
case ID_WB_MRK:
m_Cursor = m_curMRK;
break;
case ID_WB_PTR:
m_Cursor = m_curPtr;
break;
case ID_WB_IMG:
SelImage();
m_Cursor = m_curImg;
break;
case ID_WB_PEN:
m_Cursor = m_curPen;
break;
case ID_WB_LIN:
m_Cursor = m_curLin;
break;
case ID_WB_SQR:
m_Cursor = m_curSqr;
break;
case ID_WB_SQF:
m_Cursor = m_curSqf;
break;
case ID_WB_CRC:
m_Cursor = m_curCrc;
break;
case ID_WB_CRF:
m_Cursor = m_curCrf;
break;
}
SetCursor(m_Cursor);
}
void CWBEdit::SetPenSize(int nId)
{
switch (nId)
{
case ID_WB_LINE1:
m_Pen.SetWidth(1);
break;
case ID_WB_LINE2:
m_Pen.SetWidth(3);
break;
case ID_WB_LINE3:
m_Pen.SetWidth(5);
break;
case ID_WB_LINE4:
m_Pen.SetWidth(7);
break;
}
m_Pen.SetColour(m_Colour);
}
void CWBEdit::SetFrgColour(wxColour& colour)
{
m_Colour = colour;
m_Pen.SetColour(m_Colour);
}
void CWBEdit::SetTxtFont(wxFont& font)
{
m_Font = font;
}
void CWBEdit::DrawArea( PtPos& pt1, PtPos& pt2 )
{
wxClientDC dc(this);
wxPen pen(*wxBLACK, 1, wxDOT);
int oldLogicalFunction = dc.GetLogicalFunction();
wxPen oldPen = dc.GetPen();
dc.SetPen(pen);
dc.SetLogicalFunction( wxEQUIV );
dc.DrawRectangle(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);
dc.DrawRectangle(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);
m_AreaPos1.SetAttr( pt1.X, pt1.Y );
m_AreaPos2.SetAttr( pt2.X, pt2.Y );
dc.SetLogicalFunction(oldLogicalFunction);
dc.SetPen(oldPen);
m_bAreaSelected = true;
}
void CWBEdit::KillArea( )
{
if (m_bAreaSelected)
{
int difx = (m_AreaPos1.X < m_AreaPos2.X) ? 1 : -1;
int dify = (m_AreaPos1.Y < m_AreaPos2.Y) ? 1 : -1;
wxRect rc(m_AreaPos1.X - difx, m_AreaPos1.Y - dify, m_AreaPos2.X - m_AreaPos1.X + 2, m_AreaPos2.Y - m_AreaPos1.Y + 2);
m_bAreaSelected = false;
RefreshRect(rc);
m_AreaPos1.SetAttr( 0, 0 );
m_AreaPos2.SetAttr( 0, 0 );
}
}
void CWBEdit::Repaint( )
{
wxClientDC dc(this);
dc.DrawBitmap(m_bmpEdit, 0, 0);
}
void CWBEdit::DrawRect( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bFull, WB_BYTE flags )
{
wxClientDC dc(this);
wxColour ctlColor(color.cdRed, color.cdGreen, color.cdBlue);
wxPen ctlPen(ctlColor, nLin, wxSOLID);
wxBrush brush(ctlColor);
RcPos rect;
wxMemoryDC memdc;
memdc.SelectObject( m_bmpEdit );
if (bFull)
memdc.SetBrush(brush);
else
memdc.SetBrush(*wxTRANSPARENT_BRUSH);
memdc.SetLogicalFunction( wxCOPY );
memdc.SetPen(ctlPen);
if (flags & DC_AUTOSCROLL)
{
rect.SetAttr(pt1.X, pt1.Y, pt2.X, pt2.Y);
AdjScroll(rect);
}
memdc.DrawRectangle(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);
memdc.SelectObject( wxNullBitmap );
m_bAreaSelected = false;
m_AreaPos1.SetAttr(0, 0);
m_AreaPos2.SetAttr(0, 0);
if (flags & DC_REPAINT)
dc.DrawBitmap(m_bmpEdit, 0, 0);
}
void CWBEdit::DrawEllipse( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bFull, WB_BYTE flags )
{
wxClientDC dc(this);
wxColour ctlColor(color.cdRed, color.cdGreen, color.cdBlue);
wxPen ctlPen(ctlColor, nLin, wxSOLID);
wxBrush brush(ctlColor);
RcPos rect;
wxMemoryDC memdc;
memdc.SelectObject( m_bmpEdit );
if (bFull)
memdc.SetBrush(brush);
else
memdc.SetBrush(*wxTRANSPARENT_BRUSH);
memdc.SetLogicalFunction( wxCOPY );
memdc.SetPen(ctlPen);
if (flags & DC_AUTOSCROLL)
{
rect.SetAttr(pt1.X, pt1.Y, pt2.X, pt2.Y);
AdjScroll(rect);
}
memdc.DrawEllipse(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);
memdc.SelectObject( wxNullBitmap );
m_bAreaSelected = false;
m_AreaPos1.SetAttr(0, 0);
m_AreaPos2.SetAttr(0, 0);
if (flags & DC_REPAINT)
dc.DrawBitmap(m_bmpEdit, 0, 0);
}
void CWBEdit::DrawLine( PtPos& pt1, PtPos& pt2, int nLin, ColorDef& color, bool bMask, WB_BYTE flags )
{
wxClientDC dc(this);
wxColour ctlColor(color.cdRed, color.cdGreen, color.cdBlue);
wxPen ctlPen(ctlColor, nLin, wxSOLID);
RcPos rect;
wxMemoryDC memdc;
memdc.SelectObject( m_bmpEdit );
if (bMask)
memdc.SetLogicalFunction( wxAND );
else
memdc.SetLogicalFunction( wxCOPY );
memdc.SetPen(ctlPen);
if (flags & DC_AUTOSCROLL)
{
rect.SetAttr(pt1.X, pt1.Y, pt2.X, pt2.Y);
AdjScroll(rect);
}
memdc.DrawLine(pt1.X, pt1.Y, pt2.X, pt2.Y);
memdc.SelectObject( wxNullBitmap );
m_bAreaSelected = false;
m_AreaPos1.SetAttr(0, 0);
m_AreaPos2.SetAttr(0, 0);
if (flags & DC_REPAINT)
dc.DrawBitmap(m_bmpEdit, 0, 0);
}
void CWBEdit::DrawIndicator( PtPos& pt, WB_BYTE flags )
{
wxClientDC dc(this);
RcPos rect;
wxMemoryDC memdc;
memdc.SelectObject( m_bmpEdit );
wxIcon icoPtr;
icoPtr.CopyFromBitmap(m_bmpPtr);
if (flags & DC_AUTOSCROLL)
{
rect.SetAttr(pt.X - PTR_WIDTH, pt.Y - PTR_HEIGHT, pt.X, pt.Y);
AdjScroll(rect);
}
// Para manter a compatibilidade com a versão anterior
memdc.DrawIcon(icoPtr, pt.X - PTR_WIDTH, pt.Y - PTR_HEIGHT);
memdc.SelectObject( wxNullBitmap );
if (flags & DC_REPAINT)
dc.DrawBitmap(m_bmpEdit, 0, 0);
}
void CWBEdit::DrawImage( WB_PCSTR szFile, PtPos& pt1, PtPos& pt2, WB_BYTE flags )
{
wxClientDC dc(this);
RcPos rect;
wxBitmap bmpImage;
int imgWidth, imgHeight;
int edtWidth = 0;
int edtHeight = 0;
wxString strFile = wxString::FromAscii(szFile);
wxMemoryDC memdc;
memdc.SelectObject( m_bmpEdit );
GetClientSize(&edtWidth, &edtHeight);
strFile.FromAscii(szFile);
wxString extension;
wxFileName::SplitPath(strFile, NULL, NULL, &extension);
if ( extension.Lower() == _T("bmp") )
{
bmpImage.LoadFile(strFile, wxBITMAP_TYPE_BMP);
}
else if ( extension.Lower() == _T("jpg") )
{
bmpImage.LoadFile(strFile, wxBITMAP_TYPE_JPEG);
}
// Calcula largura e altura, considerando a área de edição
imgWidth = edtWidth - pt1.X;
imgHeight = edtHeight - pt1.Y;
if (imgWidth < bmpImage.GetWidth() || imgHeight < bmpImage.GetHeight())
{
float fw, fh;
if (imgWidth < bmpImage.GetWidth())
fw = (float)imgWidth / (float)bmpImage.GetWidth();
else
fw = 1;
if (imgHeight < bmpImage.GetHeight())
fh = (float)imgHeight / (float)bmpImage.GetHeight();
else
fh = 1;
if (fw < fh)
{
imgWidth = (int) (bmpImage.GetWidth() * fw);
imgHeight = (int) (bmpImage.GetHeight() * fw);
}
else
{
imgWidth = (int) (bmpImage.GetWidth() * fh);
imgHeight = (int) (bmpImage.GetHeight() * fh);
}
wxImage image = bmpImage.ConvertToImage();
bmpImage = wxBitmap(image.Scale(imgWidth, imgHeight));
}
else
{
imgWidth = bmpImage.GetWidth();
imgHeight = bmpImage.GetHeight();
}
if (flags & DC_AUTOSCROLL)
{
rect.SetAttr(pt1.X, pt1.Y, pt2.X, pt2.Y);
AdjScroll(rect);
}
memdc.DrawBitmap(bmpImage, pt1.X, pt1.Y);
memdc.SelectObject( wxNullBitmap );
if (flags & DC_REPAINT)
dc.DrawBitmap(m_bmpEdit, 0, 0);
}
void CWBEdit::EditTxt( PtPos& pt1, PtPos& pt2, FontDef& font, ColorDef& color )
{
m_bAreaSelected = false;
m_AreaPos1.SetAttr(0, 0);
m_AreaPos2.SetAttr(0, 0);
m_pText = new wxTextCtrl( this, ID_WB_EDIT_TEXT, _T(""), wxPoint(pt1.X, pt1.Y),
wxSize(pt2.X - pt1.X + SB_SIZE, pt2.Y - pt1.Y), wxALIGN_LEFT|wxTE_MULTILINE|wxSIMPLE_BORDER );
if (m_pText)
{
m_pText->Show();
m_pText->SetFocus();
m_pText->SetBackgroundColour(wxColour(255, 255, 255));
m_pText->SetForegroundColour(wxColour(color.cdRed, color.cdGreen, color.cdBlue));
m_pText->SetFont(GetTextFont(font));
}
}
void CWBEdit::GetTxt( WB_PSTR szText )
{
if (szText)
{
wxString text;
if (m_pText)
{
text = m_pText->GetValue();
strcpy(szText, text.ToAscii());
}
else
{
szText[0] = '\0';
}
}
}
void CWBEdit::DrawTxt( WB_PCSTR szText, PtPos& pt1, PtPos& pt2, FontDef& font, ColorDef& color, WB_BYTE flags )
{
wxClientDC dc(this);
RcPos rect;
wxString text = wxString::FromAscii(szText);
wxMemoryDC memdc;
memdc.SelectObject( m_bmpEdit );
if (flags & DC_AUTOSCROLL)
{
rect.SetAttr(pt1.X, pt1.Y, pt2.X, pt2.Y);
AdjScroll(rect);
}
if (m_pText)
{
delete m_pText;
m_pText = NULL;
}
if (!text.IsEmpty())
{
wxRect rcTxt;
wxString wraptxt;
rcTxt = wxRect(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);
memdc.SetBrush(*wxTRANSPARENT_BRUSH);
memdc.SetTextForeground(wxColour(color.cdRed, color.cdGreen, color.cdBlue));
memdc.SetFont(GetTextFont(font));
WrapText(text, memdc, rcTxt, wraptxt);
memdc.DrawLabel(wraptxt, rcTxt);
}
memdc.SelectObject( wxNullBitmap );
if (flags & DC_REPAINT)
dc.DrawBitmap(m_bmpEdit, 0, 0);
}
bool CWBEdit::NewExec( bool bChanged, bool bRepaint )
{
bool bNew = true;
if (bChanged)
{
if (wxMessageBox(_("The document was not saved. Proceed?"), _("White Board"),
wxYES_NO | wxICON_QUESTION, this) == wxNO)
{
bNew = false;
}
}
if (bNew)
{
RcPos rect;
wxClientDC dc(this);
wxMemoryDC memdc;
memdc.SelectObject( m_bmpEdit );
memdc.SetBrush( *wxWHITE_BRUSH );
memdc.SetPen( *wxWHITE_PEN );
memdc.DrawRectangle(0, 0, A4_WIDTH, A4_HEIGHT);
memdc.SelectObject( wxNullBitmap );
rect.SetAttr(0, 0, 0, 0);
AdjScroll(rect);
if (bRepaint)
dc.DrawBitmap( m_bmpEdit, 0, 0 );
}
return bNew;
}
void CWBEdit::SaveExec( )
{
#if wxUSE_FILEDLG
wxImage image = m_bmpEdit.ConvertToImage();
Enable(false);
wxString savefilename = wxFileSelector( _("Save"),
wxEmptyString,
wxEmptyString,
(const wxChar *)NULL,
wxT("BMP (*.bmp)|*.bmp|")
wxT("JPEG (*.jpg)|*.jpg"),
wxFD_SAVE,
this);
if ( savefilename.empty() )
return;
wxString extension;
wxFileName::SplitPath(savefilename, NULL, NULL, &extension);
if ( extension.Lower() == _T("bmp") )
{
image.SaveFile(savefilename, wxBITMAP_TYPE_BMP);
}
else if ( extension.Lower() == _T("jpg") )
{
image.SaveFile(savefilename, wxBITMAP_TYPE_JPEG);
}
Enable(true);
#endif // wxUSE_FILEDLG
}
void CWBEdit::PrintExec( )
{
wxPrintDialogData printDialogData(*m_printData);
wxPrinter printer(&printDialogData);
CWBPrintout printout(_("IP.TV White Board"));
printout.SetPageSetupData(m_pageSetupData);
printout.SetPageImage(&m_bmpEdit);
Enable(false);
if (!printer.Print(this, &printout, true))
{
if (wxPrinter::GetLastError() == wxPRINTER_ERROR)
wxMessageBox(_("There was a problem printing.\nPerhaps your current printer is not set correctly?"), _("Printing"), wxOK);
else
wxMessageBox(_("You canceled printing"), _("Printing"), wxOK);
}
else
{
(*m_printData) = printer.GetPrintDialogData().GetPrintData();
}
Enable(true);
}
void CWBEdit::PageSetup( )
{
(*m_pageSetupData) = *m_printData;
wxPageSetupDialog pageSetupDialog(this, m_pageSetupData);
pageSetupDialog.ShowModal();
(*m_printData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
(*m_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
}
void CWBEdit::CutExec( )
{
if (m_bAreaSelected)
{
if (GetProcessPtr())
GetProcessPtr()->OnEditCutArea(m_AreaPos1, m_AreaPos2);
}
}
void CWBEdit::SelArea( PtPos& pt1, PtPos& pt2 )
{
wxClientDC dc(this);
wxPen pen(*wxBLACK, 1, wxDOT);
int oldLogicalFunction = dc.GetLogicalFunction();
wxPen oldPen = dc.GetPen();
dc.SetLogicalFunction( wxEQUIV );
dc.SetPen(pen);
dc.DrawRectangle(m_AreaPos1.X, m_AreaPos1.Y, m_AreaPos2.X - m_AreaPos1.X, m_AreaPos2.Y - m_AreaPos1.Y);
dc.DrawRectangle(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);
m_AreaPos1.SetAttr( pt1.X, pt1.Y );
m_AreaPos2.SetAttr( pt2.X, pt2.Y );
dc.SetLogicalFunction(oldLogicalFunction);
dc.SetPen(oldPen);
}
void CWBEdit::SelRect( PtPos& pt1, PtPos& pt2 )
{
wxClientDC dc(this);
wxPen pen(*wxBLACK, 1);
int oldLogicalFunction = dc.GetLogicalFunction();
wxPen oldPen = dc.GetPen();
dc.SetLogicalFunction( wxEQUIV );
dc.SetPen(pen);
dc.DrawRectangle(m_AreaPos1.X, m_AreaPos1.Y, m_AreaPos2.X - m_AreaPos1.X, m_AreaPos2.Y - m_AreaPos1.Y);
dc.DrawRectangle(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);
m_AreaPos1.SetAttr( pt1.X, pt1.Y );
m_AreaPos2.SetAttr( pt2.X, pt2.Y );
dc.SetLogicalFunction(oldLogicalFunction);
dc.SetPen(oldPen);
}
void CWBEdit::SelEllipse( PtPos& pt1, PtPos& pt2 )
{
wxClientDC dc(this);
wxPen pen(*wxBLACK, 1);
int oldLogicalFunction = dc.GetLogicalFunction();
wxPen oldPen = dc.GetPen();
dc.SetLogicalFunction( wxEQUIV );
dc.SetPen(pen);
dc.DrawEllipse(m_AreaPos1.X, m_AreaPos1.Y, m_AreaPos2.X - m_AreaPos1.X, m_AreaPos2.Y - m_AreaPos1.Y);
dc.DrawEllipse(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);
m_AreaPos1.SetAttr( pt1.X, pt1.Y );
m_AreaPos2.SetAttr( pt2.X, pt2.Y );
dc.SetLogicalFunction(oldLogicalFunction);
dc.SetPen(oldPen);
}
void CWBEdit::SelLine( PtPos& pt1, PtPos& pt2 )
{
wxClientDC dc(this);
wxPen pen(*wxBLACK, 1);
int oldLogicalFunction = dc.GetLogicalFunction();
wxPen oldPen = dc.GetPen();
dc.SetLogicalFunction( wxEQUIV );
dc.SetPen(pen);
dc.DrawLine(m_AreaPos1.X, m_AreaPos1.Y, m_AreaPos2.X, m_AreaPos2.Y);
dc.DrawLine(pt1.X, pt1.Y, pt2.X, pt2.Y);
m_AreaPos1.SetAttr( pt1.X, pt1.Y );
m_AreaPos2.SetAttr( pt2.X, pt2.Y );
dc.SetLogicalFunction(oldLogicalFunction);
dc.SetPen(oldPen);
}
bool CWBEdit::SelImage( )
{
bool ret = false;
#if wxUSE_FILEDLG
Enable(false);
wxString openfilename = wxFileSelector( _("Open"),
wxEmptyString,
wxEmptyString,
(const wxChar *)NULL,
wxT("BMP (*.bmp)|*.bmp|")
wxT("JPEG (*.jpg)|*.jpg"),
wxFD_OPEN|wxFD_FILE_MUST_EXIST,
this);
if ( openfilename.empty() )
return ret;
if (GetProcessPtr())
{
GetProcessPtr()->OnToolBoxImageSel( openfilename.ToAscii() );
ret = true;
}
Enable(true);
#endif // wxUSE_FILEDLG
return ret;
}
void CWBEdit::SetScrollPos( int posx, int posy )
{
m_scrPosX = posx;
m_scrPosY = posy;
AdjClipRect();
}
/*!
* Should we show tooltips?
*/
bool CWBEdit::ShowToolTips()
{
return true;
}
wxFont CWBEdit::GetTextFont(FontDef& fd)
{
wxFont fnSel;
if ( fd.fdName[0] != '\0' )
{
wxString name = wxString::FromAscii(fd.fdName);
fnSel.SetFaceName(name);
fnSel.SetPointSize(fd.fdSize);
if (fd.fdEffect & FD_UNDERLINE)
fnSel.SetUnderlined(true);
if (fd.fdEffect & FD_ITALIC)
fnSel.SetStyle(wxFONTSTYLE_ITALIC);
if (fd.fdEffect & FD_BOLD)
fnSel.SetWeight(wxFONTWEIGHT_BOLD);
}
else
{
fnSel = GetFont();
fnSel.SetPointSize(FONT_SIZE_DEF);
}
return fnSel;
}
void CWBEdit::WrapText(const wxString& src, wxDC& dc, wxRect& rect, wxString& dest)
{
int cpos = 0;
int fpos = 0;
int lspc = -1;
int nlin = 1;
dest.Clear();
if (!src.IsEmpty())
{
wxString line;
wxSize lsize;
bool bEnter = false;
while (cpos < (int)src.Len())
{
dest.Append(src.GetChar(cpos));
if ( wxString(dest.Last()) == _T(" ") )
{
if (bEnter)
{
bEnter = false;
lspc = cpos;
}
}
else
{
bEnter = true;
}
line = dest.Mid(fpos);
lsize = dc.GetTextExtent(line);
if (lsize.GetWidth() > rect.GetWidth())
{
if (lspc >= 0)
{
dest.Remove(lspc);
dest.Append(_T("\n"));
cpos = lspc;
fpos = cpos + 1;
lspc = -1;
nlin++;
}
}
if ( (nlin * lsize.GetHeight()) > rect.GetWidth() )
{
cpos = (int) src.Len();
}
cpos++;
}
}
}
void CWBEdit::AdjClipRect()
{
wxWindow* pwnd = GetParent();
if (pwnd)
{
int cx, cy, width, height;
wxRect rc = GetRect();
pwnd->GetClientSize(&cx, &cy);
if (rc.GetWidth() < (m_scrPosX+cx))
width = rc.GetWidth() - m_scrPosX;
else
width = cx;
if (rc.GetHeight() < (m_scrPosY+cy))
height = rc.GetHeight() - m_scrPosY;
else
height = cy;
m_rcClipRect = wxRect(m_scrPosX, m_scrPosY, width, height);
}
}
void CWBEdit::AdjScroll(RcPos& rc)
{
wxWindow* pwnd = GetParent();
if (pwnd)
{
int cx, cy, cr, cb;
int dx = 0;
int dy = 0;
pwnd->GetClientSize(&cx, &cy);
cr = m_scrPosX + cx;
cb = m_scrPosY + cy;
if (rc.Left < m_scrPosX || rc.Right < m_scrPosX)
{
if (rc.Left < rc.Right)
dx = rc.Left - m_scrPosX;
else
dx = rc.Right - m_scrPosX;
}
else if (rc.Left > cr || rc.Right > cr)
{
if (rc.Left > rc.Right)
dx = rc.Left - cr;
else
dx = rc.Right - cr;
}
if (rc.Top < m_scrPosY || rc.Bottom < m_scrPosY)
{
if (rc.Top < rc.Bottom)
dy = rc.Top - m_scrPosY;
else
dy = rc.Bottom - m_scrPosY;
}
else if (rc.Top > cb || rc.Bottom > cb)
{
if (rc.Top > rc.Bottom)
dy = rc.Top - cb;
else
dy = rc.Bottom - cb;
}
if (dx != 0 || dy != 0)
{
m_scrPosX += dx;
m_scrPosY += dy;
if ( m_scrPosX < 0 )
m_scrPosX = 0;
if ( m_scrPosY < 0 )
m_scrPosY = 0;
AdjClipRect();
if (GetProcessPtr())
GetProcessPtr()->OnScreenScrollWindow( m_scrPosX, m_scrPosY );
}
}
}
/*!
* Get bitmap resources
*/
wxBitmap CWBEdit::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin CWBEdit bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end CWBEdit bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon CWBEdit::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin CWBEdit icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end CWBEdit icon retrieval
}
wxCursor CWBEdit::GetCursorResource( const wxString& name )
{
// Icon retrieval
////@begin CWBEdit cursor retrieval
wxImage image;
if (name == _T("../resource/wb_del_cur.xpm"))
{
image = wxImage(wb_del_cur);
}
else if (name == _T("../resource/wb_txt_cur.xpm"))
{
image = wxImage(wb_txt_cur);
}
else if (name == _T("../resource/wb_mrk_cur.xpm"))
{
image = wxImage(wb_mrk_cur);
}
else if (name == _T("../resource/wb_pen_cur.xpm"))
{
image = wxImage(wb_pen_cur);
}
else if (name == _T("../resource/wb_ptr_cur.xpm"))
{
image = wxImage(wb_ptr_cur);
}
else if (name == _T("../resource/wb_img_cur.xpm"))
{
image = wxImage(wb_img_cur);
}
else if (name == _T("../resource/wb_lin_cur.xpm"))
{
image = wxImage(wb_lin_cur);
}
else if (name == _T("../resource/wb_sqr_cur.xpm"))
{
image = wxImage(wb_sqr_cur);
}
else if (name == _T("../resource/wb_sqf_cur.xpm"))
{
image = wxImage(wb_sqf_cur);
}
else if (name == _T("../resource/wb_crc_cur.xpm"))
{
image = wxImage(wb_crc_cur);
}
else if (name == _T("../resource/wb_crf_cur.xpm"))
{
image = wxImage(wb_crf_cur);
}
else
{
image = wxImage(wb_pos_cur);
}
image.SetMaskColour(0, 255, 0);
wxCursor cursor(image);
return cursor;
////@end CWBEdit cursor retrieval
}
/*!
* wxEVT_LEFT_DOWN event handler for IDW_WB_EDIT
*/
void CWBEdit::OnLeftDown( wxMouseEvent& event )
{
if (!m_bAreaSelected)
{
m_AreaPos1.SetAttr( 0, 0 );
m_AreaPos2.SetAttr( 0, 0 );
}
if ( GetProcessPtr() )
{
PtPos pos;
pos.SetAttr( event.GetX(), event.GetY() );
GetProcessPtr()->OnMouseLButtonDown( WB_KEY_NONE, pos );
}
CaptureMouse();
event.Skip();
}
/*!
* wxEVT_LEFT_UP event handler for IDW_WB_EDIT
*/
void CWBEdit::OnLeftUp( wxMouseEvent& event )
{
if (HasCapture())
ReleaseMouse();
if ( GetProcessPtr() )
{
PtPos pos;
pos.SetAttr( event.GetX(), event.GetY() );
GetProcessPtr()->OnMouseLButtonUp( WB_KEY_NONE, pos );
}
event.Skip();
}
/*!
* wxEVT_MOTION event handler for IDW_WB_EDIT
*/
void CWBEdit::OnMotion( wxMouseEvent& event )
{
MouseFlag flag;
PtPos pos;
if ( event.LeftIsDown() )
flag = WB_KEY_LBUTTON;
else
flag = WB_KEY_NONE;
if (flag == WB_KEY_LBUTTON)
{
int cx, cy;
int posX = event.GetX();
int posY = event.GetY();
GetClientSize(&cx, &cy);
if ( posX < 0 )
posX = 0;
else if ( posX > cx )
posX = cx;
if ( posY < 0 )
posY = 0;
else if ( posY > cy )
posY = cy;
if ( GetProcessPtr() )
{
int scrX = 0;
int scrY = 0;
if ( posX < m_rcClipRect.GetRight() && posX >= (m_rcClipRect.GetRight() - DIF_SCROLL) )
scrX++;
else if ( m_rcClipRect.GetLeft() > 0 && posX <= (m_rcClipRect.GetLeft() + DIF_SCROLL) )
scrX--;
if ( posY < m_rcClipRect.GetBottom() && posY >= (m_rcClipRect.GetBottom() - DIF_SCROLL) )
scrY++;
else if ( m_rcClipRect.GetTop() > 0 && posY <= (m_rcClipRect.GetTop() + DIF_SCROLL) )
scrY--;
if ( scrX != 0 || scrY != 0 )
{
m_scrPosX += scrX * DIF_SCROLL;
m_scrPosY += scrY * DIF_SCROLL;
if ( m_scrPosX < 0 )
m_scrPosX = 0;
if ( m_scrPosY < 0 )
m_scrPosY = 0;
AdjClipRect();
GetProcessPtr()->OnScreenScrollWindow( m_scrPosX, m_scrPosY );
WarpPointer(posX, posY);
}
pos.SetAttr( posX, posY );
GetProcessPtr()->OnMouseMove( flag, pos );
}
}
else
{
if ( GetProcessPtr() )
{
pos.SetAttr( event.GetX(), event.GetY() );
GetProcessPtr()->OnMouseMove( flag, pos );
}
}
event.Skip();
}
void CWBEdit::OnPaint( wxPaintEvent& event )
{
wxPaintDC dc(this);
dc.DrawBitmap(m_bmpEdit, 0, 0);
if (m_bAreaSelected)
{
wxPen pen(*wxBLACK, 1, wxDOT);
int oldLogicalFunction = dc.GetLogicalFunction();
wxPen oldPen = dc.GetPen();
dc.SetPen(pen);
dc.SetLogicalFunction( wxEQUIV );
dc.DrawRectangle(m_AreaPos1.X, m_AreaPos1.Y, m_AreaPos2.X - m_AreaPos1.X, m_AreaPos2.Y - m_AreaPos1.Y);
dc.SetLogicalFunction(oldLogicalFunction);
dc.SetPen(oldPen);
}
}
void CWBEdit::OnSetFocus( wxFocusEvent& event )
{
if (GetProcessPtr())
GetProcessPtr()->OnScreenScrollWindow(m_scrPosX, m_scrPosY);
AdjClipRect();
event.Skip();
}
void CWBEdit::OnCtlTextUpdated( wxCommandEvent &event )
{
if (m_pText)
{
wxString text = m_pText->GetValue();
// Se o último caracter for ENTER, elimina da string
if (text.Right(1) == _T("\n"))
{
text.RemoveLast();
m_pText->ChangeValue(text);
m_pText->SetInsertionPointEnd();
}
}
event.Skip();
}
//////////////////////////////////////////////////////////////
// CWBPrintout Class
CWBPrintout::CWBPrintout(const wxChar *title) : wxPrintout( title )
{
m_pageSetupData = NULL;
m_bmpImage = NULL;
}
bool CWBPrintout::OnPrintPage(int page)
{
bool ret = false;
wxDC *dc = GetDC();
if (dc)
{
DrawPage();
ret = true;
}
else
{
ret = false;
}
return ret;
}
bool CWBPrintout::OnBeginDocument(int startPage, int endPage)
{
bool ret = true;
if (!wxPrintout::OnBeginDocument(startPage, endPage))
ret = false;
return ret;
}
void CWBPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
{
*minPage = 1;
*maxPage = 1;
*selPageFrom = 1;
*selPageTo = 1;
}
bool CWBPrintout::HasPage(int pageNum)
{
return (pageNum == 1);
}
void CWBPrintout::DrawPage()
{
wxDC *dc = GetDC();
if (dc && m_pageSetupData && m_bmpImage)
{
// Valores máximos para a área de edição
wxCoord maxX = A4_WIDTH;
wxCoord maxY = A4_HEIGHT;
// Ajusta as dimensões da área de edição ao papel selecionado
FitThisSizeToPageMargins(wxSize(maxX, maxY), *m_pageSetupData);
wxRect fitRect = GetLogicalPageMarginsRect(*m_pageSetupData);
// Centraliza a área de edição
wxCoord xoff = (fitRect.width - maxX) / 2;
wxCoord yoff = (fitRect.height - maxY) / 2;
OffsetLogicalOrigin(xoff, yoff);
// Imprime a imagem
dc->DrawBitmap(*m_bmpImage, 0, 0);
}
}
| [
"heineck@c016ff2c-3db2-11de-a81c-fde7d73ceb89"
] | [
[
[
1,
3908
]
]
] |
f266a45242b1303d187555a69dd62e34231efa7d | a8e78ee1cae74946b8b68aaaf0447d745d6fbaf3 | /CPPUnitBCB6/borland/TestRunner/TestRunner.h | 861933de1af23977fc26347ab1697d584fc1706d | [] | no_license | jmnavarro/BCB_CPPUnit | 66c155026bd8445ca016e1327b0d222e3f4a10ad | 7de1560d537db56d265fde482420bc6f66f01c32 | refs/heads/master | 2021-01-23T13:58:57.815624 | 2011-07-01T08:47:23 | 2011-07-01T08:47:23 | 1,982,570 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 224 | h | #ifndef TestRunnerH
#define TestRunnerH
#include "Test.h"
class TestRunner
{
public:
TestRunner();
virtual ~TestRunner();
void run();
void addTest(Test*);
private:
TestList m_tests;
};
#endif
| [
"[email protected]"
] | [
[
[
1,
20
]
]
] |
3775250da0918853884ad3af68c819b7f01514bd | 6629f18d84dc8d5a310b95fedbf5be178b00da92 | /SDK-2008-05-27/foobar2000/SDK/service.h | ac1c7d66ca265c7c4c674c759aa9c6062bff424e | [] | no_license | thenfour/WMircP | 317f7b36526ebf8061753469b10f164838a0a045 | ad6f4d1599fade2ae4e25656a95211e1ca70db31 | refs/heads/master | 2021-01-01T17:42:20.670266 | 2008-07-11T03:10:48 | 2008-07-11T03:10:48 | 16,931,152 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,738 | h | #ifndef _foobar2000_sdk_service_h_included_
#define _foobar2000_sdk_service_h_included_
typedef const void* service_class_ref;
PFC_DECLARE_EXCEPTION(exception_service_not_found,pfc::exception,"Service not found");
PFC_DECLARE_EXCEPTION(exception_service_extension_not_found,pfc::exception,"Service extension not found");
PFC_DECLARE_EXCEPTION(exception_service_duplicated,pfc::exception,"Service duplicated");
#ifdef _MSC_VER
#define FOOGUIDDECL __declspec(selectany)
#else
#define FOOGUIDDECL
#endif
#define DECLARE_GUID(NAME,A,S,D,F,G,H,J,K,L,Z,X) FOOGUIDDECL const GUID NAME = {A,S,D,{F,G,H,J,K,L,Z,X}};
#define DECLARE_CLASS_GUID(NAME,A,S,D,F,G,H,J,K,L,Z,X) FOOGUIDDECL const GUID NAME::class_guid = {A,S,D,{F,G,H,J,K,L,Z,X}};
//! Special hack to ensure errors when someone tries to ->service_add_ref()/->service_release() on a service_ptr_t
template<typename T> class service_obscure_refcounting : public T {
private:
int service_add_ref() throw();
int service_release() throw();
};
//! Converts a service interface pointer to a pointer that obscures service counter functionality.
template<typename T> static inline service_obscure_refcounting<T>* service_obscure_refcounting_cast(T * p_source) throw() {return static_cast<service_obscure_refcounting<T>*>(p_source);}
//Must be templated instead of taking service_base* because of multiple inheritance issues.
template<typename T> static void service_release_safe(T * p_ptr) throw() {
if (p_ptr != NULL) PFC_ASSERT_NO_EXCEPTION( p_ptr->service_release() );
}
//Must be templated instead of taking service_base* because of multiple inheritance issues.
template<typename T> static void service_add_ref_safe(T * p_ptr) throw() {
if (p_ptr != NULL) PFC_ASSERT_NO_EXCEPTION( p_ptr->service_add_ref() );
}
class service_base;
//! Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
template<typename T>
class service_ptr_t {
private:
typedef service_ptr_t<T> t_self;
public:
inline service_ptr_t() throw() : m_ptr(NULL) {}
inline service_ptr_t(T* p_ptr) throw() : m_ptr(NULL) {copy(p_ptr);}
inline service_ptr_t(const t_self & p_source) throw() : m_ptr(NULL) {copy(p_source);}
template<typename t_source>
inline service_ptr_t(t_source * p_ptr) throw() : m_ptr(NULL) {copy(p_ptr);}
template<typename t_source>
inline service_ptr_t(const service_ptr_t<t_source> & p_source) throw() : m_ptr(NULL) {copy(p_source);}
inline ~service_ptr_t() throw() {service_release_safe(m_ptr);}
template<typename t_source>
void copy(t_source * p_ptr) throw() {
service_add_ref_safe(p_ptr);
service_release_safe(m_ptr);
m_ptr = pfc::safe_ptr_cast<T>(p_ptr);
}
template<typename t_source>
inline void copy(const service_ptr_t<t_source> & p_source) throw() {copy(p_source.get_ptr());}
inline const t_self & operator=(const t_self & p_source) throw() {copy(p_source); return *this;}
inline const t_self & operator=(T * p_ptr) throw() {copy(p_ptr); return *this;}
template<typename t_source> inline t_self & operator=(const service_ptr_t<t_source> & p_source) throw() {copy(p_source); return *this;}
template<typename t_source> inline t_self & operator=(t_source * p_ptr) throw() {copy(p_ptr); return *this;}
inline void release() throw() {
service_release_safe(m_ptr);
m_ptr = NULL;
}
inline service_obscure_refcounting<T>* operator->() const throw() {PFC_ASSERT(m_ptr != NULL);return service_obscure_refcounting_cast(m_ptr);}
inline T* get_ptr() const throw() {return m_ptr;}
inline bool is_valid() const throw() {return m_ptr != NULL;}
inline bool is_empty() const throw() {return m_ptr == NULL;}
inline bool operator==(const t_self & p_item) const throw() {return m_ptr == p_item.get_ptr();}
inline bool operator!=(const t_self & p_item) const throw() {return m_ptr != p_item.get_ptr();}
inline bool operator>(const t_self & p_item) const throw() {return m_ptr > p_item.get_ptr();}
inline bool operator<(const t_self & p_item) const throw() {return m_ptr < p_item.get_ptr();}
template<typename t_other>
inline t_self & operator<<(service_ptr_t<t_other> & p_source) throw() {attach(p_source.detach());return *this;}
template<typename t_other>
inline t_self & operator>>(service_ptr_t<t_other> & p_dest) throw() {p_dest.attach(detach());return *this;}
inline T* __unsafe_duplicate() const throw() {//should not be used ! temporary !
service_add_ref_safe(m_ptr);
return m_ptr;
}
inline T* detach() throw() {
return pfc::replace_null_t(m_ptr);
}
template<typename t_source>
inline void attach(t_source * p_ptr) throw() {
service_release_safe(m_ptr);
m_ptr = pfc::safe_ptr_cast<T>(p_ptr);
}
T & operator*() const throw() {return *m_ptr;}
service_ptr_t<service_base> & _as_base_ptr() {
PFC_ASSERT( _as_base_ptr_check() );
return *reinterpret_cast<service_ptr_t<service_base>*>(this);
}
static bool _as_base_ptr_check() {
return static_cast<service_base*>((T*)NULL) == reinterpret_cast<service_base*>((T*)NULL);
}
private:
T* m_ptr;
};
namespace pfc {
template<typename T>
class traits_t<service_ptr_t<T> > : public traits_default {
public:
enum { realloc_safe = true, constructor_may_fail = false};
};
}
template<typename T, template<typename> class t_alloc = pfc::alloc_fast>
class service_list_t : public pfc::list_t<service_ptr_t<T>, t_alloc >
{
};
//! Helper macro for use when defining a service class. Generates standard features of a service, without ability to register using service_factory / enumerate using service_enum_t. \n
//! This is used for declaring services that are meant to be instantiated by means other than service_enum_t (or non-entrypoint services), or extensions of services (including extension of entrypoint services). \n
//! Sample non-entrypoint declaration: class myclass : public service_base {...; FB2K_MAKE_SERVICE_INTERFACE(myclass, service_base); }; \n
//! Sample extension declaration: class myclass : public myotherclass {...; FB2K_MAKE_SERVICE_INTERFACE(myclass, myotherclass); }; \n
//! This macro is intended for use ONLY WITH INTERFACE CLASSES, not with implementation classes.
#define FB2K_MAKE_SERVICE_INTERFACE(THISCLASS,PARENTCLASS) \
public: \
typedef THISCLASS t_interface; \
typedef PARENTCLASS t_interface_parent; \
\
static const GUID class_guid; \
\
virtual bool service_query(service_ptr_t<service_base> & p_out,const GUID & p_guid) { \
if (p_guid == class_guid) {p_out = this; return true;} \
else return PARENTCLASS::service_query(p_out,p_guid); \
} \
typedef service_ptr_t<t_interface> ptr; \
protected: \
THISCLASS() {} \
~THISCLASS() {} \
private: \
const THISCLASS & operator=(const THISCLASS &) {throw pfc::exception_not_implemented();} \
THISCLASS(const THISCLASS &) {throw pfc::exception_not_implemented();} \
private: \
void __private__service_declaration_selftest() { \
pfc::assert_same_type<PARENTCLASS,PARENTCLASS::t_interface>(); /*parentclass must be an interface*/ \
__validate_service_class_helper<THISCLASS>(); /*service_base must be reachable by walking t_interface_parent*/ \
pfc::safe_cast<service_base*>(this); /*this class must derive from service_base, directly or indirectly, and be implictly castable to it*/ \
}
//! Helper macro for use when defining an entrypoint service class. Generates standard features of a service, including ability to register using service_factory and enumerate using service_enum. \n
//! Sample declaration: class myclass : public service_base {...; FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(myclass); }; \n
//! Note that entrypoint service classes must directly derive from service_base, and not from another service class.
//! This macro is intended for use ONLY WITH INTERFACE CLASSES, not with implementation classes.
#define FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(THISCLASS) \
public: \
typedef THISCLASS t_interface_entrypoint; \
FB2K_MAKE_SERVICE_INTERFACE(THISCLASS,service_base)
#define FB2K_DECLARE_SERVICE_BEGIN(THISCLASS,BASECLASS) \
class NOVTABLE THISCLASS : public BASECLASS { \
FB2K_MAKE_SERVICE_INTERFACE(THISCLASS,BASECLASS); \
public:
#define FB2K_DECLARE_SERVICE_END() \
};
#define FB2K_DECLARE_SERVICE_ENTRYPOINT_BEGIN(THISCLASS) \
class NOVTABLE THISCLASS : public service_base { \
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(THISCLASS) \
public:
//! Base class for all service classes.\n
//! Provides interfaces for reference counter and querying for different interfaces supported by the object.\n
class NOVTABLE service_base
{
public:
//! Decrements reference count; deletes the object if reference count reaches zero. This is normally not called directly but managed by service_ptr_t<> template.
//! @returns New reference count. For debug purposes only, in certain conditions return values may be unreliable.
virtual int service_release() throw() = 0;
//! Increments reference count. This is normally not called directly but managed by service_ptr_t<> template.
//! @returns New reference count. For debug purposes only, in certain conditions return values may be unreliable.
virtual int service_add_ref() throw() = 0;
//! Queries whether the object supports specific interface and retrieves a pointer to that interface. This is normally not called directly but managed by service_query_t<> function template.
//! Typical implementation checks the parameter against GUIDs of interfaces supported by this object, if the GUID is one of supported interfaces, p_out is set to service_base pointer that can be static_cast<>'ed to queried interface and the method returns true; otherwise the method returns false.
virtual bool service_query(service_ptr_t<service_base> & p_out,const GUID & p_guid) {return false;}
//! Queries whether the object supports specific interface and retrieves a pointer to that interface.
//! @param p_out Receives pointer to queried interface on success.
//! returns true on success, false on failure (interface not supported by the object).
template<class T>
bool service_query_t(service_ptr_t<T> & p_out)
{
pfc::assert_same_type<T,T::t_interface>();
return service_query( *reinterpret_cast<service_ptr_t<service_base>*>(&p_out),T::class_guid);
}
typedef service_base t_interface;
protected:
service_base() {}
~service_base() {}
private:
service_base(const service_base&) {throw pfc::exception_not_implemented();}
const service_base & operator=(const service_base&) {throw pfc::exception_not_implemented();}
};
typedef service_ptr_t<service_base> service_ptr;
template<typename T>
static void __validate_service_class_helper() {
__validate_service_class_helper<T::t_interface_parent>();
}
template<>
static void __validate_service_class_helper<service_base>() {}
#include "service_impl.h"
class NOVTABLE service_factory_base {
protected:
inline service_factory_base(const GUID & p_guid) : m_guid(p_guid) {PFC_ASSERT(!core_api::are_services_available());__internal__next=__internal__list;__internal__list=this;}
inline ~service_factory_base() {PFC_ASSERT(!core_api::are_services_available());}
public:
inline const GUID & get_class_guid() const {return m_guid;}
static service_class_ref enum_find_class(const GUID & p_guid);
static bool enum_create(service_ptr_t<service_base> & p_out,service_class_ref p_class,t_size p_index);
static t_size enum_get_count(service_class_ref p_class);
inline static bool is_service_present(const GUID & g) {return enum_get_count(enum_find_class(g))>0;}
//! Throws std::bad_alloc or another exception on failure.
virtual void instance_create(service_ptr_t<service_base> & p_out) = 0;
//! FOR INTERNAL USE ONLY
static service_factory_base *__internal__list;
//! FOR INTERNAL USE ONLY
service_factory_base * __internal__next;
private:
const GUID & m_guid;
};
template<typename B>
class service_factory_base_t : public service_factory_base {
public:
service_factory_base_t() : service_factory_base(B::class_guid) {
pfc::assert_same_type<B,B::t_interface_entrypoint>();
}
};
template<typename T> static void _validate_service_ptr(service_ptr_t<T> const & ptr) {
PFC_ASSERT( ptr.is_valid() );
service_ptr_t<T> test;
PFC_ASSERT( ptr->service_query_t(test) );
}
#ifdef _DEBUG
#define FB2K_ASSERT_VALID_SERVICE_PTR(ptr) _validate_service_ptr(ptr)
#else
#define FB2K_ASSERT_VALID_SERVICE_PTR(ptr)
#endif
template<class T> static bool service_enum_create_t(service_ptr_t<T> & p_out,t_size p_index) {
pfc::assert_same_type<T,T::t_interface_entrypoint>();
service_ptr_t<service_base> ptr;
if (service_factory_base::enum_create(ptr,service_factory_base::enum_find_class(T::class_guid),p_index)) {
p_out = static_cast<T*>(ptr.get_ptr());
return true;
} else {
p_out.release();
return false;
}
}
template<typename T> static service_class_ref _service_find_class() {
pfc::assert_same_type<T,T::t_interface_entrypoint>();
return service_factory_base::enum_find_class(T::class_guid);
}
template<typename what>
static bool _service_instantiate_helper(service_ptr_t<what> & out, service_class_ref servClass, t_size index) {
/*if (out._as_base_ptr_check()) {
const bool state = service_factory_base::enum_create(out._as_base_ptr(), servClass, index);
if (state) { FB2K_ASSERT_VALID_SERVICE_PTR(out); }
return state;
} else */{
service_ptr temp;
const bool state = service_factory_base::enum_create(temp, servClass, index);
if (state) {
out.attach( static_cast<what*>( temp.detach() ) );
FB2K_ASSERT_VALID_SERVICE_PTR( out );
}
return state;
}
}
template<typename T> class service_class_helper_t {
public:
service_class_helper_t() : m_class(service_factory_base::enum_find_class(T::class_guid)) {
pfc::assert_same_type<T,T::t_interface_entrypoint>();
}
t_size get_count() const {
return service_factory_base::enum_get_count(m_class);
}
bool create(service_ptr_t<T> & p_out,t_size p_index) const {
return _service_instantiate_helper(p_out, m_class, p_index);
}
service_ptr_t<T> create(t_size p_index) const {
service_ptr_t<T> temp;
if (!create(temp,p_index)) throw pfc::exception_bug_check_v2();
return temp;
}
service_class_ref get_class() const {return m_class;}
private:
service_class_ref m_class;
};
void _standard_api_create_internal(service_ptr & out, const GUID & classID);
template<typename T> static void standard_api_create_t(service_ptr_t<T> & p_out) {
if (pfc::is_same_type<T,T::t_interface_entrypoint>::value) {
_standard_api_create_internal(p_out._as_base_ptr(), T::class_guid);
FB2K_ASSERT_VALID_SERVICE_PTR(p_out);
} else {
service_ptr_t<T::t_interface_entrypoint> temp;
standard_api_create_t(temp);
if (!temp->service_query_t(p_out)) throw exception_service_extension_not_found();
}
}
template<typename T> static service_ptr_t<T> standard_api_create_t() {
service_ptr_t<T> temp;
standard_api_create_t(temp);
return temp;
}
template<typename T>
static bool static_api_test_t() {
typedef T::t_interface_entrypoint EP;
service_class_helper_t<EP> helper;
if (helper.get_count() != 1) return false;
if (!pfc::is_same_type<T,EP>::value) {
service_ptr_t<T> t;
if (!helper.create(0)->service_query_t(t)) return false;
}
return true;
}
#define FB2K_API_AVAILABLE(API) static_api_test_t<API>()
//! Helper template used to easily access core services. \n
//! Usage: static_api_ptr_t<myclass> api; api->dosomething();
//! Can be used at any point of code, WITH EXCEPTION of static objects that are initialized during the DLL loading process before the service system is initialized; such as static static_api_ptr_t objects or having static_api_ptr_t instances as members of statically created objects.
//! Throws exception_service_not_found if service could not be reached (which can be ignored for core APIs that are always present unless there is some kind of bug in the code).
template<typename t_interface>
class static_api_ptr_t {
public:
static_api_ptr_t() {
standard_api_create_t(m_ptr);
}
service_obscure_refcounting<t_interface>* operator->() const {return service_obscure_refcounting_cast(m_ptr.get_ptr());}
t_interface* get_ptr() const {return m_ptr.get_ptr();}
private:
service_ptr_t<t_interface> m_ptr;
};
//! Helper; simulates array with instance of each available implementation of given service class.
template<typename T> class service_instance_array_t {
public:
typedef service_ptr_t<T> t_ptr;
service_instance_array_t() {
service_class_helper_t<T> helper;
const t_size count = helper.get_count();
m_data.set_size(count);
for(t_size n=0;n<count;n++) m_data[n] = helper.create(n);
}
t_size get_size() const {return m_data.get_size();}
const t_ptr & operator[](t_size p_index) const {return m_data[p_index];}
//nonconst version to allow sorting/bsearching; do not abuse
t_ptr & operator[](t_size p_index) {return m_data[p_index];}
private:
pfc::array_t<t_ptr> m_data;
};
template<typename t_interface>
class service_enum_t {
public:
service_enum_t() : m_index(0) {
pfc::assert_same_type<t_interface,typename t_interface::t_interface_entrypoint>();
}
void reset() {m_index = 0;}
template<typename t_query>
bool first(service_ptr_t<t_query> & p_out) {
reset();
return next(p_out);
}
template<typename t_query>
bool next(service_ptr_t<t_query> & p_out) {
pfc::assert_same_type<typename t_query::t_interface_entrypoint,t_interface>();
if (pfc::is_same_type<t_query,t_interface>::value) {
return __next(reinterpret_cast<service_ptr_t<t_interface>&>(p_out));
} else {
service_ptr_t<t_interface> temp;
while(__next(temp)) {
if (temp->service_query_t(p_out)) return true;
}
return false;
}
}
private:
bool __next(service_ptr_t<t_interface> & p_out) {
return m_helper.create(p_out,m_index++);
}
unsigned m_index;
service_class_helper_t<t_interface> m_helper;
};
template<typename T>
class service_factory_t : public service_factory_base_t<typename T::t_interface_entrypoint> {
public:
void instance_create(service_ptr_t<service_base> & p_out) {
p_out = pfc::safe_cast<service_base*>(pfc::safe_cast<typename T::t_interface_entrypoint*>(pfc::safe_cast<T*>( new service_impl_t<T> )));
}
};
template<typename T>
class service_factory_single_t : public service_factory_base_t<typename T::t_interface_entrypoint> {
service_impl_single_t<T> g_instance;
public:
TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(service_factory_single_t,g_instance)
void instance_create(service_ptr_t<service_base> & p_out) {
p_out = pfc::safe_cast<service_base*>(pfc::safe_cast<typename T::t_interface_entrypoint*>(pfc::safe_cast<T*>(&g_instance)));
}
inline T& get_static_instance() {return g_instance;}
};
template<typename T>
class service_factory_single_ref_t : public service_factory_base_t<typename T::t_interface_entrypoint>
{
private:
T & instance;
public:
service_factory_single_ref_t(T& param) : instance(param) {}
void instance_create(service_ptr_t<service_base> & p_out) {
p_out = pfc::safe_cast<service_base*>(pfc::safe_cast<typename T::t_interface_entrypoint*>(pfc::safe_cast<T*>(&instance)));
}
inline T& get_static_instance() {return instance;}
};
template<typename T>
class service_factory_single_transparent_t : public service_factory_base_t<typename T::t_interface_entrypoint>, public service_impl_single_t<T>
{
public:
TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(service_factory_single_transparent_t,service_impl_single_t<T>)
void instance_create(service_ptr_t<service_base> & p_out) {
p_out = pfc::safe_cast<service_base*>(pfc::safe_cast<typename T::t_interface_entrypoint*>(pfc::safe_cast<T*>(this)));
}
inline T& get_static_instance() {return *(T*)this;}
};
template<typename what>
static bool service_by_guid_fallback(service_ptr_t<what> & out, const GUID & id) {
service_enum_t<what> e;
service_ptr_t<what> ptr;
while(e.next(ptr)) {
if (ptr->get_guid() == id) {out = ptr; return true;}
}
return false;
}
template<typename what>
class service_by_guid_data {
public:
service_by_guid_data() : m_servClass(), m_inited() {}
bool ready() const {return m_inited;}
void initialize() {
if (m_inited) return;
pfc::assert_same_type< what, typename what::t_interface_entrypoint >();
m_servClass = service_factory_base::enum_find_class(what::class_guid);
const t_size servCount = service_factory_base::enum_get_count(m_servClass);
for(t_size walk = 0; walk < servCount; ++walk) {
service_ptr_t<what> temp;
if (_service_instantiate_helper(temp, m_servClass, walk)) {
m_order.set(temp->get_guid(), walk);
}
}
m_inited = true;
}
bool create(service_ptr_t<what> & out, const GUID & id) const {
PFC_ASSERT(m_inited);
t_size index;
if (!m_order.query(id,index)) return false;
return _service_instantiate_helper(out, m_servClass, index);
}
service_ptr_t<what> create(const GUID & id) const {
service_ptr_t<what> temp; if (!crete(temp,id)) throw exception_service_not_found(); return temp;
}
private:
volatile bool m_inited;
pfc::map_t<GUID,t_size> m_order;
service_class_ref m_servClass;
};
template<typename what>
class _service_by_guid_data_container {
public:
static service_by_guid_data<what> data;
};
template<typename what> service_by_guid_data<what> _service_by_guid_data_container<what>::data;
template<typename what>
static void service_by_guid_init() {
service_by_guid_data<what> & data = _service_by_guid_data_container<what>::data;
data.initialize();
}
template<typename what>
static bool service_by_guid(service_ptr_t<what> & out, const GUID & id) {
pfc::assert_same_type< what, typename what::t_interface_entrypoint >();
service_by_guid_data<what> & data = _service_by_guid_data_container<what>::data;
if (data.ready()) {
//fall-thru
} else if (core_api::is_main_thread()) {
data.initialize();
} else {
#ifdef _DEBUG
uDebugLog() << "Warning: service_by_guid() used in non-main thread without initialization, using fallback";
#endif
return service_by_guid_fallback(out,id);
}
return data.create(out,id);
}
template<typename what>
static service_ptr_t<what> service_by_guid(const GUID & id) {
service_ptr_t<what> temp;
if (!service_by_guid(temp,id)) throw exception_service_not_found();
return temp;
}
#endif //_foobar2000_sdk_service_h_included_
| [
"carl@72871cd9-16e1-0310-933f-800000000000"
] | [
[
[
1,
601
]
]
] |
592237645e3c5b515ba50f99b224ff8730d3d5d7 | 3856c39683bdecc34190b30c6ad7d93f50dce728 | /LastProject/Source/ObjectManage.cpp | a09211b52bfa9878aca5337f7ca4a7d239a42d57 | [] | no_license | yoonhada/nlinelast | 7ddcc28f0b60897271e4d869f92368b22a80dd48 | 5df3b6cec296ce09e35ff0ccd166a6937ddb2157 | refs/heads/master | 2021-01-20T09:07:11.577111 | 2011-12-21T22:12:36 | 2011-12-21T22:12:36 | 34,231,967 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 4,556 | cpp | /**
@file ObjectManage.cpp
@date 2011/11/11
@author 백경훈
@brief 오브젝트 관리 ( 네트워크와 클래스간 사용 )
*/
#include "Stdafx.h"
#include "ObjectManage.h"
#include "Charactor.h"
#include "Monster.h"
#include "TimeLifeItem.h"
#include "ASEViewer.h"
#include "LobbyScene.h"
CObjectManage::CObjectManage()
{
Clear();
}
CObjectManage::~CObjectManage()
{
Release();
}
VOID CObjectManage::Clear()
{
m_bHost = FALSE;
m_pLobbyScene = NULL;
m_iClientNumber = 0;
m_iMaxCharaNum = 4;
m_pCharactors = NULL;
//m_ppVirtualCharactors = NULL;
m_pClown = NULL;
m_pPanda = NULL;
m_pMonster = NULL;
m_pFirstAidKit = NULL;
m_pWall = NULL;
m_pASEViewer = NULL;
m_pLobbyScene = NULL;
m_wTotalDestroyPart = 0;
m_nEventTable[0] = m_nEventTable[1] = m_nEventTable[2] = m_nEventTable[3] = 0;
}
HRESULT CObjectManage::Create( LPDIRECT3DDEVICE9 a_pD3dDevice )
{
m_pD3dDevice = a_pD3dDevice;
if( FAILED( D3DXCreateSprite( m_pD3dDevice, &m_pSprite ) ) )
{
MessageBox( NULL, L"CObjectManage::CreateSprite() failed", NULL, MB_OK );
return E_FAIL;
}
LoadLoadingObject();
LoadLobbyObject();
LoadMainObject();
return S_OK;
}
HRESULT CObjectManage::LoadLoadingObject()
{
m_pPanda = new CMonster;
m_pPanda->Set_MonsterNumber( 0 );
m_pBear = new CMonster;
m_pBear->Set_MonsterNumber( 1 );
// Monster
m_pClown = new CMonster;
m_pClown->Set_MonsterNumber( 2 );
m_pMonster = new CMonster*[3];
m_pMonster[0] = m_pPanda;
m_pMonster[1] = m_pBear;
m_pMonster[2] = m_pClown;
m_pFirstAidKit = new CTimeLifeItem[5];
m_pWall = new CTimeLifeItem[3];
return S_OK;
}
HRESULT CObjectManage::LoadLobbyObject()
{
// 캐릭터 생성
m_pCharactors = new CCharactor[ m_iMaxCharaNum ];
for(INT Loop = 0; Loop < m_iMaxCharaNum; ++Loop )
{
m_pCharactors[Loop].Create( m_pD3dDevice );
m_pCharactors[Loop].LoadKindChar( Loop );
}
//m_ppVirtualCharactors = new CCharactor * [m_iMaxCharaNum];
//for ( int i = 0; i < m_iMaxCharaNum; ++i )
//{
// m_ppVirtualCharactors[i] = &(m_pCharactors[i]);
//}
return S_OK;
}
HRESULT CObjectManage::LoadMainObject()
{
// Map
m_pASEViewer = new ASEViewer( m_pD3dDevice );
return S_OK;
}
HRESULT CObjectManage::Release()
{
SAFE_RELEASE( m_pSprite );
SAFE_DELETE( m_pASEViewer );
SAFE_DELETE_ARRAY( m_pCharactors );
SAFE_DELETE_ARRAY( m_pMonster );
SAFE_DELETE( m_pClown );
SAFE_DELETE( m_pPanda );
SAFE_DELETE( m_pBear );
SAFE_DELETE_ARRAY( m_pFirstAidKit );
SAFE_DELETE_ARRAY( m_pWall );
return S_OK;
}
VOID CObjectManage::Set_PushBackNetworkSendTempVector( WORD a_wData )
{
////CDebugConsole::GetInstance()->Messagef( L"PushBack Size : %d / Data : %d\n", m_NetworkSendTempVector.size(), a_wData );
m_NetworkSendTempVector.push_back(a_wData);
}
VOID CObjectManage::Set_NetworkSendDestroyData( CHAR a_cDestroyPart, WORD a_wDestroyCount, D3DXVECTOR3& a_vDestroyDir)
{
m_wDestroyPart[m_wTotalDestroyPart] = a_cDestroyPart;
m_wDestroyCount[m_wTotalDestroyPart] = a_wDestroyCount;
m_vDestroyDir = a_vDestroyDir;
++m_wTotalDestroyPart;
}
VOID CObjectManage::Send_NetworkSendDestroyData( BOOL IsMonster, WORD wMonsterNumber )
{
if( m_wTotalDestroyPart <= 0 )
return;
if( IsMonster == TRUE )
{
CNetwork::GetInstance()->CS_UTOM_ATTACK( wMonsterNumber, m_vDestroyDir, m_wTotalDestroyPart, m_wDestroyPart, m_wDestroyCount, m_NetworkSendTempVector );
}
else if( IsMonster == FALSE )
{
CNetwork::GetInstance()->CS_MTOU_ATTACK( m_vDestroyDir, m_wDestroyCount[0], m_NetworkSendTempVector );
}
else
{
CNetwork::GetInstance()->CS_EVENT_ATTACK( wMonsterNumber, m_vDestroyDir, m_wDestroyCount[0], m_NetworkSendTempVector );
}
m_wTotalDestroyPart = 0;
m_NetworkSendTempVector.erase( m_NetworkSendTempVector.begin(), m_NetworkSendTempVector.end() );
ZeroMemory( &m_wDestroyPart, sizeof(m_wDestroyPart) );
ZeroMemory( &m_wDestroyCount, sizeof(m_wDestroyCount) );
ZeroMemory( m_vDestroyDir, sizeof(m_vDestroyDir) );
}
//VOID CObjectManage::Set_Char(INT nSelect, INT nChar, BOOL bActive )
//{
// //m_ppVirtualCharactors[nSelect] = &m_pCharactors[nChar];
//
// if ( bActive )
// {
// m_pCharactors[nChar].Set_Active( TRUE );
// }
//}
VOID CObjectManage::Set_CharTable( INT * nTable )
{
for (INT i = 0; i < 4; ++i )
{
m_nCharTable[i] = nTable[i];
if (m_nCharTable[i] != -1)
{
m_pCharactors[ m_nCharTable[i] ].Set_Active( TRUE );
}
}
} | [
"[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0",
"[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0",
"[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0"
] | [
[
[
1,
12
],
[
16,
28
],
[
33,
33
],
[
47,
47
],
[
50,
54
],
[
68,
68
],
[
115,
119
],
[
131,
132
],
[
150,
150
],
[
157,
157
],
[
165,
165
]
],
[
[
13,
14
],
[
31,
31
],
[
34,
46
],
[
48,
49
],
[
55,
67
],
[
69,
114
],
[
120,
130
],
[
133,
149
],
[
151,
156
],
[
158,
164
],
[
166,
183
],
[
185,
196
]
],
[
[
15,
15
],
[
29,
30
],
[
32,
32
],
[
184,
184
]
]
] |
c122fcd59459a4f96a7c3b71527761ffc44b30b8 | af260b99d9f045ac4202745a3c7a65ac74a5e53c | /trunk/gui/EngineWrapper/Stdafx.cpp | 3c1aa76af58e0e05eb62f693a9a58c2c677841cd | [] | no_license | BackupTheBerlios/snap-svn | 560813feabcf5d01f25bc960d474f7e218373da0 | a99b5c64384cc229e8628b22f3cf6a63a70ed46f | refs/heads/master | 2021-01-22T09:43:37.862180 | 2008-02-17T15:50:06 | 2008-02-17T15:50:06 | 40,819,397 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 200 | cpp | // stdafx.cpp : source file that includes just the standard includes
// Miew.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"aviadr1@1f8b7f26-7806-0410-ba70-a23862d07478"
] | [
[
[
1,
5
]
]
] |
6264a2bc2505cd50280c1f64ce773d112518851a | 8d3bc2c1c82dee5806c4503dd0fd32908c78a3a9 | /samples/scriptsample/main.cpp | 961a663f521fd253daf100daf93c9c220624cafa | [] | no_license | ryzom/werewolf2 | 2645d169381294788bab9a152c4071061063a152 | a868205216973cf4d1c7d2a96f65f88360177b69 | refs/heads/master | 2020-03-22T20:08:32.123283 | 2010-03-05T21:43:32 | 2010-03-05T21:43:32 | 140,575,749 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,575 | cpp | #include <iostream>
#include <nel/misc/types_nl.h>
#ifdef NL_OS_WINDOWS
#include <conio.h>
#define KEY_ESC 27
#define KEY_ENTER 13
#endif // NL_OS_WINDOWS
//#include <angelscript.h>
#include "wwscript/ScriptEngine/ScriptManager.h"
#include "wwscript/ScriptEngine/ScriptVariable.h"
#include "wwscript/ScriptEngine/ScriptFunctionInstance.h"
#include "wwscript/GlobalProperty/PropertyManager.h"
#include "wwscript/GlobalProperty/PropertyMap.h"
#include "wwscript/GlobalProperty/ConstantIntProperty.h"
#include "wwscript/GlobalProperty/PropertyTemplate.h"
#include "wwscript/ScriptBindings/ScriptBinding.h"
#include "wwscript/ScriptBindings/ScriptWwcommonSimulationBindery.h"
#include "wwcommon/CGameEventRegistrar.h"
#include "wwcommon/CFactoryRegistrar.h"
#include "wwcommon/CBaseProperty.h"
//#include "wwcommon/ISimulationObj.h"
#include "wwcommon/ISobHandler.h"
#include "wwcommon/IBaseSimulation.h"
#include "wwcommon/IGameEvent.h"
#include "wwcommon/ISobEvent.h"
#include "wwcommon/CGameSpawnRequestEvent.h"
#include "wwcommon/CGameUnspawnRequestEvent.h"
#include "wwcommon/CSobMoveEvent.h"
#include "wwcommon/CSobOrientEvent.h"
#include "wwcommon/CSobStrafeEvent.h"
#include "wwcommon/CPerformer.h"
#include "wwcommon/CSobSpawnEvent.h"
#include "nel/misc/matrix.h"
#include "CScriptedGameEventListener.h"
#include "CScriptedSobEventHandler.h"
#include "CSimulationImpl.h"
class BindScriptSampleObjects : public WWSCRIPT::ScriptBinding {
public:
bool bindObjects() {
asIScriptEngine *engine = WWSCRIPT::ScriptManager::getInstance().getEngine();
int r;
nlinfo("Binding CSimulationImpl");
// Register Object Type
r = engine->RegisterObjectType("CSimulationImpl", sizeof(CSimulationImpl), asOBJ_REF); nlassert(r>=0);
// Register Behaviors, omit factory behavior so this interface cannot be created.
r = engine->RegisterObjectBehaviour("CSimulationImpl", asBEHAVE_ADDREF, "void f()", asMETHOD(WWSCRIPT::asRefDummy,addRef), asCALL_THISCALL); nlassert(r>=0);
r = engine->RegisterObjectBehaviour("CSimulationImpl", asBEHAVE_RELEASE, "void f()", asMETHOD(WWSCRIPT::asRefDummy,release), asCALL_THISCALL); nlassert(r>=0);
// Register Parent Methods
WWSCRIPT::ScriptWwcommonSimulationBindery::registerIBaseSimulation<CSimulationImpl>("CSimulationImpl");
// Register object methods.
r = engine->RegisterObjectMethod("CSimulationImpl", "bool userLogin(uint32 &in,uint32 &in)", asMETHODPR(CSimulationImpl, userLogin, (uint32,uint32), bool), asCALL_THISCALL); nlassert(r>=0);
// Register inheritance.
r = engine->RegisterObjectBehaviour("CSimulationImpl", asBEHAVE_IMPLICIT_REF_CAST, "IBaseSimulation@ f()", asFUNCTION((WWSCRIPT::refCast<CSimulationImpl,WWCOMMON::IBaseSimulation>)), asCALL_CDECL_OBJLAST); nlassert(r>=0);
r = engine->RegisterObjectBehaviour("IBaseSimulation", asBEHAVE_REF_CAST, "CSimulationImpl@ f()", asFUNCTION((WWSCRIPT::refCast<WWCOMMON::IBaseSimulation,CSimulationImpl>)), asCALL_CDECL_OBJLAST); nlassert(r>=0);
return true;
}
};
void demonstrateManualScriptCall() {
nlinfo("*** Executing a script manually. ***");
// The vector we'll use.
NLMISC::CVector *testVec = new NLMISC::CVector(1.1f, 1.2f, 1.3f);
const WWSCRIPT::Script *exampleScr = WWSCRIPT::ScriptManager::getInstance().getScript("ExampleScript");
if(!exampleScr) {
nlerror("Failed to retrieve: ExampleScript");
return;
}
const WWSCRIPT::ScriptFunction *func = exampleScr->getFunction("testVectors");
WWSCRIPT::ScriptFunctionInstance *inst = func->getInstance();
inst->getArg("testVec")->setValue(testVec);
inst->execute();
// DONE WITH THIS FUNCTION
delete inst;
delete testVec;
}
void demonstrateScriptBinding() {
// Create a vector to bind.
NLMISC::CVector *vector = new NLMISC::CVector(1.1f,1.2f,1.3f);
// Create the "LOCAL" property map.
WWSCRIPT::PropertyMap local;
// Register the vector as a property.
local.registerProperty(new SCRIPT_PROPERTY(NLMISC::CVector*, vector, "testVec"));
// Register the property map with the manager.
WWSCRIPT::PropertyManager::instance().setPropertyMap("LOCAL", &local);
const WWSCRIPT::Script *exampleScr = WWSCRIPT::ScriptManager::getInstance().getScript("ExampleScript");
if(!exampleScr) {
nlerror("Failed to retrieve: ExampleScript");
return;
}
// Retrieve the function "testVectors"
const WWSCRIPT::ScriptFunction *func = exampleScr->getFunction("testVectors");
// Retrieve an instance of the testVectors function for execution.
WWSCRIPT::ScriptFunctionInstance *inst = func->getInstance();
// Tell the function instance to bind its arguments.
inst->setBoundArgs();
// Execute.
inst->execute();
// Change the vector property:
vector->set(3.1f, 3.2f, 3.3f);
// Then execute again.
inst->setBoundArgs();
inst->execute();
// Clean up.
delete inst;
delete vector;
}
void demonstrateScriptedEventListener() {
nlinfo("*** Executing a script event. ***");
// Retrieve a copy of our simulation implementation.
CSimulationImpl *simulation = dynamic_cast<CSimulationImpl *>(getSimulation());
// Create and add the scripted event listener.
const WWSCRIPT::Script *exampleScr = WWSCRIPT::ScriptManager::getInstance().getScript("ExampleScript");
if(!exampleScr) {
nlerror("Failed to retrieve: ExampleScript");
return;
}
// Create and set up game event listener.
const WWSCRIPT::ScriptFunction *gameFunc = exampleScr->getFunction("handleGameEvent");
CScriptedGameEventListener *listener = new CScriptedGameEventListener(gameFunc);
bool running = true;
while(running) {
simulation->updateTime();
simulation->update();
int c;
if(kbhit()) {
c = getch();
if (c == KEY_ESC) {
nlinfo("Escape pressed, ending script sample!");
running=false; // FINSIH
} else if (c == KEY_ENTER) {
nlinfo("Enter pressed, submit an event to the server.");
WWCOMMON::CGameSpawnRequestEvent *spawnEvt = new WWCOMMON::CGameSpawnRequestEvent();
spawnEvt->CharacterID=3;
WWCOMMON::CGameEventServer::instance().postEvent(spawnEvt);
} else if (c == 'm') {
demonstrateManualScriptCall();
} else if (c == 'b') {
demonstrateScriptBinding();
} else if (c == 'r') {
// Recompile script.
nlinfo("Recompiling script.");
exampleScr->recompileScript();
}
}
}
delete listener;
// delete handler;
delete gameFunc;
// delete sobFunc;
}
int main(int argc, char **argv) {
NLMISC::CApplicationContext myApplicationContext;
nlinfo("Starting up script sample application. ");
NLMISC::CPath::addSearchPath("data", true, false, NULL);
// Register game and simulation object events.
WWCOMMON::registerEvents();
WWCOMMON::registerCommonFactoryObjects();
OF_REGISTER(WWCOMMON::CSobFactory, CActor, "sobActor");
// Register our mock simulation implementation.
try {
NLMISC_REGISTER_CLASS(CSimulationImpl);
} catch(NLMISC::ERegisteredClass &e) {
nlwarning("CSimulationImpl is already registered.");
}
// Retrieve a copy of our simulation implementation.
CSimulationImpl *simulation = dynamic_cast<CSimulationImpl *>(getSimulation());
simulation->init();
// Now initialize the scripting system.
WWSCRIPT::ScriptManager::getInstance().initialize();
// Now add my "client side" bindings.
WWSCRIPT::ScriptManager::getInstance().addBindingObj(new BindScriptSampleObjects());
WWSCRIPT::ScriptManager::getInstance().initializeScripts();
demonstrateScriptedEventListener();
}
| [
"[email protected]"
] | [
[
[
1,
213
]
]
] |
391c3f8ed8844e997912f13db3bc91fcb791f285 | a0bc9908be9d42d58af7a1a8f8398c2f7dcfa561 | /SlonEngine/slon/Utility/URI/uri.hpp | 8d25fb236c793fc548a5769440fd61a951f384d4 | [] | no_license | BackupTheBerlios/slon | e0ca1137a84e8415798b5323bc7fd8f71fe1a9c6 | dc10b00c8499b5b3966492e3d2260fa658fee2f3 | refs/heads/master | 2016-08-05T09:45:23.467442 | 2011-10-28T16:19:31 | 2011-10-28T16:19:31 | 39,895,039 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,653 | hpp | #ifndef __SLON_ENGINE_UTILITY_URI_HPP__
#define __SLON_ENGINE_UTILITY_URI_HPP__
#include <boost/xpressive/xpressive.hpp>
namespace slon {
template<typename CharType>
class uri
{
public:
typedef CharType char_t;
typedef std::basic_string<char_t> string_t;
protected:
typedef boost::xpressive::basic_regex<typename string_t::const_iterator> regex_t;
typedef boost::xpressive::match_results<typename string_t::const_iterator> match_t;
public:
uri() : isValid(false) {}
uri(const string_t& uri_) { from_string(uri_); }
virtual bool from_string(const string_t& str)
{
using namespace boost::xpressive;
static const regex_t scheme_regexp = !((s1 = *(_w | _d | '+' | '-' | '.')) >> ':') // scheme
>> (s2 = *_) // hierarchical
>> !('?' >> (s3 = *_)) // query
>> !('#' >> (s4 = *_)); // fragment
match_t match;
if ( regex_match(str, match, scheme_regexp) )
{
scheme = match[1];
hierarchical = match[2];
query = match[3];
fragment = match[4];
isValid = true;
}
else {
isValid = false;
}
return isValid;
}
virtual string_t to_string() const
{
string_t res = scheme + ":" + hierarchical;
if ( !query.empty() ) {
res += "?" + query;
}
if ( !fragment.empty() ) {
res += "#" + fragment;
}
return res;
}
bool valid() const { return isValid; }
protected:
bool isValid;
public:
string_t scheme;
string_t hierarchical;
string_t query;
string_t fragment;
};
} // namespace slon
#endif // __SLON_ENGINE_UTILITY_URI_HPP__ | [
"devnull@localhost"
] | [
[
[
1,
74
]
]
] |
1513ac21e7408d3b7d2a5708972bb72e0080f442 | fbe2cbeb947664ba278ba30ce713810676a2c412 | /iptv_root/iptv_media3/test_iptv_media/Kernel/IKernelInterfaceNotify.h | c2399eb1beb5ef3439163aa6c2d5567f6165fbc5 | [] | no_license | abhipr1/multitv | 0b3b863bfb61b83c30053b15688b070d4149ca0b | 6a93bf9122ddbcc1971dead3ab3be8faea5e53d8 | refs/heads/master | 2020-12-24T15:13:44.511555 | 2009-06-04T17:11:02 | 2009-06-04T17:11:02 | 41,107,043 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 276 | h | #ifndef I_KERNEL_INTERFACE_NOTIFY_H
#define I_KERNEL_INTERFACE_NOTIFY_H
#include "media_utilities.h"
class IKernelInterfaceNotify
{
public:
virtual ~IKernelInterfaceNotify() {}
virtual ULONG SetMediaAlive(ULONG _id, MediaSpec _mediaSpec) = 0;
};
#endif | [
"heineck@c016ff2c-3db2-11de-a81c-fde7d73ceb89"
] | [
[
[
1,
15
]
]
] |
d42e86bff966c51de4bbb347d38ac77d3ae937f9 | 2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4 | /OUAN/OUAN/Src/Graphics/RenderSubsystem.cpp | 4d0ed5858abae51fef6f03a99c72f0e0f07be47b | [] | no_license | juanjmostazo/once-upon-a-night | 9651dc4dcebef80f0475e2e61865193ad61edaaa | f8d5d3a62952c45093a94c8b073cbb70f8146a53 | refs/heads/master | 2020-05-28T05:45:17.386664 | 2010-10-06T12:49:50 | 2010-10-06T12:49:50 | 38,101,059 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 50,041 | cpp | #include "OUAN_Precompiled.h"
#include "RenderSubsystem.h"
#include "../Application.h"
#include "../Loader/Configuration.h"
#include "../Game/GameWorldManager.h"
#include "../Game/GameObject/GameObjectFlashlight.h"
#include "../Physics/PhysicsSubsystem.h"
#include "../GUI/GUISubsystem.h"
#include "CameraManager/CameraManager.h"
#include "ChangeWorldRenderer.h"
#include "CameraManager/CameraControllerFirstPerson.h"
#include "TrajectoryManager/TrajectoryManager.h"
#include "RenderComponent/RenderComponent.h"
#include "RenderComponent/RenderComponentBillboardSet.h"
#include "RenderComponent/RenderComponentEntity.h"
#include "RenderComponent/RenderComponentLight.h"
#include "RenderComponent/RenderComponentParticleSystem.h"
#include "RenderComponent/RenderComponentScene.h"
#include "RenderComponent/RenderComponentPositional.h"
#include "RenderComponent/RenderComponentViewport.h"
#include "RenderComponent/RenderComponentDecal.h"
#include "RenderComponent/RenderComponentPlane.h"
using namespace OUAN;
using namespace Ogre;
RenderSubsystem::RenderSubsystem(std::string windowName)
: mWindow( NULL )
, mWindowName(windowName)
, mTexturesInitialized(false)
{
}
RenderSubsystem::~RenderSubsystem()
{
}
void RenderSubsystem::create(ApplicationPtr app,OUAN::ConfigurationPtr config)
{
mApp=app;
debugMessage = "";
createRoot(config);
}
bool RenderSubsystem::init(ConfigurationPtr config)
{
loadConfig();
defineResources(config);
if (!setupRenderSystem(config))
{
return false;
}
createRenderWindow(config);
initResourceGroups(config);
initTextures3D();
initMenusAnimTextures();
return true;
}
void RenderSubsystem::initMenusAnimTextures()
{
std::string textures[] = {"background_stars", "loading_page", "clouds"};
int nframes[] = {13,20,20};
std::string extension=".png";
Ogre::TextureManager* tMgr = Ogre::TextureManager::getSingletonPtr();
for (int i=0;i<3;i++)
{
for (int j=0;j<nframes[i];j++)
{
tMgr->load(textures[i]+"_"+StringConverter::toString(j)+extension,ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
}
}
}
void RenderSubsystem::initChangeWorldRenderer(int initialWorld)
{
mChangeWorldRenderer.reset(new ChangeWorldRenderer());
mChangeWorldRenderer->init(mSceneManager,mWindow,mApp->getCameraManager()->getCamera(),initialWorld);
}
ChangeWorldRendererPtr RenderSubsystem::getChangeWorldRenderer()
{
return mChangeWorldRenderer;
}
bool RenderSubsystem::loadConfig()
{
Configuration config;
std::string value;
bool successBar, successCompositor;
if (config.loadFromFile(BAR_CFG))
{
config.getOption("NUM_GROUPS", value);
mNumGroups = atoi(value.c_str());
config.getOption("READ_PROPORTION", value);
mReadProportion = atof(value.c_str());
successBar = true;
}
else
{
mNumGroups = 1;
mReadProportion = 0.5f;
successBar = false;
}
if (config.loadFromFile(COMPOSITOR_CFG))
{
config.getOption("BLOOM", BLOOM);
config.getOption("HDR", HDR);
config.getOption("RADIAL_BLUR", RADIAL_BLUR);
config.getOption("MOTION_BLUR", MOTION_BLUR);
config.getOption("CHANGEWORLD", CHANGEWORLD);
config.getOption("BLOOM_ACTIVATED_ALWAYS_DREAMS", value);
BLOOM_ACTIVATED_ALWAYS_DREAMS=Ogre::StringConverter::parseBool(value);
config.getOption("BLOOM_ACTIVATED_ALWAYS_NIGHTMARES", value);
BLOOM_ACTIVATED_ALWAYS_NIGHTMARES=Ogre::StringConverter::parseBool(value);
config.getOption("BLOOM_BLEND_MATERIAL", BLOOM_BLEND_MATERIAL);
config.getOption("MAX_BLOOM_BLEND", value);
MAX_BLOOM_BLEND=atof(value.c_str());
config.getOption("HDR_ACTIVATED_ALWAYS_DREAMS", value);
HDR_ACTIVATED_ALWAYS_DREAMS=Ogre::StringConverter::parseBool(value);
config.getOption("HDR_ACTIVATED_ALWAYS_NIGHTMARES", value);
HDR_ACTIVATED_ALWAYS_NIGHTMARES=Ogre::StringConverter::parseBool(value);
config.getOption("RADIAL_BLUR_ACTIVATED_ALWAYS_DREAMS", value);
RADIAL_BLUR_ACTIVATED_ALWAYS_DREAMS=Ogre::StringConverter::parseBool(value);
config.getOption("RADIAL_BLUR_ACTIVATED_ALWAYS_NIGHTMARES", value);
RADIAL_BLUR_ACTIVATED_ALWAYS_NIGHTMARES=Ogre::StringConverter::parseBool(value);
config.getOption("MOTION_BLUR_ACTIVATED_ALWAYS_DREAMS", value);
MOTION_BLUR_ACTIVATED_ALWAYS_DREAMS=Ogre::StringConverter::parseBool(value);
config.getOption("MOTION_BLUR_ACTIVATED_ALWAYS_NIGHTMARES", value);
MOTION_BLUR_ACTIVATED_ALWAYS_NIGHTMARES=Ogre::StringConverter::parseBool(value);
successCompositor = true;
}
else
{
successCompositor = false;
}
return successBar && successCompositor;
}
void RenderSubsystem::cleanUp()
{
clearScene();
}
void RenderSubsystem::createRoot(ConfigurationPtr config)
{
std::string pluginsPath=DEFAULT_OGRE_PLUGINS_PATH;
std::string configPath=DEFAULT_OGRE_CONFIG_PATH;
std::string logPath=DEFAULT_OGRE_LOG_PATH;
if (config.get())
{
if(config->hasOption(CONFIG_KEYS_OGRE_PLUGINS_PATH))
{
config->getOption(CONFIG_KEYS_OGRE_PLUGINS_PATH,pluginsPath);
}
if(config->hasOption(CONFIG_KEYS_OGRE_CONFIG_PATH))
{
config->getOption(CONFIG_KEYS_OGRE_CONFIG_PATH,configPath);
}
if(config->hasOption(CONFIG_KEYS_OGRE_LOG_PATH))
{
config->getOption(CONFIG_KEYS_OGRE_LOG_PATH,logPath);
}
}
mRoot.reset(new Ogre::Root(pluginsPath, configPath, logPath));
}
RootPtr RenderSubsystem::getRoot() const
{
return mRoot;
}
void RenderSubsystem::defineResources(ConfigurationPtr config)
{
Ogre::String sectionName, typeName, resName;
Ogre::ConfigFile cFile;
std::string resourcesPath;
if(config.get() && config->hasOption(CONFIG_KEYS_OGRE_RESOURCES_PATH))
{
config->getOption(CONFIG_KEYS_OGRE_RESOURCES_PATH,resourcesPath);
}
else
{
resourcesPath=DEFAULT_OGRE_RESOURCES_PATH;
}
cFile.load(resourcesPath);
Ogre::ConfigFile::SectionIterator secIt = cFile.getSectionIterator();
while (secIt.hasMoreElements())
{
sectionName = secIt.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap* settings = secIt.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator it;
for (it=settings->begin();it!=settings->end();++it)
{
typeName= it->first;
resName = it->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(resName,typeName,sectionName);
}
}
}
bool RenderSubsystem::setupRenderSystem(ConfigurationPtr config)
{
std::string value;
config->getOption(CONFIG_KEYS_RENDER_SYSTEM,value);
Ogre::RenderSystem* rs= mRoot->getRenderSystemByName(value);
if (rs)
{
mRoot->setRenderSystem(rs);
config->getOption(CONFIG_KEYS_FULLSCREEN,value);
rs->setConfigOption("Full Screen",value.empty()?OPTION_NO:value);
value="";
config->getOption(CONFIG_KEYS_RES,value);
rs->setConfigOption("Video Mode", value.empty()?RESOLUTION_1024X768X32:value);
value="";
config->getOption(CONFIG_KEYS_AA,value);
rs->setConfigOption("Anti aliasing", value.empty()?AA_LEVEL_0:value);
value="";
config->getOption(CONFIG_KEYS_VSYNC,value);
rs->setConfigOption("VSync",value.empty()?OPTION_NO:value);
return true;
}
return false;
//return mRoot->showConfigDialog();
}
void RenderSubsystem::createRenderWindow(ConfigurationPtr config)
{
mRoot->initialise(true, mWindowName);
mWindow=mRoot->getAutoCreatedWindow();
mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC, "Default Scene Manager");
}
void RenderSubsystem::createVisualDebugger(ConfigurationPtr config)
{
mNxOgreVisualDebugger = mApp->getPhysicsSubsystem()->getNxOgreWorld()->getVisualDebugger();
mNxOgreVisualDebuggerRenderable = new OGRE3DRenderable(NxOgre::Enums::RenderableType_VisualDebugger);
mNxOgreVisualDebugger->setRenderable(mNxOgreVisualDebuggerRenderable);
mNxOgreVisualDebuggerNode = mSceneManager->getRootSceneNode()->createChildSceneNode(
"visual_debugger#" + Application::getInstance()->getStringUniqueId());
mNxOgreVisualDebuggerNode->attachObject(mNxOgreVisualDebuggerRenderable);
mNxOgreVisualDebugger->setVisualisationMode(mApp->getDebugMode()!=DEBUGMODE_NONE?
NxOgre::Enums::VisualDebugger_ShowAll:
NxOgre::Enums::VisualDebugger_ShowNone);
}
void RenderSubsystem::createDebugFloor(ConfigurationPtr config)
{
//Initializing main floor
Ogre::Plane *plane = new Ogre::Plane;
plane->normal = Ogre::Vector3::UNIT_Y;
plane->d = 0;
Ogre::MeshManager::getSingleton().createPlane("debugFloorPlane",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, *plane,
1000, 1000, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
Ogre::Entity* pPlaneEnt = mSceneManager->createEntity("debugFloorEntity", "debugFloorPlane");
pPlaneEnt->setCastShadows(false);
pPlaneEnt->setMaterialName("GrassFloor");
SceneNode * pPlaneNode = mSceneManager->getRootSceneNode()->createChildSceneNode(
"plane_node#" + Application::getInstance()->getStringUniqueId());
pPlaneNode->attachObject(pPlaneEnt);
}
void RenderSubsystem::initResourceGroups(ConfigurationPtr config)
{
std::string mipmapNumber;
if(config.get() && config->hasOption(CONFIG_KEYS_OGRE_DEFAULT_MIPMAPS_NUMBER))
{
config->getOption(CONFIG_KEYS_OGRE_DEFAULT_MIPMAPS_NUMBER,mipmapNumber);
}
else
{
mipmapNumber=DEFAULT_OGRE_MIPMAPS_NUMBER;
}
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(DEFAULT_OGRE_MIPMAPS_NUMBER);
//Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
///////////////////////////////////////////////
Camera* mCamera = mSceneManager->createCamera("LoadingBarCam");
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));
mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
mLoadingBar.start(mWindow, (unsigned short)mNumGroups, (unsigned short)mNumGroups, mReadProportion);
// Turn off rendering of everything except overlays
mSceneManager->clearSpecialCaseRenderQueues();
mSceneManager->addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
mSceneManager->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
// Initialise resource groups, parse scripts etc
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
ResourceGroupManager::getSingleton().loadResourceGroup(
ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
false, true);
// Back to full rendering
mSceneManager->clearSpecialCaseRenderQueues();
mSceneManager->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
mLoadingBar.finish();
mWindow->removeAllViewports();
}
void RenderSubsystem::createOverlays()
{
//Ogre::OverlayManager::getSingleton().getByName("Core/DebugOverlay")->show();
}
void RenderSubsystem::clear()
{
/// Clear Scene manager
mSceneManager->clearScene();
//Prevent weird bug where a null pointer exception is thrown inside
// sceneManager::setShadowTechnique() when resetting the game
// (using soft shadowing)
mSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
}
RenderWindow* RenderSubsystem::getWindow() const
{
return mWindow;
}
void RenderSubsystem::updateVisualDebugger()
{
mNxOgreVisualDebugger->draw();
mNxOgreVisualDebuggerNode->needUpdate();
}
bool RenderSubsystem::render()
{
//Logger::getInstance()->log("[PHYSICS RENDER]");
return mRoot->renderOneFrame();
}
bool RenderSubsystem::isWindowClosed() const
{
return !mWindow || mWindow->isClosed();
}
Ogre::SceneManager* RenderSubsystem::getSceneManager() const
{
return mSceneManager;
}
void RenderSubsystem::toggleDisplaySceneNodes()
{
mSceneManager->setDisplaySceneNodes(!mSceneManager->getDisplaySceneNodes());
}
Ogre::SceneManager * RenderSubsystem::setSceneParameters(Ogre::String name,TRenderComponentSceneParameters tRenderComponentSceneParameters)
{
try
{
initShadows();
//Set SceneManager parameters
mSceneManager->setAmbientLight(tRenderComponentSceneParameters.ambient);
if(tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.active)
{
//Set SkyDome Dreams
mSceneManager->setSkyDome(tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.active,
tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.materialDreams,
tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.curvature,
tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.tiling,
tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.distance);
//Set SkyDome Nightmares
mSceneManager->setSkyDome(tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.active,
tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.materialNightmares,
tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.curvature,
tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.tiling,
tRenderComponentSceneParameters.tRenderComponentSkyDomeParameters.distance);
}
mSceneManager->setFog(
tRenderComponentSceneParameters.tRenderComponentFogParameters.fogMode,
tRenderComponentSceneParameters.tRenderComponentFogParameters.colour,
tRenderComponentSceneParameters.tRenderComponentFogParameters.density,
tRenderComponentSceneParameters.tRenderComponentFogParameters.start,
tRenderComponentSceneParameters.tRenderComponentFogParameters.end);
}
catch(Ogre::Exception &/*e*/)
{
Logger::getInstance()->log("[LevelLoader] Error creating "+name+" SceneManager!");
}
return mSceneManager;
}
Ogre::Light* RenderSubsystem::createLight(Ogre::String name,TRenderComponentLightParameters tRenderComponentLightParameters,
Ogre::String sceneNodeName)
{
SceneNode *lightNode=0;
Light *pLight=0;
// Set light parameters and create it
try
{
// Create the light
pLight = mSceneManager->createLight(name);
// Attach to Scene Manager
lightNode=mSceneManager->getSceneNode(name);
lightNode->attachObject(pLight);
//Set Light Parameters
pLight->setType(tRenderComponentLightParameters.lighttype);
pLight->setDiffuseColour(tRenderComponentLightParameters.diffuse);
pLight->setSpecularColour(tRenderComponentLightParameters.specular);
pLight->setDirection(tRenderComponentLightParameters.direction);
pLight->setCastShadows(tRenderComponentLightParameters.castshadows);
pLight->setAttenuation(
tRenderComponentLightParameters.attenuation.x,
tRenderComponentLightParameters.attenuation.y,
tRenderComponentLightParameters.attenuation.z,
tRenderComponentLightParameters.attenuation.w);
if (pLight->getType()==Ogre::Light::LT_SPOTLIGHT)
{
pLight->setSpotlightRange(Ogre::Degree(tRenderComponentLightParameters.lightrange.x),
Ogre::Degree(tRenderComponentLightParameters.lightrange.y),
tRenderComponentLightParameters.lightrange.z);
}
pLight->setPowerScale(tRenderComponentLightParameters.power);
LogManager::getSingleton().logMessage("[RenderSubsystem] Created "+name+" Light!");
}
catch(Ogre::Exception &/*e*/)
{
LogManager::getSingleton().logMessage("[LevelLoader] Error creating "+name+" Light!");
}
return pLight;
}
Ogre::Entity* RenderSubsystem::createPlane(Ogre::String nodeName,Ogre::String name,TRenderComponentPlaneParameters tPlaneParameters)
{
SceneNode *planeNode=0;
Plane plane;
Ogre::Entity * pPlaneEntity;
// Set plane parameters and create it
try
{
plane.d=tPlaneParameters.distance;
plane.normal=tPlaneParameters.normal;
// Create the plane
MeshManager::getSingleton().createPlane(name,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane,
tPlaneParameters.width,tPlaneParameters.height,tPlaneParameters.Xsegments,tPlaneParameters.Ysegments,
tPlaneParameters.hasNormals,tPlaneParameters.numCoordSets,tPlaneParameters.Utile,tPlaneParameters.Vtile,
Ogre::Vector3::UNIT_Z);
pPlaneEntity = mSceneManager->createEntity( name, name );
pPlaneEntity->setMaterialName(tPlaneParameters.material);
//set Query flags
pPlaneEntity->setQueryFlags(tPlaneParameters.cameraCollisionType);
//set RenderQueue priortiy and group
pPlaneEntity->setRenderQueueGroup(tPlaneParameters.queueID);
//attach to Scene Manager
planeNode=mSceneManager->getSceneNode(nodeName);
planeNode->attachObject(pPlaneEntity);
}
catch(Ogre::Exception &/*e*/)
{
Logger::getInstance()->log("[LevelLoader] Error creating "+name+" Plane!");
}
return pPlaneEntity;
}
Ogre::SceneNode * RenderSubsystem::createSceneNode(Ogre::String name,TRenderComponentPositionalParameters tRenderComponentPositionalParameters)
{
SceneNode *pParentSceneNode = 0;
SceneNode *sceneNode = 0;
Logger::getInstance()->log("[RenderSubsystem] Creating "+name+" SceneNode!");
// Set SceneNode parameters and create it
try
{
//Get Parent SceneNode
if(tRenderComponentPositionalParameters.parentSceneNodeName.compare("SceneManager")==0)
{
pParentSceneNode = mSceneManager->getRootSceneNode();
}
else
{
pParentSceneNode = mSceneManager->getSceneNode(tRenderComponentPositionalParameters.parentSceneNodeName);
}
//Create SceneNode
sceneNode = pParentSceneNode->createChildSceneNode(name);
//Set SceneNode parameters
sceneNode->setPosition(tRenderComponentPositionalParameters.position);
sceneNode->setOrientation(tRenderComponentPositionalParameters.orientation);
sceneNode->setScale(tRenderComponentPositionalParameters.scale);
if(tRenderComponentPositionalParameters.autotracktarget.compare("None")!=0)
{
//TODO test this
SceneNode *trackTarget;
trackTarget=mSceneManager->getSceneNode(tRenderComponentPositionalParameters.autotracktarget);
sceneNode->setAutoTracking(true,trackTarget);
}
}
catch(Ogre::Exception &e)
{
Logger::getInstance()->log("[LevelLoader] Error creating "+name+" SceneNode!: "+e.getDescription());
}
return sceneNode;
}
void RenderSubsystem::createMeshFile(const std::string& meshfile,bool initManualAnimation,
const std::string& manualAnimationName, TKeyFrameMap* keyframes)
{
MeshPtr mesh;
Ogre::Mesh::LodDistanceList distanceList;
distanceList.push_back(200);
distanceList.push_back(500);
//distanceList.push_back(500);
//distanceList.push_back(1000);
//distanceList.push_back(1000);
try
{
//Create the mesh file
if (!MeshManager::getSingleton().resourceExists(meshfile))
{
//Logger::getInstance()->log("[LevelLoader] creating "+meshfile+" meshfile");
mesh=MeshManager::getSingleton().load(meshfile,Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
if (initManualAnimation && !manualAnimationName.empty() && keyframes)
{
//we'll read through this list while loading
Ogre::PoseList poseList = mesh->getPoseList();
//used to loop through each submesh
int numSubMeshes = mesh->getNumSubMeshes();
int curPoseIndex = 0;
//create the animation on the mesh
Ogre::Animation* anim = mesh->createAnimation(manualAnimationName, 0);
//skip submesh 0 since it is the shared geometry, and we have no poses on that
for(int curSubMesh = 1; curSubMesh <= numSubMeshes; curSubMesh++){
//create the VertexTrack on this animation
Ogre::VertexAnimationTrack *vt = anim->createVertexTrack(curSubMesh, Ogre::VAT_POSE);
//create the keyframe we will use to update this vertex track
//keep all our keyframes in a map for later updating
(*keyframes)[curSubMesh] = vt->createVertexPoseKeyFrame(0);
//add the references to each pose that applies to this subMesh
unsigned short target = poseList[curPoseIndex]->getTarget();
while(target == curSubMesh){
//create a pose reference for each pose
(*keyframes)[curSubMesh]->addPoseReference(curPoseIndex, 0.0f);
curPoseIndex++;
if (curPoseIndex==poseList.size())
break;
target = poseList[curPoseIndex]->getTarget();
}
}
}
}
}
catch(Ogre::Exception &/*e*/)
{
Logger::getInstance()->log("[LevelLoader] Error creating "+meshfile+" mesh!");
}
}
void RenderSubsystem::initMaterials()
{
Ogre::MaterialManager::ResourceMapIterator it = Ogre::MaterialManager::getSingleton().getResourceIterator();
Ogre::MaterialPtr material;
while (it.hasMoreElements())
{
material=it.getNext();
if(material->isLoaded())
{
if((material->getName().compare("red")!=0) &&
(material->getName().compare("blue")!=0) &&
(material->getName().compare("green")!=0) &&
(material->getName().compare("yellow")!=0) &&
(material->getName().compare("black")!=0) &&
(material->getName().compare("white")!=0))
{
material->setLightingEnabled(false);
}
}
}
//TODO: DO THIS PROPERLY
//LOAD DECAL TEXTURES
Ogre::TextureManager::getSingleton().load(FLASHLIGHT_DECAL_TEX_NAME,"General");
Ogre::TextureManager::getSingleton().load(FLASHLIGHT_DECAL_FILTER_TEX_NAME,"General");
}
void RenderSubsystem::initTextures3D()
{
if (!mTexturesInitialized)
{
mTexture3D_1_8 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_1_8", "General", Ogre::TEX_TYPE_3D, 8, 8, 8, 0, Ogre::PF_A8R8G8B8);
mTexture3D_1_16 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_1_16", "General", Ogre::TEX_TYPE_3D, 16, 16, 16, 0, Ogre::PF_A8R8G8B8);
mTexture3D_1_32 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_1_32", "General", Ogre::TEX_TYPE_3D, 32, 32, 32, 0, Ogre::PF_A8R8G8B8);
mTexture3D_1_64 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_1_64", "General", Ogre::TEX_TYPE_3D, 64, 64, 64, 0, Ogre::PF_A8R8G8B8);
mTexture3D_1_128 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_1_128", "General", Ogre::TEX_TYPE_3D, 128, 128, 128, 0, Ogre::PF_A8R8G8B8);
mTexture3D_2_8 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_2_8", "General", Ogre::TEX_TYPE_3D, 8, 8, 8, 0, Ogre::PF_A8R8G8B8);
mTexture3D_2_16 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_2_16", "General", Ogre::TEX_TYPE_3D, 16, 16, 16, 0, Ogre::PF_A8R8G8B8);
mTexture3D_2_32 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_2_32", "General", Ogre::TEX_TYPE_3D, 32, 32, 32, 0, Ogre::PF_A8R8G8B8);
mTexture3D_2_64 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_2_64", "General", Ogre::TEX_TYPE_3D, 64, 64, 64, 0, Ogre::PF_A8R8G8B8);
mTexture3D_2_128 = Ogre::TextureManager::getSingleton().createManual(
"texture3D_2_128", "General", Ogre::TEX_TYPE_3D, 128, 128, 128, 0, Ogre::PF_A8R8G8B8);
mTexturesInitialized = true;
}
}
//TODO DO IT USING A MAP
Ogre::TexturePtr RenderSubsystem::getTexture3D(std::string texture3D){
if (texture3D.compare("texture3D_8")==0)
{
return mTexture3D_1_8;
}
else if (texture3D.compare("texture3D_1_16")==0)
{
return mTexture3D_1_16;
}
else if (texture3D.compare("texture3D_1_32")==0)
{
return mTexture3D_1_32;
}
else if (texture3D.compare("texture3D_1_64")==0)
{
return mTexture3D_1_64;
}
else if (texture3D.compare("texture3D_1_128")==0)
{
return mTexture3D_1_128;
}
else if (texture3D.compare("texture3D_2_8")==0)
{
return mTexture3D_2_8;
}
else if (texture3D.compare("texture3D_2_16")==0)
{
return mTexture3D_2_16;
}
else if (texture3D.compare("texture3D_2_32")==0)
{
return mTexture3D_2_32;
}
else if (texture3D.compare("texture3D_2_64")==0)
{
return mTexture3D_2_64;
}
else if (texture3D.compare("texture3D_2_128")==0)
{
return mTexture3D_2_128;
}
else
{
Ogre::TexturePtr nullPtr;
return nullPtr;
}
}
//
//void RenderSubsystem::setLightmaps(Ogre::Entity * pEntity)
//{
// unsigned int i;
// Ogre::String materialName = LIGHTMAP_PREFIX+pEntity->getName();
// Ogre::String lightmapName = materialName+".dds";
//
// Ogre::TexturePtr original_texture;
// Ogre::TexturePtr lightmap_texture;
// Ogre::TexturePtr new_texture;
//
// Ogre::HardwarePixelBufferSharedPtr original_pixel_buffer;
// Ogre::HardwarePixelBufferSharedPtr lightmap_pixel_buffer;
// Ogre::HardwarePixelBufferSharedPtr new_pixel_buffer;
//
// Ogre::Technique * technique;
// Ogre::Pass * pass;
// Ogre::TextureUnitState * texture_unit;
//
// if( Ogre::ResourceGroupManager::getSingleton().resourceExists(DEFAULT_OGRE_RESOURCE_MANAGER_GROUP,lightmapName))
// {
// try
// {
// //Logger::getInstance()->log("[setLightmaps] Adding "+lightmapName+" Lightmap...");
// for ( i = 0; i < pEntity->getNumSubEntities(); ++i)
// {
// // Get the material of this sub entity and build the clone material name
// Ogre::SubEntity* subEnt = pEntity->getSubEntity(i);
// Ogre::MaterialPtr material = subEnt->getMaterial();
//
// // Get/Create the clone material
// Ogre::MaterialPtr clone;
// if (Ogre::MaterialManager::getSingleton().resourceExists(materialName))
// {
// clone = Ogre::MaterialManager::getSingleton().getByName(materialName);
// }
// else
// {
// // Clone the material
// clone = material->clone(materialName);
// }
//
// // Apply the lightmap
//
// //get technique
// technique = clone->getTechnique(0);
// //set current pass attributes
// pass = technique->getPass(0);
// texture_unit = pass->getTextureUnitState(0);
//
// //clone original texture
// original_texture=Ogre::TextureManager::getSingleton().getByName(texture_unit->getTextureName());
// original_texture->copyToTexture(new_texture);
//
// //apply lightmap
// lightmap_texture=Ogre::TextureManager::getSingleton().getByName(lightmapName);
// original_pixel_buffer = original_texture->getBuffer();
// lightmap_pixel_buffer = lightmap_texture->getBuffer();
// new_pixel_buffer = new_texture->getBuffer();
//
// // create pixel boxes
// //PixelBox original_pixelbox(
// // original_pixel_buffer->getWidth(),
// // original_pixel_buffer->getHeight(),
// // original_pixel_buffer->getDepth(),
// // original_pixel_buffer->getFormat(),
// // buffer);
// //original_pixel_buffer->blitToMemory(original_pixelbox);
//
// //PixelBox lightmap_pixelbox(
// // lightmap_pixel_buffer->getWidth(),
// // lightmap_pixel_buffer->getHeight(),
// // lightmap_pixel_buffer->getDepth(),
// // lightmap_pixel_buffer->getFormat(),
// // buffer);
// //lightmap_pixel_buffer->blitToMemory(lightmap_pixelbox);
//
// //PixelBox new_pixelbox(
// // new_pixel_buffer->getWidth(),
// // new_pixel_buffer->getHeight(),
// // new_pixel_buffer->getDepth(),
// // new_pixel_buffer->getFormat(),
// // buffer);
//
// //PixelUtil::get
//
// //new_pixelbox.
// //original_pixel_buffer->blitToMemory(new_pixelbox);
//
// //new_pixel_buffer->
//
// //new_texture->setB
//
// //load lightmap
// new_texture->load();
//
// //unload original texture and lightmap
// original_texture->unload();
// lightmap_texture->unload();
//
// texture_unit->setTextureCoordSet(0);
// texture_unit->setColourOperationEx(Ogre::LBX_MODULATE);
// //create lightmap pass
// pass = technique->createPass();
// pass->setSceneBlending(Ogre::SBT_MODULATE);
// pass->setDepthBias(1);
// texture_unit = pass->createTextureUnitState();
// texture_unit->setTextureName(lightmapName);
// texture_unit->setTextureCoordSet(0);
// texture_unit->setColourOperationEx(Ogre::LBX_MODULATE);
//
// // Apply the cloned material to the sub entity.
// subEnt->setMaterial(clone);
// }
// }
// catch(Ogre::Exception &/*e*/)
// {
// Logger::getInstance()->log("[setLightmaps] Error adding "+lightmapName+" Lightmap!");
// }
// }
// else
// {
// Logger::getInstance()->log("[setLightmaps] "+lightmapName+" Lightmap does not exist");
// }
//}
Ogre::Entity* RenderSubsystem::createEntity(Ogre::String nodeName,Ogre::String name,TRenderComponentEntityParameters entityParams,TKeyFrameMap* keyframes)
{
unsigned int i;
Entity *pEntity = 0;
SceneNode *pEntityNode = 0;
try
{
//Create meshfile
createMeshFile(entityParams.meshfile,entityParams.mInitManualAnimations,
entityParams.mManualAnimationName,keyframes);
//create entity and set its parameters
pEntity = mSceneManager->createEntity(name, entityParams.meshfile);
pEntity->setCastShadows(entityParams.castshadows);
//set subentities parameters
for(i=0;i<entityParams.tRenderComponentSubEntityParameters.size();i++)
{
createSubEntity(pEntity,
i,
entityParams.tRenderComponentSubEntityParameters[i].material,
entityParams.tRenderComponentSubEntityParameters[i].visible);
}
//set Query flags
pEntity->setQueryFlags(entityParams.cameraCollisionType);
//set RenderQueue priortiy and group
pEntity->setRenderQueueGroup(entityParams.queueID);
//attach to Scene Manager
pEntityNode=mSceneManager->getSceneNode(nodeName);
pEntityNode->attachObject(pEntity);
}
catch(Ogre::Exception &/*e*/)
{
Logger::getInstance()->log("[LevelLoader] Error creating "+name+" Entity!");
}
return pEntity;
}
void RenderSubsystem::createSubEntity(Ogre::Entity *pEntity,int num,OUAN::String material,bool visible)
{
SubEntity *pSubEntity = 0;
try
{
//get the SubEntity
pSubEntity=pEntity->getSubEntity(num);
//set SubEntity attributes
pSubEntity->setMaterialName(material);
pSubEntity->setVisible(visible);
}
catch(Ogre::Exception &/*e*/)
{
Logger::getInstance()->log("[LevelLoader] Error creating "+pEntity->getName()+"'s SubEntity #"+StringConverter::toString(num)+"!");
}
}
std::vector<ParticleUniverse::ParticleSystem*> RenderSubsystem::createParticleSystems(Ogre::String name,TRenderComponentParticleSystemParameters tRenderComponentParticleSystemParameters, RenderComponentPositionalPtr pRenderComponentPositional)
{
std::vector<ParticleUniverse::ParticleSystem*> pParticleSystems(tRenderComponentParticleSystemParameters.poolSize);
for (int i=0; i<tRenderComponentParticleSystemParameters.poolSize; i++)
{
ParticleUniverse::ParticleSystem* pParticleSystem = 0;
Ogre::SceneNode* particleSystemNode = 0;
Ogre::String particleName = name + "#" + Application::getInstance()->getStringUniqueId();
/*
Logger::getInstance()->log("INNER CREATION OF PARTICLE SYSTEM");
Logger::getInstance()->log("PS INIT INFO");
Logger::getInstance()->log(particleName);
Logger::getInstance()->log(tRenderComponentParticleSystemParameters.templateName);
Logger::getInstance()->log("PS INFO END");
*/
try
{
// Create ParticleSystem
pParticleSystem = ParticleUniverse::ParticleSystemManager::getSingleton().createParticleSystem(
particleName,
tRenderComponentParticleSystemParameters.templateName,
mApp->getRenderSubsystem()->getSceneManager());
pParticleSystem->setQueryFlags(OUAN::QUERYFLAGS_NONE);
//set RenderQueue priortiy and group
pParticleSystem->setRenderQueueGroup(tRenderComponentParticleSystemParameters.queueID);
// Create Particle System scene node where required
if (tRenderComponentParticleSystemParameters.attached)
{
particleSystemNode=pRenderComponentPositional->getSceneNode()->createChildSceneNode(particleName);
}
else
{
particleSystemNode=mSceneManager->getRootSceneNode()->createChildSceneNode(particleName);
}
// Attach particle system to the created scene node
particleSystemNode->attachObject(pParticleSystem);
}
catch(Ogre::Exception &/*e*/)
{
Logger::getInstance()->log("[LevelLoader] Error creating "+particleName+" ParticleSystem!");
}
pParticleSystems[i] = pParticleSystem;
}
return pParticleSystems;
}
void RenderSubsystem::createBillboard(Ogre::BillboardSet * pBillboardSet,OUAN::ColourValue colour,OUAN::Vector2 dimensions,OUAN::Vector3 position,OUAN::Real rotation,int texcoordindex,OUAN::Vector4 texrect)
{
Billboard *pBillboard = 0;
try
{
//create Billboard
pBillboard = pBillboardSet->createBillboard(position);
//set Billboard attributes
pBillboard->setColour(colour);
pBillboard->setDimensions(dimensions.x,dimensions.y);
pBillboard->setRotation(Angle(rotation));
pBillboard->setTexcoordIndex(texcoordindex);
pBillboard->setTexcoordRect(texrect.x,texrect.y,texrect.z,texrect.w);
}
catch(Ogre::Exception &/*e*/)
{
Logger::getInstance()->log("[LevelLoader] Error creating "+pBillboardSet->getName()+"'s Billboard!");
}
}
Ogre::BillboardSet * RenderSubsystem::createBillboardSet(Ogre::String nodeName,Ogre::String name,TRenderComponentBillboardSetParameters tRenderComponentBillboardSetParameters)
{
BillboardSet *billBoardSet = 0;
SceneNode *billBoardSetNode = 0;
try
{
//Create BillboardSet
billBoardSet = mSceneManager->createBillboardSet(name);
//Attach BillboardSet to SceneNode
billBoardSetNode = mSceneManager->getSceneNode(nodeName);
billBoardSetNode->attachObject(billBoardSet);
//Set BillboardSet Attributes
billBoardSet->setMaterialName(tRenderComponentBillboardSetParameters.material);
billBoardSet->setDefaultHeight(tRenderComponentBillboardSetParameters.defaultheight);
billBoardSet->setDefaultWidth(tRenderComponentBillboardSetParameters.defaultwidth);
billBoardSet->setPointRenderingEnabled(tRenderComponentBillboardSetParameters.pointrendering);
billBoardSet->setRenderingDistance(tRenderComponentBillboardSetParameters.renderdistance);
billBoardSet->setSortingEnabled(tRenderComponentBillboardSetParameters.sorting);
billBoardSet->setBillboardType(tRenderComponentBillboardSetParameters.billboardtype);
billBoardSet->setBillboardOrigin(tRenderComponentBillboardSetParameters.billboardorigin);
billBoardSet->setBillboardRotationType(tRenderComponentBillboardSetParameters.billboardrotation);
billBoardSet->setQueryFlags(QUERYFLAGS_NONE);
//set RenderQueue priortiy and group
billBoardSet->setRenderQueueGroup(tRenderComponentBillboardSetParameters.queueID);
// Create BillboardSet's Billboards
for(unsigned int i=0;i<tRenderComponentBillboardSetParameters.tRenderComponentBillboardParameters.size();i++)
{
createBillboard(billBoardSet,
tRenderComponentBillboardSetParameters.tRenderComponentBillboardParameters[i].colour,
tRenderComponentBillboardSetParameters.tRenderComponentBillboardParameters[i].dimensions,
tRenderComponentBillboardSetParameters.tRenderComponentBillboardParameters[i].position,
tRenderComponentBillboardSetParameters.tRenderComponentBillboardParameters[i].rotation,
tRenderComponentBillboardSetParameters.tRenderComponentBillboardParameters[i].texcoordindex,
tRenderComponentBillboardSetParameters.tRenderComponentBillboardParameters[i].texrect);
}
}
catch(Ogre::Exception &/*e*/)
{
Logger::getInstance()->log("[LevelLoader] Error creating "+name+" BillboardSet!");
}
return billBoardSet;
}
Ogre::String RenderSubsystem::getDebugMessage()
{
return debugMessage;
}
void RenderSubsystem::setDebugMessage(Ogre::String debugMessage)
{
this->debugMessage = debugMessage;
}
void RenderSubsystem::updateStats()
{
static Ogre::String currFps = "Current FPS: ";
static Ogre::String avgFps = "Average FPS: ";
static Ogre::String bestFps = "Best FPS: ";
static Ogre::String worstFps = "Worst FPS: ";
static Ogre::String tris = "Triangle Count: ";
static Ogre::String batches = "Batch Count: ";
// update stats when necessary
try {
Ogre::OverlayElement* guiAvg = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
Ogre::OverlayElement* guiCurr = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
Ogre::OverlayElement* guiBest = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
Ogre::OverlayElement* guiWorst = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");
const Ogre::RenderTarget::FrameStats& stats = mWindow->getStatistics();
guiAvg->setCaption(avgFps + Ogre::StringConverter::toString(stats.avgFPS));
guiCurr->setCaption(currFps + Ogre::StringConverter::toString(stats.lastFPS));
guiBest->setCaption(bestFps + Ogre::StringConverter::toString(stats.bestFPS)
+" "+Ogre::StringConverter::toString(stats.bestFrameTime)+" ms");
guiWorst->setCaption(worstFps + Ogre::StringConverter::toString(stats.worstFPS)
+" "+Ogre::StringConverter::toString(stats.worstFrameTime)+" ms");
Ogre::OverlayElement* guiTris = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
guiTris->setCaption(tris + Ogre::StringConverter::toString(stats.triangleCount));
Ogre::OverlayElement* guiBatches = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/NumBatches");
guiBatches->setCaption(batches + Ogre::StringConverter::toString(stats.batchCount));
}
catch(...) { /* ignore */ }
}
void RenderSubsystem::updateDebugInfo()
{
try {
Ogre::OverlayElement* guiDbg = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
guiDbg->setTop(0);
//Ogre::StringConverter::toString(x);
guiDbg->setCaption(debugMessage);
}
catch(...) { /* ignore */ }
}
void RenderSubsystem::showVisualDebugger()
{
if (mNxOgreVisualDebugger)
mNxOgreVisualDebugger->setVisualisationMode(NxOgre::Enums::VisualDebugger_ShowAll);
}
void RenderSubsystem::hideVisualDebugger()
{
if (mNxOgreVisualDebugger)
mNxOgreVisualDebugger->setVisualisationMode(NxOgre::Enums::VisualDebugger_ShowNone);
}
void RenderSubsystem::showOverlay(const std::string& overlayName)
{
Ogre::Overlay* ovl;
if (ovl=Ogre::OverlayManager::getSingleton().getByName(overlayName))
ovl->show();
else Logger::getInstance()->log("[ShowOverlay] Error loading "+overlayName+" Overlay!");
}
void RenderSubsystem::hideOverlay(const std::string& overlayName)
{
Ogre::Overlay* ovl;
if (ovl=Ogre::OverlayManager::getSingleton().getByName(overlayName))
ovl->hide();
else Logger::getInstance()->log("[ShowOverlay] Error loading "+overlayName+" Overlay!");
}
void RenderSubsystem::pauseRendering()
{
Ogre::ControllerManager::getSingleton().setTimeFactor(0);
}
void RenderSubsystem::resumeRendering()
{
Ogre::ControllerManager::getSingleton().setTimeFactor(1.0);
}
void RenderSubsystem::clearScene()
{
//mSceneManager->destroyAllCameras();
//mSceneManager->clearScene();
mRoot->destroySceneManager(mSceneManager);
mWindow->removeAllViewports();
//mApp->getGUISubsystem()->clearRenderer();
}
void RenderSubsystem::resetScene()
{
clearScene();
mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC, "Default Scene Manager");
}
void RenderSubsystem::captureScene(const std::string& name)
{
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual("wtf",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, mWindow->getWidth(), mWindow->getHeight(), 0, Ogre::PF_R8G8B8A8,
TU_RENDERTARGET);
Ogre::RenderTexture *renderTexture = texture->getBuffer()->getRenderTarget();
renderTexture->addViewport(mApp->getCameraManager()->getCamera());
renderTexture->getViewport(0)->setClearEveryFrame(true);
renderTexture->getViewport(0)->setBackgroundColour(Ogre::ColourValue(0,0,0,1));
renderTexture->getViewport(0)->setOverlaysEnabled(false);
renderTexture->update();
renderTexture->writeContentsToFile(name);
}
void RenderSubsystem::hideOverlayElement(const std::string& overlayName)
{
Ogre::OverlayElement* overlayElem = Ogre::OverlayManager::getSingleton().getOverlayElement(overlayName);
if (overlayElem)
{
overlayElem->hide();
}
}
void RenderSubsystem::showOverlayElement(const std::string& overlayName)
{
Ogre::OverlayElement* overlayElem = Ogre::OverlayManager::getSingleton().getOverlayElement(overlayName);
if (overlayElem)
{
overlayElem->show();
}
}
void RenderSubsystem::initShadows()
{
//DEPTH SHADOWMAP
Configuration config;
std::string shadowTextureMaterial;
int shadowTextureCount;
int shadowTextureSize;
Ogre::PixelFormat shadowTexturePixelFormat;
bool shadowRenderBackFaces;
double shadowFarDistance;
if (config.loadFromFile(SHADOWS_CONFIG_PATH))
{
config.getOption(CONFIG_SHADOW_TEXTURE_CASTER_MATERIAL,shadowTextureMaterial);
shadowTextureCount=config.parseInt(CONFIG_SHADOW_TEXTURE_COUNT);
shadowTextureSize=config.parseInt(CONFIG_SHADOW_TEXTURE_SIZE);
shadowTexturePixelFormat=(Ogre::PixelFormat)config.parseInt(CONFIG_SHADOW_TEXTURE_PIXEL_FORMAT);
shadowRenderBackFaces=config.parseBool(CONFIG_SHADOW_TEXTURE_CASTER_RENDER_BACK_FACES);
shadowFarDistance=config.parseDouble(CONFIG_SHADOW_FAR_DISTANCE);
}
// Allow self shadowing (note: this only works in conjunction with the shaders defined above)
mSceneManager->setShadowTextureSelfShadow(true);
// Set the caster material which uses the shaders defined above
mSceneManager->setShadowTextureCasterMaterial(shadowTextureMaterial);
// Set the pixel format to floating point
mSceneManager->setShadowTexturePixelFormat(shadowTexturePixelFormat);
// You can switch this on or off, I suggest you try both and see which works best for you
mSceneManager->setShadowCasterRenderBackFaces(shadowRenderBackFaces);
// Finally enable the shadows using texture additive integrated
mSceneManager->setShadowTechnique(SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
mSceneManager->setShadowTextureSize(shadowTextureSize);
mSceneManager->setShadowFarDistance(shadowFarDistance);
mSceneManager->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::FocusedShadowCameraSetup()));
// STENCIL SHADOWS
//mSceneManager->setAmbientLight(ColourValue(0, 0, 0));
//mSceneManager->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
//Entity *ent; Light *light;
//Ogre::SceneNode * mSceneNode;
//Ogre::SceneNode * mSceneNode2;
//Entity *ent2;
//mSceneNode=mSceneManager->getRootSceneNode()->createChildSceneNode();
//mSceneManager->setAmbientLight(ColourValue(0, 0, 0));
//mSceneManager->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
//ent = mSceneManager->createEntity("Ninja", "ninja.mesh");
//ent->setCastShadows(true);
//mSceneNode->attachObject(ent);
//ent2 = mSceneManager->createEntity("Ninja2", "Any2.mesh");
//ent2->setCastShadows(true);
//ent2->setMaterialName("any_d");
//mSceneNode2=mSceneNode->createChildSceneNode();
//mSceneNode2->setPosition(0,0,-50);
//mSceneNode2->attachObject(ent2);
//Plane plane(Vector3::UNIT_Y, 0);
//MeshManager::getSingleton().createPlane("ground",
//ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
//1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);
//ent = mSceneManager->createEntity("GroundEntity", "ground");
//mSceneNode->attachObject(ent);
//ent->setMaterialName("terrain1_d");
//ent->setCastShadows(false);
//light = mSceneManager->createLight("Light1");
//light->setType(Light::LT_POINT);
//light->setPosition(Vector3(0, 150, 250));
//light->setDiffuseColour(1.0, 0.0, 0.0);
//light->setSpecularColour(1.0, 0.0, 0.0);
//light = mSceneManager->createLight("Light3");
//light->setType(Light::LT_DIRECTIONAL);
//light->setDiffuseColour(ColourValue(.25, .25, 0));
//light->setSpecularColour(ColourValue(.25, .25, 0));
//light->setDirection(Vector3( 0, -1, 1 ));
//light = mSceneManager->createLight("Light2");
//light->setType(Light::LT_SPOTLIGHT);
//light->setDiffuseColour(0, 0, 1.0);
//light->setSpecularColour(0, 0, 1.0);
//light->setDirection(-1, -1, 0);
//light->setPosition(Vector3(300, 300, 0));
//light->setSpotlightRange(Degree(35), Degree(50));
//mSceneNode->setPosition(0,250,0);
// SOFT SHADOWS
//// enable integrated additive shadows
//// actually, since we render the shadow map ourselves, it doesn't
//// really matter whether they are additive or modulative
//// as long as they are integrated v(O_o)v
//mSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
//// we'll be self shadowing
//mSceneManager->setShadowTextureSelfShadow(true);
//std::string shadowTextureMaterial=DEFAULT_SHADOW_TEXTURE_CASTER_MATERIAL;
//int shadowTextureCount=DEFAULT_SHADOW_TEXTURE_COUNT;
//int shadowTextureSize=DEFAULT_SHADOW_TEXTURE_SIZE;
//Ogre::PixelFormat shadowTexturePixelFormat=DEFAULT_SHADOW_TEXTURE_PIXEL_FORMAT;
//bool shadowRenderBackFaces=DEFAULT_SHADOW_CASTER_RENDER_BACK_FACES;
//Configuration config;
////TODO: Replace this with a more general graphics-config.
//if (config.loadFromFile(SHADOWS_CONFIG_PATH))
//{
// config.getOption(CONFIG_KEYS_SHADOW_TEXTURE_CASTER_MATERIAL,shadowTextureMaterial);
// shadowTextureCount=config.parseInt(CONFIG_KEYS_SHADOW_TEXTURE_COUNT);
// shadowTextureSize=config.parseInt(CONFIG_KEYS_SHADOW_TEXTURE_SIZE);
// shadowTexturePixelFormat=(Ogre::PixelFormat)config.parseInt(CONFIG_KEYS_SHADOW_TEXTURE_PIXEL_FORMAT);
// shadowRenderBackFaces=config.parseBool(CONFIG_KEYS_SHADOW_TEXTURE_CASTER_RENDER_BACK_FACES);
//}
//// our caster material
//mSceneManager->setShadowTextureCasterMaterial(shadowTextureMaterial);
//// note we have no "receiver". all the "receivers" are integrated.
//// get the shadow texture count from the cfg file
//// (each light needs a shadow text.)
//mSceneManager->setShadowTextureCount(shadowTextureCount);
//// the size, too (1024 looks good with 3x3 or more filtering)
//mSceneManager->setShadowTextureSize(shadowTextureSize);
//// float 16 here. we need the R and G channels.
//// float 32 works a lot better with a low/none VSM epsilon (wait till the shaders)
//// but float 16 is good enough and supports bilinear filtering on a lot of cards
//// (we should use _GR, but OpenGL doesn't really like it for some reason)
//mSceneManager->setShadowTexturePixelFormat(shadowTexturePixelFormat);
//// big NONO to render back faces for VSM. it doesn't need any biasing
//// so it's worthless (and rather problematic) to use the back face hack that
//// works so well for normal depth shadow mapping (you know, so you don't
//// get surface acne)
//mSceneManager->setShadowCasterRenderBackFaces(shadowRenderBackFaces);
//const unsigned numShadowRTTs = mSceneManager->getShadowTextureCount();
//for (unsigned i = 0; i < numShadowRTTs; ++i)
//{
// Ogre::TexturePtr tex = mSceneManager->getShadowTexture(i);
// Ogre::Viewport *vp = tex->getBuffer()->getRenderTarget()->getViewport(0);
// vp->setBackgroundColour(Ogre::ColourValue(1, 1, 1, 1));
// vp->setClearEveryFrame(true);
//}
//// and add the shader listener
//mSceneManager->addListener(&shadowListener);
}
//---------------------------
SSAOListener::SSAOListener()
:mCam(NULL)
{
}
void SSAOListener::setCamera(Ogre::Camera* cam)
{
mCam=cam;
}
// this callback we will use to modify SSAO parameters
void SSAOListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
if (pass_id != 42 || !mCam) // not SSAO, return
{
return;
}
// calculate the far-top-right corner in view-space
Ogre::Vector3 farCorner = mCam->getViewMatrix(true) * mCam->getWorldSpaceCorners()[4];
// get the pass
Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
// get the vertex shader parameters
Ogre::GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters();
// set the camera's far-top-right corner
if (params->_findNamedConstantDefinition("farCorner"))
{
params->setNamedConstant("farCorner", farCorner);
}
// get the fragment shader parameters
params = pass->getFragmentProgramParameters();
// set the projection matrix we need
static const Ogre::Matrix4 CLIP_SPACE_TO_IMAGE_SPACE(
0.5, 0, 0, 0.5,
0, -0.5, 0, 0.5,
0, 0, 1, 0,
0, 0, 0, 1);
if (params->_findNamedConstantDefinition("ptMat"))
{
params->setNamedConstant("ptMat", CLIP_SPACE_TO_IMAGE_SPACE * mCam->getProjectionMatrixWithRSDepth());
}
if (params->_findNamedConstantDefinition("far"))
{
params->setNamedConstant("far", mCam->getFarClipDistance());
}
}
//---------------------------
// this is a callback we'll be using to set up our shadow camera
void ShadowListener::shadowTextureCasterPreViewProj(Ogre::Light *light, Ogre::Camera *cam, size_t)
{
// basically, here we do some forceful camera near/far clip attenuation
// yeah. simplistic, but it works nicely. this is the function I was talking
// about you ignoring above in the Mgr declaration.
float range = light->getAttenuationRange();
cam->setNearClipDistance(0.01);
cam->setFarClipDistance(range);
// we just use a small near clip so that the light doesn't "miss" anything
// that can shadow stuff. and the far clip is equal to the lights' range.
// (thus, if the light only covers 15 units of objects, it can only
// shadow 15 units - the rest of it should be attenuated away, and not rendered)
}
// these are pure virtual but we don't need them... so just make them empty
// otherwise we get "cannot declare of type Mgr due to missing abstract
// functions" and so on
void ShadowListener::shadowTexturesUpdated(size_t) {}
void ShadowListener::shadowTextureReceiverPreViewProj(Ogre::Light*, Ogre::Frustum*) {}
void ShadowListener::preFindVisibleObjects(Ogre::SceneManager*, Ogre::SceneManager::IlluminationRenderStage, Ogre::Viewport*) {}
void ShadowListener::postFindVisibleObjects(Ogre::SceneManager*, Ogre::SceneManager::IlluminationRenderStage, Ogre::Viewport*) {} | [
"ithiliel@1610d384-d83c-11de-a027-019ae363d039",
"wyern1@1610d384-d83c-11de-a027-019ae363d039",
"juanj.mostazo@1610d384-d83c-11de-a027-019ae363d039"
] | [
[
[
1,
3
],
[
5,
5
],
[
8,
9
],
[
25,
30
],
[
32,
32
],
[
34,
37
],
[
39,
39
],
[
41,
44
],
[
46,
47
],
[
49,
50
],
[
60,
60
],
[
66,
67
],
[
69,
85
],
[
167,
170
],
[
172,
176
],
[
178,
180
],
[
182,
182
],
[
184,
184
],
[
186,
186
],
[
188,
188
],
[
190,
190
],
[
192,
192
],
[
195,
195
],
[
202,
208
],
[
210,
210
],
[
216,
232
],
[
234,
257
],
[
259,
260
],
[
262,
262
],
[
264,
264
],
[
274,
276
],
[
299,
300
],
[
302,
305
],
[
311,
311
],
[
342,
342
],
[
346,
346
],
[
353,
356
],
[
359,
362
],
[
370,
371
],
[
373,
374
],
[
376,
383
],
[
399,
399
],
[
431,
432
],
[
457,
462
],
[
514,
514
],
[
516,
516
],
[
521,
521
],
[
526,
526
],
[
532,
532
],
[
539,
542
],
[
546,
546
],
[
550,
550
],
[
557,
558
],
[
574,
605
],
[
854,
854
],
[
862,
863
],
[
866,
867
],
[
870,
870
],
[
874,
875
],
[
879,
879
],
[
882,
882
],
[
1037,
1037
],
[
1091,
1095
],
[
1097,
1097
],
[
1099,
1103
],
[
1105,
1109
],
[
1111,
1111
],
[
1113,
1117
],
[
1119,
1119
],
[
1121,
1124
],
[
1126,
1138
],
[
1140,
1152
],
[
1154,
1159
],
[
1161,
1164
],
[
1166,
1166
],
[
1168,
1168
],
[
1170,
1173
],
[
1175,
1175
],
[
1177,
1177
],
[
1179,
1180
],
[
1182,
1183
],
[
1192,
1193
],
[
1200,
1201
],
[
1340,
1340
],
[
1342,
1345
],
[
1347,
1347
],
[
1349,
1352
],
[
1355,
1357
],
[
1359,
1359
],
[
1361,
1371
],
[
1373,
1373
],
[
1375,
1383
],
[
1385,
1385
],
[
1387,
1387
],
[
1390,
1390
],
[
1392,
1392
],
[
1394,
1394
],
[
1396,
1414
]
],
[
[
4,
4
],
[
6,
7
],
[
10,
24
],
[
45,
45
],
[
61,
61
],
[
63,
63
],
[
87,
101
],
[
120,
124
],
[
127,
128
],
[
135,
138
],
[
150,
150
],
[
158,
160
],
[
162,
163
],
[
165,
166
],
[
197,
201
],
[
258,
258
],
[
349,
352
],
[
357,
358
],
[
372,
372
],
[
384,
398
],
[
400,
425
],
[
427,
430
],
[
433,
456
],
[
463,
508
],
[
510,
513
],
[
515,
515
],
[
517,
520
],
[
522,
525
],
[
527,
531
],
[
533,
538
],
[
543,
545
],
[
547,
549
],
[
551,
551
],
[
553,
556
],
[
559,
573
],
[
606,
609
],
[
611,
640
],
[
645,
646
],
[
648,
649
],
[
651,
652
],
[
654,
655
],
[
657,
673
],
[
680,
682
],
[
684,
704
],
[
706,
706
],
[
708,
708
],
[
710,
710
],
[
712,
712
],
[
714,
714
],
[
716,
716
],
[
718,
718
],
[
720,
720
],
[
722,
722
],
[
724,
725
],
[
728,
853
],
[
855,
861
],
[
864,
865
],
[
868,
869
],
[
871,
873
],
[
876,
878
],
[
880,
881
],
[
883,
889
],
[
891,
909
],
[
911,
913
],
[
915,
915
],
[
919,
919
],
[
938,
942
],
[
962,
962
],
[
965,
985
],
[
987,
1019
],
[
1021,
1033
],
[
1035,
1036
],
[
1038,
1038
],
[
1096,
1096
],
[
1104,
1104
],
[
1153,
1153
],
[
1181,
1181
],
[
1184,
1191
],
[
1194,
1199
],
[
1202,
1339
],
[
1415,
1418
]
],
[
[
31,
31
],
[
33,
33
],
[
38,
38
],
[
40,
40
],
[
48,
48
],
[
51,
59
],
[
62,
62
],
[
64,
65
],
[
68,
68
],
[
86,
86
],
[
102,
119
],
[
125,
126
],
[
129,
134
],
[
139,
149
],
[
151,
157
],
[
161,
161
],
[
164,
164
],
[
171,
171
],
[
177,
177
],
[
181,
181
],
[
183,
183
],
[
185,
185
],
[
187,
187
],
[
189,
189
],
[
191,
191
],
[
193,
194
],
[
196,
196
],
[
209,
209
],
[
211,
215
],
[
233,
233
],
[
261,
261
],
[
263,
263
],
[
265,
273
],
[
277,
298
],
[
301,
301
],
[
306,
310
],
[
312,
341
],
[
343,
345
],
[
347,
348
],
[
363,
369
],
[
375,
375
],
[
426,
426
],
[
509,
509
],
[
552,
552
],
[
610,
610
],
[
641,
644
],
[
647,
647
],
[
650,
650
],
[
653,
653
],
[
656,
656
],
[
674,
679
],
[
683,
683
],
[
705,
705
],
[
707,
707
],
[
709,
709
],
[
711,
711
],
[
713,
713
],
[
715,
715
],
[
717,
717
],
[
719,
719
],
[
721,
721
],
[
723,
723
],
[
726,
727
],
[
890,
890
],
[
910,
910
],
[
914,
914
],
[
916,
918
],
[
920,
937
],
[
943,
961
],
[
963,
964
],
[
986,
986
],
[
1020,
1020
],
[
1034,
1034
],
[
1039,
1090
],
[
1098,
1098
],
[
1110,
1110
],
[
1112,
1112
],
[
1118,
1118
],
[
1120,
1120
],
[
1125,
1125
],
[
1139,
1139
],
[
1160,
1160
],
[
1165,
1165
],
[
1167,
1167
],
[
1169,
1169
],
[
1174,
1174
],
[
1176,
1176
],
[
1178,
1178
],
[
1341,
1341
],
[
1346,
1346
],
[
1348,
1348
],
[
1353,
1354
],
[
1358,
1358
],
[
1360,
1360
],
[
1372,
1372
],
[
1374,
1374
],
[
1384,
1384
],
[
1386,
1386
],
[
1388,
1389
],
[
1391,
1391
],
[
1393,
1393
],
[
1395,
1395
]
]
] |
1111a3ce7eb4c0ffdf1af9503ea7e77a192b0fdb | 5c165fbf269ec78254dee24696588355ebb05297 | /Phoenix/PhoenixVisual.h | ded7952ef8cc7e5f5ddfb1ae0d3ae1f3a07346ea | [] | no_license | kumorikarasu/Phoenix-Engine | dce69af719f3a1a38363aa6330b1d0bb4cdc991d | 87bcfef06f4f57eb44a1c57a67e7ed76795667ec | refs/heads/master | 2021-01-10T07:57:06.020395 | 2011-06-20T13:21:06 | 2011-06-20T13:21:06 | 55,923,401 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 600 | h | #ifndef _PHOENIXVISUAL_H_
#define _PHOENIXVISUAL_H_
#include <vector>
namespace PhoenixCore{
#define VISUAL_IMAGE 1
#define VISUAL_ANIMATION 2
#define VISUAL_VBO 3
#define VISUAL_NONE 4
template<class _Ty>
class Visual{
private:
int Type;
std::vector<_Ty*> Display;
public:
Visual(){}
Visual(int _Type){
Type = _Type;
}
void AddVisual(_Ty* Visual){
Display.push_back(visual);
}
std::vector<_Ty*>& GetVisual(){
return Display;
}
int GetType(){
return Type;
}
};
};
#endif | [
"[email protected]"
] | [
[
[
1,
39
]
]
] |
e201bb4a0a773065aa83557ce89907d52ab3d03f | ea12fed4c32e9c7992956419eb3e2bace91f063a | /zombie/code/zombie/nspatial/src/nspatial/nspatialquadtreespacebuilder.cc | cd7008249e8ceaaff6d087ddf03fd4a06830df14 | [] | no_license | ugozapad/TheZombieEngine | 832492930df28c28cd349673f79f3609b1fe7190 | 8e8c3e6225c2ed93e07287356def9fbdeacf3d6a | refs/heads/master | 2020-04-30T11:35:36.258363 | 2011-02-24T14:18:43 | 2011-02-24T14:18:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,755 | cc | #include "precompiled/pchnspatial.h"
//------------------------------------------------------------------------------
// nspatialquadtreespacebuilder.cc
// (C) 2004 Conjurer Services, S.A.
//------------------------------------------------------------------------------
#include "nspatial/nspatialquadtreespacebuilder.h"
#include "nspatial/ncspatialquadtreecell.h"
#include "entity/nentityobjectserver.h"
//------------------------------------------------------------------------------
/**
constructor 1
*/
nSpatialQuadtreeSpaceBuilder::nSpatialQuadtreeSpaceBuilder()
{
}
//------------------------------------------------------------------------------
/**
constructor 2
*/
nSpatialQuadtreeSpaceBuilder::nSpatialQuadtreeSpaceBuilder(ncSpatialQuadtree *quadtreeSpace,
const bbox3 &quadtreeBox,
const bbox3 &terrainBox,
int treeDepth)
{
n_assert2(quadtreeSpace, "miquelangel.rujula: NULL pointer to spatial quadtree space component!");
n_assert2(treeDepth >= 0, "miquelangel.rujula: quadtree's depth has to be positive!");
this->m_quadtreeSpace = quadtreeSpace;
this->SetTerrainBBox(terrainBox);
this->BuildSpace(quadtreeBox, treeDepth);
}
//------------------------------------------------------------------------------
/**
constructor 3
*/
nSpatialQuadtreeSpaceBuilder::nSpatialQuadtreeSpaceBuilder(ncSpatialQuadtree *quadtreeSpace)
{
this->SetQuadtreeSpace(quadtreeSpace);
}
//------------------------------------------------------------------------------
/**
destructor
*/
nSpatialQuadtreeSpaceBuilder::~nSpatialQuadtreeSpaceBuilder()
{
}
//------------------------------------------------------------------------------
/**
Builds the quadtree space from scratch.
*/
void
nSpatialQuadtreeSpaceBuilder::BuildSpace(const bbox3 &sizeBox, int treeDepth)
{
n_assert2(treeDepth >= 0, "miquelangel.rujula");
// set the quadtree's depth
this->m_quadtreeSpace->SetDepth(treeDepth);
ncSpatialQuadtreeCell * rootCell;
rootCell = this->CreateSubtree(sizeBox, treeDepth, 0, 0);
this->m_quadtreeSpace->AddRootCell( rootCell );
}
//------------------------------------------------------------------------------
/**
*/
ncSpatialQuadtreeCell *
nSpatialQuadtreeSpaceBuilder::CreateSubtree(const bbox3 & treeBox, int curDepth, int bx, int bz)
{
bool isLeafCell = false;
bool hasTerrain = false;
ncSpatialQuadtreeCell * children[4] = { 0, 0, 0, 0 };
ncSpatialQuadtreeCell * cell = 0;
// set the cell's id
int cellId = this->m_quadtreeSpace->GetTotalNumCells();
// increase the number of cells of the quadtree space
this->m_quadtreeSpace->IncTotalNumCells();
if (curDepth > 0)
{
bbox3 cellBox;
int cellBX, cellBZ;
float x = (treeBox.vmin.x + treeBox.vmax.x) * 0.5f;
float z = (treeBox.vmin.z + treeBox.vmax.z) * 0.5f;
for(int i = 0;i < 4;i++)
{
float x0, x1, z0, z1;
// initialize cell coords (continous and discrete)
if (i & 1)
{ // i == 1, 3
x0 = x;
x1 = treeBox.vmax.x;
cellBX = 2 * bx + 1;
}
else
{ // i == 0, 2
x0 = treeBox.vmin.x;
x1 = x;
cellBX = 2 * bx;
}
if (i & 2)
{ // i == 2, 3
z0 = treeBox.vmin.z;
z1 = z;
cellBZ = 2 * bz;
}
else
{ // i == 0, 1
z0 = z;
z1 = treeBox.vmax.z;
cellBZ = 2 * bz + 1;
}
// calculate bbox
cellBox.vmin = vector3(x0, treeBox.vmin.y, z0);
cellBox.vmax = vector3(x1, treeBox.vmax.y, z1);
// create subtree first
children[i] = this->CreateSubtree(cellBox, curDepth - 1, cellBX, cellBZ);
if (children[i]->GetEntityObject())
{
hasTerrain = true;
}
}
}
else
{
// end of recursion
isLeafCell = true;
hasTerrain = this->terrainBox.contains( treeBox.center() );
}
// determine which type of cell create
if ( hasTerrain )
{
nEntityObject* newSubcell = nEntityObjectServer::Instance()->NewLocalEntityObject("neoutdoorcell");
cell = newSubcell->GetComponent<ncSpatialQuadtreeCell>();
}
else
{
cell = n_new(ncSpatialQuadtreeCell);
}
// initialize all cell parameters
cell->SetParentSpace(this->m_quadtreeSpace);
cell->SetDepth( this->m_quadtreeSpace->GetDepth() - (curDepth - 1) );
cell->SetBBox(treeBox);
cell->SetId(cellId);
cell->SetBX(bx);
cell->SetBZ(bz);
// is a leaf cell. Insert it in the leaf cells array
if (isLeafCell)
{
if (hasTerrain)
{
this->AddLeafCell(cell);
}
}
else
{
// add the new subcells to the given one
for(int i = 0;i < 4;i++)
{
cell->AddSubCell( children[i] );
children[i]->SetParentCell( cell );
}
}
return cell;
}
//------------------------------------------------------------------------------
/**
Search the cell that completely contains the parameter bounding box, starting
from the given quadtree cell. It tries to find the one that best fits the
bounding box.
*/
ncSpatialQuadtreeCell *
nSpatialQuadtreeSpaceBuilder::SearchCell(ncSpatialQuadtreeCell *quadCell, bbox3 &box)
{
if (!quadCell->GetBBox().contains(box))
{
// at least the parameter quadtree cell has to contain the bounding box
return NULL;
}
ncSpatialQuadtreeCell** subcells = 0;
// now, we'll try to find a subcell which the bounding box fits better
while (!quadCell->IsLeaf())
{
subcells = quadCell->GetSubcells();
int i;
for (i = 0; i < 4; i++)
{
if (subcells[i]->GetBBox().contains(box))
{
quadCell = subcells[i];
break;
}
}
if ( i == 4 )
{
// we haven't found any child cell containing the bounding box,
// so we'll return the actual quadtree cell
break;
}
}
return quadCell;
}
//------------------------------------------------------------------------------
/**
add a cell to the leaf cells array in its place (array is sorted by position)
*/
void
nSpatialQuadtreeSpaceBuilder::AddLeafCell(ncSpatialQuadtreeCell* cell)
{
n_assert2(cell, "miquelangel.rujula: NULL pointer to cell!");
ncSpatialQuadtreeCell *curCell = 0;
// find cell's position in the array
int i;
for (i = 0; i < this->m_quadtreeSpace->m_leafCells.Size(); i++)
{
curCell = this->m_quadtreeSpace->m_leafCells[i];
n_assert(curCell);
if (cell->GetBBox().vmax.z < curCell->GetBBox().vmax.z)
{
break;
}
else
{
if (cell->GetBBox().vmax.x < curCell->GetBBox().vmax.x)
{
break;
}
}
}
// insert the cell in the correponding position
this->m_quadtreeSpace->m_leafCells.Insert(i, cell);
}
| [
"magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91"
] | [
[
[
1,
259
]
]
] |
19a44b06d5c7c32d523dc327de564f71f8cf35d8 | 54cacc105d6bacdcfc37b10d57016bdd67067383 | /trunk/source/materials/BasicMaterial.h | 179d750e63c3084e747480b05763b0e3d4e77313 | [] | no_license | galek/hesperus | 4eb10e05945c6134901cc677c991b74ce6c8ac1e | dabe7ce1bb65ac5aaad144933d0b395556c1adc4 | refs/heads/master | 2020-12-31T05:40:04.121180 | 2009-12-06T17:38:49 | 2009-12-06T17:38:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,070 | h | /***
* hesperus: BasicMaterial.h
* Copyright Stuart Golodetz, 2009. All rights reserved.
***/
#ifndef H_HESP_BASICMATERIAL
#define H_HESP_BASICMATERIAL
#include <source/colours/Colour3d.h>
#include "Material.h"
namespace hesp {
class BasicMaterial : public Material
{
//#################### PRIVATE VARIABLES ####################
private:
Colour3d m_ambient;
Colour3d m_diffuse;
Colour3d m_emissive;
Colour3d m_specular;
double m_specularExponent;
bool m_wireframe;
//#################### CONSTRUCTORS ####################
public:
BasicMaterial(const Colour3d& ambient, const Colour3d& diffuse, const Colour3d& specular, double specularExponent, const Colour3d& emissive,
bool wireframe = false);
//#################### PUBLIC METHODS ####################
public:
const Colour3d& ambient() const;
void apply() const;
const Colour3d& diffuse() const;
const Colour3d& emissive() const;
const Colour3d& specular() const;
double specular_exponent() const;
bool uses_texcoords() const;
};
}
#endif
| [
"[email protected]"
] | [
[
[
1,
43
]
]
] |
427d88941486b16873b83d5a74469b55eb37d020 | cd0987589d3815de1dea8529a7705caac479e7e9 | /webkit/WebKit2/Shared/WebURL.h | a9f974df660648db9e6315a39abc7214d76d24ab | [] | no_license | azrul2202/WebKit-Smartphone | 0aab1ff641d74f15c0623f00c56806dbc9b59fc1 | 023d6fe819445369134dee793b69de36748e71d7 | refs/heads/master | 2021-01-15T09:24:31.288774 | 2011-07-11T11:12:44 | 2011-07-11T11:12:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,212 | h | /*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebURL_h
#define WebURL_h
#include "APIObject.h"
#include <wtf/PassRefPtr.h>
#include <wtf/text/WTFString.h>
namespace WebKit {
// WebURL - An string array type suitable for vending to an API.
class WebURL : public APIObject {
public:
static const Type APIType = TypeURL;
static PassRefPtr<WebURL> create(const WTF::String& string)
{
return adoptRef(new WebURL(string));
}
bool isNull() const { return m_string.isNull(); }
bool isEmpty() const { return m_string.isEmpty(); }
const WTF::String& string() const { return m_string; }
private:
WebURL(const WTF::String& string)
: m_string(string)
{
}
virtual Type type() const { return APIType; }
WTF::String m_string;
};
} // namespace WebKit
#endif // WebURL_h
| [
"[email protected]"
] | [
[
[
1,
64
]
]
] |
9702466b1fb15b40d44cf17c91b16d45941cddfa | 0f40e36dc65b58cc3c04022cf215c77ae31965a8 | /src/apps/topology/polygon/jarvis_march.cpp | 7160b1b1865ecb891e65e969f5cadfb3248bc6a1 | [
"MIT",
"BSD-3-Clause"
] | permissive | venkatarajasekhar/shawn-1 | 08e6cd4cf9f39a8962c1514aa17b294565e849f8 | d36c90dd88f8460e89731c873bb71fb97da85e82 | refs/heads/master | 2020-06-26T18:19:01.247491 | 2010-10-26T17:40:48 | 2010-10-26T17:40:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,351 | cpp | #include "_apps_enable_cmake.h"
#ifdef ENABLE_TOPOLOGY
#include "apps/topology/polygon/jarvis_march.h"
#include <math.h>
#include "sys/util/defutils.h"
using namespace std;
namespace polygon
{
JarvisMarch::
JarvisMarch()
{
}
// ----------------------------------------------------------------------
JarvisMarch::
~JarvisMarch()
{}
// ----------------------------------------------------------------------
vector<Vec>
JarvisMarch::
compute_convex_hull(const vector<Vec>& poly)
throw()
{
polygon_=poly;
size_of_polygon_=polygon_.size();
size_of_convex_hull_=0;
jm();
// size_of_convex_hull_ now contains the number of the first points in polygon_ (they are in the right order) which belong to the convex hull
vector<Vec> convex_hull;
for(int i=0;i<size_of_convex_hull_;i++)
{
convex_hull.push_back(polygon_[i]);
}
return convex_hull;
}
// ----------------------------------------------------------------------
void
JarvisMarch::
jm()
throw()
{
int i=index_of_lowest_point();
do
{
swap(size_of_convex_hull_, i);
i=index_of_rightmost_point_from(polygon_[size_of_convex_hull_]);
size_of_convex_hull_++;
}
while (i>0);
}
// ----------------------------------------------------------------------
int
JarvisMarch::
index_of_lowest_point()
throw()
{
int i, min=0;
for (i=1; i<size_of_polygon_; i++){
if (polygon_[i].y()<polygon_[min].y() || (EQDOUBLE(polygon_[i].y(),polygon_[min].y()) && polygon_[i].x()<polygon_[min].x()))
{
min=i;
}
}
return min;
}
// ----------------------------------------------------------------------
int
JarvisMarch::
index_of_rightmost_point_from(const Vec& q)
throw()
{
int i=0, j;
for (j=1; j<size_of_polygon_; j++){
Vec reltoj = relTo(polygon_[j],q);
Vec reltoi = relTo(polygon_[i],q);
if (isLess(reltoj, reltoi))
{
i=j;
}
}
return i;
}
// ----------------------------------------------------------------------
void
JarvisMarch::
swap(int i, int j)
throw()
{
Vec t=polygon_[i];
polygon_[i]=polygon_[j];
polygon_[j]=t;
}
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
Vec
JarvisMarch::
relTo(const Vec& p1, const Vec& p2)
throw()
{
return Vec(p1.x()-p2.x(), p1.y()-p2.y(), 0.0);
}
// ----------------------------------------------------------------------
bool
JarvisMarch::
isLess(const Vec& p1, const Vec& p2)
throw()
{
double f=cross(p1,p2);
return f>0 || (EQDOUBLE(f,0) && isFurther(p1,p2));
}
// ----------------------------------------------------------------------
double
JarvisMarch::
cross(const Vec& p1, const Vec& p2)
throw()
{
return p1.x()*p2.y()-p2.x()*p1.y();
}
// ----------------------------------------------------------------------
bool
JarvisMarch::
isFurther(const Vec& p1, const Vec& p2)
throw()
{
return mdist(p1)>mdist(p2);
}
// ----------------------------------------------------------------------
double
JarvisMarch::
mdist(const Vec& p)
throw()
{
return fabs(p.x())+fabs(p.y());
}
}
#endif
| [
"[email protected]",
"[email protected]",
"[email protected]"
] | [
[
[
1,
1
]
],
[
[
2,
16
],
[
18,
19
],
[
22,
25
],
[
27,
27
],
[
29,
29
],
[
31,
36
],
[
38,
46
],
[
50,
50
],
[
52,
63
],
[
65,
65
],
[
67,
67
],
[
69,
72
],
[
74,
80
],
[
82,
82
],
[
84,
84
],
[
86,
99
],
[
101,
101
],
[
103,
103
],
[
105,
109
],
[
111,
113
],
[
116,
116
],
[
118,
124
],
[
126,
126
],
[
128,
130
],
[
132,
133
],
[
137,
137
],
[
139,
141
],
[
144,
145
],
[
149,
155
],
[
157,
157
],
[
160,
161
],
[
164,
166
]
],
[
[
17,
17
],
[
20,
21
],
[
26,
26
],
[
28,
28
],
[
30,
30
],
[
37,
37
],
[
47,
49
],
[
51,
51
],
[
64,
64
],
[
66,
66
],
[
68,
68
],
[
73,
73
],
[
81,
81
],
[
83,
83
],
[
85,
85
],
[
100,
100
],
[
102,
102
],
[
104,
104
],
[
110,
110
],
[
114,
115
],
[
117,
117
],
[
125,
125
],
[
127,
127
],
[
131,
131
],
[
134,
136
],
[
138,
138
],
[
142,
143
],
[
146,
148
],
[
156,
156
],
[
158,
159
],
[
162,
163
]
]
] |
4e27345463c16991f9f69e12a7aae5828b084fc5 | a1e9c29572b2404e4195c14a14dbf5f2d260d595 | /src/Synthesizer.cpp | 59e05152f0a903b5dc93e182b379f2d544c6d46c | [] | no_license | morsela/texton-izer | 87333d229a34bf885e00c77b672d671ff72941f3 | 8e9f96d4a00834087247d000ae4df5282cbbfc4e | refs/heads/master | 2021-07-29T01:37:38.232643 | 2009-02-13T15:40:03 | 2009-02-13T15:40:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,868 | cpp | #include "Synthesizer.h"
#include "ColorUtils.h"
#include "defs.h"
bool SortTextonsByAppereanceNumber(Texton*& lhs, Texton*& rhs)
{
return (*lhs) < (*rhs);
}
Synthesizer::Synthesizer()
{
m_textonBgColor = TEXTON_BG_COLOR;
m_resultBgColor = RESULT_BG_COLOR;
m_nBorder = IMG_BORDER;
srand((unsigned int)time(NULL));
}
Synthesizer::~Synthesizer()
{}
bool Synthesizer::insertTexton(int x, int y,
const IplImage * textonImg,
IplImage* synthesizedImage)
{
//sanity check
if (x < 0 ||
y < 0 ||
x >= synthesizedImage->width ||
y >= synthesizedImage->height){
return false;
}
if (x + textonImg->width >= synthesizedImage->width ||
y + textonImg->height >= synthesizedImage->height){
return false;
}
bool fColored = false;
int synthStep = synthesizedImage->widthStep;
int textonStep = textonImg->widthStep;
uchar * pTextonData = reinterpret_cast<uchar *>(textonImg->imageData);
uchar * pSynthData =
reinterpret_cast<uchar *>(synthesizedImage->imageData);
for (int i = 0; i < textonImg->width; i++){
for (int j = 0; j < textonImg->height; j++) {
int pos = j*textonStep+i*3;
CvScalar color = cvScalar(pTextonData[pos+0],
pTextonData[pos+1],
pTextonData[pos+2]);
if (ColorUtils::compareColors(color, m_textonBgColor))
continue;
else {
if (j+y >= synthesizedImage->height
|| i + x >= synthesizedImage->width)
return false;
int pos = (j+y)*synthStep+(i+x)*3;
CvScalar color1 = cvScalar(pSynthData[pos+0],
pSynthData[pos+1],
pSynthData[pos+2]);
if (ColorUtils::compareColors(color1, m_resultBgColor)){
ColorUtils::recolorPixel(pSynthData,
j+y, i+x, synthStep, &color);
m_nEmptySpots--;
fColored = true;
}
}
}
}
return fColored;
}
void Synthesizer::copyImageWithoutBorder(IplImage * src,
IplImage * dst,
int nBorderSize)
{
int srcStep = src->widthStep;
int dstStep = dst->widthStep;
uchar * pSrcData = reinterpret_cast<uchar *>(src->imageData);
uchar * pDstData = reinterpret_cast<uchar *>(dst->imageData);
for (int i = nBorderSize; i < src->width - nBorderSize; i++){
for (int j = nBorderSize; j < src->height - nBorderSize; j++) {
int pos = j*srcStep + i*3;
CvScalar color = cvScalar(pSrcData[pos],
pSrcData[pos + 1],
pSrcData[pos + 2]);
ColorUtils::recolorPixel(pDstData,
(j - nBorderSize),
(i - nBorderSize),
dstStep,
&color);
}
}
}
void Synthesizer::copyImageWithoutBackground(IplImage * src, IplImage * dst)
{
int srcStep = src->widthStep;
int dstStep = dst->widthStep;
uchar * pSrcData = reinterpret_cast<uchar *>(src->imageData);
uchar * pDstData = reinterpret_cast<uchar *>(dst->imageData);
for (int i = 0; i < src->width; i++){
for (int j = 0; j < src->height; j++) {
int pos = j*srcStep+i*3;
CvScalar color = cvScalar(pSrcData[pos+0],
pSrcData[pos+1],
pSrcData[pos+2]);
if (!ColorUtils::compareColors(color, m_resultBgColor)
&& !ColorUtils::compareColors(color, RESULT_DILATION_COLOR)){
ColorUtils::recolorPixel(pDstData, j, i, dstStep, &color);
}
}
}
}
void Synthesizer::removeBorderTextons(vector<Cluster>& clusterList)
{
for (unsigned int i = 0; i < clusterList.size(); i++) {
Cluster& curCluster = clusterList[i];
list<Texton*>::iterator iter = curCluster.m_textonList.begin();
while (iter != curCluster.m_textonList.end()){
//find a suitable texton
if ((*iter)->getPosition() == Texton::NON_BORDER
&& !(*iter)->isImageBackground())
iter++;
else{
iter = curCluster.m_textonList.erase(iter);
curCluster.m_nClusterSize--;
}
}
}
}
void Synthesizer::removeNonconformingTextons(vector<Cluster> &clusterList)
{
double nDilationAvg;
for (unsigned int i = 0; i < clusterList.size(); i++) {
Cluster& cluster = clusterList[i];
nDilationAvg = 0.0;
for (list<Texton*>::iterator iter = cluster.m_textonList.begin();
iter != cluster.m_textonList.end(); iter++){
nDilationAvg += (*iter)->getDilationArea();
}
nDilationAvg = nDilationAvg / cluster.m_nClusterSize;
if (nDilationAvg > AVG_DILATION_ERROR)
{
//remove all the "too-close" textons from the list
list<Texton*>::iterator iter = cluster.m_textonList.begin();
while (iter != cluster.m_textonList.end())
{
if ((*iter)->getDilationArea() < AVG_DILATION_ERROR)
{
iter = cluster.m_textonList.erase(iter);
cluster.m_nClusterSize--;
}
else {
iter++;
}
}
}
}
}
IplImage * Synthesizer::retrieveBackground(vector<Cluster> &clusterList,
IplImage * img)
{
// Finds the cluster in which the image filling texton resides
int nBackgroundCluster = -1;
for (unsigned int i = 0; i < clusterList.size(); i++) {
if (clusterList[i].isImageBackground())
nBackgroundCluster = i;
}
IplImage * backgroundImage = cvCreateImage(cvSize(img->width,img->height),
img->depth,
img->nChannels);
CvScalar bgColor = cvScalarAll(1);
cvSet(backgroundImage, bgColor);
Texton * t = NULL;
if (nBackgroundCluster >= 0) {
// Find the image filling texton
for (list<Texton*>::iterator iter =
clusterList[nBackgroundCluster].m_textonList.begin();
iter != clusterList[nBackgroundCluster].m_textonList.end();
iter++)
{
if ((*iter)->isImageBackground())
{
t = *iter;
break;
}
}
IplImage * bgTexton = t->getTextonImg();
int radius = MAX(5,rand() % MIN(t->getTextonImg()->width/4, t->getTextonImg()->height/4));
//printf("radius=%d\n", radius);
int textonStep = bgTexton->widthStep;
int backgroundStep = backgroundImage->widthStep;
uchar * pTextonData = reinterpret_cast<uchar *>(bgTexton->imageData);
uchar * pBackgroundData =
reinterpret_cast<uchar *>(backgroundImage->imageData);
int a = 0;
int b = 0;
bool fColored = false;
int nTries = 0;
printf("* Creating background...");
while (true) {
int pos = b*backgroundStep+a*3;
CvScalar color = cvScalar(pBackgroundData[pos],
pBackgroundData[pos+1],
pBackgroundData[pos+2]);
//If the pixel is already colored,
//we don't activate the algorithm on it
if (nTries > 100
|| !ColorUtils::compareColors(color, bgColor)){
a++;
if (nTries > 100){
nTries = 0;
if (radius <MIN(t->getTextonImg()->width/4, t->getTextonImg()->height/4) - 1)
radius++;
//printf("radius=%d\t", radius);
}
if (a >= backgroundImage->width){
a = 0;
b++;
if (b >= backgroundImage->height)
break;
}
continue;
}
//Clone the target texton to a temporary one in order
//to apply a circle on it
IplImage* tempImg = cvCloneImage( bgTexton );
int tempimgStep = tempImg->widthStep;
uchar * pTempImgData =
reinterpret_cast<uchar *>(tempImg->imageData);
int x = rand() % (tempImg->width - 2*radius) + radius;
int y = rand() % (tempImg->height - 2*radius) + radius;
CvScalar circleColor = cvScalarAll(1);
//printf("+", x,y);
cvCircle(tempImg, cvPoint(x,y), radius, circleColor, -1);
//Extract all the circled area of the texton to the background
int aa = a - radius;
for (int i = (x - radius); i < (x + radius); i++, aa++){
int bb = b - radius;
for (int j = (y - radius); j < (y + radius); j++, bb++) {
int pos = j*textonStep+i*3;
int tempPos = j*tempimgStep+i*3;
CvScalar color = cvScalar(pTextonData[pos+0],
pTextonData[pos+1],
pTextonData[pos+2]);
CvScalar tempColor = cvScalar(pTempImgData[tempPos+0],
pTempImgData[tempPos+1],
pTempImgData[tempPos+2]);
if (ColorUtils::compareColors(color, m_textonBgColor))
continue;
if (ColorUtils::compareColors(tempColor, circleColor)){
if (bb >= backgroundImage->height
|| aa >= backgroundImage->width)
continue;
if (bb < 0 || aa < 0)
continue;
int bpos = bb*backgroundStep+aa*3;
CvScalar bcolor = cvScalar(pBackgroundData[bpos+0],
pBackgroundData[bpos+1],
pBackgroundData[bpos+2]);
//Color the pixel only if it is uncolored
if (ColorUtils::compareColors(bcolor, bgColor)){
ColorUtils::recolorPixel(pBackgroundData,
bb, aa, backgroundStep, &color);
fColored = true;
}
}
}
}
nTries++;
cvReleaseImage(&tempImg);
}
printf("done!\n");
}
return backgroundImage;
}
IplImage* Synthesizer::synthesize(int nNewWidth, int nNewHeight, int depth,
int nChannels, vector<Cluster> &clusterList)
{
printf("\n<<< Texton-Based Synthesizing (%d,%d) >>>\n",
nNewWidth, nNewHeight);
//create the new synthesized image and color it using
//a default background color
IplImage * tempSynthesizedImage =
cvCreateImage(cvSize(nNewWidth + m_nBorder, nNewHeight + m_nBorder),
depth,
nChannels);
cvSet( tempSynthesizedImage, m_resultBgColor);
IplImage * synthesizedImage = cvCreateImage(cvSize(nNewWidth,nNewHeight),
depth,
nChannels);
//Retrieve background from the textons
//(by using an image filling texton or a random texton)
IplImage *backgroundImage =
retrieveBackground(clusterList, tempSynthesizedImage);
/* Remove unnecessary textons */
//Remove all textons that are "too-close" according to the dilation average
removeNonconformingTextons(clusterList);
//Remove all textons that touch a border
removeBorderTextons(clusterList);
/* Synthesize the image using the given clusters */
synthesizeImage(clusterList, tempSynthesizedImage);
copyImageWithoutBackground(tempSynthesizedImage, backgroundImage);
copyImageWithoutBorder(backgroundImage, synthesizedImage, m_nBorder/2);
printf("\n>>> Texton-Based Synthesizing phase completed successfully!"
"<<<\n\n");
cvReleaseImage(&backgroundImage);
cvReleaseImage(&tempSynthesizedImage);
return synthesizedImage;
}
bool Synthesizer::checkSurrounding(int x, int y,
Texton* t,
IplImage* synthesizedImage)
{
int nArea = t->getDilationArea();
int textonStep = t->getTextonImg()->widthStep;
uchar * pTextonData =
reinterpret_cast<uchar *>(t->getTextonImg()->imageData);
int synthStep = synthesizedImage->widthStep;
uchar * pSynthData =
reinterpret_cast<uchar *>(synthesizedImage->imageData);
//Close textons make it possible to assume safe surrounding
//if they do not overlap too much
if (nArea < 2){
int nOverlapCount = 0;
//sanity check
if (x < 0 ||
y < 0 ||
x >= synthesizedImage->width ||
y >= synthesizedImage->height){
return false;
}
if (x + t->getTextonImg()->width >= synthesizedImage->width ||
y + t->getTextonImg()->height >= synthesizedImage->height){
return false;
}
//check if there is a painted texton somewhere that we may overlap
for (int i = 0; i < t->getTextonImg()->width; i++){
for (int j = 0; j < t->getTextonImg()->height; j++)
{
int pos = j*textonStep+i*3;
int synthPos = (j+y)*synthStep+(i+x)*3;
CvScalar color = cvScalar(pTextonData[pos+0],
pTextonData[pos+1],
pTextonData[pos+2]);
CvScalar synthColor = cvScalar(pSynthData[synthPos+0],
pSynthData[synthPos+1],
pSynthData[synthPos+2]);
if (ColorUtils::compareColors(color, m_textonBgColor))
continue;
if (!ColorUtils::compareColors(synthColor, m_resultBgColor)){
nOverlapCount++;
//allow small overlaps
if (nOverlapCount > MAXIMUM_TEXTON_OVERLAP)
return false;
}
}
}
}
else {
printf("2");
int maxWidth =
MIN(x + t->getTextonImg()->width + nArea, synthesizedImage->width);
int maxHeight =
MIN(y + t->getTextonImg()->height + nArea, synthesizedImage->height);
for (int i = MAX(x - nArea, 0) ; i < maxWidth; i++){
for (int j = MAX(y - nArea, 0); j < maxHeight; j++) {
//if there is any collisions in the texton surrounding,
//declare the surrounding 'false'
int pos = j*synthStep+i*3;
CvScalar color = cvScalar(pSynthData[pos+0],
pSynthData[pos+1],
pSynthData[pos+2]);
if (!ColorUtils::compareColors(color, m_resultBgColor))
return false;
}
}
cvCircle(synthesizedImage, cvPoint(x + t->getTextonImg()->width/2,
y + t->getTextonImg()->width/2),
nArea + t->getTextonImg()->width/2,
RESULT_DILATION_COLOR, -1);
}
return true;
}
Texton* Synthesizer::chooseFirstTexton(vector<Cluster> &clusterList)
{
unsigned int nFirstCluster = 0;
list<Texton*>::iterator iter;
//choose the first texton to put in the image randomly
while (nFirstCluster < clusterList.size()){
if (clusterList[nFirstCluster].m_nClusterSize > 0){
iter = clusterList[nFirstCluster].m_textonList.begin();
int nFirstTexton =
rand()%clusterList[nFirstCluster].m_nClusterSize;
for (int i = 0; i < nFirstTexton; i++){
iter++;
}
break;
}
else
nFirstCluster++;
}
if (nFirstCluster >= clusterList.size()){
printf("+++ Unable to synthesize image! +++\n");
throw SynthesizerException();
}
return (*iter);
}
void Synthesizer::synthesizeImage(vector<Cluster> &clusterList,
IplImage * synthesizedImage)
{
list<CoOccurenceQueueItem> coQueue;
Texton * texton = NULL;
Texton * firstTexton = chooseFirstTexton(clusterList);
printf("* Synthesizing image");
// Put the first texton in a place close to the the image sides,
// in order to allow better texton expanding
int x = synthesizedImage->width / 2;
int y = synthesizedImage->height / 2;
checkSurrounding(x,y, firstTexton, synthesizedImage);
insertTexton(x, y, firstTexton->getTextonImg(), synthesizedImage);
vector<CoOccurences>* co = firstTexton->getCoOccurences();
CoOccurenceQueueItem item(x,y,co);
coQueue.push_back(item);
int nCount = 0;
//go through all the textons co-occurences and build the image with them
while (coQueue.size() > 0) {
CoOccurenceQueueItem curItem = coQueue.front();
//printf("size=%d\n",coQueue.size());
coQueue.pop_front();
vector<CoOccurences> co = *(curItem.m_co);
for (unsigned int ico = 0; ico < co.size(); ico++){
Cluster& curCluster = clusterList[co[ico].nCluster];
int nNewX = curItem.m_x + co[ico].distX;
int nNewY = curItem.m_y + co[ico].distY;
bool fInsertedTexton = false;
if (nNewX < 0 || nNewY < 0
|| nNewX >= synthesizedImage->width
|| nNewY >= synthesizedImage->height)
continue;
for (list<Texton*>::iterator iter =
curCluster.m_textonList.begin();
iter != curCluster.m_textonList.end(); iter++){
//try to insert a texton while maintaining an adequate surroundings
texton = *iter;
if (checkSurrounding(nNewX, nNewY,texton,synthesizedImage))
if (insertTexton(nNewX, nNewY,
texton->getTextonImg(),
synthesizedImage)){
fInsertedTexton = true;
break;
}
}
if (fInsertedTexton){
//update the inserted texton's co occurence list
vector<CoOccurences>* coo = texton->getCoOccurences();
CoOccurenceQueueItem newItem(nNewX, nNewY, coo);
coQueue.push_back(newItem);
//update the texton appearance and sort the texton list
//accordingly in order to maintain a fair share for each texton
texton->addAppereance();
curCluster.m_textonList.sort(SortTextonsByAppereanceNumber);
}
}
nCount++;
if (nCount > 50){
printf(".");
nCount = 0;
}
}
}
| [
"morsela@7f168336-c49e-11dd-bdf1-993be837f8bb",
"genged@7f168336-c49e-11dd-bdf1-993be837f8bb"
] | [
[
[
1,
5
],
[
9,
12
],
[
14,
14
],
[
16,
21
],
[
25,
25
],
[
30,
30
],
[
35,
35
],
[
39,
101
],
[
103,
156
],
[
158,
159
],
[
162,
162
],
[
164,
166
],
[
168,
168
],
[
170,
177
],
[
179,
192
],
[
195,
196
],
[
200,
200
],
[
202,
317
],
[
320,
325
],
[
327,
360
],
[
364,
546
]
],
[
[
6,
8
],
[
13,
13
],
[
15,
15
],
[
22,
24
],
[
26,
29
],
[
31,
34
],
[
36,
38
],
[
102,
102
],
[
157,
157
],
[
160,
161
],
[
163,
163
],
[
167,
167
],
[
169,
169
],
[
178,
178
],
[
193,
194
],
[
197,
199
],
[
201,
201
],
[
318,
319
],
[
326,
326
],
[
361,
363
],
[
547,
547
]
]
] |
833f2b77254d9a9311cc81a579cb707f08f09aba | 011400d5f1831c3771a3c15768a0a7509eb64b55 | /Plugins/DXSystemEx/DXSystemEx/Touch/GestureInfo.cpp | 1cf62ded4a86e58b7ba1d11245934eee0388a3b0 | [] | no_license | lineCode/desktopx | 9d8bbb66ceabe8784725d4fa6960523f91e6e961 | 9d939bf1fbdccfa70c7d81246cf7b984e87f53f3 | refs/heads/master | 2021-05-27T15:28:08.371707 | 2011-10-01T16:14:32 | 2011-10-01T16:14:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,727 | cpp | ///////////////////////////////////////////////////////////////////////////////////////////////
//
// DXSystemEx - Extended System Information
//
// Copyright (c) 2009-2011, Julien Templier
// All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "GestureInfo.h"
#include <intsafe.h>
void CGestureInfo::Init(HWND hwnd, GESTUREINFO info)
{
// Id
_id = info.dwID;
// Location
POINTS pt = localizePoint(hwnd, info.ptsLocation);
_x = pt.x;
_y = pt.y;
// Flags
_flags = info.dwFlags;
// Gesture-specific data
switch (_id)
{
default:
// Unrecognized gesture
break;
case GID_ZOOM:
case GID_TWOFINGERTAP:
_distance = LODWORD(info.ullArguments);
break;
case GID_PAN:
_distance = LODWORD(info.ullArguments);
// Handle inertia
if (_flags & GF_INERTIA) {
DWORD vec = HIDWORD(info.ullArguments);
POINTS inertia = MAKEPOINTS(vec);
_x1 = inertia.x;
_y1 = inertia.y;
}
break;
case GID_ROTATE:
_angle = (int)GID_ROTATE_ANGLE_FROM_ARGUMENT(info.ullArguments);
break;
case GID_PRESSANDTAP:
if (info.ullArguments > 0) {
POINTS pts = MAKEPOINTS(info.ullArguments);
POINT delta;
POINTSTOPOINT(delta, pts);
_x1 = delta.x;
_y1 = delta.y;
}
break;
}
}
POINTS CGestureInfo::localizePoint(HWND hwnd, const POINTS& pt)
{
POINT point;
point.x = pt.x;
point.y = pt.y;
ScreenToClient(hwnd, &point);
POINTS pts;
pts.x = (SHORT)point.x;
pts.y = (SHORT)point.y;
return pts;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ISupportErrorInfo
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
STDMETHODIMP CGestureInfo::InterfaceSupportsErrorInfo(REFIID riid)
{
static const IID* arr[] =
{
&IID_IGestureInfo
};
for (unsigned int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++)
{
if (InlineIsEqualGUID(*arr[i],riid))
return S_OK;
}
return S_FALSE;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IGestureInfo
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
STDMETHODIMP CGestureInfo::get_Id(int* id)
{
*id = _id;
return S_OK;
}
STDMETHODIMP CGestureInfo::get_X(int* x)
{
*x = _x;
return S_OK;
}
STDMETHODIMP CGestureInfo::get_Y(int* y)
{
*y = _y;
return S_OK;
}
STDMETHODIMP CGestureInfo::get_Distance(int* distance)
{
*distance = _distance;
return S_OK;
}
STDMETHODIMP CGestureInfo::get_Angle(int* angle)
{
*angle = _angle;
return S_OK;
}
STDMETHODIMP CGestureInfo::get_X1(int* x1)
{
*x1 = _x1;
return S_OK;
}
STDMETHODIMP CGestureInfo::get_Y1(int* y1)
{
*y1 = _y1;
return S_OK;
}
STDMETHODIMP CGestureInfo::HasFlag(int id, VARIANT_BOOL* hasFlag)
{
*hasFlag = (_flags & id) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
} | [
"[email protected]"
] | [
[
[
1,
181
]
]
] |
09662dcdb058ab1c61f44879c20474742f6b0556 | 6bdb3508ed5a220c0d11193df174d8c215eb1fce | /Codes/Halak/Rectangle.cpp | 09bd0ec81541c083955371c10e71dd10fec2ba03 | [] | no_license | halak/halak-plusplus | d09ba78640c36c42c30343fb10572c37197cfa46 | fea02a5ae52c09ff9da1a491059082a34191cd64 | refs/heads/master | 2020-07-14T09:57:49.519431 | 2011-07-09T14:48:07 | 2011-07-09T14:48:07 | 66,716,624 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,187 | cpp | #include <Halak/PCH.h>
#include <Halak/Rectangle.h>
#include <Halak/Math.h>
namespace Halak
{
Rectangle Rectangle::Intersect(const Rectangle& a, const Rectangle& b)
{
const int maximumLeft = Math::Max(a.GetLeft(), b.GetLeft());
const int maximumTop = Math::Max(a.GetTop(), b.GetTop());
const int minimumRight = Math::Min(a.GetRight(), b.GetRight());
const int minimumBottom = Math::Min(a.GetBottom(), b.GetBottom());
return Rectangle(Point(maximumLeft, maximumTop),
Point(minimumRight, minimumBottom));
}
Rectangle Rectangle::Union(const Rectangle& a, const Rectangle& b)
{
const int minimumLeft = Math::Min(a.GetLeft(), b.GetLeft());
const int minimumTop = Math::Min(a.GetTop(), b.GetTop());
const int maximumRight = Math::Max(a.GetRight(), b.GetRight());
const int maximumBottom = Math::Max(a.GetBottom(), b.GetBottom());
return Rectangle(Point(minimumLeft, minimumTop),
Point(maximumRight, maximumBottom));
}
const Rectangle Rectangle::Empty = Rectangle(0, 0, 0, 0);
} | [
"[email protected]"
] | [
[
[
1,
29
]
]
] |
4505986744b8fdedd1901f8505a2dff2411ce603 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /SMDK/RTTS/RioTintoTS/FlowStream1.cpp | 6fc388fdbdf1e8b855ec3cbae9289f6587541786 | [] | no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,412 | cpp |
// externals
#include "FlowStream1.h"
#include <cmath>
#include <vector>
#include <sstream>
//#pragma optimize("", off)
//-- Externals ------------------------------------------------------------------------
using namespace RioTintoTS;
//-- FlowStream1( ) -------------------------------------------------------------------
//
// Empty, unconfigured FlowStream1
//
FlowStream1::FlowStream1( void )
{
/* void */
}
//-- ~FlowStream1( ) ------------------------------------------------------------------
//
FlowStream1::~FlowStream1( void )
{
/* void */
}
/****************************************************************************
*
* FlowStream1::Initialize( )
*
* Apply array of variant arguments to initialize the values
* of a FlowStream1 object
*
****************************************************************************/
bool FlowStream1::Initialize
(
PStreamInfo1 Config,
Matrix solids,
double liquid
)
{
// Attempt to build stream structure to match these
if( !SetConfig( Config ) )
goto initFailed;
// Test that dimensions are sensible
if( nSize_<2 || nType_<1 )
goto initFailed;
// test that supplied matrix is correct size
if( solids.rowCount() == nSize()
&& solids.columnCount() == nType() )
{
// use the provided solids data
solids_ = solids;
}
// use supplied liquid flow
liquid_ = liquid;
// refresh calculated values
Refresh( );
return true;
initFailed:
return false;
}
/****************************************************************************
*
* FlowStream1::SetConfig( )
*
* Configure a stream to match the materials and dimensions
* specified by supplied material and sizing information objects.
*
****************************************************************************/
bool FlowStream1::SetConfig( PStreamInfo1 Config )
{
// locals
int i = 0;
// Test that arguments are reasonable (size)
if( Config->nType()<1 || Config->nSize()<2 )
goto configFail;
// Load members with information arguments
config_ = Config;
nType_ = Config->nType();
nSize_ = Config->nSize();
// Construct empty Solids matrix and liquid flow
solids_.resize( nSize_, nType_ );
solids_.clear( 0.0 );
liquid_ = 0;
// Build P80, SG and combinedSolids vectors
massInSize_.resize( nSize_ );
volumeInSize_.resize( nSize_ );
massInType_.resize( nType_ );
volumeInType_.resize( nType_ );
P80_.resize( nType_ );
SG_.resize( nType_ );
InvSG_.resize( nType_ );
// Set late calculated values to 0.0
massInSize_.clear( 0.0 );
volumeInSize_.clear( 0.0 );
massInType_.clear( 0.0 );
volumeInType_.clear( 0.0 );
P80_.clear( 0.0 );
// Set the SG and InvSG_ vector from the mineral types
for( i=0; i<nType_; i++ )
{
double SG = config_->GetMineral(i)->SG();
SG_[i] = SG;
if( fabs(SG) < EPSILON )
InvSG_[i] = 0.0;
else
InvSG_[i] = 1.0 / SG;
}
// FlowStream1 successfully configured
// and can be used
return true;
configFail:
// Configuration failure. FlowStream object
// should be destroyed or re-configured
return false;
}
/****************************************************************************
*
* FlowStream1::RockType( )
*
* Obtain the material properties of one of the solid materials
* represented by a FlowStream1 object
*
****************************************************************************/
PMineralInfo1 FlowStream1::GetMineral( int iType )
{
if( config_ && iType < nType_ )
{
return config_->GetMineral(iType);
}
else
{
return PMineralInfo1();
}
}
/****************************************************************************
*
* FlowStream1::Clear( )
*
* Set all components of a stream to 0
*
****************************************************************************/
void FlowStream1::Clear( )
{
liquid_ = 0.0;
if( nSize_>0 && nType_>0 )
solids_.clear();
}
/****************************************************************************
*
* FlowStream1::SetStream( )
*
* Set the values contained in this stream to be the same as another
* stream. Can only succeed if both streams have the same number of
* size fractions and the same number of mineral types.
*
****************************************************************************/
void FlowStream1::SetStream( PFlowStream1 Stream2 )
{
if( nSize_ == Stream2->nSize() && nType_ == Stream2->nType() )
{
liquid_ = Stream2->GetLiquidMass();
solids_ = Stream2->AccessSolidsMatrix();
}
}
/****************************************************************************
*
* FlowStream1::AddStream( )
*
* Add to the values contained in this stream with the values
* of another stream. Can only succeed if both streams have the
* same number of size fractions and the same number of types.
*
****************************************************************************/
void FlowStream1::AddStream( PFlowStream1 Stream2 )
{
int i=0;
int j=0;
if( nSize_ == Stream2->nSize() && nType_ == Stream2->nType() )
{
liquid_ += Stream2->GetLiquidMass();
MatrixView AddSolids = Stream2->AccessSolidsMatrix();
for( i=0; i<nSize_; i++ )
for( j=0; j<nType_; j++ )
solids_[i][j] += AddSolids[i][j];
}
}
/****************************************************************************
*
* FlowStream1::AbsDifference( ) * STATIC FREE FUNCTION *
*
* Determine the greatest absolute numerical difference between
* the values in one stream and the corresponding values in
* another stream. Can only succeed if both streams have the
* same number of size fractions and the same number of mineral
* types.
*
****************************************************************************/
double FlowStream1::AbsDifference( PFlowStream1 Stream1, PFlowStream1 Stream2 )
{
int i=0;
int j=0;
double maxError = 0.0;
double delta = 0.0;
int nSize = Stream1->nSize();
int nType = Stream1->nType();
if( nSize == Stream2->nSize() && nType == Stream2->nType() )
{
delta = fabs( Stream1->GetLiquidMass() - Stream2->GetLiquidMass() );
if( delta > maxError ) maxError = delta;
MatrixView& Solids1 = Stream1->AccessSolidsMatrix();
MatrixView& Solids2 = Stream2->AccessSolidsMatrix();
for( i=0; i<nSize; i++ )
{
for( j=0; j<nType; j++ )
{
delta = fabs( Solids1[i][j] - Solids2[i][j] );
if( delta > maxError ) maxError = delta;
}
}
}
return maxError;
}
/****************************************************************************
*
* FlowStream1::CalcWaterAddition( )
*
* Calculates the ammount of water required to have the solids
* desnity by mass of a flow stream to be equal to the
* supplied %solids value. Does not modify the flow stream.
*
* Returns the quantity of water required (m3/h).
*
****************************************************************************/
double FlowStream1::CalcWaterAddition( const double& percentSolids )
{
double WaterRequired = 0.0;
double WaterAddition = 0.0;
// Determine the mass of solids
double SolidsMass = solids_.sum();
// Determine the mass of water required
if( percentSolids < EPSILON )
{
WaterAddition = 0;
}
else if( percentSolids >= 100.0 )
{
WaterAddition = 0;
}
else if( fabs(SolidsMass) < EPSILON )
{
WaterAddition = 0;
}
else
{
WaterRequired = (SolidsMass/percentSolids)*(100-percentSolids);
WaterAddition = WaterRequired - liquid_;
}
return WaterAddition;
}
/****************************************************************************
*
* FlowStream1::SetSolidsDensity( )
*
* Adds the ammount of water required to have the solids
* density by mass of a flow stream to be equal to the
* suppled %solids value. Returns the ammount of water
* required to perform this adjustment.
*
****************************************************************************/
double FlowStream1::SetSolidsDensity( const double& percentSolids )
{
double WaterAddition = CalcWaterAddition( percentSolids );
liquid_ += WaterAddition;
return WaterAddition;
}
/****************************************************************************
*
* FlowStream1::Create( )
*
* Create a new FlowStream1 that matches the supplied
* materials information and size distribution series.
*
****************************************************************************/
PFlowStream1 FlowStream1::Create( PStreamInfo1 Config )
{
// Empty flowstream to build
PFlowStream1 NewStream;
// Test that arguments are valid
if( Config )
{
// Create new FlowStream1
NewStream = PFlowStream1( new FlowStream1 );
// Test configuration with arguments
if( false == NewStream->SetConfig(Config) )
{
// Failed - remove the newly created stream
NewStream = PFlowStream1( );
}
}
// Send newly created/configured stream to caller
return NewStream;
}
/****************************************************************************
*
* FlowStream1::Refresh( )
*
* Create a new FlowStream1 that matches the supplied
* materials information and size distribution series.
*
****************************************************************************/
void FlowStream1::Refresh( )
{
int iSize = 0;
int iType = 0;
// start with the first row of the solids matrix
TableVector RowVec = solids_.row( 0 );
// Start solids totals
solidsMass_ = 0.0;
solidsVolume_ = 0.0;
// loop over sizes (rows of the solids matrix)
for( iSize=0; iSize<nSize_; iSize++ )
{
// calculate mass/volume in this size fraction
double mass = RowVec.sum();
double volume = dotProduct( RowVec, InvSG_ );
// store mass in fraction
massInSize_[iSize] = mass;
volumeInSize_[iSize] = volume;
// accumulate totals
solidsMass_ += mass;
solidsVolume_ += volume;
// go to the next row of the solids matrix
RowVec.next();
}
// start with the first column of the solid matrix
TableVector ColVec = solids_.column( 0 );
// loop over types (columns of the solids matrix)
for( iType=0; iType<nType_; iType++ )
{
// calculate the total material in this type
double mass = ColVec.sum();
massInType_[iType] = mass;
volumeInType_[iType] = mass * InvSG_[iType];
// go to the next column of the solids matrix
ColVec.next();
}
}
| [
"[email protected]"
] | [
[
[
1,
449
]
]
] |
b85595f3dd10a3d0e4539c7f40a798c7ab9a9216 | 21da454a8f032d6ad63ca9460656c1e04440310e | /src/wcpp/lang/service/wscThreadImpl.cpp | ade05e2b54c045f39ea0155623da95f312b79aa9 | [] | no_license | merezhang/wcpp | d9879ffb103513a6b58560102ec565b9dc5855dd | e22eb48ea2dd9eda5cd437960dd95074774b70b0 | refs/heads/master | 2021-01-10T06:29:42.908096 | 2009-08-31T09:20:31 | 2009-08-31T09:20:31 | 46,339,619 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,608 | cpp | #include "wscThreadImpl.h"
#include <wcpp/lang/wscThrowable.h>
wscThreadImpl::wscThreadImpl(wsiRunnable * target, wsiString * name) : m_thread( WS_NULL )
{
m_target = target;
m_name = name;
}
wscThreadImpl::~wscThreadImpl(void)
{
ws_thread * thd = m_thread;
m_thread = WS_NULL;
if (thd) delete thd;
}
ws_result wscThreadImpl::GetName(wsiString ** rName)
{
WS_THROW( wseUnsupportedOperationException , "" );
}
ws_int wscThreadImpl::GetPriority(void)
{
WS_THROW( wseUnsupportedOperationException , "" );
}
ws_result wscThreadImpl::Interrupt(void)
{
WS_THROW( wseUnsupportedOperationException , "" );
}
ws_boolean wscThreadImpl::IsAlive(void)
{
WS_THROW( wseUnsupportedOperationException , "" );
}
ws_result wscThreadImpl::Join(void)
{
WS_THROW( wseUnsupportedOperationException , "" );
}
ws_result wscThreadImpl::Run(void)
{
WS_THROW( wseUnsupportedOperationException , "" );
}
ws_result wscThreadImpl::SetPriority(ws_int newPriority)
{
WS_THROW( wseUnsupportedOperationException , "" );
}
ws_result wscThreadImpl::Start(void)
{
ws_thread * thd = m_thread;
if (thd == WS_NULL) {
thd = ws_thread::StartThread( this );
m_thread = thd;
if (thd==WS_NULL) {
WS_THROW( wseIllegalThreadStateException , "" );
}
return ws_result( WS_RLT_SUCCESS );
}
else {
WS_THROW( wseIllegalThreadStateException , "" );
}
}
ws_result wscThreadImpl::ThreadProc(void)
{
return m_target->Run();
}
| [
"xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8"
] | [
[
[
1,
83
]
]
] |
7b9961f178540d548e81a3ff87341850cf5897c6 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ObjectDLL/ObjectShared/AIGoalSpecialDamage.cpp | ca0f79bac9277b554fd07afdd4945850df777968 | [] | no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 36,098 | cpp | // ----------------------------------------------------------------------- //
//
// MODULE : AIGoalSpecialDamage.cpp
//
// PURPOSE : AIGoalSpecialDamage implementation
//
// CREATED : 3/21/02
//
// (c) 2002 Monolith Productions, Inc. All Rights Reserved
// ----------------------------------------------------------------------- //
#include "stdafx.h"
#include "AIGoalSpecialDamage.h"
#include "AIGoalMgr.h"
#include "AIHuman.h"
#include "AIHumanState.h"
#include "AIGoalButeMgr.h"
#include "AIPathKnowledgeMgr.h"
#include "AINode.h"
#include "AINodeMgr.h"
#include "AIStimulusMgr.h"
#include "AITarget.h"
#include "AIUtils.h"
#include "CharacterMgr.h"
#include "Attachments.h"
#include "AIMovement.h"
DEFINE_AI_FACTORY_CLASS_SPECIFIC(Goal, CAIGoalSpecialDamage, kGoal_SpecialDamage);
// Labels correspond to SmartObjects in AIGoals.txt
#define SMART_OBJECT_SLEEPING "KnockOut"
#define SMART_OBJECT_SLEEPING_INFINITE "KnockOutInfinite"
#define SMART_OBJECT_STUNNED "Stun"
#define SMART_OBJECT_TRAPPED "BearTrap"
#define SMART_OBJECT_GLUED "Glue"
#define SMART_OBJECT_LAUGHING "LaughingGas"
#define SMART_OBJECT_SLIPPING "Slip"
#define SMART_OBJECT_BLEEDING "Bleed"
#define SMART_OBJECT_BURNING "Burn"
#define SMART_OBJECT_CHOKING "Choke"
#define SMART_OBJECT_POISONING "Poison"
#define SMART_OBJECT_ELECTROCUTE "Electrocute"
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::Con/destructor
//
// PURPOSE: Factory Con/destructor
//
// ----------------------------------------------------------------------- //
CAIGoalSpecialDamage::CAIGoalSpecialDamage()
{
m_eDamageType = DT_UNSPECIFIED;
m_eDamageAnim = kAP_None;
m_eSpecialDamageStimID = kStimID_Unset;
m_bIncapacitated = LTFALSE;
m_bProgressiveDamage = LTFALSE;
m_fProgressiveMinTime = 0.f;
m_hDamager = LTNULL;
m_bFleeing = LTFALSE;
m_fRelaxTime = 0.f;
m_bInfinite = LTFALSE;
m_bNeedsClearState = false;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::Save / Load
//
// PURPOSE: Save / Load
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::Save(ILTMessage_Write *pMsg)
{
super::Save(pMsg);
SAVE_DWORD( m_eDamageType );
SAVE_DWORD( m_eDamageAnim );
SAVE_DWORD( m_eSpecialDamageStimID );
SAVE_BOOL( m_bIncapacitated );
SAVE_BOOL( m_bProgressiveDamage );
SAVE_FLOAT( m_fProgressiveMinTime );
SAVE_HOBJECT( m_hDamager );
SAVE_BOOL( m_bFleeing );
SAVE_TIME( m_fRelaxTime );
SAVE_BOOL( m_bInfinite );
SAVE_bool( m_bNeedsClearState );
}
void CAIGoalSpecialDamage::Load(ILTMessage_Read *pMsg)
{
super::Load(pMsg);
LOAD_DWORD_CAST( m_eDamageType, DamageType );
LOAD_DWORD_CAST( m_eDamageAnim, EnumAnimProp );
LOAD_DWORD_CAST( m_eSpecialDamageStimID, EnumAIStimulusID );
LOAD_BOOL( m_bIncapacitated );
LOAD_BOOL( m_bProgressiveDamage );
LOAD_FLOAT( m_fProgressiveMinTime );
LOAD_HOBJECT( m_hDamager );
LOAD_BOOL( m_bFleeing );
LOAD_TIME( m_fRelaxTime );
LOAD_BOOL( m_bInfinite );
LOAD_bool( m_bNeedsClearState );
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::ActivateGoal
//
// PURPOSE: Activate goal.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::ActivateGoal()
{
super::ActivateGoal();
m_pGoalMgr->LockGoal(this);
m_bFleeing = LTFALSE;
m_bIncapacitated = LTTRUE;
m_pAI->SetCurSenseFlags( kSense_None );
// Get the SmartObject corresponding to the damage type.
LTBOOL bLoopingSound = LTFALSE;
m_bProgressiveDamage = LTFALSE;
EnumAISoundType eSound;
AIGBM_SmartObjectTemplate* pSmartObject = LTNULL;
switch( m_eDamageType )
{
case DT_SLEEPING:
if( m_bInfinite )
{
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_SLEEPING_INFINITE );
}
else {
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_SLEEPING );
}
m_eDamageAnim = kAP_DamageSleeping;
eSound = kAIS_DamageSleeping;
break;
case DT_STUN:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_STUNNED );
m_eDamageAnim = kAP_DamageStunned;
eSound = kAIS_DamageStun;
break;
case DT_BEAR_TRAP:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_TRAPPED );
m_eDamageAnim = kAP_DamageTrapped;
eSound = kAIS_DamageBearTrap;
break;
case DT_GLUE:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_GLUED );
m_eDamageAnim = kAP_DamageGlued;
eSound = kAIS_DamageGlue;
break;
case DT_LAUGHING:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_LAUGHING );
m_eDamageAnim = kAP_DamageLaughing;
eSound = kAIS_DamageLaughing;
bLoopingSound = LTTRUE;
break;
case DT_SLIPPERY:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_SLIPPING );
m_eDamageAnim = kAP_DamageSlipping;
eSound = kAIS_DamageSlippery;
break;
case DT_BLEEDING:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_BLEEDING );
m_eDamageAnim = kAP_DamageBleeding;
eSound = kAIS_Bleeding;
bLoopingSound = LTTRUE;
m_bProgressiveDamage = LTTRUE;
break;
case DT_BURN:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_BURNING );
m_eDamageAnim = kAP_DamageBurning;
eSound = kAIS_Burning;
m_bProgressiveDamage = LTTRUE;
break;
case DT_CHOKE:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_CHOKING );
m_eDamageAnim = kAP_DamageChoking;
eSound = kAIS_Choking;
bLoopingSound = LTTRUE;
m_bProgressiveDamage = LTTRUE;
break;
case DT_ASSS:
case DT_POISON:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_POISONING );
m_eDamageAnim = kAP_DamagePoisoning;
eSound = kAIS_Poisoning;
bLoopingSound = LTTRUE;
m_bProgressiveDamage = LTTRUE;
break;
case DT_ELECTROCUTE:
pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_ELECTROCUTE );
m_eDamageAnim = kAP_DamageElectrocuting;
eSound = kAIS_Electrocute;
bLoopingSound = LTTRUE;
m_bProgressiveDamage = LTTRUE;
break;
}
// Register a new stimulus.
if( m_eSpecialDamageStimID != kStimID_Unset )
{
g_pAIStimulusMgr->RemoveStimulus( m_eSpecialDamageStimID );
m_eSpecialDamageStimID = kStimID_Unset;
}
// Use the DeathVisible stimulus for knocked out AIs, and SpecialDamageVisible for the rest.
// Make knocked-out AI non-solid.
switch( m_eDamageType )
{
case DT_SLEEPING:
case DT_SLIPPERY:
m_eSpecialDamageStimID = g_pAIStimulusMgr->RegisterStimulus( kStim_AllyDeathVisible, m_pAI->m_hObject, m_pAI->GetPosition(), 1.f );
m_pAI->SetClientSolid( LTFALSE );
//make sure sleeping AI can be searched
m_pAI->SetUnconscious( true );
// AI that are sleeping forever cannot be woken.
m_pAI->SetCanWake( !m_bInfinite );
// Enemies ignore sleeping AI.
m_pAI->RemovePersistentStimuli();
break;
default:
m_eSpecialDamageStimID = g_pAIStimulusMgr->RegisterStimulus( kStim_AllySpecialDamageVisible, m_pAI->m_hObject, m_pAI->GetPosition(), 1.f );
break;
}
// AI is suspicious while incapacitated.
// The main reason to do this is so that an AI that was
// chasing will lose interest until seeing the target again.
m_pAI->SetAwareness( kAware_Suspicious );
// Try to limp to a cover node for progressive damage.
if( m_bProgressiveDamage )
{
// React for at least 4 seconds.
m_fProgressiveMinTime = g_pLTServer->GetTime() + 4.f;
// Do not use any special volume types while damaged.
// AI needs to clear existing knowledge of paths.
m_pAI->SetCurValidVolumeMask( AIVolume::kVolumeType_BaseVolume | AIVolume::kVolumeType_Junction );
m_pAI->GetPathKnowledgeMgr()->ClearPathKnowledge();
AINode* pNode = g_pAINodeMgr->FindNearestNodeFromThreat( m_pAI, kNode_Cover, m_pAI->GetPosition(), m_hDamager, FLT_MAX );
if( pNode && ( pNode->GetPos().DistSqr( m_pAI->GetPosition() ) > 64.f*64.f ) )
{
m_pAI->ClearAndSetState( kState_HumanGoto );
CAIHumanStateGoto* pStateGoto = (CAIHumanStateGoto*)(m_pAI->GetState());
pStateGoto->SetDestNode( pNode->m_hObject );
pStateGoto->SetMood( m_eDamageAnim );
// Play damage sound.
if( bLoopingSound )
{
pStateGoto->SetLoopingSound( eSound );
}
else {
m_pAI->PlaySound( eSound, LTTRUE );
}
return;
}
}
if( m_bNeedsClearState )
{
m_pAI->ClearState();
m_bNeedsClearState = false;
}
// Set UseObject state.
m_pAI->SetState( kState_HumanUseObject );
CAIHumanStateUseObject* pStateUseObject = (CAIHumanStateUseObject*)(m_pAI->GetState());
pStateUseObject->SetAllowDialogue( LTTRUE );
// Play damage sound.
if( bLoopingSound )
{
pStateUseObject->SetLoopingSound( eSound );
}
else {
m_pAI->PlaySound( eSound, LTTRUE );
}
// Get the SmartObject's command string.
if( pSmartObject )
{
HSTRING hstrCmd = LTNULL;
SMART_OBJECT_CMD_MAP::iterator it = pSmartObject->mapCmds.find( kNode_DamageType );
if(it != pSmartObject->mapCmds.end())
{
hstrCmd = it->second;
}
if(hstrCmd != LTNULL)
{
pStateUseObject->SetSmartObjectCommand(hstrCmd);
// Determine if we should play animations specific to some activity (e.g. deskwork).
HandleActivity();
}
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::DeactivateGoal
//
// PURPOSE: Deactivate goal.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::DeactivateGoal()
{
super::DeactivateGoal();
// Remove stimulus.
if( m_eSpecialDamageStimID != kStimID_Unset )
{
g_pAIStimulusMgr->RemoveStimulus( m_eSpecialDamageStimID );
m_eSpecialDamageStimID = kStimID_Unset;
}
RestoreAwareness();
m_pAI->ResetBaseValidVolumeMask();
// Remove anything attached (e.g. BearTrap).
// The animation takes care of this usually, but we may
// have gone from BearTrapped to KnockedOut.
char szTrigger[128];
sprintf( szTrigger, "%s LeftFoot", KEY_DETACH );
SendTriggerMsgToObject( m_pAI, m_pAI->m_hObject, LTFALSE, szTrigger );
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::HandleActivity
//
// PURPOSE: Determine if there are special animations for the current activity.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::HandleActivity()
{
EnumAnimProp eActivity = m_pAI->GetAnimationContext()->GetCurrentProp( kAPG_Awareness );
EnumAnimProp ePose = m_pAI->GetAnimationContext()->GetCurrentProp( kAPG_Posture );
// No activity or special pose.
if( ( eActivity == kAP_None ) && ( ePose == kAP_Stand ) )
{
return;
}
CAIHumanStateUseObject* pStateUseObject = (CAIHumanStateUseObject*)m_pAI->GetState();
CAIHuman* pAIHuman = (CAIHuman*)m_pAI;
CAnimationProps animProps;
animProps.Set( kAPG_Posture, ePose );
animProps.Set( kAPG_Weapon, pAIHuman->GetCurrentWeaponProp() );
animProps.Set( kAPG_WeaponPosition, kAP_Lower );
animProps.Set( kAPG_Awareness, eActivity );
animProps.Set( kAPG_Action, kAP_Idle );
animProps.Set( kAPG_Mood, m_eDamageAnim );
// If this activity has a special damage animation, use it.
if( m_pAI->GetAnimationContext()->AnimationExists( animProps ) )
{
pStateUseObject->SetActivity( eActivity );
pStateUseObject->SetPose( ePose );
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::RestoreAwareness
//
// PURPOSE: Deactivate goal.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::RestoreAwareness()
{
m_bIncapacitated = LTFALSE;
// Make AI solid.
m_pAI->SetClientSolid( LTTRUE );
//make sure waking AI can no longer be searched
m_pAI->SetUnconscious( false );
// Reset AIs default senses, from aibutes.txt.
m_pAI->ResetBaseSenseFlags();
// Clear AIs damage flags
m_pAI->SetDamageFlags( 0 );
// Ensure AI is visible to enemies.
m_pAI->RegisterPersistentStimuli();
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::UpdateGoal
//
// PURPOSE: Update goal.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::UpdateGoal()
{
CAIState* pState = m_pAI->GetState();
switch(pState->GetStateType())
{
case kState_HumanGoto:
HandleStateGoto();
break;
case kState_HumanUseObject:
HandleStateUseObject();
break;
case kState_HumanIdle:
HandleStateIdle();
break;
case kState_HumanSearch:
HandleStateSearch();
break;
case kState_HumanDraw:
HandleStateDraw();
break;
case kState_HumanAware:
HandleStateAware();
break;
case kState_HumanPanic:
HandleStatePanic();
break;
// Unexpected State.
default: AIASSERT(0, m_pAI->m_hObject, "CAIGoalSpecialDamage::UpdateGoal: Unexpected State.");
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: void CAIGoalSpecialDamage::HandleStateGoto()
//
// PURPOSE: Determine what to do when in state Goto.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::HandleStateGoto()
{
switch( m_pAI->GetState()->GetStateStatus() )
{
case kSStat_Initialized:
{
CDestructible* pDamage = m_pAI->GetDestructible();
if( ( !pDamage->IsTakingProgressiveDamage( m_eDamageType ) ) &&
( m_fProgressiveMinTime < g_pLTServer->GetTime() ) )
{
CAIHumanStateGoto* pStateGoto = (CAIHumanStateGoto*)(m_pAI->GetState());
pStateGoto->SetMood( kAP_None );
pStateGoto->SetLoopingSound( kAIS_None );
pStateGoto->SetMovement( kAP_Run );
RestoreAwareness();
}
}
break;
case kSStat_StateComplete:
{
// AI needs to clear existing knowledge of paths.
m_pAI->GetPathKnowledgeMgr()->ClearPathKnowledge();
RestoreAwareness();
// Search.
if( m_pAI->CanSearch() && !m_pAI->GetSenseRecorder()->HasFullStimulation( kSense_SeeEnemy ) )
{
SetStateSearch();
}
else {
m_pAI->SetState( kState_HumanAware );
}
}
break;
// Unexpected StateStatus.
default: AIASSERT(0, m_pAI->m_hObject, "CAIGoalSpecialDamage::HandleStateGoto: Unexpected State Status.");
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: void CAIGoalSpecialDamage::HandleStateAware()
//
// PURPOSE: Determine what to do when in state Aware.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::HandleStateAware()
{
switch( m_pAI->GetState()->GetStateStatus() )
{
case kSStat_Initialized:
if( (!m_bFleeing) && m_pGoalMgr->IsGoalLocked( this ) &&
( !m_pAI->GetAnimationContext()->IsTransitioning() ) )
{
if( m_pAI->GetPrimaryWeapon() ||
m_pAI->HasHolsterString() ||
(!m_pAI->HasBackupHolsterString()) )
{
m_pGoalMgr->UnlockGoal(this);
}
// AI has been disarmed and needs to re-arm at a panic node.
else {
// Get rid of possible LeftHand weapon (e.g. RifleButt)
// since we have no RightHand weapon.
char szDetachMsg[128];
sprintf( szDetachMsg, "%s LEFTHAND", KEY_DETACH );
SendTriggerMsgToObject( m_pAI, m_pAI->m_hObject, LTFALSE, szDetachMsg );
m_bFleeing = LTTRUE;
CAIHumanStateAware* pStateAware = (CAIHumanStateAware*)m_pAI->GetState();
pStateAware->SetPlayOnce( LTTRUE );
// Say "Who took my weapon?!"
m_pAI->PlaySound( kAIS_Disarmed, LTFALSE );
}
}
break;
case kSStat_StateComplete:
// Flee to panic node, if AI does not have the ability to disappear.
if( m_pAI->HasTarget() &&
( !m_pAI->GetBrain()->GetAIDataExist( kAIData_DisappearDistMin ) ) )
{
AINodePanic* pPanicNode = (AINodePanic*)g_pAINodeMgr->FindNearestNodeFromThreat( m_pAI, kNode_Panic, m_pAI->GetPosition(), m_pAI->GetTarget()->GetObject(), 1.f );
if( pPanicNode )
{
m_fRelaxTime = g_pLTServer->GetTime() + 30.f;
m_pAI->SetState( kState_HumanPanic );
CAIHumanStatePanic* pStatePanic = (CAIHumanStatePanic*)m_pAI->GetState();
pStatePanic->SetPanicNode( pPanicNode );
m_pAI->SetAwareness( kAware_Suspicious );
m_pGoalMgr->LockGoal( this );
return;
}
}
// Bail.
m_pGoalMgr->UnlockGoal( this );
m_fCurImportance = 0.f;
break;
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalFlee::HandleStatePanic
//
// PURPOSE: Determine what to do when in state Panic.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::HandleStatePanic()
{
switch( m_pAI->GetState()->GetStateStatus() )
{
case kSStat_Initialized:
// Unlock goal if AI can re-arm and nothing has been sensed for 30 secs.
if( m_pGoalMgr->IsGoalLocked( this ) && m_pAI->HasBackupHolsterString() )
{
if( m_pAI->GetSenseRecorder()->HasAnyStimulation( kSense_All ) )
{
m_fRelaxTime = g_pLTServer->GetTime() + 30.f;
}
else if( g_pLTServer->GetTime() > m_fRelaxTime )
{
m_pAI->SetHolsterString( m_pAI->GetBackupHolsterString() );
m_pGoalMgr->UnlockGoal( this );
}
}
break;
case kSStat_FailedComplete:
{
// Try to find a new panic node.
AINodePanic* pPanicNode = (AINodePanic*)g_pAINodeMgr->FindNearestNodeFromThreat( m_pAI, kNode_Panic, m_pAI->GetPosition(), m_pAI->GetTarget()->GetObject(), 1.f );
if( pPanicNode )
{
m_fRelaxTime = g_pLTServer->GetTime() + 30.f;
CAIHumanStatePanic* pStatePanic = (CAIHumanStatePanic*)m_pAI->GetState();
pStatePanic->SetPanicNode( pPanicNode );
}
else {
m_pGoalMgr->UnlockGoal( this );
}
}
break;
case kSStat_StateComplete:
m_fCurImportance = 0.f;
break;
// Unexpected StateStatus.
default: AIASSERT(0, m_pAI->m_hObject, "CAIGoalSpecialDamage::HandleStatePanic: Unexpected State Status.");
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::HandleStateUseObject
//
// PURPOSE: Determine what to do when in state UseObject.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::HandleStateUseObject()
{
// Handle special case updates for damage types.
switch( m_eDamageType )
{
case DT_SLEEPING:
case DT_SLIPPERY:
// Kill AI that are knocked out and dropped on stairs.
if( m_pAI->HasCurrentVolume() &&
( !m_bInfinite ) &&
( m_pAI->GetCurrentVolume()->GetVolumeType() == AIVolume::kVolumeType_Stairs ) )
{
m_pAI->GetDestructible()->HandleDestruction( m_hDamager );
}
break;
}
// Handle the StateStatus.
switch( m_pAI->GetState()->GetStateStatus() )
{
case kSStat_Paused:
break;
case kSStat_Initialized:
break;
case kSStat_Moving:
break;
case kSStat_HolsterWeapon:
break;
case kSStat_PathComplete:
// Knocked out AIs do not wake up if a player is standing on them.
// Do not check for other AIs because this could result in a deadlock
// if 2 knocked out AIs are near each other.
if( ( m_eDamageType == DT_SLEEPING ) || ( m_eDamageType == DT_SLIPPERY ) )
{
CAIHumanStateUseObject* pStateUseObject = (CAIHumanStateUseObject*)m_pAI->GetState();
if( pStateUseObject->GetAnimTimeRemaining() < 10.f )
{
LTVector vPos = m_pAI->GetPosition();
if( g_pCharacterMgr->FindCharactersWithinRadius( LTNULL, vPos, m_pAI->GetRadius(), CCharacterMgr::kList_Players ) )
{
pStateUseObject->AddAnimTime( 30.f );
}
}
}
// Progressive damage sets time infinite on SmartObjects, and stops
// animating when progressive damage stops.
// Animate for a minimal amount of time, regardless of progressive damage.
else if( m_bProgressiveDamage )
{
CDestructible* pDamage = m_pAI->GetDestructible();
if( ( !pDamage->IsTakingProgressiveDamage( m_eDamageType ) ) &&
( m_fProgressiveMinTime < g_pLTServer->GetTime() ) )
{
RestoreAwareness();
// Search.
if( m_pAI->CanSearch() && !m_pAI->GetSenseRecorder()->HasFullStimulation( kSense_SeeEnemy ) )
{
SetStateSearch();
}
else {
m_pAI->SetState( kState_HumanAware );
}
}
}
break;
case kSStat_StateComplete:
{
RestoreAwareness();
if( !m_pAI->GetPrimaryWeapon() )
{
// Get rid of possible LeftHand weapon (e.g. RifleButt)
// since we have no RightHand weapon.
char szDetachMsg[128];
sprintf( szDetachMsg, "%s LEFTHAND", KEY_DETACH );
SendTriggerMsgToObject( m_pAI, m_pAI->m_hObject, LTFALSE, szDetachMsg );
}
// Search.
if( m_pAI->CanSearch() && !m_pAI->GetSenseRecorder()->HasFullStimulation( kSense_SeeEnemy ) )
{
SetStateSearch();
}
else {
m_pAI->SetState( kState_HumanAware );
}
}
break;
// Unexpected StateStatus.
default: AIASSERT( 0, m_pAI->m_hObject, "CAIGoalSpecialDamage::HandleStateUseObject: Unexpected State Status.");
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::HandleDamage
//
// PURPOSE: Handle special damage.
//
// ----------------------------------------------------------------------- //
LTBOOL CAIGoalSpecialDamage::HandleDamage(const DamageStruct& damage)
{
// Clear old damage type if AI is not knocked out.
if( m_bIncapacitated && ( damage.eType != m_eDamageType ) && !m_pAI->GetDestructible()->IsDead() )
{
if( (m_eDamageType != DT_SLEEPING) && (m_eDamageType != DT_SLIPPERY) )
{
switch( damage.eType )
{
case DT_SLIPPERY:
case DT_SLEEPING:
case DT_STUN:
case DT_LAUGHING:
case DT_BLEEDING:
case DT_ELECTROCUTE:
case DT_BURN:
case DT_CHOKE:
case DT_POISON:
case DT_ASSS:
case DT_BEAR_TRAP:
case DT_GLUE:
RestoreAwareness();
m_pAI->GetAnimationContext()->ClearCurAnimation();
m_bNeedsClearState = true;
default :
break;
}
}
}
// Apply a new damage type.
if( !m_bIncapacitated )
{
LTBOOL bRequiresMovement = LTFALSE;
LTBOOL bRequiresStanding = LTFALSE;
switch( damage.eType )
{
case DT_SLEEPING:
case DT_STUN:
case DT_LAUGHING:
case DT_BLEEDING:
case DT_ELECTROCUTE:
case DT_BURN:
case DT_CHOKE:
case DT_POISON:
case DT_ASSS:
case DT_GLUE:
break;
case DT_SLIPPERY:
bRequiresStanding = LTTRUE;
break;
case DT_BEAR_TRAP:
bRequiresMovement = LTTRUE;
break;
default:
return LTFALSE;
}
AITRACE( AIShowGoals, ( m_pAI->m_hObject, "Hit with SpecialDamage!" ) );
// Damage types that require movement have no effect if AI
// is not walking or running.
if( bRequiresMovement && !m_pAI->IsWalkingOrRunning() )
{
return LTTRUE;
}
if( bRequiresStanding && !m_pAI->IsStanding() )
{
return LTTRUE;
}
// Some AI are killed instantly by all SpecialDamage. (e.g. rats and rabbits)
if( m_pAI->GetBrain()->GetAIDataExist( kAIData_LethalSpecialDamage ) )
{
if( damage.eType != DT_SLIPPERY )
{
m_pAI->GetDestructible()->HandleDestruction( damage.hDamager );
return LTTRUE;
}
return LTFALSE;
}
// Handle special damage in special volumes.
if( m_pAI->HasCurrentVolume() && ( !m_bInfinite ) )
{
switch( m_pAI->GetCurrentVolume()->GetVolumeType() )
{
// If an AI is on a ladder, either take him off them ladder
// or kill him, depending on how high up he is.
case AIVolume::kVolumeType_Ladder:
{
LTFLOAT fHeight = 0.f;
m_pAI->FindFloorHeight( m_pAI->GetPosition(), &fHeight );
if( ( m_pAI->GetPosition().y - fHeight ) < ( 2.f * m_pAI->GetDims().y ) )
{
m_pAI->GetAIMovement()->UnlockMovement();
}
else {
m_pAI->GetDestructible()->HandleDestruction( damage.hDamager );
}
}
break;
// Kill AI who are knocked out on ledges.
// Kill AI who are knocked out on stairs.
case AIVolume::kVolumeType_Ledge:
case AIVolume::kVolumeType_Stairs:
if( ( damage.eType == DT_SLEEPING ) || ( damage.eType == DT_SLIPPERY ) )
{
m_pAI->GetDestructible()->HandleDestruction( damage.hDamager );
}
break;
}
}
m_eDamageType = damage.eType;
// Record who caused the damage.
m_hDamager = damage.hDamager;
m_pAI->Target( m_hDamager );
// Set AIs damage flags
m_pAI->SetDamageFlags( DamageTypeToFlag( m_eDamageType ) );
// Handle the damage immediately.
m_bRequiresImmediateResponse = LTTRUE;
SetCurToBaseImportance();
// Reactivate if already active.
if( m_pGoalMgr->IsCurGoal( this ) )
{
ActivateGoal();
}
return LTTRUE;
}
else if( m_pGoalMgr->IsCurGoal( this ) )
{
// We are already affected by the damage so check for one shot one kill...
switch( m_eDamageType )
{
case DT_SLEEPING:
case DT_SLIPPERY:
break;
default :
return LTFALSE;
}
// Make sure the AI can be damaged by the damagetype...
if( m_pAI->GetDestructible()->IsCantDamageType( damage.eType ) || !m_pAI->GetDestructible()->GetCanDamage() || damage.fDamage <= 0.0f)
{
return LTFALSE;
}
// Kill it...
m_pAI->GetDestructible()->HandleDestruction( damage.hDamager );
return LTTRUE;
}
return LTFALSE;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::GetAlternateDeathAnimation
//
// PURPOSE: Give goal a chance to choose an appropriate death animation.
//
// ----------------------------------------------------------------------- //
HMODELANIM CAIGoalSpecialDamage::GetAlternateDeathAnimation()
{
// Were killed in the middle of an activity?
if( ( m_pAI->GetState()->GetStateType() == kState_HumanUseObject ) &&
( m_pAI->GetState()->GetStateStatus() == kSStat_PathComplete ) )
{
CAIHumanStateUseObject* pStateUseObject = (CAIHumanStateUseObject*)m_pAI->GetState();
EnumAnimProp eActivity = pStateUseObject->GetActivity();
EnumAnimProp eMood = pStateUseObject->GetMood();
CAIHuman* pAIHuman = (CAIHuman*)m_pAI;
CAnimationProps animProps;
animProps.Set( kAPG_Posture, pStateUseObject->GetPose() );
animProps.Set( kAPG_Weapon, pAIHuman->GetCurrentWeaponProp() );
animProps.Set( kAPG_WeaponPosition, kAP_Lower );
animProps.Set( kAPG_Awareness, eActivity );
animProps.Set( kAPG_Mood, eMood );
animProps.Set( kAPG_Action, kAP_Death );
// Find a death animation for this activity.
if( m_pAI->GetAnimationContext()->AnimationExists( animProps ) )
{
// Use the In-transition as the death if transitioning.
if( m_bIncapacitated && m_pAI->GetAnimationContext()->IsTransitioning() )
{
switch( m_eDamageType )
{
case DT_SLEEPING:
case DT_SLIPPERY:
return g_pLTServer->GetModelAnimation( m_pAI->m_hObject );
}
}
// Use the actual death animation.
return m_pAI->GetAnimationContext()->GetAni( animProps );
}
}
// Were killed while running for cover?
else if( m_pAI->GetState()->GetStateType() == kState_HumanGoto )
{
CAIHumanStateGoto* pStateGoto = (CAIHumanStateGoto*)m_pAI->GetState();
EnumAnimProp eMood = pStateGoto->GetMood();
CAIHuman* pAIHuman = (CAIHuman*)m_pAI;
CAnimationProps animProps;
animProps.Set( kAPG_Posture, kAP_Stand );
animProps.Set( kAPG_Weapon, pAIHuman->GetCurrentWeaponProp() );
animProps.Set( kAPG_WeaponPosition, kAP_Lower );
animProps.Set( kAPG_Mood, eMood );
animProps.Set( kAPG_Action, kAP_Death );
// Find a death animation.
if( m_pAI->GetAnimationContext()->AnimationExists( animProps ) )
{
return m_pAI->GetAnimationContext()->GetAni( animProps );
}
}
// No alternate.
return INVALID_ANI;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::InterruptSpecialDamage
//
// PURPOSE: Interrupt special damage.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::InterruptSpecialDamage(LTBOOL bSearch)
{
if( !m_bIncapacitated )
{
return;
}
if( !m_pAI->GetPrimaryWeapon() )
{
// Get rid of possible LeftHand weapon (e.g. RifleButt)
// since we have no RightHand weapon.
char szDetachMsg[128];
sprintf( szDetachMsg, "%s LEFTHAND", KEY_DETACH );
SendTriggerMsgToObject( m_pAI, m_pAI->m_hObject, LTFALSE, szDetachMsg );
}
RestoreAwareness();
// Go idle before searching to ensure playing the out transition.
if( bSearch )
{
m_pAI->SetState( kState_HumanIdle );
}
else {
m_pGoalMgr->UnlockGoal(this);
m_pAI->SetState( kState_HumanAware );
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::HandleStateIdle
//
// PURPOSE: Determine what to do when in state Idle.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::HandleStateIdle()
{
// Wait until the out transition finishes.
if( m_pAI->GetAnimationContext()->IsTransitioning() ||
m_pAI->GetState()->IsFirstUpdate() )
{
return;
}
// Search.
if( m_pAI->CanSearch() && !m_pAI->GetSenseRecorder()->HasFullStimulation( kSense_SeeEnemy ) )
{
SetStateSearch();
}
else {
m_pGoalMgr->UnlockGoal(this);
m_pAI->SetState( kState_HumanAware );
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::PauseSpecialDamage
//
// PURPOSE: Pause or unpause SpecialDamage. For use while being moved.
//
// ----------------------------------------------------------------------- //
void CAIGoalSpecialDamage::PauseSpecialDamage(LTBOOL bPause)
{
if( m_pAI->GetState()->GetStateType() != kState_HumanUseObject )
{
return;
}
CAIHumanStateUseObject* pStateUseObject = (CAIHumanStateUseObject*)(m_pAI->GetState());
pStateUseObject->Pause( bPause );
//clear old stimulus
if( m_eSpecialDamageStimID != kStimID_Unset )
{
g_pAIStimulusMgr->RemoveStimulus( m_eSpecialDamageStimID );
m_eSpecialDamageStimID = kStimID_Unset;
}
if( bPause )
{
AITRACE( AIShowGoals, ( m_pAI->m_hObject, "Pausing SpecialDamage" ) );
return;
}
AITRACE( AIShowGoals, ( m_pAI->m_hObject, "Unpausing SpecialDamage" ) );
// AI needs to clear existing knowledge of paths.
m_pAI->GetPathKnowledgeMgr()->ClearPathKnowledge();
// Reset last volume info.
m_pAI->RecalcLastVolumePos();
// If we are unpausing register a new stimulus.
// Use the DeathVisible stimulus for knocked out AIs, and SpecialDamageVisible for the rest.
switch( m_eDamageType )
{
case DT_SLEEPING:
case DT_SLIPPERY:
m_eSpecialDamageStimID = g_pAIStimulusMgr->RegisterStimulus( kStim_AllyDeathVisible, m_pAI->m_hObject, m_pAI->GetPosition(), 1.f );
break;
default:
m_eSpecialDamageStimID = g_pAIStimulusMgr->RegisterStimulus( kStim_AllySpecialDamageVisible, m_pAI->m_hObject, m_pAI->GetPosition(), 1.f );
break;
}
// Clear any activity that was set (e.g. working at a desk).
m_pAI->GetAnimationContext()->ClearCurAnimation();
pStateUseObject->SetPose( kAP_Stand );
pStateUseObject->SetActivity( kAP_None );
// Special case handling for being moved while knocked out from a banana.
// Treat like the AI was tranquilized to keep him from re-slipping when dropped.
if( m_eDamageType == DT_SLIPPERY )
{
m_eDamageType = DT_SLEEPING;
m_pAI->SetDamageFlags( DamageTypeToFlag( m_eDamageType ) );
if( m_pAI->GetState()->GetStateType() == kState_HumanUseObject )
{
AIGBM_SmartObjectTemplate* pSmartObject = g_pAIGoalButeMgr->GetSmartObjectTemplate( SMART_OBJECT_SLEEPING );
if( pSmartObject )
{
HSTRING hstrCmd = LTNULL;
SMART_OBJECT_CMD_MAP::iterator it = pSmartObject->mapCmds.find( kNode_DamageType );
if(it != pSmartObject->mapCmds.end())
{
hstrCmd = it->second;
}
if(hstrCmd != LTNULL)
{
CAIHumanStateUseObject* pStateUseObject = (CAIHumanStateUseObject*)(m_pAI->GetState());
pStateUseObject->SetSmartObjectCommand(hstrCmd);
pStateUseObject->StartAnimation();
}
}
}
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::HandleNameValuePair
//
// PURPOSE: Handles getting a name/value pair.
//
// ----------------------------------------------------------------------- //
LTBOOL CAIGoalSpecialDamage::HandleNameValuePair(const char *szName, const char *szValue)
{
ASSERT(szName && szValue);
if ( !_stricmp(szName, "PAUSE") )
{
PauseSpecialDamage( IsTrueChar( szValue[0] ) );
return LTTRUE;
}
if ( !_stricmp(szName, "SLEEPFOREVER") )
{
if( IsTrueChar( szValue[0] ) )
{
m_bInfinite = LTTRUE;
m_eDamageType = DT_SLEEPING;
m_pAI->SetDamageFlags( DamageTypeToFlag( DT_SLEEPING ) );
// Handle the damage immediately.
m_bRequiresImmediateResponse = LTTRUE;
SetCurToBaseImportance();
}
return LTTRUE;
}
return LTFALSE;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CAIGoalSpecialDamage::HandleSense
//
// PURPOSE: React to a sense.
//
// ----------------------------------------------------------------------- //
LTBOOL CAIGoalSpecialDamage::HandleGoalSenseTrigger(AISenseRecord* pSenseRecord)
{
if( m_pGoalMgr->IsCurGoal( this ) && ( !m_bIncapacitated ) &&
super::HandleGoalSenseTrigger(pSenseRecord) )
{
// Break out of search animations.
if( ( !m_pAI->GetAnimationContext()->IsTransitioning() ) &&
( m_pAI->GetAnimationContext()->IsLocked() ) &&
( m_pAI->GetState()->GetStateType() == kState_HumanSearch ) )
{
m_pAI->GetAnimationContext()->ClearLock();
}
if( ( !m_pAI->GetPrimaryWeapon() ) && ( !m_pAI->HasHolsterString() ) )
{
// Get rid of possible LeftHand weapon (e.g. RifleButt)
// since we have no RightHand weapon.
char szDetachMsg[128];
sprintf( szDetachMsg, "%s LEFTHAND", KEY_DETACH );
SendTriggerMsgToObject( m_pAI, m_pAI->m_hObject, LTFALSE, szDetachMsg );
}
// Only bail if we are armed, otherwise stay in goal to panic.
else {
switch( pSenseRecord->eSenseType )
{
// Do not bail if only sensing agitated allies.
case kSense_SeeAllyDisturbance:
case kSense_HearAllyDisturbance:
break;
default:
AITRACE( AIShowGoals, ( m_pAI->m_hObject, "CAIGoalSpecialDamage: Bailing due to sensing %s", CAISenseRecorderAbstract::SenseToString( pSenseRecord->eSenseType ) ) );
m_fCurImportance = 0.f;
break;
}
}
}
return LTFALSE;
}
| [
"[email protected]"
] | [
[
[
1,
1329
]
]
] |
b3d033c54d7fed8af507c008c3ecb4040bf38883 | f90b1358325d5a4cfbc25fa6cccea56cbc40410c | /src/GUI/proRataResidueComposition.h | dfd6dbce4b067219caab6e93b3f979f5c045e9dc | [] | no_license | ipodyaco/prorata | bd52105499c3fad25781d91952def89a9079b864 | 1f17015d304f204bd5f72b92d711a02490527fe6 | refs/heads/master | 2021-01-10T09:48:25.454887 | 2010-05-11T19:19:40 | 2010-05-11T19:19:40 | 48,766,766 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 513 | h |
#ifndef PRORATARESIDUECOMPOSITION_H
#define PRORATARESIDUECOMPOSITION_H
#include "proRataIsotop.h"
class ProRataResidueComposition : public QWidget
{
Q_OBJECT
public:
ProRataResidueComposition( QWidget* qwParent = 0, Qt::WFlags qwfFl = 0 );
~ProRataResidueComposition();
void buildUI();
void setValues();
protected:
ProRataIsotopologue *priReference;
ProRataIsotopologue *priTreatment;
QGridLayout* qgMainLayout;
};
#endif //PRORATARESIDUECOMPOSITION_H
| [
"chongle.pan@c58cc1ec-c975-bb1e-ac29-6983d7497d3a"
] | [
[
[
1,
29
]
]
] |
23884a7198f88159b567d4eae73456866248367f | 35ae0e99b77bc61a60fbeb75a9e9ba5f659349b9 | /src/TIFF.cpp | 2f616ce59ae098c2f41fd4365301b3e4ba75d2e4 | [] | no_license | lamhaianh/SPIL | 308636ca64bfffe3b39108ef8ca3fc6ab0767210 | 48cb8db15d4be84c0bbf1dac1b1fee4aff98ee7c | refs/heads/master | 2021-01-23T00:20:27.088278 | 2011-10-01T06:29:35 | 2011-10-01T06:29:35 | 2,493,811 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 88 | cpp | #include "TIFF.h"
TIFF::TIFF()
{
//ctor
}
TIFF::~TIFF()
{
//dtor
}
| [
"[email protected]"
] | [
[
[
1,
11
]
]
] |
b74ca2727bd2eda475376225dd433eb45fafa4e0 | b84a38aad619acf34c22ed6e6caa0f7b00ebfa0a | /Code/TootleRender/TScreen.cpp | 42c9ee4a4aba845940495fea66c922d431c89904 | [] | no_license | SoylentGraham/Tootle | 4ae4e8352f3e778e3743e9167e9b59664d83b9cb | 17002da0936a7af1f9b8d1699d6f3e41bab05137 | refs/heads/master | 2021-01-24T22:44:04.484538 | 2010-11-03T22:53:17 | 2010-11-03T22:53:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,121 | cpp | #include "TScreen.h"
#include "TRenderTarget.h"
#include "TRenderNodeText.h"
#include "TRenderGraph.h"
#include <TootleOpenglRasteriser/OpenglRasteriser.h>
//---------------------------------------------------------
//
//---------------------------------------------------------
TLRender::TScreen::TScreen(TRefRef ScreenRef,const Type2<u16>& Size,TScreenShape ScreenShape) :
m_HasShutdown ( false ),
m_Ref ( ScreenRef ),
m_InitialSize ( Size ),
m_ScreenShape ( ScreenShape )
{
// gr: disabled for now, core manager limits frame rate instead of using hardware sync
//m_Flags.Set( Flag_SyncFrameRate );
}
//---------------------------------------------------------
//
//---------------------------------------------------------
TLRender::TScreen::~TScreen()
{
// if we haven't had a shutdown invoke an emergency shutdown
if ( !m_HasShutdown )
Shutdown();
}
//----------------------------------------------------------
// create window
//----------------------------------------------------------
SyncBool TLRender::TScreen::Init()
{
// already initialised with window
if ( m_pWindow )
return SyncTrue;
// allocate window
m_pWindow = TLGui::CreateGuiWindow( GetRef() );
if ( !m_pWindow )
return SyncFalse;
// set size
m_pWindow->SetSize( m_InitialSize );
// center the window
int4 WindowDimensions;
WindowDimensions.zw() = m_pWindow->GetSize();
GetCenteredSize( WindowDimensions );
m_pWindow->SetPosition( WindowDimensions.xy() );
// create opengl canvas
m_pCanvas = TLGui::CreateOpenglCanvas( *m_pWindow, GetRef() );
if ( !m_pCanvas )
return SyncFalse;
// create rasteriser to go with the canvas
m_pCanvas->MakeCurrent();
m_pRasteriser = new TLRaster::OpenglRasteriser();
if ( !m_pRasteriser || !m_pRasteriser->Initialise() )
{
m_pRasteriser = NULL;
m_pCanvas = NULL;
return SyncFalse;
}
// make the window visible
m_pWindow->Show();
// Subscirbe to the window
SubscribeTo(m_pWindow);
return SyncTrue;
}
//---------------------------------------------------------
// do screen update
//---------------------------------------------------------
SyncBool TLRender::TScreen::Update()
{
// lost window?
if ( !m_pWindow )
return SyncFalse;
// continue
return SyncTrue;
}
//---------------------------------------------------------
// clean up
//---------------------------------------------------------
SyncBool TLRender::TScreen::Shutdown()
{
// already done a successfull shutdown
if ( m_HasShutdown )
return SyncTrue;
SyncBool ShutdownResult = SyncTrue;
// clean up render targets
if ( m_RenderTargets.GetSize() )
{
for ( s32 r=m_RenderTargets.GetSize()-1; r>=0; r-- )
{
/*
SyncBool Result = m_RenderTargets[r]->Shutdown();
// error
if ( Result == SyncFalse )
return SyncFalse;
// wait
if ( Result == SyncWait )
{
ShutdownResult = SyncWait;
continue;
}
*/
// shutdown okay, release
m_RenderTargets[r] = NULL;
m_RenderTargets.RemoveAt( r );
}
}
// mark as shutdown if everything has succeeded
if ( ShutdownResult == SyncTrue )
m_HasShutdown = TRUE;
m_pCanvas = NULL;
m_pWindow = NULL;
return ShutdownResult;
}
//---------------------------------------------------------
// render the render targets
//---------------------------------------------------------
void TLRender::TScreen::Draw()
{
// get the rasteriser
if ( !m_pRasteriser )
return;
TLRaster::TRasteriser& Rasteriser = *m_pRasteriser;
// render each render target in z order
m_RenderTargets.Sort();
for ( u32 r=0; r<m_RenderTargets.GetSize(); r++ )
{
// get render target
TRenderTarget* pRenderTarget = m_RenderTargets[r];
if ( !pRenderTarget )
continue;
// check is enabled
TRenderTarget& RenderTarget = *pRenderTarget;
if ( !RenderTarget.IsEnabled() )
continue;
// get the size... fails if it's too small to be of any use
Type4<s32> RenderTargetSize;
if ( !GetRenderTargetSize( RenderTargetSize, RenderTarget ) )
continue;
// draw the render target's data into the rasteriser (this traverses the render tree)
RenderTarget.Draw( Rasteriser );
// rasterise the rasterer
Rasteriser.Rasterise( RenderTarget, *this );
}
// flip buffers - gr: this should be in the rasteriser?
m_pCanvas->EndRender();
}
TPtr<TLRender::TRenderTarget> TLRender::TScreen::CreateRenderTarget(TRefRef TargetRef)
{
// Check to make sure a render target with the specified name doesn;t already exist
if ( m_RenderTargets.Exists( TargetRef ) )
return NULL;
// Create a new render target and add it to the list
TPtr<TLRender::TRenderTarget> pRenderTarget = new TRenderTarget(TargetRef);
if(!pRenderTarget)
return NULL;
// add render target to list
m_RenderTargets.Add( pRenderTarget );
// resort render targets by z
OnRenderTargetZChanged( *pRenderTarget );
return pRenderTarget;
}
//---------------------------------------------------------
// fetch render target
//---------------------------------------------------------
TPtr<TLRender::TRenderTarget>& TLRender::TScreen::GetRenderTarget(const TRef& TargetRef)
{
return m_RenderTargets.FindPtr( TargetRef );
}
//---------------------------------------------------------
// shutdown a render target
//---------------------------------------------------------
SyncBool TLRender::TScreen::DeleteRenderTarget(const TRef& TargetRef)
{
// find the active render target index
s32 Index = m_RenderTargets.FindIndex(TargetRef);
// doesnt exist
if ( Index == -1 )
{
// if it's in the shutdown list, return wait
if ( m_ShutdownRenderTargets.Exists( TargetRef ) )
return SyncWait;
// non-existant target ref
return SyncFalse;
}
// grab pointer to the render target
TPtr<TRenderTarget> pRenderTarget = m_RenderTargets[Index];
// remove from render target list
m_RenderTargets.RemoveAt( (u32)Index );
pRenderTarget = NULL;
/*
// shutdown render target
SyncBool Result = pRenderTarget->Shutdown();
// instant shutdown, so destroy
if ( Result != SyncWait )
{
pRenderTarget = NULL;
return Result;
}
// is shutting down, move to shutdown list
m_ShutdownRenderTargets.Add( pRenderTarget );
*/
return SyncWait;
}
Bool TLRender::TScreen::GetRenderTargetSize(Type4<s32>& Size,TRefRef TargetRef)
{
const TRenderTarget* pRenderTarget = GetRenderTarget( TargetRef );
return pRenderTarget ? GetRenderTargetSize( Size, *pRenderTarget ) : FALSE;
}
//---------------------------------------------------------
// get the dimensions of a render target
//---------------------------------------------------------
Bool TLRender::TScreen::GetRenderTargetSize(Type4<s32>& Size,const TRenderTarget& RenderTarget)
{
Type4<s32> RenderTargetMaxSize = GetRenderTargetMaxSize();
RenderTarget.GetSize( Size, RenderTargetMaxSize );
return true;
}
//---------------------------------------------------------
// Get a render target-relative cursor position from a screen pos - fails if outside render target box
//---------------------------------------------------------
Bool TLRender::TScreen::GetRenderTargetPosFromScreenPos(const TRenderTarget& RenderTarget,Type2<s32>& RenderTargetPos,Type4<s32>& RenderTargetSize,const Type2<s32>& ScreenPos)
{
// check the point is inside the screen viewport
Type4<s32> ViewportMaxSize = GetViewportMaxSize();
if ( !ViewportMaxSize.GetIsInside( ScreenPos ) )
return FALSE;
// convert screen(viewport) pos to render target pos by rotating it inside the viewport
RenderTargetPos = ScreenPos;
Type4<s32> MaxRenderTargetSize = GetRenderTargetMaxSize();
// rotate screen pos to be in "render target" space
if ( GetScreenShape() == TLRender::ScreenShape_WideLeft )
{
// rotate RIGHT
RenderTargetPos.Left() = MaxRenderTargetSize.Right() - ScreenPos.Top();
// RenderTargetPos.Left() = ViewportMaxSize.Right() - ScreenPos.Top();
RenderTargetPos.Top() = ScreenPos.Left();
}
else if ( GetScreenShape() == TLRender::ScreenShape_WideRight )
{
// rotate LEFT
RenderTargetPos.Left() = ScreenPos.Top();
// RenderTargetPos.Top() = ViewportMaxSize.Bottom() - ScreenPos.Left();
RenderTargetPos.Top() = MaxRenderTargetSize.Bottom() - ScreenPos.Left();
}
// make relative to render target
RenderTarget.GetSize( RenderTargetSize, MaxRenderTargetSize );
RenderTargetPos.Left() -= RenderTargetSize.Left();
RenderTargetPos.Top() -= RenderTargetSize.Top();
// outside render target, fail
if ( !RenderTargetSize.GetIsInside( RenderTargetPos ) )
return FALSE;
return TRUE;
}
//---------------------------------------------------------
// Get a screen pos from a render target-relative cursor position - fails if outside render target box
//---------------------------------------------------------
Bool TLRender::TScreen::GetScreenPosFromRenderTargetPos(Type2<s32>& ScreenPos, const TRenderTarget& RenderTarget,const Type2<s32>& RenderTargetPos, Type4<s32>& RenderTargetSize) // Get a screen pos render target-relative cursor position- fails if outside render target box
{
// outside render target, fail
if ( !RenderTargetSize.GetIsInside( RenderTargetPos ) )
return FALSE;
// convert screen(viewport) pos to render target pos by rotating it inside the viewport
Type2<s32> RotatedScreenPos = RenderTargetPos;
Type4<s32> MaxRenderTargetSize = GetRenderTargetMaxSize();
// make relative to render target
RenderTarget.GetSize( RenderTargetSize, MaxRenderTargetSize );
RotatedScreenPos.Left() += RenderTargetSize.Left();
RotatedScreenPos.Top() += RenderTargetSize.Top();
// rotate screen pos to be in "screen" space
if ( GetScreenShape() == TLRender::ScreenShape_WideLeft )
{
// rotate RIGHT
RotatedScreenPos.Top() = MaxRenderTargetSize.Right() - RenderTargetPos.Left();
RotatedScreenPos.Left() = RenderTargetPos.Top();
}
else if ( GetScreenShape() == TLRender::ScreenShape_WideRight )
{
// rotate LEFT
RotatedScreenPos.Top() = RenderTargetPos.Left();
RotatedScreenPos.Left() = MaxRenderTargetSize.Bottom() - RenderTargetPos.Top();
}
// Calculate the rotated render target sizes
Type4<s32> RotatedRenderTargetSize = RenderTargetSize;
if ( GetScreenShape() == ScreenShape_WideLeft )
{
// gr: rendertarget is rotated left, so to get viewport, rotate it right again
// rotate right
RotatedRenderTargetSize.x = RenderTargetSize.Top();
RotatedRenderTargetSize.y = MaxRenderTargetSize.Width() - RenderTargetSize.Right();
RotatedRenderTargetSize.Width() = RenderTargetSize.Height();
RotatedRenderTargetSize.Height() = RenderTargetSize.Width();
}
else if ( GetScreenShape() == ScreenShape_WideRight )
{
// gr: rendertarget is rotated right, so to get viewport, rotate it left again
// rotate left
RotatedRenderTargetSize.x = MaxRenderTargetSize.Height() - RenderTargetSize.Bottom();
RotatedRenderTargetSize.y = RenderTargetSize.Left();
RotatedRenderTargetSize.Width() = RenderTargetSize.Height();
RotatedRenderTargetSize.Height() = RenderTargetSize.Width();
}
// Now flip the Y based on the rotated render target to get a final pos in screen space
ScreenPos.Left() = RotatedScreenPos.Left();
ScreenPos.Top() = RotatedRenderTargetSize.Height() - RotatedScreenPos.Top();
// check the point is inside the screen viewport
Type4<s32> ViewportMaxSize = GetViewportMaxSize();
if ( !ViewportMaxSize.GetIsInside( ScreenPos ) )
return FALSE;
return TRUE;
}
//---------------------------------------------------------
// get a world position from this screen posiiton
//---------------------------------------------------------
Bool TLRender::TScreen::GetWorldRayFromScreenPos(const TRenderTarget& RenderTarget,TLMaths::TLine& WorldRay,const Type2<s32>& ScreenPos)
{
Type2<s32> RenderTargetPos;
Type4<s32> RenderTargetSize;
if ( !GetRenderTargetPosFromScreenPos( RenderTarget, RenderTargetPos, RenderTargetSize, ScreenPos ) )
return FALSE;
// let render target do it's own conversions what with fancy cameras n that
return RenderTarget.GetWorldRay( WorldRay, RenderTargetPos, RenderTargetSize, GetScreenShape() );
}
//---------------------------------------------------------
//
//---------------------------------------------------------
Bool TLRender::TScreen::GetWorldPosFromScreenPos(const TRenderTarget& RenderTarget,float3& WorldPos,float WorldDepth,const Type2<s32>& ScreenPos)
{
Type2<s32> RenderTargetPos;
Type4<s32> RenderTargetSize;
if ( !GetRenderTargetPosFromScreenPos( RenderTarget, RenderTargetPos, RenderTargetSize, ScreenPos ) )
return FALSE;
// let render target do it's own conversions what with fancy cameras n that
return RenderTarget.GetWorldPos( WorldPos, WorldDepth, RenderTargetPos, RenderTargetSize, GetScreenShape() );
}
Bool TLRender::TScreen::GetScreenPosFromWorldPos(const TRenderTarget& RenderTarget, const float3& WorldPos, Type2<s32>& ScreenPos)
{
Type4<s32> MaxRenderTargetSize = GetRenderTargetMaxSize();
Type4<s32> RenderTargetSize;
RenderTarget.GetSize(RenderTargetSize, MaxRenderTargetSize);
// let render target do it's own conversions what with fancy cameras n that
Type2<s32> RenderTargetPos;
if ( !RenderTarget.GetRenderTargetPos( RenderTargetPos, WorldPos, RenderTargetSize, GetScreenShape()) )
return FALSE;
return GetScreenPosFromRenderTargetPos( ScreenPos, RenderTarget, RenderTargetPos, RenderTargetSize);
}
//---------------------------------------------------------
// get the render target max size (in "render target space") - this is the viewport size, but rotated
//---------------------------------------------------------
Type4<s32> TLRender::TScreen::GetRenderTargetMaxSize()
{
Type4<s32> MaxSize = GetViewportMaxSize();
// rotate render target so it's in "render target" space
if ( GetScreenShape() == TLRender::ScreenShape_WideLeft )
{
Type4<s32> ViewportMaxSize = MaxSize;
// rotate left
// topleft = bottomleft
// topright = topleft
// bottomright = topright
// bottomleft = bottomright
MaxSize.x = ViewportMaxSize.Height() - ViewportMaxSize.Bottom();
MaxSize.y = ViewportMaxSize.Left();
MaxSize.Width() = ViewportMaxSize.Height();
MaxSize.Height() = ViewportMaxSize.Width();
}
else if ( GetScreenShape() == TLRender::ScreenShape_WideRight )
{
Type4<s32> ViewportMaxSize = MaxSize;
// rotate right
MaxSize.x = ViewportMaxSize.Top();
MaxSize.y = ViewportMaxSize.Width() - ViewportMaxSize.Right();
MaxSize.Width() = ViewportMaxSize.Height();
MaxSize.Height() = ViewportMaxSize.Width();
}
return MaxSize;
}
//---------------------------------------------------------
//
//---------------------------------------------------------
void TLRender::TScreen::CreateDebugRenderTarget(TRefRef FontRef)
{
if ( !FontRef.IsValid() )
return;
TPtr<TLRender::TRenderTarget> pRenderTarget = CreateRenderTarget("Debug");
if ( !pRenderTarget )
return;
pRenderTarget->SetScreenZ(99);
pRenderTarget->SetClearColour( TColour(0.f, 1.f, 0.f, 0.f ) );
TPtr<TLRender::TCamera> pCamera = new TLRender::TOrthoCamera;
pCamera->SetPosition( float3( 0, 0, -10.f ) );
pRenderTarget->SetCamera( pCamera );
// store render target
m_DebugRenderTarget = pRenderTarget->GetRef();
// init root node
TRef RootRenderNode;
{
float DebugScale = GetScreenShape() == TLRender::ScreenShape_Portrait ? 5.f : 3.0f;
TLMessaging::TMessage InitMessage(TLCore::InitialiseRef);
InitMessage.ExportData("Scale", float3( DebugScale, DebugScale, 1.f ) );
InitMessage.ExportData("Colour", TColour( 1.f, 1.f, 1.f, 0.8f ) );
RootRenderNode = TLRender::g_pRendergraph->CreateNode( "root", TRef(), TRef(), &InitMessage );
pRenderTarget->SetRootRenderNode( RootRenderNode );
}
// add fps text
{
TLMessaging::TMessage InitMessage(TLCore::InitialiseRef);
InitMessage.ExportData("FontRef", FontRef );
TRef FpsRenderNode = TLRender::g_pRendergraph->CreateNode( "dbgfps", "txtext", RootRenderNode, &InitMessage );
m_DebugRenderText.Add( "fps", FpsRenderNode );
}
}
//---------------------------------------------------------
// return text render node for this debug text
//---------------------------------------------------------
TLRender::TRenderNodeText* TLRender::TScreen::Debug_GetRenderNodeText(TRefRef DebugTextRef)
{
TRef* ppRenderNodeRef = m_DebugRenderText.Find( DebugTextRef );
if ( !ppRenderNodeRef )
return NULL;
TLRender::TRenderNode* pRenderNode = TLRender::g_pRendergraph->FindNode( *ppRenderNodeRef );
if ( !pRenderNode )
return NULL;
return static_cast<TLRender::TRenderNodeText*>(pRenderNode);
}
//---------------------------------------------------------
// z has changed on render target - resorts render targets
//---------------------------------------------------------
void TLRender::TScreen::OnRenderTargetZChanged(const TRenderTarget& RenderTarget)
{
m_RenderTargets.Sort();
}
//----------------------------------------------------------
// get the desktop dimensions
//----------------------------------------------------------
void TLRender::TScreen::GetDesktopSize(Type4<s32>& DesktopSize) const
{
TLGui::Platform::GetDesktopSize( DesktopSize );
}
//----------------------------------------------------------
// take a screen size and center it on the desktop
//----------------------------------------------------------
void TLRender::TScreen::GetCenteredSize(Type4<s32>& Size) const
{
Type4<s32> DesktopSize;
GetDesktopSize( DesktopSize );
s32 DesktopCenterX = DesktopSize.x + (DesktopSize.Width() / 2);
s32 DesktopCenterY = DesktopSize.y + (DesktopSize.Height() / 2);
Size.x = DesktopCenterX - (Size.Width() / 2);
Size.y = DesktopCenterY - (Size.Height() / 2);
}
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
2
],
[
6,
6
],
[
9,
11
],
[
17,
33
],
[
37,
38
],
[
78,
86
],
[
92,
137
],
[
141,
144
],
[
146,
150
],
[
155,
155
],
[
159,
160
],
[
163,
164
],
[
168,
169
],
[
180,
180
],
[
184,
185
],
[
187,
193
],
[
195,
200
],
[
205,
272
],
[
274,
274
],
[
277,
277
],
[
279,
284
],
[
286,
286
],
[
288,
288
],
[
317,
318
],
[
321,
321
],
[
323,
325
],
[
329,
341
],
[
343,
390
],
[
392,
401
],
[
412,
421
],
[
423,
423
],
[
425,
434
],
[
436,
439
],
[
442,
450
]
],
[
[
3,
5
],
[
7,
8
],
[
12,
16
],
[
34,
36
],
[
39,
77
],
[
87,
91
],
[
138,
140
],
[
145,
145
],
[
151,
154
],
[
156,
158
],
[
161,
162
],
[
165,
167
],
[
170,
179
],
[
181,
183
],
[
186,
186
],
[
194,
194
],
[
201,
204
],
[
273,
273
],
[
275,
276
],
[
278,
278
],
[
285,
285
],
[
287,
287
],
[
289,
316
],
[
319,
320
],
[
322,
322
],
[
326,
328
],
[
342,
342
],
[
391,
391
],
[
402,
411
],
[
422,
422
],
[
424,
424
],
[
435,
435
],
[
440,
441
],
[
451,
585
]
]
] |
1547f305b1cb6ffe990d0d0aaf1a439aec797eff | 9d3fb15c6c417ce0f2354a11cdb094bdcf2e8a46 | /nxtOSEK/etrobo2010sample_cpp/StartStopDriver.cpp | 8487adf322942a2243096aa825e1eea9a4ede986 | [] | no_license | ngoclt-28/robo2011sample | af19f552c13ddaf7ffd5b90d9464f3db271fe86f | be4199623256646673eacea8eda9044927952a6d | refs/heads/master | 2021-01-17T14:26:03.163227 | 2011-08-06T07:47:39 | 2011-08-06T07:47:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 986 | cpp | //
// StartStopDriver.cpp
//
#include "StartStopDriver.h"
using namespace ecrobot;
//=============================================================================
// Update driver status
void StartStopDriver::update(void)
{
// driver state machine
switch(mDriverReq)
{
case Driver::STOP:
if (mInputFalseToTrue)
{
mDriverReq = Driver::START;
mInputFalseToTrue = false;
}
break;
case Driver::NO_REQ:
if (mInputFalseToTrue)
{
mDriverReq = Driver::STOP;
mInputFalseToTrue = false;
}
break;
case Driver::START:
default:
mDriverReq = Driver::NO_REQ;
break;
}
}
//=============================================================================
// Check boolean typed input (e.g Touch Sensor) to trigger start/stop of a robot
void StartStopDriver::checkInput(bool input)
{
mInputFalseToTrue = false;
if (input && !mInputState)
{
mInputFalseToTrue = true;
}
mInputState = input;
}
| [
"[email protected]"
] | [
[
[
1,
47
]
]
] |
e129502202083383ca7fb887fd55db24971c79e1 | b38ab5dcfb913569fc1e41e8deedc2487b2db491 | /libraries/GLFX/module/Overrides.cpp | 34aef8d4c628822e9bcfd9d9b8a53f4f5fe3f55a | [] | no_license | santosh90n/Fury2 | dacec86ab3972952e4cf6442b38e66b7a67edade | 740a095c2daa32d33fdc24cc47145a1c13431889 | refs/heads/master | 2020-03-21T00:44:27.908074 | 2008-10-16T07:09:17 | 2008-10-16T07:09:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 123,978 | cpp | #include "../header/GLFX.hpp"
#include "../header/Tilemap.hpp"
#include "../header/WindowSkin.hpp"
using namespace SoftFX;
using namespace GL;
using namespace BlendModes;
using namespace ScaleModes;
#define defFilter(name, shadername) \
defOverride(FilterSimple_##name) { \
readParam(int, Image, 0); \
contextCheck(Image); \
shaderCheck(); \
lockCheck(Image); \
readParamRect(Area, 1, Image); \
selectContext(Image); \
clipCheck(Image, Area); \
enableTextures(); \
selectImageAsTextureN<0>(Image); \
setBlendMode<Normal>(); \
setVertexColor(White); \
setBlendColor(White); \
GLSL::Program* shader = Global->GetShader(std::string(shadername)); \
GLSL::useProgram(*shader); \
FilterSimple_Shader_Core(Parameters, shader); \
GLSL::disableProgram(); \
SetImageDirty(Image, 1); \
return Success; \
}
#define contextCheck(param) \
if (checkNamedTag(param, Framebuffer)) { GL::setFramebuffer(reinterpret_cast<Framebuffer*>(getNamedTag(param, Framebuffer))); } \
else if (!checkNamedTag(param, Context)) { return Failure; } \
else { GL::setFramebuffer(0); }
#define contextSwitch(param) \
if (checkNamedTag(param, Framebuffer)) { GL::setFramebuffer(reinterpret_cast<Framebuffer*>(getNamedTag(param, Framebuffer))); } \
else { GL::setFramebuffer(0); }
#define lockCheck(param) \
if (!GetImageLocked(param)) { return Failure; }
#define shaderCheck() \
if (!GLSL::isSupported()) { return Failure; }
#define clipCheck(img, rect) \
if (!ClipRectangle_ImageClipRect(&rect, img)) return Trivial_Success;
void setScaler(int Scaler) {
if (Scaler == GetBilinearScaler()) {
setScaleMode<Bilinear>();
} else if (Scaler == GetBilinearWrapScaler()) {
setScaleMode<Bilinear_Wrap>();
} else if (Scaler == GetBilinearClampScaler()) {
setScaleMode<Bilinear_Clamp>();
} else if (Scaler == GetLinearWrapScaler()) {
setScaleMode<Linear_Wrap>();
} else if (Scaler == GetLinearClampScaler()) {
setScaleMode<Linear_Clamp>();
} else {
setScaleMode<Linear>();
}
}
void setRenderer(int Renderer, Pixel RenderArgument) {
if ((Renderer == GetSourceAlphaRenderer()) || (Renderer == GetMergeRenderer())) {
setBlendMode<SourceAlpha>();
if (RenderArgument[::Alpha] > 0) {
setFogColor(RenderArgument);
enableFog();
setFogOpacity(Global->FloatLookup[RenderArgument[::Alpha]]);
} else {
disableFog();
}
setBlendColor(White);
} else if (Renderer == GetFontSourceAlphaRenderer()) {
setBlendMode<Font_SourceAlpha>();
setVertexColor(RenderArgument);
disableFog();
setBlendColor(White);
} else if (Renderer == GetAdditiveRenderer()) {
setBlendMode<Additive>();
disableFog();
setBlendColor(White);
} else if (Renderer == GetSubtractiveRenderer()) {
setBlendMode<Subtractive>();
disableFog();
setBlendColor(White);
} else if (Renderer == GetAdditiveSourceAlphaRenderer()) {
setBlendMode<Additive_SourceAlpha>();
disableFog();
setBlendColor(White);
} else if (Renderer == GetSubtractiveSourceAlphaRenderer()) {
setBlendMode<Subtractive_SourceAlpha>();
disableFog();
setBlendColor(White);
} else {
setBlendMode<Normal>();
if (RenderArgument[::Alpha] > 0) {
setFogColor(RenderArgument);
enableFog();
setFogOpacity(Global->FloatLookup[RenderArgument[::Alpha]]);
} else {
disableFog();
}
setBlendColor(White);
}
}
void setMaskRenderer(int Renderer, Pixel RenderArgument) {
if ((Renderer == GetSourceAlphaRenderer()) || (Renderer == GetMergeRenderer())) {
setBlendMode<Mask_SourceAlpha>();
if (RenderArgument[::Alpha] > 0) {
setFogColor(RenderArgument);
enableFog();
setFogOpacity(Global->FloatLookup[RenderArgument[::Alpha]]);
} else {
disableFog();
}
} else {
setBlendMode<Mask_Normal>();
if (RenderArgument[::Alpha] > 0) {
setFogColor(RenderArgument);
enableFog();
setFogOpacity(Global->FloatLookup[RenderArgument[::Alpha]]);
} else {
disableFog();
}
}
}
defOverride(Allocate_Context) {
endDraw();
readParam(int, Image, 0);
readParam(int, Width, 1);
readParam(int, Height, 2);
if (Width < 1) return 0;
if (Height < 1) return 0;
if (Image == Null) return 0;
flushImageHeap();
Global->Framebuffer = Image;
PIXELFORMATDESCRIPTOR pfdFormat = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
32, // 32-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
0, // no z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
int iFormat = 0;
iFormat = ChoosePixelFormat(Global->DC, &pfdFormat);
SetPixelFormat(Global->DC, iFormat, &pfdFormat);
Global->Context = wglCreateContext(Global->DC);
wglMakeCurrent(Global->DC, Global->Context);
glewInit();
GL::init();
glEnable(GL_SCISSOR_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, Global->OutputWidth, Global->OutputHeight, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, Global->OutputWidth, Global->OutputHeight);
glScissor(0, 0, Global->OutputWidth, Global->OutputHeight);
glLineWidth(1.0f);
if(wglSwapInterval)
wglSwapInterval(0);
setNamedTagAndKey(Image, Context, Global->Context);
setNamedTag(Image, DC, Global->DC);
setNamedTag(Image, Pointer, malloc(Width * Height * 4));
SetImageWidth(Image, Width);
SetImageHeight(Image, Height);
SetImagePitch(Image, 0);
SetImagePointer(Image, Null);
SetImageLocked(Image, true);
Global->NullShader = new GLSL::FragmentShader();
return Success;
}
defOverride(Allocate_Framebuffer) {
endDraw();
disableAA(); // wtf ATI
readParam(int, Image, 0);
readParam(int, Width, 1);
readParam(int, Height, 2);
if (Width < 1) return 0;
if (Height < 1) return 0;
if (Image == Null) return 0;
if (GLEW_EXT_framebuffer_object) {
Framebuffer* buffer = new Framebuffer();
Texture* tex = GL::createTexture(Width, Height, false);
// Texture* attachedTex = GL::createTexture(Width, Height, false);
tex->flipVertical();
// attachedTex->flipVertical();
buffer->Image = Image;
buffer->AttachedTexture = tex; //attachedTex;
buffer->Width = Width;
buffer->Height = Height;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, buffer->Handle);
Global->checkError();
buffer->attachTexture(*tex); //*attachedTex);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
Global->checkError();
setNamedTagAndKey(Image, Framebuffer, buffer);
setNamedTag(Image, Texture, tex);
setNamedTag(Image, Pointer, malloc(Width * Height * 4));
SetImageWidth(Image, Width);
SetImageHeight(Image, Height);
SetImagePitch(Image, 0);
SetImagePointer(Image, Null);
SetImageLocked(Image, true);
}
return Success;
}
defOverride(Allocate) {
endDraw();
readParam(int, Image, 0);
readParam(int, Width, 1);
readParam(int, Height, 2);
if (Width < 1) return 0;
if (Height < 1) return 0;
if (Image == Null) return 0;
if (checkNamedTag(Image, Framebuffer)) {
return _Allocate_Framebuffer(Parameters);
} else if (checkNamedTag(Image, Context)) {
return _Allocate_Context(Parameters);
} else {
return 0;
}
return 0;
}
void BlitSimple_Core(Override::OverrideParameters *Parameters) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParamRect(Area, 2, Null);
readParam(int, SourceX, 3);
readParam(int, SourceY, 4);
FX::Rectangle AreaCopy = Area;
if (Clip2D_SimpleRect(&Area, Dest, Source, &AreaCopy, SourceX, SourceY)) {
selectImageAsTexture(Source);
selectImageAsTexture(Source);
enableTextures();
setScaleMode<Linear>();
contextSwitch(Dest);
Texture* tex = getTexture(Source);
if ((Area.Width == tex->Width) && (Area.Height == tex->Height) && (SourceX == 0) && (SourceY == 0)) {
drawTexturedRectangle(Area, tex->U1, tex->V1, tex->U2, tex->V2);
} else {
float U1 = tex->U(SourceX), V1 = tex->V(SourceY);
float U2 = tex->U(SourceX + Area.Width), V2 = tex->V(SourceY + Area.Height);
drawTexturedRectangle(Area, U1, V1, U2, V2);
}
SetImageDirty(Dest, 1);
}
}
void BlitSimple_Shader_Core(Override::OverrideParameters *Parameters, GLSL::Program* shader) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParamRect(Area, 2, Null);
readParam(int, SourceX, 3);
readParam(int, SourceY, 4);
FX::Rectangle AreaCopy = Area;
if (Clip2D_SimpleRect(&Area, Dest, Source, &AreaCopy, SourceX, SourceY)) {
enableTextures();
selectImageAsTexture(Source);
selectImageAsTexture(Source);
setScaleMode<Linear>();
contextSwitch(Dest);
Texture* tex = getTexture(Source);
initShaderVariables(shader);
if ((Area.Width == tex->Width) && (Area.Height == tex->Height) && (SourceX == 0) && (SourceY == 0)) {
drawTexturedRectangle(Area, tex->U1, tex->V1, tex->U2, tex->V2);
} else {
float U1 = tex->U(SourceX), V1 = tex->V(SourceY);
float U2 = tex->U(SourceX + Area.Width), V2 = tex->V(SourceY + Area.Height);
drawTexturedRectangle(Area, U1, V1, U2, V2);
}
SetImageDirty(Dest, 1);
}
}
void FilterSimple_Shader_Core(Override::OverrideParameters *Parameters, GLSL::Program* shader) {
readParam(int, Dest, 0);
readParamRect(Area, 1, Null);
FX::Rectangle AreaCopy = Area;
if (ClipRectangle_ImageClipRect(&Area, Dest)) {
enableTextures();
selectImageAsTexture(Dest);
selectImageAsTexture(Dest);
contextSwitch(Dest);
setScaleMode<Linear>();
Texture* tex = getTexture(Dest);
initShaderVariables(shader);
if ((Area.Width == tex->Width) && (Area.Height == tex->Height) && (Area.Left == 0) && (Area.Top == 0)) {
drawTexturedRectangle(Area, tex->U1, tex->V1, tex->U2, tex->V2);
} else {
float U1 = tex->U(Area.Left), V1 = tex->V(Area.Top);
float U2 = tex->U(Area.right()), V2 = tex->V(Area.bottom());
drawTexturedRectangle(Area, U1, V1, U2, V2);
}
SetImageDirty(Dest, 1);
}
}
void BlitSimple_FBTex_Core(Override::OverrideParameters *Parameters) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParamRect(Area, 2, Null);
readParam(int, SourceX, 3);
readParam(int, SourceY, 4);
FX::Rectangle AreaCopy = Area;
if (Clip2D_SimpleRect(&Area, Dest, Source, &AreaCopy, SourceX, SourceY)) {
// copyFramebufferToTexture(getTexture(Dest), Dest);
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Dest);
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Dest);
enableTexture<0>();
enableTexture<1>();
setScaleMode<Linear>();
contextSwitch(Dest);
Texture* tex = getTexture(Source);
Texture* fbtex = getTexture(Dest);
float U1 = tex->U(SourceX), V1 = tex->V(SourceY);
float U2 = tex->U(SourceX + Area.Width), V2 = tex->V(SourceY + Area.Height);
float U3 = fbtex->U(Area.Left), V3 = fbtex->V(Area.Top);
float U4 = fbtex->U(Area.right()), V4 = fbtex->V(Area.bottom());
draw2TexturedRectangle(Area, U1, V1, U2, V2, U3, V3, U4, V4);
SetImageDirty(Dest, 1);
}
}
void BlitSimple_Shader_FBTex_Core(Override::OverrideParameters *Parameters, GLSL::Program* shader) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParamRect(Area, 2, Null);
readParam(int, SourceX, 3);
readParam(int, SourceY, 4);
FX::Rectangle AreaCopy = Area;
if (Clip2D_SimpleRect(&Area, Dest, Source, &AreaCopy, SourceX, SourceY)) {
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Dest);
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Dest);
enableTexture<0>();
enableTexture<1>();
setScaleMode<Linear>();
contextSwitch(Dest);
Texture* tex = getTexture(Source);
Texture* fbtex = getTexture(Dest);
initShaderVariables(shader);
float U1 = tex->U(SourceX), V1 = tex->V(SourceY);
float U2 = tex->U(SourceX + Area.Width), V2 = tex->V(SourceY + Area.Height);
float U3 = fbtex->U(Area.Left), V3 = fbtex->V(Area.Top);
float U4 = fbtex->U(Area.right()), V4 = fbtex->V(Area.bottom());
draw2TexturedRectangle(Area, U1, V1, U2, V2, U3, V3, U4, V4);
SetImageDirty(Dest, 1);
}
}
defOverride(Clear) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
selectContext(Image);
endDraw();
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
SetImageDirty(Image, 1);
return Success;
}
defOverride(Lock) {
readParam(int, Image, 0);
contextCheck(Image);
if (GetImageLocked(Image)) return Failure;
if (GetImageDirty(Image)) {
if (checkNamedTag(Image, Context)) {
copyImageToFramebuffer(Image);
SetImageLocked(Image, 1);
SetImagePointer(Image, 0);
SetImageDirty(Image, 0);
return Success;
} else if (checkNamedTag(Image, Framebuffer)) {
Framebuffer* buffer = (Framebuffer*)getNamedTag(Image, Framebuffer);
GL::setFramebuffer(buffer);
copyImageToFramebuffer(Image);
SetImageLocked(Image, 1);
SetImagePointer(Image, 0);
SetImageDirty(Image, 0);
return Success;
}
}
return Failure;
}
defOverride(Unlock) {
readParam(int, Image, 0);
contextCheck(Image);
if (!GetImageLocked(Image)) return Failure;
if (GetImageDirty(Image)) {
if (checkNamedTag(Image, Context)) {
SetImagePointer(Image, (void*)getNamedTag(Image, Pointer));
SetImageLocked(Image, 0);
SetImageDirty(Image, 0);
copyFramebufferToImage(Image);
return Success;
} else if (checkNamedTag(Image, Framebuffer)) {
SetImagePointer(Image, (void*)getNamedTag(Image, Pointer));
SetImageLocked(Image, 0);
SetImageDirty(Image, 0);
Framebuffer* buffer = (Framebuffer*)getNamedTag(Image, Framebuffer);
GL::setFramebuffer(buffer);
copyFramebufferToImage(Image);
return Success;
}
}
return Failure;
}
defOverride(FilterSimple_Fill) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Normal>();
setVertexColor(Color);
setBlendColor(White);
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Fill_Channel) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(int, Channel, 2);
readParam(int, Value, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Subtractive>();
Pixel ChannelMask = Pixel(0, 0, 0, 0);
ChannelMask[Channel] = 255;
setVertexColor(ChannelMask);
setBlendColor(White);
drawRectangle(Area);
setBlendMode<Additive>();
ChannelMask[Channel] = Value;
setVertexColor(ChannelMask);
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Invert_Channel) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(int, Channel, 2);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("invert_channel"));
GLSL::useProgram(*shader);
if (Channel == 0) {
Channel = 2;
} else if (Channel == 2) {
Channel = 0;
}
shader->getVariable("channel").set(Channel);
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Swap_Channels) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(int, Channel1, 2);
readParam(int, Channel2, 3);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("swap_channels"));
GLSL::useProgram(*shader);
if (Channel1 == 0) {
Channel1 = 2;
} else if (Channel1 == 2) {
Channel1 = 0;
}
if (Channel2 == 0) {
Channel2 = 2;
} else if (Channel2 == 2) {
Channel2 = 0;
}
shader->getVariable("channel1").set(Channel1);
shader->getVariable("channel2").set(Channel2);
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Fill_Opacity) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
readParam(int, Opacity, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Normal>();
setVertexColor(Color);
setBlendColor(Pixel(255,255,255,Opacity));
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Fill_SourceAlpha) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<SourceAlpha>();
setVertexColor(Color);
setBlendColor(White);
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Fill_SourceAlpha_Opacity) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
readParam(int, Opacity, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<SourceAlpha>();
setVertexColor(MultiplyAlpha(Color, Opacity));
setBlendColor(White);
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Fill_Additive) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Additive>();
setVertexColor(Color);
setBlendColor(White);
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Fill_Additive_Opacity) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
readParam(int, Opacity, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Additive>();
setVertexColor(Color);
setBlendColor(Pixel(255, 255, 255, Opacity));
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Fill_Subtractive) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Subtractive>();
setVertexColor(Color);
setBlendColor(White);
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Fill_Subtractive_Opacity) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
readParam(int, Opacity, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Subtractive>();
setVertexColor(Color);
setBlendColor(Pixel(255, 255, 255, Opacity));
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(BlitSimple_Normal) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Normal>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Channel) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(int, DestChannel, 5);
readParam(int, SourceChannel, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
Pixel ChannelMask = Pixel(0, 0, 0, 0);
ChannelMask[DestChannel] = 255;
selectImageAsTextureN<0>(Source);
disableTextures();
setBlendMode<Subtractive>();
setTextureColor(White);
setVertexColor(ChannelMask);
setBlendColor(White);
readParamRect(Area, 2, Null);
FX::Rectangle AreaCopy = Area;
if (ClipRectangle_ImageClipRect(&AreaCopy, Dest)) {
drawRectangle(AreaCopy);
setBlendMode<Additive>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("copy_channel"));
GLSL::useProgram(*shader);
if (DestChannel == 0) {
DestChannel = 2;
} else if (DestChannel == 2) {
DestChannel = 0;
}
if (SourceChannel == 0) {
SourceChannel = 2;
} else if (SourceChannel == 2) {
SourceChannel = 0;
}
shader->getVariable("dest_channel").set(DestChannel);
shader->getVariable("source_channel").set(SourceChannel);
SoftFX::SetImageDirty(Source, 0);
BlitSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
}
return Success;
}
defOverride(BlitSimple_NormalMap) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(Vec3*, LightVector, 5);
readParam(Pixel, LightColor, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
selectImageAsTextureN<0>(Source);
disableTextures();
setBlendMode<SourceAlpha>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
readParamRect(Area, 2, Null);
FX::Rectangle AreaCopy = Area;
if (ClipRectangle_ImageClipRect(&AreaCopy, Dest)) {
LightVector->normalize();
GLSL::Program* shader = Global->GetShader(std::string("normal_map"));
GLSL::useProgram(*shader);
shader->getVariable("light_vector").set(*LightVector);
shader->getVariable("light_color").set(LightColor);
SoftFX::SetImageDirty(Source, 0);
BlitSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
}
return Success;
}
defOverride(BlitSimple_NormalMap_Additive) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(Vec3*, LightVector, 5);
readParam(Pixel, LightColor, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
selectImageAsTextureN<0>(Source);
disableTextures();
setBlendMode<Additive_SourceAlpha>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
readParamRect(Area, 2, Null);
FX::Rectangle AreaCopy = Area;
if (ClipRectangle_ImageClipRect(&AreaCopy, Dest)) {
LightVector->normalize();
GLSL::Program* shader = Global->GetShader(std::string("normal_map"));
GLSL::useProgram(*shader);
shader->getVariable("light_vector").set(*LightVector);
shader->getVariable("light_color").set(LightColor);
SoftFX::SetImageDirty(Source, 0);
BlitSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
}
return Success;
}
defOverride(BlitSimple_NormalMap_SourceAlpha) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(Vec3*, LightVector, 5);
readParam(Pixel, LightColor, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
selectImageAsTextureN<0>(Source);
disableTextures();
setBlendMode<SourceAlpha>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
readParamRect(Area, 2, Null);
FX::Rectangle AreaCopy = Area;
if (ClipRectangle_ImageClipRect(&AreaCopy, Dest)) {
LightVector->normalize();
GLSL::Program* shader = Global->GetShader(std::string("normal_map_sourcealpha"));
GLSL::useProgram(*shader);
shader->getVariable("light_vector").set(*LightVector);
shader->getVariable("light_color").set(LightColor);
SoftFX::SetImageDirty(Source, 0);
BlitSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
}
return Success;
}
defOverride(BlitSimple_NormalMap_Additive_SourceAlpha) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(Vec3*, LightVector, 5);
readParam(Pixel, LightColor, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
selectImageAsTextureN<0>(Source);
disableTextures();
setBlendMode<Additive_SourceAlpha>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
readParamRect(Area, 2, Null);
FX::Rectangle AreaCopy = Area;
if (ClipRectangle_ImageClipRect(&AreaCopy, Dest)) {
LightVector->normalize();
GLSL::Program* shader = Global->GetShader(std::string("normal_map_sourcealpha"));
GLSL::useProgram(*shader);
shader->getVariable("light_vector").set(*LightVector);
shader->getVariable("light_color").set(LightColor);
SoftFX::SetImageDirty(Source, 0);
BlitSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
}
return Success;
}
defOverride(BlitSimple_Merge) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Dest);
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Dest);
disableTextures();
setBlendMode<Normal>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
readParamRect(Area, 2, Null);
FX::Rectangle AreaCopy = Area;
if (ClipRectangle_ImageClipRect(&AreaCopy, Dest)) {
GLSL::Program* shader = Global->GetShader(std::string("merge"));
GLSL::useProgram(*shader);
shader->getVariable("tex").set(0);
shader->getVariable("framebuffer").set(1);
shader->getVariable("opacity").set(1.0f);
SoftFX::SetImageDirty(Source, 0);
BlitSimple_Shader_FBTex_Core(Parameters, shader);
GLSL::disableProgram();
}
return Success;
}
defOverride(BlitSimple_Merge_Opacity) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Dest);
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Dest);
disableTextures();
setBlendMode<Normal>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
readParamRect(Area, 2, Null);
FX::Rectangle AreaCopy = Area;
if (ClipRectangle_ImageClipRect(&AreaCopy, Dest)) {
GLSL::Program* shader = Global->GetShader(std::string("merge"));
GLSL::useProgram(*shader);
shader->getVariable("tex").set(0);
shader->getVariable("framebuffer").set(1);
shader->getVariable("opacity").set(Global->FloatLookup[ClipByte(Opacity)]);
SoftFX::SetImageDirty(Source, 0);
BlitSimple_Shader_FBTex_Core(Parameters, shader);
GLSL::disableProgram();
}
return Success;
}
defOverride(BlitSimple_Normal_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Normal>();
setVertexColor(White);
setTextureColor(White);
setBlendColor(Pixel(255, 255, 255, Opacity));
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Subtractive) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Subtractive>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Subtractive_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Subtractive>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(Pixel(255, 255, 255, Opacity));
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Additive) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Additive>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(White);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Additive_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Additive>();
setTextureColor(White);
setVertexColor(White);
setBlendColor(Pixel(255, 255, 255, Opacity));
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Subtractive_SourceAlpha) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Subtractive_SourceAlpha>();
setTextureColor(White);
setVertexColor(White);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Subtractive_SourceAlpha_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Subtractive_SourceAlpha>();
setTextureColor(White);
setVertexColor(Pixel(255, 255, 255, Opacity));
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Additive_SourceAlpha) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Additive_SourceAlpha>();
setTextureColor(White);
setVertexColor(White);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Additive_SourceAlpha_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Additive_SourceAlpha>();
setTextureColor(White);
setVertexColor(Pixel(255, 255, 255, Opacity));
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Multiply) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
enableTextures();
setBlendMode<Multiply>();
setTextureColor(White);
setVertexColor(White);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Multiply_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
enableTextures();
setBlendMode<Multiply>();
setVertexColor(White);
setTextureColor(Pixel(Opacity, Opacity, Opacity, Opacity));
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Lightmap) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
enableTexture<0>();
setTextureColor(White);
enableTexture<1>();
setBlendMode<Lightmap>();
setVertexColor(White);
setBlendColor(White);
BlitSimple_FBTex_Core(Parameters);
disableTexture<1>();
switchTextureStage<0>();
return Success;
}
defOverride(BlitSimple_Lightmap_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
enableTexture<0>();
setTextureColor(White);
enableTexture<1>();
setBlendMode<Lightmap>();
setVertexColor(White);
setBlendColor(Pixel(Opacity, Opacity, Opacity, Opacity));
BlitSimple_FBTex_Core(Parameters);
disableTexture<1>();
switchTextureStage<0>();
return Success;
}
passOverride(BlitSimple_Lightmap_RGB, BlitSimple_Lightmap);
passOverride(BlitSimple_Lightmap_RGB_Opacity, BlitSimple_Lightmap_Opacity);
defOverride(BlitSimple_Normal_Tint) {
readParam(int, Dest, 0);
readParam(Pixel, Color, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
setFogColor(Color);
setFogOpacity(Global->FloatLookup[Color[::Alpha]]);
enableFog();
BlitSimple_Core(Parameters);
disableFog();
return Success;
}
defOverride(BlitSimple_Normal_Tint_Opacity) {
readParam(int, Dest, 0);
readParam(Pixel, Color, 5);
readParam(int, Opacity, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(Pixel(255, 255, 255, Opacity));
setFogColor(Color);
setFogOpacity(Global->FloatLookup[Color[::Alpha]]);
enableFog();
BlitSimple_Core(Parameters);
disableFog();
return Success;
}
void prepMatte(int Image) {
Texture* tex = getTexture(Image);
if (tex == 0) selectImageAsTexture(Image);
tex = getTexture(Image);
if (tex) {
if (tex->MatteOptimized) {
} else {
Pixel matteColor = GetImageMatteColor(Image);
FilterSimple_Replace(Image, 0, matteColor, Pixel(0, 0, 0, 0));
SetImageMatteColor(Image, Pixel(0, 0, 0, 0));
uploadImageToTexture(tex, Image);
tex->MatteOptimized = true;
}
}
}
defOverride(BlitSimple_Matte) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setVertexColor(White);
prepMatte(Source);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Matte_Opacity) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setVertexColor(Pixel(255, 255, 255, Opacity));
prepMatte(Source);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_Matte_Tint) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(Pixel, Color, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setVertexColor(White);
setFogColor(Color);
setFogOpacity(Global->FloatLookup[Color[::Alpha]]);
enableFog();
prepMatte(Source);
BlitSimple_Core(Parameters);
disableFog();
return Success;
}
defOverride(BlitSimple_Matte_Tint_Opacity) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(Pixel, Color, 5);
readParam(int, Opacity, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setVertexColor(Pixel(255, 255, 255, Opacity));
setFogColor(Color);
setFogOpacity(Global->FloatLookup[Color[::Alpha]]);
enableFog();
prepMatte(Source);
BlitSimple_Core(Parameters);
disableFog();
return Success;
}
defOverride(BlitSimple_SourceAlpha) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setTextureColor(White);
setVertexColor(White);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_SourceAlpha_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setTextureColor(White);
setVertexColor(Pixel(255, 255, 255, Opacity));
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_SourceAlpha_Premultiplied) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha_Premultiplied>();
setTextureColor(White);
setVertexColor(White);
BlitSimple_Core(Parameters);
return Success;
}
defOverride(BlitSimple_SourceAlpha_Premultiplied_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha_Premultiplied>();
setTextureColor(White);
setVertexColor(Pixel(255, 255, 255, Opacity));
BlitSimple_Core(Parameters);
return Success;
}
passOverride(BlitSimple_SourceAlphaMatte, BlitSimple_SourceAlpha)
passOverride(BlitSimple_SourceAlphaMatte_Opacity, BlitSimple_SourceAlpha_Opacity)
//passOverride(BlitSimple_Merge, BlitSimple_SourceAlpha)
//passOverride(BlitSimple_Merge_Opacity, BlitSimple_SourceAlpha_Opacity)
defOverride(BlitSimple_SourceAlpha_Tint) {
readParam(int, Dest, 0);
readParam(Pixel, Color, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setTextureColor(White);
setVertexColor(White);
setFogColor(Color);
setFogOpacity(Global->FloatLookup[Color[::Alpha]]);
enableFog();
BlitSimple_Core(Parameters);
disableFog();
return Success;
}
passOverride(BlitSimple_SourceAlpha_Solid_Tint, BlitSimple_SourceAlpha_Tint)
defOverride(BlitSimple_SourceAlpha_Tint_Opacity) {
readParam(int, Dest, 0);
readParam(Pixel, Color, 5);
readParam(int, Opacity, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setTextureColor(White);
setVertexColor(Pixel(255, 255, 255, Opacity));
setFogColor(Color);
setFogOpacity(Global->FloatLookup[Color[::Alpha]]);
enableFog();
BlitSimple_Core(Parameters);
disableFog();
return Success;
}
defOverride(BlitSimple_Font_SourceAlpha) {
readParam(int, Dest, 0);
readParam(int, Color, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Font_SourceAlpha>();
setBlendColor(White);
setTextureColorN<0>(White);
setVertexColor(Color);
BlitSimple_Core(Parameters);
return Success;
}
passOverride(BlitSimple_Font_SourceAlpha_RGB, BlitSimple_Font_SourceAlpha)
defOverride(BlitSimple_Font_SourceAlpha_Opacity) {
readParam(int, Dest, 0);
readParam(int, Color, 5);
readParam(int, Opacity, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Font_SourceAlpha>();
setBlendColor(White);
setTextureColorN<0>(White);
setVertexColor(MultiplyAlpha(Color, Opacity));
BlitSimple_Core(Parameters);
return Success;
}
passOverride(BlitSimple_Font_SourceAlpha_RGB_Opacity, BlitSimple_Font_SourceAlpha_Opacity)
passOverride(BlitSimple_Font_Merge_RGB, BlitSimple_Font_SourceAlpha)
passOverride(BlitSimple_Font_Merge_RGB_Opacity, BlitSimple_Font_SourceAlpha_Opacity)
void BlitResample_Core(Override::OverrideParameters *Parameters) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParamRect(DestRect, 2, Null);
readParamRect(SourceRect, 3, Null);
readParam(int, Scaler, 4);
FX::Rectangle DestCopy = DestRect;
FX::Rectangle SourceCopy = SourceRect;
if (Clip2D_PairedRect(&DestCopy, &SourceCopy, Dest, Source, &DestRect, &SourceRect, 0)) {
selectImageAsTexture(Source);
enableTextures();
setScaler(Scaler);
contextSwitch(Dest);
Texture* tex = getTexture(Source);
if ((SourceRect.Width == tex->Width) && (SourceRect.Height == tex->Height) && (SourceRect.Left == 0) && (SourceRect.Top == 0)) {
drawTexturedRectangle(DestRect, tex->U1, tex->V1, tex->U2, tex->V2);
} else {
float U1 = tex->U(SourceRect.Left), V1 = tex->V(SourceRect.Top);
float U2 = tex->U(SourceRect.right()), V2 = tex->V(SourceRect.bottom());
drawTexturedRectangle(DestRect, U1, V1, U2, V2);
}
SetImageDirty(Dest, 1);
}
}
defOverride(BlitResample_Normal) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
BlitResample_Core(Parameters);
return Success;
}
defOverride(BlitResample_Normal_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(Pixel(255, 255, 255, Opacity));
BlitResample_Core(Parameters);
return Success;
}
defOverride(BlitResample_SourceAlpha) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setVertexColor(White);
BlitResample_Core(Parameters);
return Success;
}
defOverride(BlitResample_SourceAlpha_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setVertexColor(Pixel(255, 255, 255, Opacity));
BlitResample_Core(Parameters);
return Success;
}
defOverride(BlitResample_SourceAlpha_Tint) {
readParam(int, Dest, 0);
readParam(int, tint, 5);
Pixel Tint(tint);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setVertexColor(White);
setFogColor(Tint);
setFogOpacity(Global->FloatLookup[Tint[::Alpha]]);
enableFog();
BlitResample_Core(Parameters);
disableFog();
return Success;
}
defOverride(BlitResample_SourceAlpha_Tint_Opacity) {
readParam(int, Dest, 0);
readParam(int, tint, 5);
Pixel Tint(tint);
readParam(int, Opacity, 6);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
setVertexColor(Pixel(255, 255, 255, Opacity));
setFogColor(Tint);
setFogOpacity(Global->FloatLookup[Tint[::Alpha]]);
enableFog();
BlitResample_Core(Parameters);
disableFog();
return Success;
}
defOverride(BlitResample_Additive) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Additive>();
setVertexColor(White);
setBlendColor(White);
BlitResample_Core(Parameters);
return Success;
}
defOverride(BlitResample_Additive_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Additive>();
setVertexColor(White);
setBlendColor(Pixel(255, 255, 255, Opacity));
BlitResample_Core(Parameters);
return Success;
}
defOverride(BlitResample_Subtractive) {
readParam(int, Dest, 0);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Subtractive>();
setVertexColor(White);
setBlendColor(White);
BlitResample_Core(Parameters);
return Success;
}
defOverride(BlitResample_Subtractive_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 5);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<Subtractive>();
setVertexColor(White);
setBlendColor(Pixel(255, 255, 255, Opacity));
BlitResample_Core(Parameters);
return Success;
}
void BlitMask_Core(Override::OverrideParameters *Parameters) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(int, Mask, 2);
readParamRect(Area, 3, Null);
readParam(int, SourceX, 4);
readParam(int, SourceY, 5);
readParam(int, MaskX, 6);
readParam(int, MaskY, 7);
FX::Rectangle AreaCopy = Area;
if (Clip2D_SimpleRect(&Area, Dest, Source, &AreaCopy, SourceX, SourceY)) {
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Mask);
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<1>(Mask);
enableTexture<0>();
enableTexture<1>();
contextSwitch(Dest);
Texture* tex = getTexture(Source);
Texture* mtex = getTexture(Mask);
float U1 = tex->U(SourceX), V1 = tex->V(SourceY);
float U2 = tex->U(SourceX + Area.Width), V2 = tex->V(SourceY + Area.Height);
float U3 = mtex->U(MaskX), V3 = mtex->V(MaskY);
float U4 = mtex->U(MaskX + Area.Width), V4 = mtex->V(MaskY + Area.Height);
setScaleMode<Linear>();
draw2TexturedRectangle(Area, U1, V1, U2, V2, U3, V3, U4, V4);
SetImageDirty(Dest, 1);
}
}
defOverride(BlitMask_Normal_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 8);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
enableTexture<0>();
setTextureColor(Pixel(255, 255, 255, Opacity));
enableTexture<1>();
setTextureColor(Pixel(255, 255, 255, Opacity));
setBlendMode<Mask_Normal>();
setVertexColor(White);
BlitMask_Core(Parameters);
disableTexture<1>();
switchTextureStage<0>();
return Success;
}
defOverride(BlitMask_SourceAlpha_Opacity) {
readParam(int, Dest, 0);
readParam(int, Opacity, 8);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
enableTexture<0>();
setTextureColor(Pixel(255, 255, 255, Opacity));
enableTexture<1>();
setTextureColor(Pixel(255, 255, 255, Opacity));
setBlendMode<Mask_SourceAlpha>();
setVertexColor(White);
BlitMask_Core(Parameters);
disableTexture<1>();
switchTextureStage<0>();
return Success;
}
passOverride(BlitMask_Merge_Opacity, BlitMask_SourceAlpha_Opacity)
defOverride(FilterSimple_Gradient_4Point) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, ColorTL, 2);
readParam(Pixel, ColorTR, 3);
readParam(Pixel, ColorBL, 4);
readParam(Pixel, ColorBR, 5);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Normal>();
setBlendColor(White);
drawGradientRectangle(Area, ColorTL, ColorTR, ColorBL, ColorBR);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gradient_4Point_SourceAlpha) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, ColorTL, 2);
readParam(Pixel, ColorTR, 3);
readParam(Pixel, ColorBL, 4);
readParam(Pixel, ColorBR, 5);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
drawGradientRectangle(Area, ColorTL, ColorTR, ColorBL, ColorBR);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gradient_Horizontal) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, ColorR, 2);
readParam(Pixel, ColorL, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Normal>();
setBlendColor(White);
drawGradientRectangle(Area, ColorL, ColorR, ColorL, ColorR);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gradient_Horizontal_SourceAlpha) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, ColorR, 2);
readParam(Pixel, ColorL, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
drawGradientRectangle(Area, ColorL, ColorR, ColorL, ColorR);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gradient_Vertical) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, ColorB, 2);
readParam(Pixel, ColorT, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Normal>();
setBlendColor(White);
drawGradientRectangle(Area, ColorT, ColorT, ColorB, ColorB);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gradient_Vertical_SourceAlpha) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, ColorB, 2);
readParam(Pixel, ColorT, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
drawGradientRectangle(Area, ColorT, ColorT, ColorB, ColorB);
SetImageDirty(Image, 1);
return Success;
}
int FilterSimple_Gradient_Radial_GLSL(Override::OverrideParameters *Parameters) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color1, 2);
readParam(Pixel, Color2, 3);
selectContext(Image);
disableTextures();
setBlendMode<Normal>();
setBlendColor(White);
setVertexColor(White);
float w = Area.Width / 2.0f, h = Area.Height / 2.0f;
GLSL::Program* shader = Global->GetShader(std::string("radial_gradient"));
GLSL::useProgram(*shader);
shader->getVariable("startColor").set(Color1);
shader->getVariable("endColor").set(Color2);
drawGradientRectangle(Area, Pixel(0,0,0,255), Pixel(255,0,0,255), Pixel(0,255,0,255), Pixel(255,255,0,255));
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
int FilterSimple_Gradient_Radial_SourceAlpha_GLSL(Override::OverrideParameters *Parameters) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color1, 2);
readParam(Pixel, Color2, 3);
selectContext(Image);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
setVertexColor(White);
float w = Area.Width / 2.0f, h = Area.Height / 2.0f;
GLSL::Program* shader = Global->GetShader(std::string("radial_gradient"));
GLSL::useProgram(*shader);
shader->getVariable("startColor").set(Color1);
shader->getVariable("endColor").set(Color2);
drawGradientRectangle(Area, Pixel(0,0,0,255), Pixel(255,0,0,255), Pixel(0,255,0,255), Pixel(255,255,0,255));
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gradient_Radial) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
if (GLSL::isSupported()) {
return FilterSimple_Gradient_Radial_GLSL(Parameters);
}
readParamRect(Area, 1, Image);
readParam(Pixel, Color1, 2);
readParam(Pixel, Color2, 3);
selectContext(Image);
disableTextures();
setBlendMode<Normal>();
setBlendColor(White);
setVertexColor(Color2);
drawRectangle(Area);
enableTextures();
Global->GenerateRadialImage();
selectImageAsTexture(Global->RadialImage);
setBlendMode<SourceAlpha>();
setVertexColor(Color1);
float w = Area.Width / 2.0f, h = Area.Height / 2.0f;
float x1 = Area.Left, y1 = Area.Top;
float x2 = Area.Left + w, y2 = Area.Top + h;
drawTexturedRectangleF(x1, y1, w, h, 1, 1, 0, 0);
drawTexturedRectangleF(x2, y1, w, h, 0, 1, 1, 0);
drawTexturedRectangleF(x1, y2, w, h, 1, 0, 0, 1);
drawTexturedRectangleF(x2, y2, w, h, 0, 0, 1, 1);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gradient_Radial_SourceAlpha) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
if (GLSL::isSupported()) {
return FilterSimple_Gradient_Radial_SourceAlpha_GLSL(Parameters);
}
readParamRect(Area, 1, Image);
readParam(Pixel, Color1, 2);
readParam(Pixel, Color2, 3);
selectContext(Image);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
setVertexColor(Color2);
drawRectangle(Area);
enableTextures();
Global->GenerateRadialImage();
selectImageAsTexture(Global->RadialImage);
setBlendMode<SourceAlpha>();
setScaleMode<Linear>();
setVertexColor(Color1);
float w = Area.Width / 2.0f, h = Area.Height / 2.0f;
float x1 = Area.Left, y1 = Area.Top;
float x2 = Area.Left + w, y2 = Area.Top + h;
drawTexturedRectangleF(x1, y1, w, h, 1, 1, 0, 0);
drawTexturedRectangleF(x2, y1, w, h, 0, 1, 1, 0);
drawTexturedRectangleF(x1, y2, w, h, 1, 0, 0, 1);
drawTexturedRectangleF(x2, y2, w, h, 0, 0, 1, 1);
SetImageDirty(Image, 1);
return Success;
}
defOverride(SetPixel) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParam(int, X, 1);
readParam(int, Y, 2);
readParam(Pixel, Color, 3);
selectContext(Image);
disableTextures();
setBlendMode<Normal>();
setBlendColor(White);
setVertexColor(Color);
disableAA();
drawPixel(X, Y);
SetImageDirty(Image, 1);
return Success;
}
defOverride(SetPixelAA) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParam(int, Xi, 1);
readParam(int, Yi, 2);
readParam(int, Xf, 3);
readParam(int, Yf, 4);
readParam(Pixel, Color, 5);
selectContext(Image);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
setVertexColor(Color);
enableAA();
drawPixel((float)Xi + ((float)Xf / 255.0f) + 0.5f, (float)Yi + ((float)Yf / 255.0f) + 0.5f);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Line) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
FPoint start, end;
Area.getLine(start, end);
selectContext(Image);
disableTextures();
setBlendMode<Normal>();
setBlendColor(White);
setVertexColor(Color);
disableAA();
drawLine(start, end);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Line_SourceAlpha) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
FPoint start, end;
Area.getLine(start, end);
selectContext(Image);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
setVertexColor(Color);
drawLine(start, end);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Line_AA) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParam(float, X1, 1);
readParam(float, Y1, 2);
readParam(float, X2, 3);
readParam(float, Y2, 4);
readParam(Pixel, Color, 5);
selectContext(Image);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
setVertexColor(Color);
enableAA();
drawLine(FPoint(X1 + 0.5f, Y1 + 0.5f), FPoint(X2 + 0.5f, Y2 + 0.5f));
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Line_Gradient_AA) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParam(float, X1, 1);
readParam(float, Y1, 2);
readParam(float, X2, 3);
readParam(float, Y2, 4);
readParam(Pixel, StartColor, 5);
readParam(Pixel, EndColor, 6);
selectContext(Image);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
enableAA();
drawGradientLine(FPoint(X1 + 0.5f, Y1 + 0.5f), FPoint(X2 + 0.5f, Y2 + 0.5f), StartColor, EndColor);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Line_Additive) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
FPoint start, end;
Area.getLine(start, end);
selectContext(Image);
disableTextures();
setBlendMode<Additive>();
setBlendColor(White);
setVertexColor(Color);
disableAA();
drawLine(start, end);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Line_Subtractive) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
FPoint start, end;
Area.getLine(start, end);
selectContext(Image);
disableTextures();
setBlendMode<Subtractive>();
setBlendColor(White);
setVertexColor(Color);
disableAA();
drawLine(start, end);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Line_Gradient) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, ColorS, 2);
readParam(Pixel, ColorE, 3);
FPoint start, end;
Area.getLine(start, end);
selectContext(Image);
disableTextures();
setBlendMode<Normal>();
setBlendColor(White);
disableAA();
drawGradientLine(start, end, ColorS, ColorE);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Line_Gradient_SourceAlpha) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, ColorS, 2);
readParam(Pixel, ColorE, 3);
FPoint start, end;
Area.getLine(start, end);
selectContext(Image);
disableTextures();
setBlendMode<SourceAlpha>();
setBlendColor(White);
disableAA();
drawGradientLine(start, end, ColorS, ColorE);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Box) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<Normal>();
setVertexColor(Color);
setBlendColor(White);
disableAA();
drawBox(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Box_SourceAlpha) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
setBlendMode<SourceAlpha>();
setVertexColor(Color);
setBlendColor(White);
disableAA();
drawBox(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Adjust) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(int, Amount, 2);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
if (Amount > 0) {
setBlendMode<Additive>();
setVertexColor(Pixel(Amount, Amount, Amount, 255));
} else if (Amount < 0) {
setBlendMode<Subtractive>();
setVertexColor(Pixel(-Amount, -Amount, -Amount, 255));
}
setBlendColor(White);
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Composite) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, Color, 2);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("composite"));
GLSL::useProgram(*shader);
shader->getVariable("background_color").set(Color);
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Replace) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(Pixel, FindColor, 2);
readParam(Pixel, ReplaceColor, 3);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("replace"));
GLSL::useProgram(*shader);
shader->getVariable("find").set(FindColor);
shader->getVariable("replace").set(ReplaceColor);
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gamma) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(float, Gamma, 2);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("gamma"));
GLSL::useProgram(*shader);
shader->getVariable("gamma").set(Vec4(1.0f / Gamma, 1.0f));
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Blur) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(int, XRadius, 2);
readParam(int, YRadius, 3);
if (XRadius != YRadius) return Failure;
selectContext(Image);
clipCheck(Image, Area);
GLSL::Program* shader = Null;
if (XRadius == 1)
shader = Global->GetShader(std::string("blur_1x1"));
else if (XRadius == 2)
shader = Global->GetShader(std::string("blur_2x2"));
else
return Failure;
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::useProgram(*shader);
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gamma_RGB) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(float, RedGamma, 2);
readParam(float, GreenGamma, 3);
readParam(float, BlueGamma, 4);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("gamma"));
GLSL::useProgram(*shader);
shader->getVariable("gamma").set(Vec4(1.0f / RedGamma, 1.0f / GreenGamma, 1.0f / BlueGamma, 1.0f));
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Gamma_Channel) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(int, Channel, 2);
readParam(float, Gamma, 3);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("gamma"));
GLSL::useProgram(*shader);
Vec4 vec = Vec4(1.0f);
if (Channel == 0) {
Channel = 2;
} else if (Channel == 2) {
Channel = 0;
}
vec.V[Channel] = 1.0f / Gamma;
shader->getVariable("gamma").set(vec);
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Multiply) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(float, Factor, 2);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("multiply"));
GLSL::useProgram(*shader);
shader->getVariable("factor").set(Vec4(Factor, 1.0f));
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Multiply_RGB) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(float, RedFactor, 2);
readParam(float, GreenFactor, 3);
readParam(float, BlueFactor, 4);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("multiply"));
GLSL::useProgram(*shader);
shader->getVariable("factor").set(Vec4(RedFactor, GreenFactor, BlueFactor, 1.0f));
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Multiply_Channel) {
readParam(int, Image, 0);
contextCheck(Image);
shaderCheck();
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(int, Channel, 2);
readParam(float, Factor, 3);
selectContext(Image);
clipCheck(Image, Area);
enableTextures();
selectImageAsTextureN<0>(Image);
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(White);
GLSL::Program* shader = Global->GetShader(std::string("multiply"));
GLSL::useProgram(*shader);
Vec4 vec = Vec4(1.0f);
if (Channel == 0) {
Channel = 2;
} else if (Channel == 2) {
Channel = 0;
}
vec.V[Channel] = Factor;
shader->getVariable("factor").set(vec);
FilterSimple_Shader_Core(Parameters, shader);
GLSL::disableProgram();
SetImageDirty(Image, 1);
return Success;
}
defFilter(Grayscale, "grayscale")
defFilter(Invert, "invert")
defFilter(Invert_RGB, "invert_rgb")
defOverride(FilterSimple_Adjust_RGB) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(int, RedAmount, 2);
readParam(int, GreenAmount, 3);
readParam(int, BlueAmount, 4);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
int Amount;
Pixel Color;
for (int c = 0; c < 3; ++c) {
switch (c) {
case ::Blue:
Amount = BlueAmount;
break;
case ::Green:
Amount = GreenAmount;
break;
case ::Red:
Amount = RedAmount;
break;
}
Color = Pixel(0, 0, 0, 255);
if (Amount > 0) {
setBlendMode<Additive>();
Color[c] = Amount;
} else {
setBlendMode<Subtractive>();
Color[c] = -Amount;
}
setVertexColor(Color);
setBlendColor(White);
drawRectangle(Area);
}
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_Adjust_Channel) {
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(int, Channel, 2);
readParam(int, Amount, 3);
selectContext(Image);
clipCheck(Image, Area);
disableTextures();
Pixel Color = Pixel(0, 0, 0, 255);
if (Amount > 0) {
setBlendMode<Additive>();
Color[Channel] = Amount;
} else {
setBlendMode<Subtractive>();
Color[Channel] = -Amount;
}
setVertexColor(Color);
setBlendColor(White);
drawRectangle(Area);
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_ConvexPolygon) {
readParam(int, Image, 0);
readParam(int, Polygon, 1);
readParam(Pixel, Color, 2);
readParam(int, Renderer, 3);
readParam(Pixel, RenderArgument, 4);
contextCheck(Image);
lockCheck(Image);
selectContext(Image);
disableTextures();
setRenderer(Renderer, RenderArgument);
setVertexColor(Color);
FPoint* ptr = GetPolygonVertexPointer(Polygon, 0);
int vertex_count = GetPolygonVertexCount(Polygon);
if (vertex_count == 4) {
beginDraw(GL_QUADS);
} else if (vertex_count == 3) {
beginDraw(GL_TRIANGLES);
} else {
beginDraw(GL_POLYGON);
}
for (int i = 0; i < vertex_count; ++i) {
glVertex2f(ptr->X, ptr->Y);
ptr++;
}
if (vertex_count > 4) endDraw();
disableFog();
SetImageDirty(Image, 1);
return Success;
}
defOverride(FilterSimple_ConvexPolygon_Gradient) {
readParam(int, Image, 0);
readParam(int, Polygon, 1);
readParam(Pixel, Color, 2);
readParam(int, Renderer, 3);
readParam(Pixel, RenderArgument, 4);
contextCheck(Image);
lockCheck(Image);
selectContext(Image);
disableTextures();
setRenderer(Renderer, RenderArgument);
GradientVertex* ptr = GetGradientPolygonVertexPointer(Polygon, 0);
int vertex_count = GetGradientPolygonVertexCount(Polygon);
if (vertex_count == 4) {
beginDraw(GL_QUADS);
} else if (vertex_count == 3) {
beginDraw(GL_TRIANGLES);
} else {
beginDraw(GL_POLYGON);
}
for (int i = 0; i < vertex_count; ++i) {
setVertexColor(ptr->Color);
glVertex2f(ptr->X, ptr->Y);
ptr++;
}
if (vertex_count > 4) endDraw();
disableFog();
SetImageDirty(Image, 1);
return Success;
}
passOverride(FilterSimple_ConvexPolygon_AntiAlias, FilterSimple_ConvexPolygon);
defOverride(FilterSimple_ConvexPolygon_Textured) {
readParam(int, Image, 0);
readParam(int, TextureImage, 1);
readParam(int, Polygon, 2);
readParam(int, Scaler, 3);
readParam(int, Renderer, 4);
readParam(Pixel, RenderArgument, 5);
contextCheck(Image);
lockCheck(Image);
selectContext(Image);
enableTextures();
selectImageAsTexture(TextureImage);
setRenderer(Renderer, RenderArgument);
setScaler(Scaler);
setVertexColor(Pixel(255, 255, 255, 255));
Texture* tex = getTexture(TextureImage);
TexturedVertex* ptr = GetTexturedPolygonVertexPointer(Polygon, 0);
int vertex_count = GetTexturedPolygonVertexCount(Polygon);
if (vertex_count == 4) {
beginDraw(GL_QUADS);
} else if (vertex_count == 3) {
beginDraw(GL_TRIANGLES);
} else {
beginDraw(GL_POLYGON);
}
for (int i = 0; i < vertex_count; ++i) {
glTexCoord2f(tex->U(ptr->U), tex->V(ptr->V));
glVertex2f(ptr->X, ptr->Y);
ptr++;
}
if (vertex_count > 4) endDraw();
disableFog();
SetImageDirty(Image, 1);
return Success;
}
passOverride(FilterSimple_ConvexPolygon_Textured_AntiAlias, FilterSimple_ConvexPolygon_Textured);
defOverride(Copy) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
contextCheck(Source);
if (GetImageLocked(Source)) {
UnlockImage(Source);
FX::Rectangle rect = FX::Rectangle(0, 0, GetImageWidth(Source), GetImageHeight(Source));
ReallocateImage(Dest, rect.Width, rect.Height);
BlitSimple_Normal(Dest, Source, &rect, 0, 0);
LockImage(Source);
SetImageDirty(Dest, 1);
return Success;
}
return Failure;
}
void BlitTiled(int Dest, int Source, FX::Rectangle* DestRect) {
if (ClipRectangle_ImageClipRect(DestRect, Dest)) {
enableTextures();
selectImageAsTexture(Source);
Texture* tex = getTexture(Source);
setScaleMode<Linear>();
drawTexturedRectangleTiledF(DestRect->Left, DestRect->Top, DestRect->Width, DestRect->Height, tex->Width, tex->Height, tex->U1, tex->V1, tex->U2, tex->V2);
}
}
void BlitScaled(int Dest, int Source, FX::Rectangle* DestRect) {
if (ClipRectangle_ImageClipRect(DestRect, Dest)) {
enableTextures();
selectImageAsTexture(Source);
setScaleMode<Linear>();
Texture* tex = getTexture(Source);
drawTexturedRectangleF(DestRect->Left, DestRect->Top, DestRect->Width, DestRect->Height, tex->U1, tex->V1, tex->U2, tex->V2);
}
}
defOverride(RenderWindow) {
FX::Rectangle dest, source, clipper, clip;
int xs = 0, ys = 0;
int xm[2] = {0,0}, ym[2] = {0,0};
readParam(int, Image, 0);
contextCheck(Image);
lockCheck(Image);
readParamRect(Area, 1, Image);
readParam(WindowSkinParam*, WindowSkin, 2);
readParam(wsSectionFlags, SectionFlags, 3);
selectContext(Image);
GetImageClipRectangle(Image, &clip);
clipper = clip;
clipper.Left = ClipValue(Area.Left - WindowSkin->EdgeOffsets[0], clip.Left, clip.right());
clipper.setRight(ClipValue(Area.right() + WindowSkin->EdgeOffsets[2], clip.Left, clip.right()));
clipper.Top = ClipValue(Area.Top - WindowSkin->EdgeOffsets[1], clip.Top, clip.bottom());
clipper.setBottom(ClipValue(Area.bottom() + WindowSkin->EdgeOffsets[3], clip.Top, clip.bottom()));
xm[0] = _Max(_Max(GetImageWidth(WindowSkin->pImages[wsTopLeft]), GetImageWidth(WindowSkin->pImages[wsLeft])),GetImageWidth(WindowSkin->pImages[wsBottomLeft]));
xm[1] = _Max(_Max(GetImageWidth(WindowSkin->pImages[wsTopRight]), GetImageWidth(WindowSkin->pImages[wsRight])),GetImageWidth(WindowSkin->pImages[wsBottomRight]));
ym[0] = _Max(_Max(GetImageHeight(WindowSkin->pImages[wsTopLeft]), GetImageHeight(WindowSkin->pImages[wsTop])),GetImageHeight(WindowSkin->pImages[wsTopRight]));
ym[1] = _Max(_Max(GetImageHeight(WindowSkin->pImages[wsBottomLeft]), GetImageHeight(WindowSkin->pImages[wsBottom])),GetImageHeight(WindowSkin->pImages[wsBottomRight]));
xs = GetImageWidth(WindowSkin->pImages[wsMiddle]);
ys = GetImageHeight(WindowSkin->pImages[wsMiddle]);
switch(WindowSkin->RenderMode) {
case BlitMode_Additive:
setBlendMode<Additive>();
break;
case BlitMode_Subtractive:
setBlendMode<Subtractive>();
break;
case BlitMode_SourceAlpha:
setBlendMode<SourceAlpha>();
break;
case BlitMode_Font_SourceAlpha:
setBlendMode<Font_SourceAlpha>();
break;
case BlitMode_Normal:
setBlendMode<Normal>();
break;
default:
case BlitMode_Default:
return Failure;
break;
}
SetImageClipRectangle(Image, &clipper);
if (SectionFlags & sfMiddle) {
GetImageRectangle(WindowSkin->pImages[wsMiddle], &source);
dest.setValues(Area.Left - WindowSkin->EdgeOffsets[0], Area.Top - WindowSkin->EdgeOffsets[1],
Area.Width + WindowSkin->EdgeOffsets[0] + WindowSkin->EdgeOffsets[2], Area.Height + WindowSkin->EdgeOffsets[1] + WindowSkin->EdgeOffsets[3]);
setFog(WindowSkin->TintColors[wsMiddle]);
switch (WindowSkin->BackgroundMode) {
default:
case 0:
// tiled blit
setVertexColor(Pixel(255, 255, 255, WindowSkin->Alpha));
BlitTiled(Image, WindowSkin->pImages[wsMiddle], &dest);
break;
case 1:
// scaled blit
setVertexColor(Pixel(255, 255, 255, WindowSkin->Alpha));
BlitScaled(Image, WindowSkin->pImages[wsMiddle], &dest);
break;
case 2:
// gradient
disableTextures();
drawGradientRectangle(&dest, MultiplyAlpha(WindowSkin->CornerColors[0], WindowSkin->Alpha), MultiplyAlpha(WindowSkin->CornerColors[1], WindowSkin->Alpha), MultiplyAlpha(WindowSkin->CornerColors[2], WindowSkin->Alpha), MultiplyAlpha(WindowSkin->CornerColors[3], WindowSkin->Alpha));
break;
case 3:
// tiled blit
setVertexColor(Pixel(255, 255, 255, WindowSkin->Alpha));
BlitTiled(Image, WindowSkin->pImages[wsMiddle], &dest);
disableTextures();
drawGradientRectangle(&dest, MultiplyAlpha(WindowSkin->CornerColors[0], WindowSkin->Alpha), MultiplyAlpha(WindowSkin->CornerColors[1], WindowSkin->Alpha), MultiplyAlpha(WindowSkin->CornerColors[2], WindowSkin->Alpha), MultiplyAlpha(WindowSkin->CornerColors[3], WindowSkin->Alpha));
break;
case 4:
// scaled blit
setVertexColor(Pixel(255, 255, 255, WindowSkin->Alpha));
BlitScaled(Image, WindowSkin->pImages[wsMiddle], &dest);
disableTextures();
drawGradientRectangle(&dest, MultiplyAlpha(WindowSkin->CornerColors[0], WindowSkin->Alpha), MultiplyAlpha(WindowSkin->CornerColors[1], WindowSkin->Alpha), MultiplyAlpha(WindowSkin->CornerColors[2], WindowSkin->Alpha), MultiplyAlpha(WindowSkin->CornerColors[3], WindowSkin->Alpha));
break;
}
}
setVertexColor(Pixel(255, 255, 255, WindowSkin->Alpha));
SetImageClipRectangle(Image, &clip);
if (SectionFlags & sfTop) {
setFog(WindowSkin->TintColors[wsTop]);
dest.setValues(Area.Left, Area.Top - GetImageHeight(WindowSkin->pImages[wsTop]), Area.Width, GetImageHeight(WindowSkin->pImages[wsTop]));
BlitTiled(Image, WindowSkin->pImages[wsTop], &dest);
}
if (SectionFlags & sfBottom) {
setFog(WindowSkin->TintColors[wsBottom]);
dest.setValues(Area.Left, Area.bottom(), Area.Width, GetImageHeight(WindowSkin->pImages[wsBottom]));
BlitTiled(Image, WindowSkin->pImages[wsBottom], &dest);
}
if (SectionFlags & sfLeft) {
setFog(WindowSkin->TintColors[wsLeft]);
dest.setValues(Area.Left - GetImageWidth(WindowSkin->pImages[wsLeft]), Area.Top, GetImageWidth(WindowSkin->pImages[wsLeft]), Area.Height);
BlitTiled(Image, WindowSkin->pImages[wsLeft], &dest);
}
if (SectionFlags & sfRight) {
setFog(WindowSkin->TintColors[wsRight]);
dest.setValues(Area.right(), Area.Top, GetImageWidth(WindowSkin->pImages[wsRight]), Area.Height);
BlitTiled(Image, WindowSkin->pImages[wsRight], &dest);
}
if (SectionFlags & sfBottomRight) {
setFog(WindowSkin->TintColors[wsBottomRight]);
dest.setValues(Area.right(), Area.bottom(), GetImageWidth(WindowSkin->pImages[wsBottomRight]), GetImageHeight(WindowSkin->pImages[wsBottomRight]));
BlitScaled(Image, WindowSkin->pImages[wsBottomRight], &dest);
}
if (SectionFlags & sfBottomLeft) {
setFog(WindowSkin->TintColors[wsBottomLeft]);
dest.setValues(Area.Left - GetImageWidth(WindowSkin->pImages[wsBottomLeft]), Area.bottom(), GetImageWidth(WindowSkin->pImages[wsBottomLeft]), GetImageHeight(WindowSkin->pImages[wsBottomLeft]));
BlitScaled(Image, WindowSkin->pImages[wsBottomLeft], &dest);
}
if (SectionFlags & sfTopRight) {
setFog(WindowSkin->TintColors[wsTopRight]);
dest.setValues(Area.right(), Area.Top - GetImageHeight(WindowSkin->pImages[wsTopRight]), GetImageWidth(WindowSkin->pImages[wsTopRight]), GetImageHeight(WindowSkin->pImages[wsTopRight]));
BlitScaled(Image, WindowSkin->pImages[wsTopRight], &dest);
}
if (SectionFlags & sfTopLeft) {
setFog(WindowSkin->TintColors[wsTopLeft]);
dest.setValues(Area.Left - GetImageWidth(WindowSkin->pImages[wsTopLeft]), Area.Top - GetImageHeight(WindowSkin->pImages[wsTopLeft]), GetImageWidth(WindowSkin->pImages[wsTopLeft]), GetImageHeight(WindowSkin->pImages[wsTopLeft]));
BlitScaled(Image, WindowSkin->pImages[wsTopLeft], &dest);
}
disableFog();
SetImageDirty(Image, 1);
return Success;
}
/*
Export int RenderWindow(Image *Dest, Rectangle *Area, WindowSkinParam * wp, int SectionFlags) {
int xs = 0, ys = 0;
int xm[2] = {0,0}, ym[2] = {0,0};
Rectangle dest, source, clipper, *clip;
Rectangle old_clip;
if (!Dest) return Failure;
if (!wp) return Failure;
if (!wp->pImages) return Failure;
if (!Area) return Failure;
if (SectionFlags <= 0) {
SectionFlags = sfAll;
}
int result;
if (result = Override::EnumOverrides(Override::RenderWindow, 4, Dest, Area, wp, SectionFlags)) {
return result;
}
enableClipping = true;
old_clip = Dest->ClipRectangle;
dest = *Area;
clip = &(Dest->ClipRectangle);
clipper = *clip;
clipper.Left = ClipValue(Area->Left - wp->EdgeOffsets[0], clip->Left, clip->right());
clipper.setRight(ClipValue(Area->right() + wp->EdgeOffsets[2], clip->Left, clip->right()));
clipper.Top = ClipValue(Area->Top - wp->EdgeOffsets[1], clip->Top, clip->bottom());
clipper.setBottom(ClipValue(Area->bottom() + wp->EdgeOffsets[3], clip->Top, clip->bottom()));
Dest->ClipRectangle = clipper;
xm[0] = _Max(_Max(wp->pImages[wsTopLeft]->Width, wp->pImages[wsLeft]->Width),wp->pImages[wsBottomLeft]->Width);
xm[1] = _Max(_Max(wp->pImages[wsTopRight]->Width, wp->pImages[wsRight]->Width),wp->pImages[wsBottomRight]->Width);
ym[0] = _Max(_Max(wp->pImages[wsTopLeft]->Height, wp->pImages[wsTop]->Height),wp->pImages[wsTopRight]->Height);
ym[1] = _Max(_Max(wp->pImages[wsBottomLeft]->Height, wp->pImages[wsBottom]->Height),wp->pImages[wsBottomRight]->Height);
xs = wp->pImages[wsMiddle]->Width;
ys = wp->pImages[wsMiddle]->Height;
if (SectionFlags & sfMiddle) {
source = wp->pImages[wsMiddle]->getRectangle();
dest.setValues(Area->Left - wp->EdgeOffsets[0], Area->Top - wp->EdgeOffsets[1],
Area->Width + wp->EdgeOffsets[0] + wp->EdgeOffsets[2], Area->Height + wp->EdgeOffsets[1] + wp->EdgeOffsets[3]);
switch (wp->BackgroundMode) {
default:
case 0:
if ((xs <= 1) && (ys <= 1)) {
// alpha fill
FilterSimple_Fill_SourceAlpha_Opacity(Dest, &dest, wp->pImages[wsMiddle]->getPixel(0,0), wp->Alpha);
} else {
// tiled blit
ModedTiledBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsMiddle], &dest, wp->TintColors[wsMiddle], wp->Alpha);
}
break;
case 1:
if ((xs <= 1) && (ys <= 1)) {
// alpha fill
FilterSimple_Fill_SourceAlpha_Opacity(Dest, &dest, wp->pImages[wsMiddle]->getPixel(0,0), wp->Alpha);
} else {
// scaled blit
ModedResampleBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsMiddle], &dest, &source, wp->TintColors[wsMiddle], wp->Alpha);
}
break;
case 2:
// gradient
FilterSimple_Gradient_4Point_SourceAlpha(Dest, &dest, MultiplyAlpha(wp->CornerColors[0], wp->Alpha), MultiplyAlpha(wp->CornerColors[1], wp->Alpha), MultiplyAlpha(wp->CornerColors[2], wp->Alpha), MultiplyAlpha(wp->CornerColors[3], wp->Alpha));
break;
case 3:
if ((xs <= 1) && (ys <= 1)) {
// alpha fill
FilterSimple_Fill_SourceAlpha_Opacity(Dest, &dest, wp->pImages[wsMiddle]->getPixel(0,0), wp->Alpha);
} else {
// tiled blit
ModedTiledBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsMiddle], &dest, wp->TintColors[wsMiddle], wp->Alpha);
}
FilterSimple_Gradient_4Point_SourceAlpha(Dest, &dest, MultiplyAlpha(wp->CornerColors[0], wp->Alpha), MultiplyAlpha(wp->CornerColors[1], wp->Alpha), MultiplyAlpha(wp->CornerColors[2], wp->Alpha), MultiplyAlpha(wp->CornerColors[3], wp->Alpha));
break;
case 4:
if ((xs <= 1) && (ys <= 1)) {
// alpha fill
FilterSimple_Fill_SourceAlpha_Opacity(Dest, &dest, wp->pImages[wsMiddle]->getPixel(0,0), wp->Alpha);
} else {
// scaled blit
ModedResampleBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsMiddle], &dest, &source, wp->TintColors[wsMiddle], wp->Alpha);
}
FilterSimple_Gradient_4Point(Dest, &dest, MultiplyAlpha(wp->CornerColors[0], wp->Alpha), MultiplyAlpha(wp->CornerColors[1], wp->Alpha), MultiplyAlpha(wp->CornerColors[2], wp->Alpha), MultiplyAlpha(wp->CornerColors[3], wp->Alpha));
break;
}
}
Dest->ClipRectangle = old_clip;
if (SectionFlags & sfTop) {
dest.setValues(Area->Left, Area->Top - wp->pImages[wsTop]->Height, Area->Width, wp->pImages[wsTop]->Height);
ModedTiledBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsTop], &dest, wp->TintColors[wsTop], wp->Alpha);
}
if (SectionFlags & sfBottom) {
dest.setValues(Area->Left, Area->bottom(), Area->Width, wp->pImages[wsBottom]->Height);
ModedTiledBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsBottom], &dest, wp->TintColors[wsBottom], wp->Alpha);
}
if (SectionFlags & sfLeft) {
dest.setValues(Area->Left - wp->pImages[wsLeft]->Width, Area->Top, wp->pImages[wsLeft]->Width, Area->Height);
ModedTiledBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsLeft], &dest, wp->TintColors[wsLeft], wp->Alpha);
}
if (SectionFlags & sfRight) {
dest.setValues(Area->right(), Area->Top, wp->pImages[wsRight]->Width, Area->Height);
ModedTiledBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsRight], &dest, wp->TintColors[wsRight], wp->Alpha);
}
Dest->ClipRectangle = old_clip;
if (SectionFlags & sfBottomRight) {
dest.setValues(Area->right(), Area->bottom(), wp->pImages[wsBottomRight]->Width, wp->pImages[wsBottomRight]->Height);
ModedBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsBottomRight], &dest, 0, 0, wp->TintColors[wsBottomRight], wp->Alpha);
}
if (SectionFlags & sfBottomLeft) {
dest.setValues(Area->Left - wp->pImages[wsBottomLeft]->Width, Area->bottom(), wp->pImages[wsBottomLeft]->Width, wp->pImages[wsBottomLeft]->Height);
ModedBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsBottomLeft], &dest, 0, 0, wp->TintColors[wsBottomLeft], wp->Alpha);
}
if (SectionFlags & sfTopRight) {
dest.setValues(Area->right(), Area->Top - wp->pImages[wsTopRight]->Height, wp->pImages[wsTopRight]->Width, wp->pImages[wsTopRight]->Height);
ModedBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsTopRight], &dest, 0, 0, wp->TintColors[wsTopRight], wp->Alpha);
}
if (SectionFlags & sfTopLeft) {
dest.setValues(Area->Left - wp->pImages[wsTopLeft]->Width, Area->Top - wp->pImages[wsTopLeft]->Height, wp->pImages[wsTopLeft]->Width, wp->pImages[wsTopLeft]->Height);
ModedBlit((SFX_BlitModes)wp->RenderMode, Dest, wp->pImages[wsTopLeft], &dest, 0, 0, wp->TintColors[wsTopLeft], wp->Alpha);
}
Dest->ClipRectangle = old_clip;
return true;
}
*/
defOverride(RenderTilemapLayer) {
int tile = 0, lasttile = -1;
int cx = 0, cy = 0;
short *pRow, *pTile;
FX::Rectangle rctDest;
FX::Rectangle oldRect;
int pTarget = 0;
int maxX = 0, maxY = 0;
int cv = 0;
Texture* tex;
readParam(TilemapLayerParam*, Layer, 0);
readParam(CameraParam*, Camera, 1);
readParam(int, sx, 2);
readParam(int, sy, 3);
readParam(int, ex, 4);
readParam(int, ey, 5);
readParam(int, camerax, 6);
readParam(int, cameray, 7);
readParam(int, alpha, 8);
pTarget = Camera->pImage();
if (Layer->RenderTarget < Camera->RenderTargetCount) {
pTarget = Camera->pRenderTargets[Layer->RenderTarget];
}
contextCheck(pTarget);
lockCheck(pTarget);
selectContext(pTarget);
maxX = Layer->Width - 1;
maxY = Layer->Height - 1;
int tileCount = GetTileCount(Layer->pTileset);
int tileWidth = GetTileWidth(Layer->pTileset);
int tileHeight = GetTileHeight(Layer->pTileset);
switch(Layer->Effect) {
default:
case 0:
setBlendMode<Normal>();
setVertexColor(White);
setBlendColor(Pixel(255, 255, 255, alpha));
if (Layer->TintColor[::Alpha] > 0) {
enableFog();
setFogColor(Layer->TintColor);
setFogOpacity(Global->FloatLookup[Layer->TintColor[::Alpha]]);
}
break;
case 1:
case 2:
setBlendMode<SourceAlpha>();
setVertexColor(Pixel(255, 255, 255, alpha));
if (Layer->TintColor[::Alpha] > 0) {
enableFog();
setFogColor(Layer->TintColor);
setFogOpacity(Global->FloatLookup[Layer->TintColor[::Alpha]]);
}
break;
case 3:
setBlendMode<Additive>();
setVertexColor(White);
setBlendColor(Pixel(255, 255, 255, alpha));
break;
case 4:
setBlendMode<Subtractive>();
setVertexColor(White);
setBlendColor(Pixel(255, 255, 255, alpha));
break;
case 7:
setBlendMode<Multiply>();
setVertexColor(White);
setTextureColor(Pixel(alpha, alpha, alpha, alpha));
break;
case 8:
setBlendMode<Lightmap>();
setVertexColor(White);
setTextureColor(Pixel(alpha, alpha, alpha, alpha));
break;
}
enableTextures();
// initialize the y coordinate
float tx, ty, tw = tileWidth, th = tileHeight;
ty = -cameray;
for (cy = sy; cy < ey; ++cy) {
tx = -camerax;
if (Layer->WrapY) {
pRow = Layer->pData + (Layer->Width * (cy % maxY));
} else {
pRow = Layer->pData + (Layer->Width * cy);
}
pTile = pRow + sx;
for (cx = sx; cx < ex; ++cx) {
if (Layer->WrapX) {
pTile = pRow + (cx % maxX);
}
cv = *pTile;
if ((cv == Layer->MaskedTile) || (cv >= tileCount) || (cv < 0)) {
} else {
tile = GetTileFast(Layer->pTileset, cv, Layer->pAnimationMap);
if (tile != lasttile) {
selectImageAsTexture(tile);
if (Layer->Effect == 1) prepMatte(tile);
tex = getTexture(tile);
lasttile = tile;
}
drawTexturedRectangleF(tx, ty, tw, th, tex->U1, tex->V1, tex->U2, tex->V2);
}
tx += tw;
pTile++;
}
ty += th;
}
SetImageDirty(pTarget, 1);
disableFog();
return Success;
}
defOverride(Deallocate) {
readParam(int, Image, 0);
void* ptr = (void*)getNamedTag(Image, Pointer);
if (ptr) {
free(ptr);
setNamedTag(Image, Pointer, 0);
}
if (GetImagePointer(Image, 0, 0) != 0) {
Texture* tex = getTexture(Image);
if (tex) {
for (unsigned int i = 0; i < Global->SmallImageCache.size(); ++i) {
Global->SmallImageCache[i]->freeSpot(tex);
}
delete getTexture(Image);
setNamedTag(Image, Texture, 0);
}
for (unsigned int i = 0; i < Global->ImageHeap.size(); ++i) {
if (Global->ImageHeap[i] == Image) {
Global->ImageHeap[i] = 0;
}
}
}
if (checkNamedTag(Image, Context)) {
HGLRC context = (HGLRC)getNamedTag(Image, Context);
if (context != 0) {
flushImageHeap();
wglMakeCurrent(Global->DC, 0);
wglDeleteContext(context);
if (Global->Framebuffer == Image) {
Global->Framebuffer = 0;
}
SetImageLocked(Image, 0);
}
Global->Context = 0;
setNamedTag(Image, Context, 0);
}
if (checkNamedTag(Image, Framebuffer)) {
Framebuffer* fb = (Framebuffer*)getNamedTag(Image, Framebuffer);
if (fb != 0) {
// Texture* attachedTex = fb->AttachedTexture;
fb->detachTexture();
fb->unbind();
delete fb;
// delete attachedTex;
fb = 0;
}
setNamedTag(Image, Framebuffer, 0);
}
return Failure;
}
defOverride(BlitConvolve) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(Filter*, TheFilter, 2);
readParamRect(Area, 3, Null);
readParam(int, SourceX, 4);
readParam(int, SourceY, 5);
readParam(Pixel, RenderArgument, 6);
readParam(int, Renderer, 7);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
FX::Rectangle AreaCopy = Area;
if (!GLSL::isSupported()) return Failure;
GLSL::Program* program = 0;
if ((TheFilter->Width == 3) && (TheFilter->Height == 3)) {
program = Global->GetShader(std::string("convolve_3x3"));
} else if ((TheFilter->Width == 5) && (TheFilter->Height == 5)) {
program = Global->GetShader(std::string("convolve_5x5"));
}
if (program == 0) return Failure;
if (Clip2D_SimpleRect(&Area, Dest, Source, &AreaCopy, SourceX, SourceY)) {
enableTextures();
selectImageAsTexture(Source);
setRenderer(Renderer, RenderArgument);
setScaleMode<Linear>();
Texture* tex = getTexture(Source);
float U1 = tex->U(SourceX), V1 = tex->V(SourceY);
float U2 = tex->U(SourceX + Area.Width), V2 = tex->V(SourceY + Area.Height);
GLSL::useProgram(*program);
initShaderVariables(program);
program->getVariable("divisor").set(TheFilter->Divisor);
program->getVariable("offset").set(TheFilter->Offset);
program->getVariable("xOffset").set(TheFilter->XOffset);
program->getVariable("yOffset").set(TheFilter->YOffset);
if ((TheFilter->Width == 3) && (TheFilter->Height == 3)) {
program->getVariable("weights").set(reinterpret_cast<Mat3*>(TheFilter->Weights), 1);
} else if ((TheFilter->Width == 5) && (TheFilter->Height == 5)) {
program->getVariable("weights").set(reinterpret_cast<float*>(TheFilter->Weights), 25);
}
drawTexturedRectangle(Area, U1, V1, U2, V2);
GLSL::disableProgram();
SetImageDirty(Dest, 1);
}
setTextureColorN<0>(White);
setTextureColorN<1>(White);
disableTextures();
return Success;
}
defOverride(BlitConvolveMask) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(int, Mask, 2);
readParam(Filter*, TheFilter, 3);
readParamRect(Area, 4, Null);
readParam(int, SourceX, 5);
readParam(int, SourceY, 6);
readParam(int, MaskX, 7);
readParam(int, MaskY, 8);
readParam(Pixel, RenderArgument, 9);
readParam(int, Renderer, 10);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
FX::Rectangle AreaCopy = Area;
if (!GLSL::isSupported()) return Failure;
GLSL::Program* program = 0;
if ((TheFilter->Width == 3) && (TheFilter->Height == 3)) {
program = Global->GetShader(std::string("convolve_3x3_mask"));
} else if ((TheFilter->Width == 5) && (TheFilter->Height == 5)) {
program = Global->GetShader(std::string("convolve_5x5_mask"));
}
if (program == 0) return Failure;
if (Clip2D_SimpleRect(&Area, Dest, Source, &AreaCopy, SourceX, SourceY)) {
selectImageAsTextureN<1>(Mask);
selectImageAsTextureN<1>(Mask);
setScaleMode<Linear>();
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<0>(Source);
setScaleMode<Linear>();
enableTexture<0>();
enableTexture<1>();
setRenderer(Renderer, RenderArgument);
Texture* tex = getTexture(Source);
Texture* mtex = getTexture(Mask);
float U1 = tex->U(SourceX), V1 = tex->V(SourceY);
float U2 = tex->U(SourceX + Area.Width), V2 = tex->V(SourceY + Area.Height);
float U3 = mtex->U(MaskX), V3 = mtex->V(MaskY);
float U4 = mtex->U(MaskX + Area.Width), V4 = mtex->V(MaskY + Area.Height);
switchTextureStage<0>();
GLSL::useProgram(*program);
initShaderVariables(program);
program->getVariable("tex").set(0);
program->getVariable("mask").set(1);
program->getVariable("divisor").set(TheFilter->Divisor);
program->getVariable("offset").set(TheFilter->Offset);
program->getVariable("xOffset").set(TheFilter->XOffset);
program->getVariable("yOffset").set(TheFilter->YOffset);
if ((TheFilter->Width == 3) && (TheFilter->Height == 3)) {
program->getVariable("weights").set(reinterpret_cast<Mat3*>(TheFilter->Weights), 1);
} else if ((TheFilter->Width == 5) && (TheFilter->Height == 5)) {
program->getVariable("weights").set(reinterpret_cast<float*>(TheFilter->Weights), 25);
}
draw2TexturedRectangle(Area, U1, V1, U2, V2, U3, V3, U4, V4);
GLSL::disableProgram();
SetImageDirty(Dest, 1);
}
setTextureColorN<0>(White);
setTextureColorN<1>(White);
disableTextures();
return Success;
}
int BlitDeform_GLSL(Override::OverrideParameters *Parameters) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(MeshParam*, Mesh, 2);
readParamRect(DestRect, 3, Null);
readParamRect(SourceRect, 4, Null);
readParam(Pixel, RenderArgument, 5);
readParam(int, Renderer, 6);
readParam(int, Scaler, 7);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
//clipCheck(Dest, DestRect);
if (Global->MeshTexture) {
if ((Global->MeshTexture->Width != Mesh->Width) || (Global->MeshTexture->Height != Mesh->Height) || (Global->MeshTexture->isInvalid())) {
delete Global->MeshTexture;
Global->MeshTexture = 0;
}
}
if (Global->MeshTexture) {
} else {
Global->MeshTexture = GL::createTextureEx(Mesh->Width, Mesh->Height, GL_LUMINANCE_ALPHA_FLOAT16_ATI, GL_LUMINANCE_ALPHA, GL_FLOAT);
}
enableTextures();
selectImageAsTextureN<0>(Source);
GL::switchTextureStage<0>();
setRenderer(Renderer, RenderArgument);
setScaler(Scaler);
GL::switchTextureStage<1>();
selectTextureN<1>(Global->MeshTexture->Handle);
glTexSubImage2D(GL_TEXTURE_2D, 0, Global->MeshTexture->Left, Global->MeshTexture->Top, Mesh->Width, Mesh->Height, GL_LUMINANCE_ALPHA, GL_FLOAT, Mesh->pData);
ScaleModes::Linear_Clamp::Set();
GL::switchTextureStage<0>();
GLSL::Program* program = 0;
if ((Scaler == SoftFX::GetLinearWrapScaler()) || (Scaler == SoftFX::GetBilinearWrapScaler())) {
program = Global->GetShader(std::string("deform_wrap"));
} else {
program = Global->GetShader(std::string("deform"));
}
if (program == 0) return Failure;
Texture* tex = getTexture(Source);
float U1 = tex->U(SourceRect.Left), V1 = tex->V(SourceRect.Top);
float U2 = tex->U(SourceRect.Left + SourceRect.Width), V2 = tex->V(SourceRect.Top + SourceRect.Height);
GLSL::useProgram(*program);
initShaderVariables(program);
program->getVariable("tex").set(0);
program->getVariable("mesh").set(1);
float u1, v1, u2, v2;
u1 = Global->MeshTexture->U(0.5);
v1 = Global->MeshTexture->V(0.5);
u2 = Global->MeshTexture->U(Global->MeshTexture->Width - 0.5);
v2 = Global->MeshTexture->V(Global->MeshTexture->Height - 0.5);
Vec2 size;
size.V[0] = Global->MeshTexture->U(1) - Global->MeshTexture->U(0);
size.V[1] = Global->MeshTexture->V(1) - Global->MeshTexture->V(0);
program->getVariable("meshPointSize").set(size);
size.V[0] = _Min(u1, u2);
size.V[1] = _Min(v1, v2);
program->getVariable("meshTopLeft").set(size);
size.V[0] = _Max(u1, u2);
size.V[1] = _Max(v1, v2);
program->getVariable("meshBottomRight").set(size);
draw2TexturedRectangle(DestRect, U1, V1, U2, V2, Global->MeshTexture->U(0), Global->MeshTexture->V(0), Global->MeshTexture->U(Mesh->Width), Global->MeshTexture->V(Mesh->Height));
GLSL::disableProgram();
SetImageDirty(Dest, 1);
endDraw();
setTextureColorN<0>(White);
setTextureColorN<1>(White);
disableTextures();
return Success;
}
int BlitDeformMask_GLSL(Override::OverrideParameters *Parameters) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(int, Mask, 2);
readParam(MeshParam*, Mesh, 3);
readParamRect(DestRect, 4, Null);
readParamRect(SourceRect, 5, Null);
readParamRect(MaskRect, 6, Null);
readParam(Pixel, RenderArgument, 7);
readParam(int, Opacity, 8);
readParam(int, Renderer, 9);
readParam(int, Scaler, 10);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
//clipCheck(Dest, DestRect);
if (Global->MeshTexture) {
if ((Global->MeshTexture->Width != Mesh->Width) || (Global->MeshTexture->Height != Mesh->Height) || (Global->MeshTexture->isInvalid())) {
delete Global->MeshTexture;
Global->MeshTexture = 0;
}
}
if (Global->MeshTexture) {
} else {
Global->MeshTexture = GL::createTextureEx(Mesh->Width, Mesh->Height, GL_LUMINANCE_ALPHA_FLOAT16_ATI, GL_LUMINANCE_ALPHA, GL_FLOAT);
}
enableTexture<0>();
enableTexture<1>();
enableTexture<2>();
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<2>(Mask);
GL::switchTextureStage<0>();
setRenderer(Renderer, RenderArgument);
setScaler(Scaler);
GL::switchTextureStage<1>();
selectTextureN<1>(Global->MeshTexture->Handle);
glTexSubImage2D(GL_TEXTURE_2D, 0, Global->MeshTexture->Left, Global->MeshTexture->Top, Mesh->Width, Mesh->Height, GL_LUMINANCE_ALPHA, GL_FLOAT, Mesh->pData);
ScaleModes::Linear_Clamp::Set();
GL::switchTextureStage<2>();
ScaleModes::Linear_Clamp::Set();
selectImageAsTextureN<0>(Source);
selectImageAsTextureN<2>(Mask);
GL::switchTextureStage<0>();
GLSL::Program* program = 0;
if ((Scaler == SoftFX::GetLinearWrapScaler()) || (Scaler == SoftFX::GetBilinearWrapScaler())) {
program = Global->GetShader(std::string("deform_mask_wrap"));
} else {
program = Global->GetShader(std::string("deform_mask"));
}
if (program == 0) return Failure;
Texture* tex = getTexture(Source);
Texture* mtex = getTexture(Mask);
float U1 = tex->U(SourceRect.Left), V1 = tex->V(SourceRect.Top);
float U2 = tex->U(SourceRect.Left + SourceRect.Width), V2 = tex->V(SourceRect.Top + SourceRect.Height);
float MU1 = mtex->U(MaskRect.Left), MV1 = mtex->V(MaskRect.Top);
float MU2 = mtex->U(MaskRect.Left + MaskRect.Width), MV2 = mtex->V(MaskRect.Top + MaskRect.Height);
GLSL::useProgram(*program);
initShaderVariables(program);
program->getVariable("tex").set(0);
program->getVariable("mesh").set(1);
program->getVariable("mask").set(2);
program->getVariable("opacity").set(Global->FloatLookup[ClipByte(Opacity)]);
float u1, v1, u2, v2;
u1 = Global->MeshTexture->U(0.5);
v1 = Global->MeshTexture->V(0.5);
u2 = Global->MeshTexture->U(Global->MeshTexture->Width - 0.5);
v2 = Global->MeshTexture->V(Global->MeshTexture->Height - 0.5);
Vec2 size;
size.V[0] = Global->MeshTexture->U(1) - Global->MeshTexture->U(0);
size.V[1] = Global->MeshTexture->V(1) - Global->MeshTexture->V(0);
program->getVariable("meshPointSize").set(size);
size.V[0] = _Min(u1, u2);
size.V[1] = _Min(v1, v2);
program->getVariable("meshTopLeft").set(size);
size.V[0] = _Max(u1, u2);
size.V[1] = _Max(v1, v2);
program->getVariable("meshBottomRight").set(size);
draw3TexturedRectangle(DestRect, U1, V1, U2, V2, Global->MeshTexture->U(0), Global->MeshTexture->V(0), Global->MeshTexture->U(Mesh->Width), Global->MeshTexture->V(Mesh->Height), MU1, MV1, MU2, MV2);
GLSL::disableProgram();
SetImageDirty(Dest, 1);
endDraw();
setTextureColorN<0>(White);
setTextureColorN<1>(White);
disableTextures();
return Success;
}
defOverride(BlitDeform) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(MeshParam*, Mesh, 2);
readParamRect(DestRect, 3, Null);
readParamRect(SourceRect, 4, Null);
readParam(Pixel, RenderArgument, 5);
readParam(int, Renderer, 6);
readParam(int, Scaler, 7);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
contextSwitch(Dest);
if (GLSL::isSupported() && GLEW_ATI_texture_float) {
return BlitDeform_GLSL(Parameters);
}
//clipCheck(Dest, DestRect);
enableTextures();
selectImageAsIsolatedTexture(Source);
selectImageAsIsolatedTexture(Source);
setRenderer(Renderer, RenderArgument);
setScaler(Scaler);
DoubleWord iCX = 0, iCY = DestRect.Height + 1;
int pixelsToDraw = 0;
int mw = Mesh->Width - 1, mh = Mesh->Height - 1;
if ((mw < 1) || (mh < 1)) return Failure;
int cx = 0, cy = 0;
float cxw = 0, cyw = 0, sx = 0, sy = 0, lsx = 0, lsy = 0;
float cxi = (mw / (float)DestRect.Width), cyi = (mh / (float)DestRect.Height);
float dx = DestRect.Left, dy = DestRect.Top;
bool update_points = true, first_update = true, perform_draw = false;
Texture* tex = getTexture(Source);
if (tex->IsolatedTexture != 0) tex = tex->IsolatedTexture;
float bx = SourceRect.Left, by = SourceRect.Top;
float bxi = (1 / (DestRect.Width / (float)(SourceRect.Width))), byi = (1 / (DestRect.Height / (float)(SourceRect.Height)));
MeshPoint p[4];
disableAA();
beginDraw(GL_LINES);
while (iCY--) {
iCX = (DoubleWord)DestRect.Width + 1;
cxw = 0;
cx = 0;
bx = SourceRect.Left;
dx = DestRect.Left;
update_points = true;
first_update = true;
pixelsToDraw = 0;
while (iCX--) {
cxw += cxi;
pixelsToDraw++;
while (cxw >= 1.0f) {
cxw -= 1.0f;
cx++;
update_points = true;
}
if ((update_points) || (iCX == 0)) {
update_points = false;
lsx = sx;
lsy = sy;
/* sometimes i hate that inline is just a hint
Mesh->get4Points(cx, cy, p);
this is one of those times */
int iy = ClipValue(cy, mh) * Mesh->Width;
int ix1 = ClipValue(cx, mw);
int ix2 = ClipValue(cx+1, mw);
p[0] = (Mesh->pData[ix1 + (iy)]);
p[1] = (Mesh->pData[ix2 + (iy)]);
iy = ClipValue(cy+1, mh) * Mesh->Width;
p[2] = (Mesh->pData[ix1 + (iy)]);
p[3] = (Mesh->pData[ix2 + (iy)]);
float xr1 = (p[0].X) + ((p[1].X - p[0].X) * cxw);
float xr2 = (p[2].X) + ((p[3].X - p[2].X) * cxw);
sx = bx + (xr1 + ((xr2 - xr1) * cyw));
xr1 = (p[0].Y) + ((p[1].Y - p[0].Y) * cxw);
xr2 = (p[2].Y) + ((p[3].Y - p[2].Y) * cxw);
sy = by + (xr1 + ((xr2 - xr1) * cyw)) - 0.5f;
if (first_update) {
first_update = false;
bx += bxi;
}
else
perform_draw = true;
}
if (perform_draw) {
if (iCX == 0) pixelsToDraw--;
perform_draw = false;
glTexCoord2f(tex->U(lsx), tex->V(lsy));
glVertex2f(dx, dy);
glTexCoord2f(tex->U(sx), tex->V(sy));
glVertex2f(dx + pixelsToDraw, dy);
dx += pixelsToDraw;
pixelsToDraw = 0;
}
bx += bxi;
}
by += byi;
cyw += cyi;
dy += 1.0f;
while (cyw >= 1.0f) {
cyw -= 1.0f;
cy++;
update_points = true;
}
}
endDraw();
setTextureColorN<0>(White);
setTextureColorN<1>(White);
disableTextures();
return Success;
}
defOverride(BlitDeformMask) {
readParam(int, Dest, 0);
readParam(int, Source, 1);
readParam(int, Mask, 2);
readParam(MeshParam*, Mesh, 3);
readParamRect(DestRect, 4, Null);
readParamRect(SourceRect, 5, Null);
readParamRect(MaskRect, 6, Null);
readParam(Pixel, RenderArgument, 7);
readParam(int, Opacity, 8);
readParam(int, Renderer, 9);
readParam(int, Scaler, 10);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
contextSwitch(Dest);
if (GLSL::isSupported() && GLEW_ATI_texture_float) {
return BlitDeformMask_GLSL(Parameters);
}
//clipCheck(Dest, DestRect);
enableTextures();
disableTexture<2>();
enableTexture<1>();
enableTexture<0>();
selectImageAsIsolatedTextureN<0>(Source);
selectImageAsIsolatedTextureN<1>(Mask);
selectImageAsIsolatedTextureN<0>(Source);
setTextureColor(Pixel(255, 255, 255, Opacity));
selectImageAsIsolatedTextureN<1>(Mask);
setBlendColor(White);
setVertexColor(White);
disableFog();
setMaskRenderer(Renderer, RenderArgument);
setScaler(Scaler);
DoubleWord iCX = 0, iCY = DestRect.Height + 1;
int pixelsToDraw = 0;
int mw = Mesh->Width - 1, mh = Mesh->Height - 1;
if ((mw < 1) || (mh < 1)) return Failure;
int cx = 0, cy = 0;
float cxw = 0, cyw = 0, sx = 0, sy = 0, lsx = 0, lsy = 0;
float cxi = (mw / (float)DestRect.Width), cyi = (mh / (float)DestRect.Height);
float dx = DestRect.Left, dy = DestRect.Top;
bool update_points = true, first_update = true, perform_draw = false;
Texture* tex = getTexture(Source);
Texture* mtex = getTexture(Mask);
if (tex->IsolatedTexture != 0) tex = tex->IsolatedTexture;
if (mtex->IsolatedTexture != 0) mtex = mtex->IsolatedTexture;
float bx = SourceRect.Left, by = SourceRect.Top;
float bxi = (1 / (DestRect.Width / (float)(SourceRect.Width))), byi = (1 / (DestRect.Height / (float)(SourceRect.Height)));
MeshPoint p[4];
disableAA();
beginDraw(GL_LINES);
while (iCY--) {
iCX = (DoubleWord)DestRect.Width + 1;
cxw = 0;
cx = 0;
bx = SourceRect.Left;
dx = DestRect.Left;
update_points = true;
first_update = true;
pixelsToDraw = 0;
while (iCX--) {
cxw += cxi;
pixelsToDraw++;
while (cxw >= 1.0f) {
cxw -= 1.0f;
cx++;
update_points = true;
}
if ((update_points) || (iCX == 0)) {
update_points = false;
lsx = sx;
lsy = sy;
/* sometimes i hate that inline is just a hint
Mesh->get4Points(cx, cy, p);
this is one of those times */
int iy = ClipValue(cy, mh) * Mesh->Width;
int ix1 = ClipValue(cx, mw);
int ix2 = ClipValue(cx+1, mw);
p[0] = (Mesh->pData[ix1 + (iy)]);
p[1] = (Mesh->pData[ix2 + (iy)]);
iy = ClipValue(cy+1, mh) * Mesh->Width;
p[2] = (Mesh->pData[ix1 + (iy)]);
p[3] = (Mesh->pData[ix2 + (iy)]);
float xr1 = (p[0].X) + ((p[1].X - p[0].X) * cxw);
float xr2 = (p[2].X) + ((p[3].X - p[2].X) * cxw);
sx = bx + (xr1 + ((xr2 - xr1) * cyw));
xr1 = (p[0].Y) + ((p[1].Y - p[0].Y) * cxw);
xr2 = (p[2].Y) + ((p[3].Y - p[2].Y) * cxw);
sy = by + (xr1 + ((xr2 - xr1) * cyw)) - 0.5f;
if (first_update) {
first_update = false;
bx += bxi;
}
else
perform_draw = true;
}
if (perform_draw) {
if (iCX == 0) pixelsToDraw--;
if (pixelsToDraw) {
perform_draw = false;
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, tex->U(lsx), tex->V(lsy));
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, mtex->U(dx + MaskRect.Left), mtex->V(dy + MaskRect.Top));
glVertex2f(dx, dy);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, tex->U(sx), tex->V(sy));
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, mtex->U(dx + pixelsToDraw + MaskRect.Left), mtex->V(dy + MaskRect.Top));
glVertex2f(dx + pixelsToDraw, dy);
dx += pixelsToDraw;
pixelsToDraw = 0;
}
}
bx += bxi;
}
by += byi;
cyw += cyi;
dy += 1.0f;
while (cyw >= 1.0f) {
cyw -= 1.0f;
cy++;
update_points = true;
}
}
endDraw();
setTextureColorN<0>(White);
setTextureColorN<1>(White);
disableTextures();
return Success;
}
Export void GLRenderFunction(int Dest, int X, int Y, void *Source, int Count) {
if (Global->RenderTexture) {
disableAA();
endDraw();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Count, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, Source);
GL::drawTexturedLine(X, Y + 1, X + Count, Y + 1, Global->RenderTexture->U(0), Global->RenderTexture->V(0), Global->RenderTexture->U(Count), Global->RenderTexture->V(0));
}
}
defOverride(GetScanlineRenderer) {
readParam(int, Dest, 0);
readParam(int, Renderer, 1);
readParam(int, Count, 2);
readParam(Pixel, Argument, 3);
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
disableTextures();
if (Global->RenderTexture) {
if ((Global->RenderTexture->Width < Count) || (Global->RenderTexture->isInvalid())) {
delete Global->RenderTexture;
Global->RenderTexture = 0;
}
}
if (Global->RenderTexture) {
} else {
Global->RenderTexture = GL::createTexture(Count + 1, 2, false);
}
Global->RenderFunction = Renderer;
setVertexColor(White);
setRenderer(Renderer, Argument);
disableFog();
enableTextures();
selectTexture(Global->RenderTexture->Handle);
return reinterpret_cast<int>(GLRenderFunction);
}
void InstallOverrides() {
addOverride(Allocate);
addOverride(Deallocate);
addOverride(Clear);
addOverride(Copy);
addOverride(Lock);
addOverride(Unlock);
addOverride(SetPixel);
addOverride(SetPixelAA);
addOverride(FilterSimple_Fill_Channel);
addOverride(FilterSimple_Fill);
addOverride(FilterSimple_Fill_Opacity);
addOverride(FilterSimple_Fill_SourceAlpha);
addOverride(FilterSimple_Fill_SourceAlpha_Opacity);
addOverride(FilterSimple_Fill_Additive);
addOverride(FilterSimple_Fill_Additive_Opacity);
addOverride(FilterSimple_Fill_Subtractive);
addOverride(FilterSimple_Fill_Subtractive_Opacity);
addOverride(BlitSimple_Normal);
addOverride(BlitSimple_Normal_Opacity);
addOverride(BlitSimple_Normal_Tint);
addOverride(BlitSimple_Normal_Tint_Opacity);
addOverride(BlitSimple_Matte);
addOverride(BlitSimple_Matte_Opacity);
addOverride(BlitSimple_Matte_Tint);
addOverride(BlitSimple_Matte_Tint_Opacity);
addOverride(BlitSimple_SourceAlpha);
addOverride(BlitSimple_SourceAlpha_Opacity);
addOverride(BlitSimple_SourceAlpha_Premultiplied);
addOverride(BlitSimple_SourceAlpha_Premultiplied_Opacity);
addOverride(BlitSimple_SourceAlphaMatte);
addOverride(BlitSimple_SourceAlphaMatte_Opacity);
addOverride(BlitSimple_SourceAlpha_Tint);
addOverride(BlitSimple_SourceAlpha_Solid_Tint);
addOverride(BlitSimple_SourceAlpha_Tint_Opacity);
addOverride(BlitSimple_Font_SourceAlpha);
addOverride(BlitSimple_Font_SourceAlpha_Opacity);
addOverride(BlitSimple_Font_SourceAlpha_RGB);
addOverride(BlitSimple_Font_SourceAlpha_RGB_Opacity);
addOverride(BlitSimple_Additive);
addOverride(BlitSimple_Additive_Opacity);
addOverride(BlitSimple_Multiply);
addOverride(BlitSimple_Multiply_Opacity);
addOverride(BlitSimple_Lightmap);
addOverride(BlitSimple_Lightmap_Opacity);
addOverride(BlitSimple_Lightmap_RGB);
addOverride(BlitSimple_Lightmap_RGB_Opacity);
addOverride(BlitSimple_Subtractive);
addOverride(BlitSimple_Subtractive_Opacity);
addOverride(BlitSimple_Additive_SourceAlpha);
addOverride(BlitSimple_Additive_SourceAlpha_Opacity);
addOverride(BlitSimple_Subtractive_SourceAlpha);
addOverride(BlitSimple_Subtractive_SourceAlpha_Opacity);
addOverride(BlitSimple_Merge);
addOverride(BlitSimple_Merge_Opacity);
addOverride(BlitSimple_Font_Merge_RGB);
addOverride(BlitSimple_Font_Merge_RGB_Opacity);
addOverride(BlitSimple_NormalMap);
addOverride(BlitSimple_NormalMap_Additive);
addOverride(BlitSimple_NormalMap_SourceAlpha);
addOverride(BlitSimple_NormalMap_Additive_SourceAlpha);
addOverride(BlitResample_Normal);
addOverride(BlitResample_Normal_Opacity);
addOverride(BlitResample_SourceAlpha);
addOverride(BlitResample_SourceAlpha_Opacity);
addOverride(BlitResample_SourceAlpha_Tint);
addOverride(BlitResample_SourceAlpha_Tint_Opacity);
addOverride(BlitResample_Additive);
addOverride(BlitResample_Additive_Opacity);
addOverride(BlitResample_Subtractive);
addOverride(BlitResample_Subtractive_Opacity);
addOverride(BlitMask_Normal_Opacity);
addOverride(BlitMask_SourceAlpha_Opacity);
addOverride(BlitMask_Merge_Opacity);
addOverride(BlitDeform);
addOverride(BlitDeformMask);
addOverride(BlitConvolve);
addOverride(BlitConvolveMask);
addOverride(FilterSimple_Gradient_4Point);
addOverride(FilterSimple_Gradient_4Point_SourceAlpha);
addOverride(FilterSimple_Gradient_Vertical);
addOverride(FilterSimple_Gradient_Vertical_SourceAlpha);
addOverride(FilterSimple_Gradient_Horizontal);
addOverride(FilterSimple_Gradient_Horizontal_SourceAlpha);
addOverride(FilterSimple_Gradient_Radial);
addOverride(FilterSimple_Gradient_Radial_SourceAlpha);
addOverride(FilterSimple_Line);
addOverride(FilterSimple_Line_SourceAlpha);
addOverride(FilterSimple_Line_Additive);
addOverride(FilterSimple_Line_Subtractive);
addOverride(FilterSimple_Line_Gradient);
addOverride(FilterSimple_Line_Gradient_SourceAlpha);
addOverride(FilterSimple_Line_AA);
addOverride(FilterSimple_Line_Gradient_AA);
addOverride(FilterSimple_Box);
addOverride(FilterSimple_Box_SourceAlpha);
addOverride(FilterSimple_Adjust);
addOverride(FilterSimple_Adjust_RGB);
addOverride(FilterSimple_Adjust_Channel);
addOverride(FilterSimple_ConvexPolygon);
addOverride(FilterSimple_ConvexPolygon_Textured);
addOverride(FilterSimple_ConvexPolygon_Gradient);
// addOverride(FilterSimple_Grayscale);
// addOverride(FilterSimple_ConvexPolygon_AntiAlias);
// addOverride(FilterSimple_ConvexPolygon_Textured_AntiAlias);
addOverride(RenderTilemapLayer);
addOverride(RenderWindow);
addOverride(GetScanlineRenderer);
addOverride(FilterSimple_Gamma);
addOverride(FilterSimple_Blur);
addOverride(FilterSimple_Multiply);
addOverride(FilterSimple_Gamma_RGB);
addOverride(FilterSimple_Multiply_RGB);
addOverride(FilterSimple_Gamma_Channel);
addOverride(FilterSimple_Multiply_Channel);
addOverride(FilterSimple_Composite);
addOverride(FilterSimple_Replace);
addOverride(FilterSimple_Grayscale);
addOverride(FilterSimple_Invert);
addOverride(FilterSimple_Invert_RGB);
addOverride(FilterSimple_Invert_Channel);
addOverride(FilterSimple_Swap_Channels);
addOverride(BlitSimple_Channel);
}
void UninstallOverrides() {
removeOverride(Allocate);
removeOverride(Deallocate);
removeOverride(Clear);
removeOverride(Copy);
removeOverride(Lock);
removeOverride(Unlock);
removeOverride(SetPixel);
removeOverride(SetPixelAA);
removeOverride(FilterSimple_Fill_Channel);
removeOverride(FilterSimple_Fill);
removeOverride(FilterSimple_Fill_Opacity);
removeOverride(FilterSimple_Fill_SourceAlpha);
removeOverride(FilterSimple_Fill_SourceAlpha_Opacity);
removeOverride(FilterSimple_Fill_Additive);
removeOverride(FilterSimple_Fill_Additive_Opacity);
removeOverride(FilterSimple_Fill_Subtractive);
removeOverride(FilterSimple_Fill_Subtractive_Opacity);
removeOverride(BlitSimple_Normal);
removeOverride(BlitSimple_Normal_Opacity);
removeOverride(BlitSimple_Normal_Tint);
removeOverride(BlitSimple_Normal_Tint_Opacity);
removeOverride(BlitSimple_Matte);
removeOverride(BlitSimple_Matte_Opacity);
removeOverride(BlitSimple_Matte_Tint);
removeOverride(BlitSimple_Matte_Tint_Opacity);
removeOverride(BlitSimple_SourceAlpha);
removeOverride(BlitSimple_SourceAlpha_Opacity);
removeOverride(BlitSimple_SourceAlpha_Premultiplied);
removeOverride(BlitSimple_SourceAlpha_Premultiplied_Opacity);
removeOverride(BlitSimple_SourceAlphaMatte);
removeOverride(BlitSimple_SourceAlphaMatte_Opacity);
removeOverride(BlitSimple_SourceAlpha_Tint);
removeOverride(BlitSimple_SourceAlpha_Solid_Tint);
removeOverride(BlitSimple_SourceAlpha_Tint_Opacity);
removeOverride(BlitSimple_Font_SourceAlpha);
removeOverride(BlitSimple_Font_SourceAlpha_Opacity);
removeOverride(BlitSimple_Font_SourceAlpha_RGB);
removeOverride(BlitSimple_Font_SourceAlpha_RGB_Opacity);
removeOverride(BlitSimple_Additive);
removeOverride(BlitSimple_Additive_Opacity);
removeOverride(BlitSimple_Multiply);
removeOverride(BlitSimple_Multiply_Opacity);
removeOverride(BlitSimple_Lightmap);
removeOverride(BlitSimple_Lightmap_Opacity);
removeOverride(BlitSimple_Lightmap_RGB);
removeOverride(BlitSimple_Lightmap_RGB_Opacity);
removeOverride(BlitSimple_Subtractive);
removeOverride(BlitSimple_Subtractive_Opacity);
removeOverride(BlitSimple_Additive_SourceAlpha);
removeOverride(BlitSimple_Additive_SourceAlpha_Opacity);
removeOverride(BlitSimple_Subtractive_SourceAlpha);
removeOverride(BlitSimple_Subtractive_SourceAlpha_Opacity);
removeOverride(BlitSimple_Merge);
removeOverride(BlitSimple_Merge_Opacity);
removeOverride(BlitSimple_Font_Merge_RGB);
removeOverride(BlitSimple_Font_Merge_RGB_Opacity);
removeOverride(BlitSimple_NormalMap);
removeOverride(BlitSimple_NormalMap_Additive);
removeOverride(BlitSimple_NormalMap_SourceAlpha);
removeOverride(BlitSimple_NormalMap_Additive_SourceAlpha);
removeOverride(BlitResample_Normal);
removeOverride(BlitResample_Normal_Opacity);
removeOverride(BlitResample_SourceAlpha);
removeOverride(BlitResample_SourceAlpha_Opacity);
removeOverride(BlitResample_SourceAlpha_Tint);
removeOverride(BlitResample_SourceAlpha_Tint_Opacity);
removeOverride(BlitResample_Additive);
removeOverride(BlitResample_Additive_Opacity);
removeOverride(BlitResample_Subtractive);
removeOverride(BlitResample_Subtractive_Opacity);
removeOverride(BlitMask_Normal_Opacity);
removeOverride(BlitMask_SourceAlpha_Opacity);
removeOverride(BlitMask_Merge_Opacity);
removeOverride(BlitDeform);
removeOverride(BlitDeformMask);
removeOverride(BlitConvolve);
removeOverride(BlitConvolveMask);
removeOverride(FilterSimple_Gradient_4Point);
removeOverride(FilterSimple_Gradient_4Point_SourceAlpha);
removeOverride(FilterSimple_Gradient_Vertical);
removeOverride(FilterSimple_Gradient_Vertical_SourceAlpha);
removeOverride(FilterSimple_Gradient_Horizontal);
removeOverride(FilterSimple_Gradient_Horizontal_SourceAlpha);
removeOverride(FilterSimple_Gradient_Radial);
removeOverride(FilterSimple_Gradient_Radial_SourceAlpha);
removeOverride(FilterSimple_Line);
removeOverride(FilterSimple_Line_SourceAlpha);
removeOverride(FilterSimple_Line_Additive);
removeOverride(FilterSimple_Line_Subtractive);
removeOverride(FilterSimple_Line_Gradient);
removeOverride(FilterSimple_Line_Gradient_SourceAlpha);
removeOverride(FilterSimple_Line_AA);
removeOverride(FilterSimple_Line_Gradient_AA);
removeOverride(FilterSimple_Box);
removeOverride(FilterSimple_Box_SourceAlpha);
removeOverride(FilterSimple_Adjust);
removeOverride(FilterSimple_Adjust_RGB);
removeOverride(FilterSimple_Adjust_Channel);
// removeOverride(FilterSimple_Grayscale);
removeOverride(FilterSimple_ConvexPolygon);
removeOverride(FilterSimple_ConvexPolygon_Textured);
removeOverride(FilterSimple_ConvexPolygon_Gradient);
// removeOverride(FilterSimple_ConvexPolygon_AntiAlias);
// removeOverride(FilterSimple_ConvexPolygon_Textured_AntiAlias);
removeOverride(RenderTilemapLayer);
removeOverride(RenderWindow);
removeOverride(GetScanlineRenderer);
removeOverride(FilterSimple_Gamma);
removeOverride(FilterSimple_Blur);
removeOverride(FilterSimple_Multiply);
removeOverride(FilterSimple_Gamma_RGB);
removeOverride(FilterSimple_Multiply_RGB);
removeOverride(FilterSimple_Gamma_Channel);
removeOverride(FilterSimple_Multiply_Channel);
removeOverride(FilterSimple_Composite);
removeOverride(FilterSimple_Grayscale);
removeOverride(FilterSimple_Invert);
removeOverride(FilterSimple_Invert_RGB);
removeOverride(FilterSimple_Invert_Channel);
removeOverride(FilterSimple_Swap_Channels);
removeOverride(BlitSimple_Channel);
}
Export void GLInstallAllocateHook() {
addNamedOverride(Allocate, Allocate_Context);
return;
}
Export void GLUninstallAllocateHook() {
removeNamedOverride(Allocate, Allocate_Context);
return;
}
Export void GLInstallFBAllocateHook() {
addNamedOverride(Allocate, Allocate_Framebuffer);
return;
}
Export void GLUninstallFBAllocateHook() {
removeNamedOverride(Allocate, Allocate_Framebuffer);
return;
}
Export int GLShaderBlit(int Dest, int Source, FX::Rectangle* DestRect, FX::Rectangle* SourceRect, int Renderer, int Scaler, GLSL::Program* Shader) {
if (Dest == 0) return Failure;
if (Source == 0) return Failure;
if (DestRect == 0) return Failure;
if (SourceRect == 0) return Failure;
if (Shader == 0) return Failure;
contextCheck(Dest);
lockCheck(Dest);
selectContext(Dest);
setBlendMode<SourceAlpha>();
FX::Rectangle DestCopy = DestRect;
FX::Rectangle SourceCopy = SourceRect;
if (Clip2D_PairedRect(&DestCopy, &SourceCopy, Dest, Source, DestRect, SourceRect, 0)) {
GLSL::useProgram(*Shader);
enableTextures();
selectImageAsTexture(Source);
setRenderer(Renderer, 0);
setScaler(Scaler);
Texture* tex = getTexture(Source);
initShaderVariables(Shader);
if ((SourceRect->Width == tex->Width) && (SourceRect->Height == tex->Height) && (SourceRect->Left == 0) && (SourceRect->Top == 0)) {
drawTexturedRectangle(DestRect, tex->U1, tex->V1, tex->U2, tex->V2);
} else {
float U1 = tex->U(SourceRect->Left), V1 = tex->V(SourceRect->Top);
float U2 = tex->U(SourceRect->right()), V2 = tex->V(SourceRect->bottom());
drawTexturedRectangle(DestRect, U1, V1, U2, V2);
}
SetImageDirty(Dest, 1);
GLSL::disableProgram();
}
return Success;
}
| [
"janus@1af785eb-1c5d-444a-bf89-8f912f329d98",
"janusfury@1af785eb-1c5d-444a-bf89-8f912f329d98"
] | [
[
[
1,
176
],
[
179,
1366
],
[
1368,
1400
],
[
1436,
3524
],
[
3527,
3650
],
[
3653,
3762
]
],
[
[
177,
178
],
[
1367,
1367
],
[
1401,
1435
],
[
3525,
3526
],
[
3651,
3652
]
]
] |
bf90d977933b0030d7a26769078d9c78a2f19094 | 3bfc30f7a07ce0f6eabcd526e39ba1030d84c1f3 | /BlobbyWarriors/Source/BlobbyWarriors/Model/Entity/Ground.h | 2b94b5e1111008994adff1118f92cb97789bf3c0 | [] | no_license | visusnet/Blobby-Warriors | b0b70a0b4769b60d96424b55ad7c47b256e60061 | adec63056786e4e8dfcb1ed7f7fe8b09ce05399d | refs/heads/master | 2021-01-19T14:09:32.522480 | 2011-11-29T21:53:25 | 2011-11-29T21:53:25 | 2,850,563 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 189 | h | #ifndef GROUND_H
#define GROUND_H
class Ground;
#include "AbstractEntity.h"
#include "../../Debug.h"
class Ground : public AbstractEntity
{
public:
void draw();
};
#endif | [
"[email protected]"
] | [
[
[
1,
15
]
]
] |
f412c360a3b11b8e36f2f1876f6b4f68ef03236b | 097718ad5b708ce1d628b3b1c21ddc08428a5555 | /ext/RunUnitTests/stdafx.cpp | 5cac384b7fdc03cd98d136af784d5b3633b1833c | [] | no_license | breakingthings/mfct | 49c1d0a29ba0a0ff06ef434bec50b29b80136260 | efe5cf0ccedad98f342cd4acbfda117189f80648 | refs/heads/master | 2021-01-01T16:40:24.011737 | 2011-09-12T21:35:53 | 2011-09-12T21:35:53 | 2,326,800 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 299 | cpp | // stdafx.cpp : source file that includes just the standard includes
// RunUnitTests.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"[email protected]"
] | [
[
[
1,
8
]
]
] |
0f82bb4590252b89f9c4822e7e6e5f68e4b9c08c | c54f5a7cf6de3ed02d2e02cf867470ea48bd9258 | /pyobjc/PyOpenGL-2.0.2.01/src/interface/GL.EXT._index_func.0104.inc | 7b9f643891c8d1636816a9815e7950c5a8296462 | [] | no_license | orestis/pyobjc | 01ad0e731fbbe0413c2f5ac2f3e91016749146c6 | c30bf50ba29cb562d530e71a9d6c3d8ad75aa230 | refs/heads/master | 2021-01-22T06:54:35.401551 | 2009-09-01T09:24:47 | 2009-09-01T09:24:47 | 16,895 | 8 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 53,976 | inc | /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.23
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
#define SWIGPYTHON
#ifndef SWIG_TEMPLATE_DISAMBIGUATOR
# if defined(__SUNPRO_CC)
# define SWIG_TEMPLATE_DISAMBIGUATOR template
# else
# define SWIG_TEMPLATE_DISAMBIGUATOR
# endif
#endif
#include <Python.h>
/***********************************************************************
* common.swg
*
* This file contains generic SWIG runtime support for pointer
* type checking as well as a few commonly used macros to control
* external linkage.
*
* Author : David Beazley ([email protected])
*
* Copyright (c) 1999-2000, The University of Chicago
*
* This file may be freely redistributed without license or fee provided
* this copyright message remains intact.
************************************************************************/
#include <string.h>
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if !defined(STATIC_LINKED)
# define SWIGEXPORT(a) __declspec(dllexport) a
# else
# define SWIGEXPORT(a) a
# endif
#else
# define SWIGEXPORT(a) a
#endif
#define SWIGRUNTIME(x) static x
#ifndef SWIGINLINE
#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
# define SWIGINLINE inline
#else
# define SWIGINLINE
#endif
#endif
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
#define SWIG_RUNTIME_VERSION "1"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
#define SWIG_QUOTE_STRING(x) #x
#define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
#define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
#else
#define SWIG_TYPE_TABLE_NAME
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef void *(*swig_converter_func)(void *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
typedef struct swig_type_info {
const char *name;
swig_converter_func converter;
const char *str;
void *clientdata;
swig_dycast_func dcast;
struct swig_type_info *next;
struct swig_type_info *prev;
} swig_type_info;
static swig_type_info *swig_type_list = 0;
static swig_type_info **swig_type_list_handle = &swig_type_list;
/*
Compare two type names skipping the space characters, therefore
"char*" == "char *" and "Class<int>" == "Class<int >", etc.
Return 0 when the two name types are equivalent, as in
strncmp, but skipping ' '.
*/
static int
SWIG_TypeNameComp(const char *f1, const char *l1,
const char *f2, const char *l2) {
for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
while ((*f1 == ' ') && (f1 != l1)) ++f1;
while ((*f2 == ' ') && (f2 != l2)) ++f2;
if (*f1 != *f2) return *f1 - *f2;
}
return (l1 - f1) - (l2 - f2);
}
/*
Check type equivalence in a name list like <name1>|<name2>|...
*/
static int
SWIG_TypeEquiv(const char *nb, const char *tb) {
int equiv = 0;
const char* te = tb + strlen(tb);
const char* ne = nb;
while (!equiv && *ne) {
for (nb = ne; *ne; ++ne) {
if (*ne == '|') break;
}
equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0;
if (*ne) ++ne;
}
return equiv;
}
/* Register a type mapping with the type-checking */
static swig_type_info *
SWIG_TypeRegister(swig_type_info *ti) {
swig_type_info *tc, *head, *ret, *next;
/* Check to see if this type has already been registered */
tc = *swig_type_list_handle;
while (tc) {
/* check simple type equivalence */
int typeequiv = (strcmp(tc->name, ti->name) == 0);
/* check full type equivalence, resolving typedefs */
if (!typeequiv) {
/* only if tc is not a typedef (no '|' on it) */
if (tc->str && ti->str && !strstr(tc->str,"|")) {
typeequiv = SWIG_TypeEquiv(ti->str,tc->str);
}
}
if (typeequiv) {
/* Already exists in the table. Just add additional types to the list */
if (ti->clientdata) tc->clientdata = ti->clientdata;
head = tc;
next = tc->next;
goto l1;
}
tc = tc->prev;
}
head = ti;
next = 0;
/* Place in list */
ti->prev = *swig_type_list_handle;
*swig_type_list_handle = ti;
/* Build linked lists */
l1:
ret = head;
tc = ti + 1;
/* Patch up the rest of the links */
while (tc->name) {
head->next = tc;
tc->prev = head;
head = tc;
tc++;
}
if (next) next->prev = head;
head->next = next;
return ret;
}
/* Check the typename */
static swig_type_info *
SWIG_TypeCheck(char *c, swig_type_info *ty) {
swig_type_info *s;
if (!ty) return 0; /* Void pointer */
s = ty->next; /* First element always just a name */
do {
if (strcmp(s->name,c) == 0) {
if (s == ty->next) return s;
/* Move s to the top of the linked list */
s->prev->next = s->next;
if (s->next) {
s->next->prev = s->prev;
}
/* Insert s as second element in the list */
s->next = ty->next;
if (ty->next) ty->next->prev = s;
ty->next = s;
s->prev = ty;
return s;
}
s = s->next;
} while (s && (s != ty->next));
return 0;
}
/* Cast a pointer up an inheritance hierarchy */
static SWIGINLINE void *
SWIG_TypeCast(swig_type_info *ty, void *ptr) {
if ((!ty) || (!ty->converter)) return ptr;
return (*ty->converter)(ptr);
}
/* Dynamic pointer casting. Down an inheritance hierarchy */
static swig_type_info *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
swig_type_info *lastty = ty;
if (!ty || !ty->dcast) return ty;
while (ty && (ty->dcast)) {
ty = (*ty->dcast)(ptr);
if (ty) lastty = ty;
}
return lastty;
}
/* Return the name associated with this type */
static SWIGINLINE const char *
SWIG_TypeName(const swig_type_info *ty) {
return ty->name;
}
/* Return the pretty name associated with this type,
that is an unmangled type name in a form presentable to the user.
*/
static const char *
SWIG_TypePrettyName(const swig_type_info *type) {
/* The "str" field contains the equivalent pretty names of the
type, separated by vertical-bar characters. We choose
to print the last name, as it is often (?) the most
specific. */
if (type->str != NULL) {
const char *last_name = type->str;
const char *s;
for (s = type->str; *s; s++)
if (*s == '|') last_name = s+1;
return last_name;
}
else
return type->name;
}
/* Search for a swig_type_info structure */
static swig_type_info *
SWIG_TypeQuery(const char *name) {
swig_type_info *ty = *swig_type_list_handle;
while (ty) {
if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty;
if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
ty = ty->prev;
}
return 0;
}
/* Set the clientdata field for a type */
static void
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
swig_type_info *tc, *equiv;
if (ti->clientdata) return;
/* if (ti->clientdata == clientdata) return; */
ti->clientdata = clientdata;
equiv = ti->next;
while (equiv) {
if (!equiv->converter) {
tc = *swig_type_list_handle;
while (tc) {
if ((strcmp(tc->name, equiv->name) == 0))
SWIG_TypeClientData(tc,clientdata);
tc = tc->prev;
}
}
equiv = equiv->next;
}
}
/* Pack binary data into a string */
static char *
SWIG_PackData(char *c, void *ptr, size_t sz) {
static char hex[17] = "0123456789abcdef";
unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
register unsigned char uu;
for (; u != eu; ++u) {
uu = *u;
*(c++) = hex[(uu & 0xf0) >> 4];
*(c++) = hex[uu & 0xf];
}
return c;
}
/* Unpack binary data from a string */
static char *
SWIG_UnpackData(char *c, void *ptr, size_t sz) {
register unsigned char uu = 0;
register int d;
unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
uu = ((d - ('a'-10)) << 4);
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu |= (d - '0');
else if ((d >= 'a') && (d <= 'f'))
uu |= (d - ('a'-10));
*u = uu;
}
return c;
}
/* This function will propagate the clientdata field of type to
* any new swig_type_info structures that have been added into the list
* of equivalent types. It is like calling
* SWIG_TypeClientData(type, clientdata) a second time.
*/
static void
SWIG_PropagateClientData(swig_type_info *type) {
swig_type_info *equiv = type->next;
swig_type_info *tc;
if (!type->clientdata) return;
while (equiv) {
if (!equiv->converter) {
tc = *swig_type_list_handle;
while (tc) {
if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata)
SWIG_TypeClientData(tc, type->clientdata);
tc = tc->prev;
}
}
equiv = equiv->next;
}
}
#ifdef __cplusplus
}
#endif
/* -----------------------------------------------------------------------------
* SWIG API. Portion that goes into the runtime
* ----------------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C" {
#endif
/* -----------------------------------------------------------------------------
* for internal method declarations
* ----------------------------------------------------------------------------- */
#ifndef SWIGINTERN
#define SWIGINTERN static
#endif
#ifndef SWIGINTERNSHORT
#ifdef __cplusplus
#define SWIGINTERNSHORT static inline
#else /* C case */
#define SWIGINTERNSHORT static
#endif /* __cplusplus */
#endif
/* Common SWIG API */
#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags)
#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags)
#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
/* Python-specific SWIG API */
#define SWIG_newvarlink() SWIG_Python_newvarlink()
#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
/*
Exception handling in wrappers
*/
#define SWIG_fail goto fail
#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
#define SWIG_append_errmsg(msg) SWIG_Python_AddErrMesg(msg,0)
#define SWIG_preppend_errmsg(msg) SWIG_Python_AddErrMesg(msg,1)
#define SWIG_type_error(type,obj) SWIG_Python_TypeError(type,obj)
#define SWIG_null_ref(type) SWIG_Python_NullRef(type)
/*
Contract support
*/
#define SWIG_contract_assert(expr, msg) \
if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else
/* -----------------------------------------------------------------------------
* Constant declarations
* ----------------------------------------------------------------------------- */
/* Constant Types */
#define SWIG_PY_INT 1
#define SWIG_PY_FLOAT 2
#define SWIG_PY_STRING 3
#define SWIG_PY_POINTER 4
#define SWIG_PY_BINARY 5
/* Constant information structure */
typedef struct swig_const_info {
int type;
char *name;
long lvalue;
double dvalue;
void *pvalue;
swig_type_info **ptype;
} swig_const_info;
/* -----------------------------------------------------------------------------
* Pointer declarations
* ----------------------------------------------------------------------------- */
/*
Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent
C/C++ pointers in the python side. Very useful for debugging, but
not always safe.
*/
#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES)
# define SWIG_COBJECT_TYPES
#endif
/* Flags for pointer conversion */
#define SWIG_POINTER_EXCEPTION 0x1
#define SWIG_POINTER_DISOWN 0x2
/* -----------------------------------------------------------------------------
* Alloc. memory flags
* ----------------------------------------------------------------------------- */
#define SWIG_OLDOBJ 1
#define SWIG_NEWOBJ SWIG_OLDOBJ + 1
#define SWIG_PYSTR SWIG_NEWOBJ + 1
#ifdef __cplusplus
}
#endif
/***********************************************************************
* pyrun.swg
*
* This file contains the runtime support for Python modules
* and includes code for managing global variables and pointer
* type checking.
*
* Author : David Beazley ([email protected])
************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/* -----------------------------------------------------------------------------
* global variable support code.
* ----------------------------------------------------------------------------- */
typedef struct swig_globalvar {
char *name; /* Name of global variable */
PyObject *(*get_attr)(); /* Return the current value */
int (*set_attr)(PyObject *); /* Set the value */
struct swig_globalvar *next;
} swig_globalvar;
typedef struct swig_varlinkobject {
PyObject_HEAD
swig_globalvar *vars;
} swig_varlinkobject;
static PyObject *
swig_varlink_repr(swig_varlinkobject *v) {
v = v;
return PyString_FromString("<Global variables>");
}
static int
swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
swig_globalvar *var;
flags = flags;
fprintf(fp,"Global variables { ");
for (var = v->vars; var; var=var->next) {
fprintf(fp,"%s", var->name);
if (var->next) fprintf(fp,", ");
}
fprintf(fp," }\n");
return 0;
}
static PyObject *
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
swig_globalvar *var = v->vars;
while (var) {
if (strcmp(var->name,n) == 0) {
return (*var->get_attr)();
}
var = var->next;
}
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
return NULL;
}
static int
swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
swig_globalvar *var = v->vars;
while (var) {
if (strcmp(var->name,n) == 0) {
return (*var->set_attr)(p);
}
var = var->next;
}
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
return 1;
}
static PyTypeObject varlinktype = {
PyObject_HEAD_INIT(0)
0, /* Number of items in variable part (ob_size) */
(char *)"swigvarlink", /* Type name (tp_name) */
sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
0, /* Itemsize (tp_itemsize) */
0, /* Deallocator (tp_dealloc) */
(printfunc) swig_varlink_print, /* Print (tp_print) */
(getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
(setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
0, /* tp_compare */
(reprfunc) swig_varlink_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
0, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
#if PY_VERSION_HEX >= 0x02020000
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
#endif
#if PY_VERSION_HEX >= 0x02030000
0, /* tp_del */
#endif
#ifdef COUNT_ALLOCS
/* these must be last */
0, /* tp_alloc */
0, /* tp_free */
0, /* tp_maxalloc */
0, /* tp_next */
#endif
};
/* Create a variable linking object for use later */
static PyObject *
SWIG_Python_newvarlink(void) {
swig_varlinkobject *result = 0;
result = PyMem_NEW(swig_varlinkobject,1);
varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */
result->ob_type = &varlinktype;
result->vars = 0;
result->ob_refcnt = 0;
Py_XINCREF((PyObject *) result);
return ((PyObject*) result);
}
static void
SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
swig_varlinkobject *v;
swig_globalvar *gv;
v= (swig_varlinkobject *) p;
gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
gv->name = (char *) malloc(strlen(name)+1);
strcpy(gv->name,name);
gv->get_attr = get_attr;
gv->set_attr = set_attr;
gv->next = v->vars;
v->vars = gv;
}
/* -----------------------------------------------------------------------------
* errors manipulation
* ----------------------------------------------------------------------------- */
static void
SWIG_Python_TypeError(const char *type, PyObject *obj)
{
if (type) {
if (!PyCObject_Check(obj)) {
const char *otype = (obj ? obj->ob_type->tp_name : 0);
if (otype) {
PyObject *str = PyObject_Str(obj);
const char *cstr = str ? PyString_AsString(str) : 0;
if (cstr) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
type, otype, cstr);
} else {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
type, otype);
}
Py_DECREF(str);
return;
}
} else {
const char *otype = (char *) PyCObject_GetDesc(obj);
if (otype) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PyCObject(%s)' is received",
type, otype);
return;
}
}
PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
} else {
PyErr_Format(PyExc_TypeError, "unexpected type is received");
}
}
static SWIGINLINE void
SWIG_Python_NullRef(const char *type)
{
if (type) {
PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type);
} else {
PyErr_Format(PyExc_TypeError, "null reference was received");
}
}
static int
SWIG_Python_AddErrMesg(const char* mesg, int infront)
{
if (PyErr_Occurred()) {
PyObject *type = 0;
PyObject *value = 0;
PyObject *traceback = 0;
PyErr_Fetch(&type, &value, &traceback);
if (value) {
PyObject *old_str = PyObject_Str(value);
Py_XINCREF(type);
PyErr_Clear();
if (infront) {
PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
} else {
PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
}
Py_DECREF(old_str);
}
return 1;
} else {
return 0;
}
}
static int
SWIG_Python_ArgFail(int argnum)
{
if (PyErr_Occurred()) {
/* add information about failing argument */
char mesg[256];
sprintf(mesg, "argument number %d:", argnum);
return SWIG_Python_AddErrMesg(mesg, 1);
} else {
return 0;
}
}
/* -----------------------------------------------------------------------------
* pointers/data manipulation
* ----------------------------------------------------------------------------- */
/* Convert a pointer value */
static int
SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
swig_type_info *tc;
char *c = 0;
static PyObject *SWIG_this = 0;
int newref = 0;
PyObject *pyobj = 0;
void *vptr;
if (!obj) return 0;
if (obj == Py_None) {
*ptr = 0;
return 0;
}
#ifdef SWIG_COBJECT_TYPES
if (!(PyCObject_Check(obj))) {
if (!SWIG_this)
SWIG_this = PyString_FromString("this");
pyobj = obj;
obj = PyObject_GetAttr(obj,SWIG_this);
newref = 1;
if (!obj) goto type_error;
if (!PyCObject_Check(obj)) {
Py_DECREF(obj);
goto type_error;
}
}
vptr = PyCObject_AsVoidPtr(obj);
c = (char *) PyCObject_GetDesc(obj);
if (newref) Py_DECREF(obj);
goto type_check;
#else
if (!(PyString_Check(obj))) {
if (!SWIG_this)
SWIG_this = PyString_FromString("this");
pyobj = obj;
obj = PyObject_GetAttr(obj,SWIG_this);
newref = 1;
if (!obj) goto type_error;
if (!PyString_Check(obj)) {
Py_DECREF(obj);
goto type_error;
}
}
c = PyString_AS_STRING(obj);
/* Pointer values must start with leading underscore */
if (*c != '_') {
if (strcmp(c,"NULL") == 0) {
if (newref) { Py_DECREF(obj); }
*ptr = (void *) 0;
return 0;
} else {
if (newref) { Py_DECREF(obj); }
goto type_error;
}
}
c++;
c = SWIG_UnpackData(c,&vptr,sizeof(void *));
if (newref) { Py_DECREF(obj); }
#endif
type_check:
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) goto type_error;
*ptr = SWIG_TypeCast(tc,vptr);
}
if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) {
PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False);
}
return 0;
type_error:
PyErr_Clear();
if (pyobj && !obj) {
obj = pyobj;
if (PyCFunction_Check(obj)) {
/* here we get the method pointer for callbacks */
char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
c = doc ? strstr(doc, "swig_ptr: ") : 0;
if (c) {
c += 10;
if (*c == '_') {
c++;
c = SWIG_UnpackData(c,&vptr,sizeof(void *));
goto type_check;
}
}
}
}
if (flags & SWIG_POINTER_EXCEPTION) {
if (ty) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
} else {
SWIG_Python_TypeError("C/C++ pointer", obj);
}
}
return -1;
}
/* Convert a pointer value, signal an exception on a type mismatch */
static void *
SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
void *result;
if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
PyErr_Clear();
if (flags & SWIG_POINTER_EXCEPTION) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
SWIG_Python_ArgFail(argnum);
}
}
return result;
}
/* Convert a packed value value */
static int
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) {
swig_type_info *tc;
char *c = 0;
if ((!obj) || (!PyString_Check(obj))) goto type_error;
c = PyString_AS_STRING(obj);
/* Pointer values must start with leading underscore */
if (*c != '_') goto type_error;
c++;
c = SWIG_UnpackData(c,ptr,sz);
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) goto type_error;
}
return 0;
type_error:
PyErr_Clear();
if (flags & SWIG_POINTER_EXCEPTION) {
if (ty) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
} else {
SWIG_Python_TypeError("C/C++ packed data", obj);
}
}
return -1;
}
/* Create a new pointer string */
static char *
SWIG_Python_PointerStr(char *buff, void *ptr, const char *name, size_t bsz) {
char *r = buff;
if ((2*sizeof(void *) + 2) > bsz) return 0;
*(r++) = '_';
r = SWIG_PackData(r,&ptr,sizeof(void *));
if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
strcpy(r,name);
return buff;
}
/* Create a new pointer object */
static PyObject *
SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) {
PyObject *robj;
if (!ptr) {
Py_INCREF(Py_None);
return Py_None;
}
#ifdef SWIG_COBJECT_TYPES
robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL);
#else
{
char result[1024];
SWIG_Python_PointerStr(result, ptr, type->name, 1024);
robj = PyString_FromString(result);
}
#endif
if (!robj || (robj == Py_None)) return robj;
if (type->clientdata) {
PyObject *inst;
PyObject *args = Py_BuildValue((char*)"(O)", robj);
Py_DECREF(robj);
inst = PyObject_CallObject((PyObject *) type->clientdata, args);
Py_DECREF(args);
if (inst) {
if (own) {
PyObject_SetAttrString(inst,(char*)"thisown",Py_True);
}
robj = inst;
}
}
return robj;
}
static PyObject *
SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
char result[1024];
char *r = result;
if ((2*sz + 2 + strlen(type->name)) > 1024) return 0;
*(r++) = '_';
r = SWIG_PackData(r,ptr,sz);
strcpy(r,type->name);
return PyString_FromString(result);
}
/* -----------------------------------------------------------------------------
* constants/methods manipulation
* ----------------------------------------------------------------------------- */
/* Install Constants */
static void
SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
int i;
PyObject *obj;
for (i = 0; constants[i].type; i++) {
switch(constants[i].type) {
case SWIG_PY_INT:
obj = PyInt_FromLong(constants[i].lvalue);
break;
case SWIG_PY_FLOAT:
obj = PyFloat_FromDouble(constants[i].dvalue);
break;
case SWIG_PY_STRING:
if (constants[i].pvalue) {
obj = PyString_FromString((char *) constants[i].pvalue);
} else {
Py_INCREF(Py_None);
obj = Py_None;
}
break;
case SWIG_PY_POINTER:
obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
break;
case SWIG_PY_BINARY:
obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
break;
default:
obj = 0;
break;
}
if (obj) {
PyDict_SetItemString(d,constants[i].name,obj);
Py_DECREF(obj);
}
}
}
/* Fix SwigMethods to carry the callback ptrs when needed */
static void
SWIG_Python_FixMethods(PyMethodDef *methods,
swig_const_info *const_table,
swig_type_info **types,
swig_type_info **types_initial) {
int i;
for (i = 0; methods[i].ml_name; ++i) {
char *c = methods[i].ml_doc;
if (c && (c = strstr(c, "swig_ptr: "))) {
int j;
swig_const_info *ci = 0;
char *name = c + 10;
for (j = 0; const_table[j].type; j++) {
if (strncmp(const_table[j].name, name,
strlen(const_table[j].name)) == 0) {
ci = &(const_table[j]);
break;
}
}
if (ci) {
size_t shift = (ci->ptype) - types;
swig_type_info *ty = types_initial[shift];
size_t ldoc = (c - methods[i].ml_doc);
size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
char *ndoc = (char*)malloc(ldoc + lptr + 10);
char *buff = ndoc;
void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue: (void *)(ci->lvalue);
strncpy(buff, methods[i].ml_doc, ldoc);
buff += ldoc;
strncpy(buff, "swig_ptr: ", 10);
buff += 10;
SWIG_Python_PointerStr(buff, ptr, ty->name, lptr);
methods[i].ml_doc = ndoc;
}
}
}
}
/* -----------------------------------------------------------------------------
* Lookup type pointer
* ----------------------------------------------------------------------------- */
#if PY_MAJOR_VERSION < 2
/* PyModule_AddObject function was introduced in Python 2.0. The following function
is copied out of Python/modsupport.c in python version 2.3.4 */
static int
PyModule_AddObject(PyObject *m, char *name, PyObject *o)
{
PyObject *dict;
if (!PyModule_Check(m)) {
PyErr_SetString(PyExc_TypeError,
"PyModule_AddObject() needs module as first arg");
return -1;
}
if (!o) {
PyErr_SetString(PyExc_TypeError,
"PyModule_AddObject() needs non-NULL value");
return -1;
}
dict = PyModule_GetDict(m);
if (dict == NULL) {
/* Internal error -- modules must have a dict! */
PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
PyModule_GetName(m));
return -1;
}
if (PyDict_SetItemString(dict, name, o))
return -1;
Py_DECREF(o);
return 0;
}
#endif
static PyMethodDef swig_empty_runtime_method_table[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
static void
SWIG_Python_LookupTypePointer(swig_type_info ***type_list_handle) {
PyObject *module, *pointer;
void *type_pointer;
/* first check if module already created */
type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
if (type_pointer) {
*type_list_handle = (swig_type_info **) type_pointer;
} else {
PyErr_Clear();
/* create a new module and variable */
module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
pointer = PyCObject_FromVoidPtr((void *) (*type_list_handle), NULL);
if (pointer && module) {
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
}
}
}
#ifdef __cplusplus
}
#endif
/* -------- TYPES TABLE (BEGIN) -------- */
#define SWIGTYPE_p_GLsizei swig_types[0]
#define SWIGTYPE_p_GLshort swig_types[1]
#define SWIGTYPE_p_GLboolean swig_types[2]
#define SWIGTYPE_size_t swig_types[3]
#define SWIGTYPE_p_GLushort swig_types[4]
#define SWIGTYPE_p_GLenum swig_types[5]
#define SWIGTYPE_p_GLvoid swig_types[6]
#define SWIGTYPE_p_GLint swig_types[7]
#define SWIGTYPE_p_char swig_types[8]
#define SWIGTYPE_p_GLclampd swig_types[9]
#define SWIGTYPE_p_GLclampf swig_types[10]
#define SWIGTYPE_p_GLuint swig_types[11]
#define SWIGTYPE_ptrdiff_t swig_types[12]
#define SWIGTYPE_p_GLbyte swig_types[13]
#define SWIGTYPE_p_GLbitfield swig_types[14]
#define SWIGTYPE_p_GLfloat swig_types[15]
#define SWIGTYPE_p_GLubyte swig_types[16]
#define SWIGTYPE_p_GLdouble swig_types[17]
static swig_type_info *swig_types[19];
/* -------- TYPES TABLE (END) -------- */
/*-----------------------------------------------
@(target):= _index_func.so
------------------------------------------------*/
#define SWIG_init init_index_func
#define SWIG_name "_index_func"
SWIGINTERN PyObject *
SWIG_FromCharPtr(const char* cptr)
{
if (cptr) {
size_t size = strlen(cptr);
if (size > INT_MAX) {
return SWIG_NewPointerObj((char*)(cptr),
SWIG_TypeQuery("char *"), 0);
} else {
if (size != 0) {
return PyString_FromStringAndSize(cptr, size);
} else {
return PyString_FromString(cptr);
}
}
}
Py_INCREF(Py_None);
return Py_None;
}
/*@C:\\bin\\SWIG-1.3.23\\Lib\\python\\pymacros.swg,66,SWIG_define@*/
#define SWIG_From_int PyInt_FromLong
/*@@*/
/**
*
* GL.EXT.index_func Module for PyOpenGL
*
* Date: May 2001
*
* Authors: Tarn Weisner Burton <[email protected]>
*
***/
GLint PyOpenGL_round(double x) {
if (x >= 0) {
return (GLint) (x+0.5);
} else {
return (GLint) (x-0.5);
}
}
int __PyObject_AsArray_Size(PyObject* x);
#ifdef NUMERIC
#define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : ((PyArray_Check(x)) ? PyArray_Size(x) : __PyObject_AsArray_Size(x)))
#else /* NUMERIC */
#define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : __PyObject_AsArray_Size(x))
#endif /* NUMERIC */
#define _PyObject_As(NAME, BASE) BASE* _PyObject_As##NAME(PyObject* source, PyObject** temp, int* len);
#define _PyObject_AsArray_Cleanup(target, temp) if (temp) Py_XDECREF(temp); else PyMem_Del(target)
_PyObject_As(FloatArray, float)
_PyObject_As(DoubleArray, double)
_PyObject_As(CharArray, signed char)
_PyObject_As(UnsignedCharArray, unsigned char)
_PyObject_As(ShortArray, short)
_PyObject_As(UnsignedShortArray, unsigned short)
_PyObject_As(IntArray, int)
_PyObject_As(UnsignedIntArray, unsigned int)
void* _PyObject_AsArray(GLenum type, PyObject* source, PyObject** temp, int* len);
#define PyErr_XPrint() if (PyErr_Occurred()) PyErr_Print()
#if HAS_DYNAMIC_EXT
#define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\
RET PROC_NAME PROTO\
{\
typedef RET (APIENTRY *proc_##PROC_NAME) PROTO;\
proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\
if (proc) return proc CALL;\
PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\
return ERROR_RET;\
}
#define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\
void PROC_NAME PROTO\
{\
typedef void (APIENTRY *proc_##PROC_NAME) PROTO;\
proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\
if (proc) proc CALL;\
else {\
PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\
}\
}
#else
#define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\
RET PROC_NAME PROTO\
{\
PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\
return ERROR_RET;\
}
#define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\
void PROC_NAME PROTO\
{\
PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\
}
#endif
#define _PyTuple_From(NAME, BASE) PyObject* _PyTuple_From##NAME(int len, BASE* data);
_PyTuple_From(UnsignedCharArray, unsigned char)
_PyTuple_From(CharArray, signed char)
_PyTuple_From(UnsignedShortArray, unsigned short)
_PyTuple_From(ShortArray, short)
_PyTuple_From(UnsignedIntArray, unsigned int)
_PyTuple_From(IntArray, int)
_PyTuple_From(FloatArray, float)
_PyTuple_From(DoubleArray, double)
#define _PyObject_From(NAME, BASE) PyObject* _PyObject_From##NAME(int nd, int* dims, BASE* data, int own);
_PyObject_From(UnsignedCharArray, unsigned char)
_PyObject_From(CharArray, signed char)
_PyObject_From(UnsignedShortArray, unsigned short)
_PyObject_From(ShortArray, short)
_PyObject_From(UnsignedIntArray, unsigned int)
_PyObject_From(IntArray, int)
_PyObject_From(FloatArray, float)
_PyObject_From(DoubleArray, double)
PyObject* _PyObject_FromArray(GLenum type, int nd, int *dims, void* data, int own);
void* SetupPixelRead(int rank, GLenum format, GLenum type, int *dims);
void SetupPixelWrite(int rank);
void* SetupRawPixelRead(GLenum format, GLenum type, int n, const int *dims, int* size);
void* _PyObject_AsPointer(PyObject* x);
/* The following line causes a warning on linux and cygwin
The function is defined in interface_utils.c, which is
linked to each extension module. For some reason, though,
this declaration doesn't get recognised as a declaration
prototype for that function.
*/
void init_util();
typedef void *PTR;
typedef struct
{
void (*_decrement)(void* pointer);
void (*_decrementPointer)(GLenum pname);
int (*_incrementLock)(void *pointer);
int (*_incrementPointerLock)(GLenum pname);
void (*_acquire)(void* pointer);
void (*_acquirePointer)(GLenum pname);
#if HAS_DYNAMIC_EXT
PTR (*GL_GetProcAddress)(const char* name);
#endif
int (*InitExtension)(const char *name, const char** procs);
PyObject *_GLerror;
PyObject *_GLUerror;
} util_API;
static util_API *_util_API = NULL;
#define decrementLock(x) (*_util_API)._decrement(x)
#define decrementPointerLock(x) (*_util_API)._decrementPointer(x)
#define incrementLock(x) (*_util_API)._incrementLock(x)
#define incrementPointerLock(x) (*_util_API)._incrementPointerLock(x)
#define acquire(x) (*_util_API)._acquire(x)
#define acquirePointer(x) (*_util_API)._acquirePointer(x)
#define GLerror (*_util_API)._GLerror
#define GLUerror (*_util_API)._GLUerror
#if HAS_DYNAMIC_EXT
#define GL_GetProcAddress(x) (*_util_API).GL_GetProcAddress(x)
#endif
#define InitExtension(x, y) (*_util_API).InitExtension(x, (const char**)y)
#define PyErr_SetGLerror(code) PyErr_SetObject(GLerror, Py_BuildValue("is", code, gluErrorString(code)));
#define PyErr_SetGLUerror(code) PyErr_SetObject(GLUerror, Py_BuildValue("is", code, gluErrorString(code)));
int _PyObject_Dimension(PyObject* x, int rank);
#define ERROR_MSG_SEP ", "
#define ERROR_MSG_SEP_LEN 2
int GLErrOccurred()
{
if (PyErr_Occurred()) return 1;
if (CurrentContextIsValid())
{
GLenum error, *errors = NULL;
char *msg = NULL;
const char *this_msg;
int count = 0;
error = glGetError();
while (error != GL_NO_ERROR)
{
this_msg = gluErrorString(error);
if (count)
{
msg = realloc(msg, (strlen(msg) + strlen(this_msg) + ERROR_MSG_SEP_LEN + 1)*sizeof(char));
strcat(msg, ERROR_MSG_SEP);
strcat(msg, this_msg);
errors = realloc(errors, (count + 1)*sizeof(GLenum));
}
else
{
msg = malloc((strlen(this_msg) + 1)*sizeof(char));
strcpy(msg, this_msg);
errors = malloc(sizeof(GLenum));
}
errors[count++] = error;
error = glGetError();
}
if (count)
{
PyErr_SetObject(GLerror, Py_BuildValue("Os", _PyTuple_FromIntArray(count, (int*)errors), msg));
free(errors);
free(msg);
return 1;
}
}
return 0;
}
void PyErr_SetGLErrorMessage( int id, char * message ) {
/* set a GLerror with an ID and string message
This tries pretty hard to look just like a regular
error as produced by GLErrOccurred()'s formatter,
save that there's only the single error being reported.
Using id 0 is probably best for any future use where
there isn't a good match for the exception description
in the error-enumeration set.
*/
PyObject * args = NULL;
args = Py_BuildValue( "(i)s", id, message );
if (args) {
PyErr_SetObject( GLerror, args );
Py_XDECREF( args );
} else {
PyErr_SetGLerror(id);
}
}
#if !EXT_DEFINES_PROTO || !defined(GL_EXT_index_func)
DECLARE_VOID_EXT(glIndexFuncEXT, (GLenum func, GLfloat ref), (func, ref))
#endif
#include <limits.h>
SWIGINTERNSHORT int
SWIG_CheckUnsignedLongInRange(unsigned long value,
unsigned long max_value,
const char *errmsg)
{
if (value > max_value) {
if (errmsg) {
PyErr_Format(PyExc_OverflowError,
"value %lu is greater than '%s' minimum %lu",
value, errmsg, max_value);
}
return 0;
}
return 1;
}
SWIGINTERN int
SWIG_AsVal_unsigned_SS_long(PyObject *obj, unsigned long *val)
{
if (PyInt_Check(obj)) {
long v = PyInt_AS_LONG(obj);
if (v >= 0) {
if (val) *val = v;
return 1;
}
}
if (PyLong_Check(obj)) {
unsigned long v = PyLong_AsUnsignedLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return 1;
} else {
if (!val) PyErr_Clear();
return 0;
}
}
if (val) {
SWIG_type_error("unsigned long", obj);
}
return 0;
}
#if UINT_MAX != ULONG_MAX
SWIGINTERN int
SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val)
{
const char* errmsg = val ? "unsigned int" : (char*)0;
unsigned long v;
if (SWIG_AsVal_unsigned_SS_long(obj, &v)) {
if (SWIG_CheckUnsignedLongInRange(v, INT_MAX, errmsg)) {
if (val) *val = (unsigned int)(v);
return 1;
}
} else {
PyErr_Clear();
}
if (val) {
SWIG_type_error(errmsg, obj);
}
return 0;
}
#else
SWIGINTERNSHORT unsigned int
SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val)
{
return SWIG_AsVal_unsigned_SS_long(obj,(unsigned long *)val);
}
#endif
SWIGINTERNSHORT unsigned int
SWIG_As_unsigned_SS_int(PyObject* obj)
{
unsigned int v;
if (!SWIG_AsVal_unsigned_SS_int(obj, &v)) {
/*
this is needed to make valgrind/purify happier.
*/
memset((void*)&v, 0, sizeof(unsigned int));
}
return v;
}
#include <float.h>
SWIGINTERN int
SWIG_CheckDoubleInRange(double value, double min_value,
double max_value, const char* errmsg)
{
if (value < min_value) {
if (errmsg) {
PyErr_Format(PyExc_OverflowError,
"value %g is less than %s minimum %g",
value, errmsg, min_value);
}
return 0;
} else if (value > max_value) {
if (errmsg) {
PyErr_Format(PyExc_OverflowError,
"value %g is greater than %s maximum %g",
value, errmsg, max_value);
}
return 0;
}
return 1;
}
SWIGINTERN int
SWIG_AsVal_double(PyObject *obj, double *val)
{
if (PyFloat_Check(obj)) {
if (val) *val = PyFloat_AS_DOUBLE(obj);
return 1;
}
if (PyInt_Check(obj)) {
if (val) *val = PyInt_AS_LONG(obj);
return 1;
}
if (PyLong_Check(obj)) {
double v = PyLong_AsDouble(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return 1;
} else {
if (!val) PyErr_Clear();
return 0;
}
}
if (val) {
SWIG_type_error("double", obj);
}
return 0;
}
SWIGINTERN int
SWIG_AsVal_float(PyObject *obj, float *val)
{
const char* errmsg = val ? "float" : (char*)0;
double v;
if (SWIG_AsVal_double(obj, &v)) {
if (SWIG_CheckDoubleInRange(v, -FLT_MAX, FLT_MAX, errmsg)) {
if (val) *val = (float)(v);
return 1;
} else {
return 0;
}
} else {
PyErr_Clear();
}
if (val) {
SWIG_type_error(errmsg, obj);
}
return 0;
}
SWIGINTERNSHORT float
SWIG_As_float(PyObject* obj)
{
float v;
if (!SWIG_AsVal_float(obj, &v)) {
/*
this is needed to make valgrind/purify happier.
*/
memset((void*)&v, 0, sizeof(float));
}
return v;
}
SWIGINTERNSHORT int
SWIG_Check_unsigned_SS_int(PyObject* obj)
{
return SWIG_AsVal_unsigned_SS_int(obj, (unsigned int*)0);
}
SWIGINTERNSHORT int
SWIG_Check_float(PyObject* obj)
{
return SWIG_AsVal_float(obj, (float*)0);
}
static char _doc_glIndexFuncEXT[] = "glIndexFuncEXT(func, ref) -> None";
static char *proc_names[] =
{
#if !EXT_DEFINES_PROTO || !defined(GL_EXT_index_func)
"glIndexFuncEXT",
#endif
NULL
};
#define glInitIndexFuncEXT() InitExtension("GL_EXT_index_func", proc_names)
static char _doc_glInitIndexFuncEXT[] = "glInitIndexFuncEXT() -> bool";
PyObject *__info()
{
if (glInitIndexFuncEXT())
{
PyObject *info = PyList_New(0);
return info;
}
Py_INCREF(Py_None);
return Py_None;
}
#ifdef __cplusplus
extern "C" {
#endif
static PyObject *_wrap_glIndexFuncEXT(PyObject *self, PyObject *args) {
PyObject *resultobj;
GLenum arg1 ;
GLfloat arg2 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"OO:glIndexFuncEXT",&obj0,&obj1)) goto fail;
{
arg1 = (GLenum)(SWIG_As_unsigned_SS_int(obj0));
if (SWIG_arg_fail(1)) SWIG_fail;
}
{
arg2 = (GLfloat)(SWIG_As_float(obj1));
if (SWIG_arg_fail(2)) SWIG_fail;
}
{
glIndexFuncEXT(arg1,arg2);
if (GLErrOccurred()) {
return NULL;
}
}
Py_INCREF(Py_None); resultobj = Py_None;
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_glInitIndexFuncEXT(PyObject *self, PyObject *args) {
PyObject *resultobj;
int result;
if(!PyArg_ParseTuple(args,(char *)":glInitIndexFuncEXT")) goto fail;
{
result = (int)glInitIndexFuncEXT();
if (GLErrOccurred()) {
return NULL;
}
}
{
resultobj = SWIG_From_int((int)(result));
}
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap___info(PyObject *self, PyObject *args) {
PyObject *resultobj;
PyObject *result;
if(!PyArg_ParseTuple(args,(char *)":__info")) goto fail;
{
result = (PyObject *)__info();
if (GLErrOccurred()) {
return NULL;
}
}
{
resultobj= result;
}
return resultobj;
fail:
return NULL;
}
static PyMethodDef SwigMethods[] = {
{ (char *)"glIndexFuncEXT", _wrap_glIndexFuncEXT, METH_VARARGS, NULL},
{ (char *)"glInitIndexFuncEXT", _wrap_glInitIndexFuncEXT, METH_VARARGS, NULL},
{ (char *)"__info", _wrap___info, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
static swig_type_info _swigt__p_GLsizei[] = {{"_p_GLsizei", 0, "int *|GLsizei *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLshort[] = {{"_p_GLshort", 0, "short *|GLshort *", 0, 0, 0, 0},{"_p_GLshort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLboolean[] = {{"_p_GLboolean", 0, "unsigned char *|GLboolean *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__size_t[] = {{"_size_t", 0, "size_t", 0, 0, 0, 0},{"_size_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLushort[] = {{"_p_GLushort", 0, "unsigned short *|GLushort *", 0, 0, 0, 0},{"_p_GLushort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLenum[] = {{"_p_GLenum", 0, "unsigned int *|GLenum *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLvoid[] = {{"_p_GLvoid", 0, "void *|GLvoid *", 0, 0, 0, 0},{"_p_GLvoid", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLint[] = {{"_p_GLint", 0, "int *|GLint *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_char[] = {{"_p_char", 0, "char *", 0, 0, 0, 0},{"_p_char", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLclampd[] = {{"_p_GLclampd", 0, "double *|GLclampd *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLclampf[] = {{"_p_GLclampf", 0, "float *|GLclampf *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLuint[] = {{"_p_GLuint", 0, "unsigned int *|GLuint *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__ptrdiff_t[] = {{"_ptrdiff_t", 0, "ptrdiff_t", 0, 0, 0, 0},{"_ptrdiff_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLbyte[] = {{"_p_GLbyte", 0, "signed char *|GLbyte *", 0, 0, 0, 0},{"_p_GLbyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLbitfield[] = {{"_p_GLbitfield", 0, "unsigned int *|GLbitfield *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLfloat[] = {{"_p_GLfloat", 0, "float *|GLfloat *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLubyte[] = {{"_p_GLubyte", 0, "unsigned char *|GLubyte *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLdouble[] = {{"_p_GLdouble", 0, "double *|GLdouble *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info *swig_types_initial[] = {
_swigt__p_GLsizei,
_swigt__p_GLshort,
_swigt__p_GLboolean,
_swigt__size_t,
_swigt__p_GLushort,
_swigt__p_GLenum,
_swigt__p_GLvoid,
_swigt__p_GLint,
_swigt__p_char,
_swigt__p_GLclampd,
_swigt__p_GLclampf,
_swigt__p_GLuint,
_swigt__ptrdiff_t,
_swigt__p_GLbyte,
_swigt__p_GLbitfield,
_swigt__p_GLfloat,
_swigt__p_GLubyte,
_swigt__p_GLdouble,
0
};
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
static swig_const_info swig_const_table[] = {
{ SWIG_PY_POINTER, (char*)"__version__", 0, 0, (void *)"1.22.6.1", &SWIGTYPE_p_char},
{ SWIG_PY_POINTER, (char*)"__date__", 0, 0, (void *)"2004/11/14 23:19:04", &SWIGTYPE_p_char},
{ SWIG_PY_POINTER, (char*)"__author__", 0, 0, (void *)"Tarn Weisner Burton <[email protected]>", &SWIGTYPE_p_char},
{ SWIG_PY_POINTER, (char*)"__doc__", 0, 0, (void *)"http://oss.sgi.com/projects/ogl-sample/registry/EXT/index_func.txt", &SWIGTYPE_p_char},
{0, 0, 0, 0.0, 0, 0}};
#ifdef __cplusplus
}
#endif
#ifdef SWIG_LINK_RUNTIME
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if defined(_MSC_VER) || defined(__GNUC__)
# define SWIGIMPORT(a) extern a
# else
# if defined(__BORLANDC__)
# define SWIGIMPORT(a) a _export
# else
# define SWIGIMPORT(a) a
# endif
# endif
#else
# define SWIGIMPORT(a) a
#endif
#ifdef __cplusplus
extern "C"
#endif
SWIGEXPORT(void *) SWIG_ReturnGlobalTypeList(void *);
#endif
#ifdef __cplusplus
extern "C"
#endif
SWIGEXPORT(void) SWIG_init(void) {
static PyObject *SWIG_globals = 0;
static int typeinit = 0;
PyObject *m, *d;
int i;
if (!SWIG_globals) SWIG_globals = SWIG_newvarlink();
/* Fix SwigMethods to carry the callback ptrs when needed */
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_types_initial);
m = Py_InitModule((char *) SWIG_name, SwigMethods);
d = PyModule_GetDict(m);
if (!typeinit) {
#ifdef SWIG_LINK_RUNTIME
swig_type_list_handle = (swig_type_info **) SWIG_ReturnGlobalTypeList(swig_type_list_handle);
#else
# ifndef SWIG_STATIC_RUNTIME
SWIG_Python_LookupTypePointer(&swig_type_list_handle);
# endif
#endif
for (i = 0; swig_types_initial[i]; i++) {
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
}
typeinit = 1;
}
SWIG_InstallConstants(d,swig_const_table);
PyDict_SetItemString(d,"__version__", SWIG_FromCharPtr("1.22.6.1"));
PyDict_SetItemString(d,"__date__", SWIG_FromCharPtr("2004/11/14 23:19:04"));
{
PyDict_SetItemString(d,"__api_version__", SWIG_From_int((int)(260)));
}
PyDict_SetItemString(d,"__author__", SWIG_FromCharPtr("Tarn Weisner Burton <[email protected]>"));
PyDict_SetItemString(d,"__doc__", SWIG_FromCharPtr("http://oss.sgi.com/projects/ogl-sample/registry/EXT/index_func.txt"));
#ifdef NUMERIC
PyArray_API = NULL;
import_array();
init_util();
PyErr_Clear();
#endif
{
PyObject *util = PyImport_ImportModule("OpenGL.GL._GL__init__");
if (util)
{
PyObject *api_object = PyDict_GetItemString(PyModule_GetDict(util), "_util_API");
if (PyCObject_Check(api_object)) _util_API = (util_API*)PyCObject_AsVoidPtr(api_object);
}
}
{
PyDict_SetItemString(d,"GL_INDEX_TEST_EXT", SWIG_From_int((int)(0x81B5)));
}
{
PyDict_SetItemString(d,"GL_INDEX_TEST_FUNC_EXT", SWIG_From_int((int)(0x81B6)));
}
{
PyDict_SetItemString(d,"GL_INDEX_TEST_REF_EXT", SWIG_From_int((int)(0x81B7)));
}
}
| [
"ronaldoussoren@f55f28a5-9edb-0310-a011-a803cfcd5d25"
] | [
[
[
1,
1843
]
]
] |
b0775d4572cefc1bb2eb3b0adc2c327f21da0cea | ee44b7f80be6bddad3e337991acccdac4dc7b8a7 | /MVAnalyzer/MVAnalyzer.h | 16b8bedc3b95d02e94d376d3170e87ebdb123b44 | [] | no_license | vuduykhuong1412/mv-analyzer | d97a11e71a7189dac6414fea369eaa773e7789fa | 3eb424bd8ee5938453dc342944ec3ec8af9bb3e7 | refs/heads/master | 2021-01-10T01:28:22.124681 | 2009-05-27T16:08:00 | 2009-05-27T16:08:00 | 48,032,634 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,368 | h | // MVAnalyzer.h : main header file for the MVANALYZER application
//
#if !defined(AFX_MVANALYZER_H__0CACBD6F_9644_4E0E_8513_89AC5774453B__INCLUDED_)
#define AFX_MVANALYZER_H__0CACBD6F_9644_4E0E_8513_89AC5774453B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CMVAnalyzerApp:
// See MVAnalyzer.cpp for the implementation of this class
//
class CMVAnalyzerApp : public CWinApp
{
public:
CMVAnalyzerApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMVAnalyzerApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CMVAnalyzerApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MVANALYZER_H__0CACBD6F_9644_4E0E_8513_89AC5774453B__INCLUDED_)
| [
"taopin@727d0554-1d2d-11de-b56b-c9554f25afe1"
] | [
[
[
1,
49
]
]
] |
62ab8ac9e727b001eee8630f44e7c33fbc9d0b44 | fd792229322e4042f6e88a01144665cebdb1c339 | /src/networkPacket.h | a5597c94a885ec8244e351d74b0413e86ab7a46b | [] | no_license | weimingtom/mmomm | 228d70d9d68834fa2470d2cd0719b9cd60f8dbcd | cab04fcad551f7f68f99fa0b6bb14cec3b962023 | refs/heads/master | 2021-01-10T02:14:31.896834 | 2010-03-15T16:15:43 | 2010-03-15T16:15:43 | 44,764,408 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,421 | h | #ifndef NETWORK_PACKET_H_
#define NETWORK_PACKET_H_
#include "frameTimer.h"
#include "serializationException.h"
#include "vector2D.h"
#include <RakNet/BitStream.h>
#include <RakNet/NativeTypes.h>
#include <RakNet/RakNetTypes.h>
#include <RakNet/RakPeerInterface.h>
#include <boost/foreach.hpp>
#include <string>
#include <vector>
#include <typeinfo>
using RakNet::BitStream;
class User;
// Parameters for a network packet.
// See similarly-named NetworkPacket functions.
struct NetworkParams {
NetworkParams(uint8_t kind,
PacketPriority priority=LOW_PRIORITY,
PacketReliability reliability=RELIABLE_ORDERED,
char orderingChannel=0,
bool useTimestamp=false):
kind(kind), priority(priority), reliability(reliability),
orderingChannel(orderingChannel), useTimestamp(useTimestamp)
{
}
uint8_t kind;
PacketPriority priority;
PacketReliability reliability;
char orderingChannel;
bool useTimestamp;
};
// Base class for a packet of network data from the other side.
class NetworkPacket {
public:
// Does basic initialization.
NetworkPacket();
virtual ~NetworkPacket() { }
// Copies the given raw packet into this structure.
void read(const Packet *packet, User *user = 0);
// Copies this structure into the given (empty) bitstream.
void write(BitStream& bs) const;
// The kind of packet this is.
uint8_t kind() const { return params().kind; }
// What priority to send this packet at.
// Defaults to LOW_PRIORITY.
PacketPriority priority() const { return params().priority; }
// What reliability to send this packet with.
// Defaults to RELIABLE_ORDERED.
PacketReliability reliability() const { return params().reliability; }
// Which ordering channel to ship this packet on.
// 0 to 31; separate sets of channels for ORDERED and SEQUENCED
// Defaults to 0.
char orderingChannel() const { return params().orderingChannel; }
// Whether or not to include a timestamp.
// Defaults to false.
bool useTimestamp() const { return params().useTimestamp; }
// The timestamp on this packet (only available upon receipt).
// Should only be available if useTimestamp.
double timestamp() const { assert(useTimestamp()); return FrameTimer::fromTimestamp(_timestamp); }
// The system address of the sender (only available upon receipt).
// Server only!
User& sender() const { assert(_sender); return *_sender; }
// Specify the parameters to use for sending this packet.
virtual NetworkParams params() const = 0;
// Serialize or deserialize data from the specific packet type.
// bs: the stream used to serialize the data
// write: true means to write to the bitstream, false means to read from it
virtual void serialize(BitStream& bs, bool write) { (void)bs; (void)write; }
// Respond to this packet being received.
// Implementation is different between client and server.
// HACK: Use macro to avoid errors for not defining one or the other.
#ifdef MMOMM_CLIENT
virtual void respondClient() const
{
INVALID_PACKET_EXCEPTION(
"Received unexpected packet on client of type " <<
typeid(this).name() << ".");
}
#else
virtual void respondServer() const
{
INVALID_PACKET_EXCEPTION(
"Received unexpected packet on server of type " <<
typeid(this).name() << ".");
}
#endif
private:
RakNetTime _timestamp;
User *_sender;
};
#endif
| [
"[email protected]",
"grandfunkdynasty@191a6260-07ae-11df-8636-19de83dc8dca",
"kingoipo@191a6260-07ae-11df-8636-19de83dc8dca"
] | [
[
[
1,
12
],
[
15,
21
],
[
23,
31
],
[
33,
42
],
[
44,
46
],
[
48,
49
],
[
51,
52
],
[
54,
55
],
[
57,
63
],
[
65,
68
],
[
70,
72
],
[
74,
76
],
[
78,
80
],
[
82,
88
],
[
90,
92
],
[
94,
114
]
],
[
[
13,
13
]
],
[
[
14,
14
],
[
22,
22
],
[
32,
32
],
[
43,
43
],
[
47,
47
],
[
50,
50
],
[
53,
53
],
[
56,
56
],
[
64,
64
],
[
69,
69
],
[
73,
73
],
[
77,
77
],
[
81,
81
],
[
89,
89
],
[
93,
93
]
]
] |
eee974b02133abd31285961c696484ffcddb018e | 28a5dacf5e1a5a2d0d3fdf89bdc12a88dd897f86 | /AttendanceDlg.cpp | b44cb6fe6c9de529c0a25191dfd25699d7e96c76 | [] | no_license | yogengg6/fp_attendance | 3f4cababbe33d03e519341a6312015e5cb365a63 | 574338e53717ff2fbc62c57f14fa749a3a84a53a | refs/heads/master | 2020-04-07T20:02:06.843808 | 2011-07-20T13:09:12 | 2011-07-20T13:09:12 | 158,672,408 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 9,020 | cpp | /**
* Project Name : FP_Attendance
* description : a fingerprint based attendance(work with moodle attendanc
* e module)
* Copyleft : This program is published under GPL
* Author : Yusuke([email protected])
* Author : Bojue([email protected])
* Date : 2011-5-29 20:29
*/
#include "stdafx.h"
#include <dpDefs.h>
#include <dpRcodes.h>
#include <DPDevClt.h>
#include <dpFtrEx.h>
#include <dpMatch.h>
#include "ultility.h"
#include "FP_Attendance.h"
#include "AttendanceDlg.h"
#include "mdldb/userinfo.h"
#include "mdldb/exception.h"
// CAttendanceDlg 对话框
using namespace mdldb;
IMPLEMENT_DYNAMIC(CAttendanceDlg, CDialog)
CAttendanceDlg::CAttendanceDlg(mdldb::Mdldb& mdl, CWnd* pParent /*=NULL*/)
: CDialog(CAttendanceDlg::IDD, pParent),
m_hOperationVerify(0),
m_fxContext(0), m_mcContext(0),
m_mdl(mdl),
m_notify(NULL)
{
}
void CAttendanceDlg::TerminateFpDevice()
{
delete [] m_RegTemplate.pbData;
m_RegTemplate.cbData = 0;
m_RegTemplate.pbData = NULL;
if (m_hOperationVerify) {
DPFPStopAcquisition(m_hOperationVerify);
DPFPDestroyAcquisition(m_hOperationVerify);
m_hOperationVerify = 0;
}
if (m_fxContext) {
FX_closeContext(m_fxContext);
m_fxContext = 0;
}
if (m_mcContext) {
MC_closeContext(m_mcContext);
m_mcContext = 0;
}
}
void CAttendanceDlg::initFpDevice()
{
ZeroMemory(&m_RegTemplate, sizeof(m_RegTemplate));
if (FT_OK != FX_createContext(&m_fxContext)) {
MessageBox(L"创建特征提取上下文失败。", L"指纹注册", MB_OK | MB_ICONSTOP);
}
if (FT_OK != MC_createContext(&m_mcContext)) {
MessageBox(_T("创建比对上下文失败。"), _T("指纹注册"), MB_OK | MB_ICONSTOP);
}
MC_SETTINGS mcSettings = {0};
if (FT_OK != MC_getSettings(&mcSettings)) {
MessageBox(_T("获取预设置指纹特征集提取次数失败。"), _T("指纹注册"), MB_OK | MB_ICONSTOP);
}
DPFPCreateAcquisition( DP_PRIORITY_NORMAL, GUID_NULL,
DP_SAMPLE_TYPE_IMAGE, m_hWnd,
FP_NOTIFY, &m_hOperationVerify
);
DPFPStartAcquisition(m_hOperationVerify);
}
CAttendanceDlg::~CAttendanceDlg()
{
TerminateFpDevice();
time_t now = time(NULL);
if (now >= m_session.sessdate + m_session.duration) {
vector<AttendInfo>::iterator it= m_studentsToAttendant.begin();
while (it++ != m_studentsToAttendant.end()) {
m_mdl.attendant(m_student_info[it->index].get_idnumber(),
ABSENT,
CStringToString(it->description));
}
}
}
void CAttendanceDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BOOL CAttendanceDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if (!m_mdl.connected())
return FALSE;
m_notify = (CListBox *) GetDlgItem(IDC_ATTENDANT_NOTIFY);
initFpDevice();
try {
m_mdl.get_course_students(m_student_info);
m_session = m_mdl.get_session();
} catch (mdldb::MDLDB_Exception& e) {
MessageBox(CString(e.what()), L"考勤");
}
return TRUE;
}
BEGIN_MESSAGE_MAP(CAttendanceDlg, CDialog)
ON_MESSAGE (FP_NOTIFY, &CAttendanceDlg::OnFpNotify)
ON_BN_CLICKED(ID_EXIT, &CAttendanceDlg::OnBnClickedExit)
ON_BN_CLICKED(ID_BACK, &CAttendanceDlg::OnBnClickedBack)
END_MESSAGE_MAP()
// CAttendanceDlg 消息处理程序
void CAttendanceDlg::OnBnClickedBack()
{
time_t now = time(NULL);
if (now <= m_session.sessdate + m_session.duration) {
if (MessageBox(L"您真的打算后退么?\n如果这样做的话,所有暂存的考勤记录都会失效并消失!", L"考勤", MB_OKCANCEL) == IDOK)
this->EndDialog(ID_BACK);
} else
this->EndDialog(ID_BACK);
}
void CAttendanceDlg::OnBnClickedExit()
{
time_t now = time(NULL);
if (now <= m_session.sessdate + m_session.duration) {
if (MessageBox(L"你真的打算退出么?\n如果这样做的话,所有暂存的考勤记录都会失效并消失!", L"考勤", MB_OKCANCEL) == IDOK)
this->EndDialog(ID_BACK);
} else
this->EndDialog(ID_EXIT);
}
void CAttendanceDlg::AddStatus(LPCTSTR s) {
int lIdx = SendDlgItemMessage(IDC_ATTENDANT_NOTIFY, LB_ADDSTRING, 0, (LPARAM)s);
SendDlgItemMessage(IDC_ATTENDANT_NOTIFY, LB_SETTOPINDEX, lIdx, 0);
}
int CAttendanceDlg::MatchFeatures(DATA_BLOB* const fpImage)
{
if (m_student_info.size() == 0)
return DEVICE_ERROR;
FT_BOOL extractStatus;
HRESULT hr = S_OK;
FT_BYTE* fpTemplate = NULL;
try {
//提取指纹特征集
FT_RETCODE rc = FT_OK;
int iRecommendedVerFtrLen = 0;
rc = FX_getFeaturesLen(FT_VER_FTR, &iRecommendedVerFtrLen, NULL);
if (FT_OK != rc)
return DEVICE_ERROR;
if ((fpTemplate = new FT_BYTE[iRecommendedVerFtrLen]) == NULL)
return DEVICE_ERROR;
FT_IMG_QUALITY imgQuality;
FT_FTR_QUALITY ftrQuality;
rc = FX_extractFeatures(m_fxContext,
fpImage->cbData,
fpImage->pbData,
FT_VER_FTR,
iRecommendedVerFtrLen,
fpTemplate,
&imgQuality,
&ftrQuality,
&extractStatus);
if (FT_OK <= rc && extractStatus == FT_TRUE) {
FT_BOOL bRegFeaturesChanged = FT_FALSE;
FT_BOOL match_result = FT_FALSE;
FT_VER_SCORE VerScore = FT_UNKNOWN_SCORE;
double dFalseAcceptProbability = 0.0;
//使用生成的特征集与数据库指纹模版逐一比较
for (unsigned int i = 0; i < m_student_info.size(); ++i) {
Fpdata fpdata = m_student_info[i].get_fpdata();
if (fpdata.size == 0)
continue;
rc = MC_verifyFeaturesEx(m_mcContext,
fpdata.size,
fpdata.data,
iRecommendedVerFtrLen,
fpTemplate,
0,
&bRegFeaturesChanged,
NULL,
&VerScore,
&dFalseAcceptProbability,
&match_result);
if (rc == FT_OK) {
if (match_result == FT_TRUE) {
delete fpTemplate;
return i;
}
} else {
delete fpTemplate;
return DEVICE_ERROR;
}
}
delete fpTemplate;
return FP_NOT_FOUND;
}
} catch (...) {
throw;
}
return DEVICE_ERROR;
}
int CAttendanceDlg::locateStudentsToAttendant(int index)
{
for (uint i = 0; i < m_studentsToAttendant.size(); ++i) {
if (index == m_studentsToAttendant[i].index)
return i;
}
return -1;
}
int CAttendanceDlg::preAttendant(int index)
{
time_t now = time(NULL);
if (locateStudentsToAttendant(index) != -1)
return ALREADY_PRE_ATTEND;
if (now <= m_session.sessdate) {
AttendInfo attend_info = {index, ATTEND, L""};
m_studentsToAttendant.push_back(attend_info);
return ATTEND;
} else {
CString description;
description.Format(L"迟到%d分钟", (now - m_session.sessdate)/60);
AttendInfo attend_info = {index, LATE, description};
m_studentsToAttendant.push_back(attend_info);
return LATE;
}
}
LRESULT CAttendanceDlg::OnFpNotify(WPARAM wParam, LPARAM lParam) {
switch(wParam) {
case WN_COMPLETED:
{
DATA_BLOB* fpImage = reinterpret_cast<DATA_BLOB*>(lParam);
int index, status;
time_t now = time(NULL);
if ((index = MatchFeatures(fpImage)) >= 0) {
CString idnumber = stringToCString(m_student_info[index].get_idnumber());
CString fullname = stringToCString(m_student_info[index].get_fullname());
SetDlgItemText(IDC_ATTENDANT_IDNUMBER, idnumber);
SetDlgItemText(IDC_ATTENDANT_FULLNAME, fullname);
if (now <= m_session.sessdate + m_session.duration) {
status = preAttendant(index);
CString status_str = L"";
status_str.LoadString(IDS_ATTENDANT_STATUS + status);
SetDlgItemText(IDC_ATTENDANT_STATUS, status_str);
if (status != ALREADY_PRE_ATTEND){
if (status == ATTEND)
AddStatus(fullname + L":请课程结束后再次验证您的信息以完成考勤。");
else
AddStatus(fullname + L":请课程结束后再次验证您的信息以完成考勤。");
}
else
AddStatus(fullname + L":这种玩笑开不得:-)");
} else if (now > m_session.sessdate + m_session.duration) {
int i = locateStudentsToAttendant(index);
if (i != -1) {
m_mdl.attendant(m_student_info[index].get_idnumber(),
m_studentsToAttendant[i].status,
CStringToString(m_studentsToAttendant[i].description));
AddStatus(fullname + L":您的出勤信息已成功记录");
} else
AddStatus(fullname + L":很遗憾,看来你已经旷课了……");
} else
AddStatus(fullname + L":呃,难道你打算旷课么?");
} else {
AddStatus(L"对不起,没有找到指纹相应的数据");
}
break;
}
case WN_ERROR:
{
//lParam记录错误代码
AddStatus(L"发生错误。");
break;
}
case WN_DISCONNECT:
AddStatus(_T("指纹识别仪没有连接或失去连接"));
break;
case WN_RECONNECT:
AddStatus(_T("指纹识别仪已连接"));
break;
default:
break;
}
return S_OK;
}
| [
"yusuke2000@e4a03d97-ca6b-4887-8e5f-4c51e936fd37"
] | [
[
[
1,
327
]
]
] |
178b916ee3c0909c98c76d23eef686dbb6b6c411 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/Shared/VersionMgr.h | 2a4285ccd25cf565579533e0ec98d5c1b8e2744a | [] | no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,471 | h | // ----------------------------------------------------------------------- //
//
// MODULE : VersionMgr.h
//
// PURPOSE : Definition of versioning manager
//
// CREATED : 11/16/2000
//
// (c) 2000 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef __VERSION_MGR_H__
#define __VERSION_MGR_H__
#include "ltbasetypes.h"
#include "regmgr.h"
extern LTGUID GAMEGUID;
extern char const GAME_NAME[];
extern int const GAME_HANDSHAKE_VER_MAJOR;
extern int const GAME_HANDSHAKE_VER_MINOR;
extern int const GAME_HANDSHAKE_VER;
class CVersionMgr
{
public :
CVersionMgr();
virtual ~CVersionMgr() {}
virtual void UpdateCT() {}
virtual const char* GetVersion() = 0;
virtual const char* GetBuild() = 0;
virtual const uint32 GetSaveVersion() = 0;
virtual const char* GetNetGameName() = 0;
virtual const char* GetNetVersion() = 0;
virtual const char* GetNetRegion() { return m_szNetRegion; }
virtual LTGUID const* GetBuildGuid() = 0;
const char* GetLanguage() const { return m_szLanguage; }
//low violence needs to be implemented on clientside only
#ifdef _CLIENTBUILD
inline bool IsLowViolence() const { return m_bLowViolence; }
#endif
CRegMgr* GetRegMgr() { return &m_regMgr; }
typedef uint32 TSaveVersion;
// The SaveVersions should be set to the build number of the released version. The CurrentBuild
// should always be set to the curent development build number. The latest save version should also
// equal the CurrentBuild.
static const TSaveVersion kSaveVersion__1_1;
static const TSaveVersion kSaveVersion__1_2;
static const TSaveVersion kSaveVersion__1_3;
private:
static const TSaveVersion kSaveVersion__CurrentBuild;
public:
void SetCurrentSaveVersion( TSaveVersion nCurrentSaveVersion ) { m_nCurrentSaveVersion = nCurrentSaveVersion; }
TSaveVersion GetCurrentSaveVersion( ) const;
void SetLGFlags( uint8 nLGFlags ) { m_nLastLGFlags = nLGFlags; }
protected :
CRegMgr m_regMgr;
char m_szLanguage[64];
char m_szNetRegion[64];
bool m_bLowViolence;
// This is the save version of the currently loading save game.
// This number is only valid during a ILTServer::RestoreObjects call.
TSaveVersion m_nCurrentSaveVersion;
uint8 m_nLastLGFlags;
};
extern CVersionMgr* g_pVersionMgr;
#endif __VERSION_MGR_H__ | [
"[email protected]"
] | [
[
[
1,
88
]
]
] |
34638eaf704bc0a7bbf1e98fbb662ca1c6538228 | 854ee643a4e4d0b7a202fce237ee76b6930315ec | /arcemu_svn/src/arcemu-world/HonorHandler.h | 517e53fb8fcb16db68919c843f3196371bcbede7 | [] | no_license | miklasiak/projekt | df37fa82cf2d4a91c2073f41609bec8b2f23cf66 | 064402da950555bf88609e98b7256d4dc0af248a | refs/heads/master | 2021-01-01T19:29:49.778109 | 2008-11-10T17:14:14 | 2008-11-10T17:14:14 | 34,016,391 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,189 | h | /*
* ArcEmu MMORPG Server
* Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/>
* Copyright (C) 2008 <http://www.ArcEmu.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef HONORHANDLER_H
#define HONORHANDLER_H
class HonorHandler
{
public:
static int32 CalculateHonorPointsForKill(Player *pPlayer, Unit* pVictim);
static void RecalculateHonorFields(Player *pPlayer);
static void AddHonorPointsToPlayer(Player *pPlayer, uint32 uAmount);
static void OnPlayerKilledUnit(Player *pPlayer, Unit* pVictim);
};
#endif
| [
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef",
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef"
] | [
[
[
1,
1
],
[
5,
34
]
],
[
[
2,
4
]
]
] |
87fa13cfd19001c5b1401994900479c154bc18bc | 516b78edbad95d6fb76b6a51c5353eaeb81b56d6 | /engine2/src/renderer/Renderer.h | daf3985e5e0ccf64dfc92dc2d089352e9851f6da | [] | no_license | BackupTheBerlios/lutaprakct | 73d9fb2898e0a1a019d8ea7870774dd68778793e | fee62fa093fa560e51a26598619b97926ea9cb6b | refs/heads/master | 2021-01-18T14:05:20.313781 | 2008-06-16T21:51:13 | 2008-06-16T21:51:13 | 40,252,766 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,147 | h | #ifndef RENDERER_H_
#define RENDERER_H_
#include <SDL/SDL.h>
#include "../events/eventhandler.h"
#include "../util/Singleton.h"
#include "../util/VideoConfig.h"
class Renderer : public EventHandler{
public:
enum{
FULLSCREEN = 1 << 7,
RESIZABLE = 1 << 10,
NOFRAME = 1 << 11,
};
Renderer();
~Renderer();
bool initialize(VideoConfig& config);
int initializeOpenGl();
int initializeSdl(VideoConfig& config);
void update();
void stop();
void handleEvent(const event &e);
unsigned int initializeVBO(unsigned int size, const void* data);
void killVBO(unsigned int vboID);
void drawVBO(unsigned int vertexID, unsigned int normalID,const unsigned int indicesID,
unsigned int trianglesCount);
private:
int screenShotNumber;
void draw();
void beginDraw();
void endDraw();
void setupViewMatrix();
void setupProjectionMatrix();
SDL_Surface *screen;
int height, width, bpp, flags;
float clearcolor[4];
float znear, zfar, fovy;
};
typedef Singleton<Renderer> RENDERER;
#endif /*RENDERER_H_*/
| [
"gha"
] | [
[
[
1,
55
]
]
] |
ded1fca0dcee4646ce87e098d538fa32a8d4e6fa | 368acbbc055ee3a84dd9ce30777ae3bbcecec610 | /project/jni/third_party/fcollada/FCollada_FREE_3.05B/FCollada/FColladaTest/FCTestExportImport/FCTEIExtra.cpp | 3a24ccad5c578853955af2d39ae27307834854f0 | [
"MIT",
"LicenseRef-scancode-x11-xconsortium-veillard"
] | permissive | jcayzac/androido3d | 298559ebbe657482afe6b3b616561a1127320388 | 18e0a4cd4799b06543588cf7bea33f12500fb355 | HEAD | 2016-09-06T06:31:09.984535 | 2011-09-17T09:47:51 | 2011-09-17T09:47:51 | 1,816,466 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,514 | cpp | /*
Copyright (C) 2005-2007 Feeling Software Inc.
Portions of the code are:
Copyright (C) 2005-2007 Sony Computer Entertainment America
MIT License: http://www.opensource.org/licenses/mit-license.php
*/
#include "StdAfx.h"
#include "FCDocument/FCDExtra.h"
#include "FCTestExportImport.h"
namespace FCTestExportImport
{
static const char* szTestName = "FCTestExportImportExtra";
bool FillExtraTree(FULogFile& fileOut, FCDExtra* extra, bool hasTypes)
{
FailIf(extra == NULL);
// Add a test technique.
PassIf(extra->GetDefaultType()->GetTechniqueCount() == 0);
FCDETechnique* technique1 = extra->GetDefaultType()->AddTechnique("FCTEI_TestProfile");
FCDETechnique* technique2 = extra->GetDefaultType()->AddTechnique("FCTEI_TestProfile");
FailIf(technique1 == NULL);
FailIf(technique2 == NULL);
PassIf(technique1 == technique2);
PassIf(extra->GetDefaultType()->GetTechniqueCount() == 1);
// Add a parent parameter to the technique and two subsequent parameters with the same name.
FCDENode* parameterTree = technique1->AddChildNode();
parameterTree->SetName("MainParameterTree");
FCDENode* firstParameter = parameterTree->AddChildNode();
firstParameter->SetName("SomeParameter");
firstParameter->SetContent(FS("Test_SomeParameter"));
firstParameter->AddAttribute("Guts", 0);
FCDENode* secondParameter = parameterTree->AddChildNode();
secondParameter->SetName("SomeParameter");
secondParameter->AddAttribute("Guts", 3);
secondParameter->SetContent(FS("Test_ThatParameter!"));
PassIf(parameterTree->GetChildNodeCount() == 2);
// Add some attributes to the parameter tree
parameterTree->AddAttribute("Vicious", FC("Squirrel"));
parameterTree->AddAttribute("Gross", 1002);
if (hasTypes)
{
// Add a second extra type
// Empty named-types should be supported.
FCDEType* secondType = extra->AddType("verificator");
PassIf(secondType != NULL);
PassIf(secondType != extra->GetDefaultType());
PassIf(secondType->GetTechniqueCount() == 0);
}
return true;
}
bool CheckExtraTree(FULogFile& fileOut, FCDExtra* extra, bool hasTypes)
{
FailIf(extra == NULL);
// Find and verify the one technique
FailIf(extra->GetDefaultType()->GetTechniqueCount() < 1); // note that FCDLight adds some <extra> elements of its own.
FCDETechnique* technique = extra->GetDefaultType()->FindTechnique("FCTEI_TestProfile");
FailIf(technique == NULL);
// Find and verify the base parameter tree node
FailIf(technique->GetChildNodeCount() != 1);
FCDENode* baseNode = technique->GetChildNode(0);
PassIf(baseNode != NULL);
PassIf(extra->GetDefaultType()->FindRootNode("MainParameterTree") == baseNode);
// Verify the base node attributes
PassIf(baseNode->GetAttributeCount() == 2);
FCDEAttribute* a1 = baseNode->FindAttribute("Vicious");
FCDEAttribute* a2 = baseNode->FindAttribute("Gross");
FailIf(a1 == NULL);
FailIf(a2 == NULL);
FailIf(a1 == a2);
PassIf(IsEquivalent(a1->GetValue(), FC("Squirrel")));
PassIf(IsEquivalent(FUStringConversion::ToUInt32(a2->GetValue()), 1002));
// Identify the base node leaves
PassIf(baseNode->GetChildNodeCount() == 2);
FCDENode* leaf0 = NULL,* leaf3 = NULL;
for (size_t i = 0; i < 2; ++i)
{
FCDENode* leaf = baseNode->GetChildNode(i);
PassIf(IsEquivalent(leaf->GetName(), "SomeParameter"));
FCDEAttribute* guts = leaf->FindAttribute("Guts");
FailIf(guts == NULL || guts->GetValue().empty());
uint32 gutsIndex = FUStringConversion::ToUInt32(guts->GetValue());
if (gutsIndex == 0) { FailIf(leaf0 != NULL); leaf0 = leaf; }
else if (gutsIndex == 3) { FailIf(leaf3 != NULL); leaf3 = leaf; }
else Fail;
}
FailIf(leaf0 == NULL || leaf3 == NULL);
// Verify the base node leaves
PassIf(leaf0->GetChildNodeCount() == 0);
PassIf(leaf3->GetChildNodeCount() == 0);
PassIf(leaf0->GetAttributeCount() == 1);
PassIf(leaf3->GetAttributeCount() == 1);
PassIf(IsEquivalent(leaf0->GetContent(), FC("Test_SomeParameter")));
PassIf(IsEquivalent(leaf3->GetContent(), FS("Test_ThatParameter!")));
if (hasTypes)
{
// Verify the second extra type
// Empty named-types should be imported without complaints or merging.
FCDEType* secondType = extra->FindType("verificator");
PassIf(secondType != NULL);
PassIf(secondType != extra->GetDefaultType());
PassIf(secondType->GetTechniqueCount() == 0);
}
return true;
}
}
| [
"[email protected]"
] | [
[
[
1,
120
]
]
] |
f9f50d51a892d3ef812000c174420d43744dc0ab | 3ea33f3b6b61d71216d9e81993a7b6ab0898323b | /src/Network/SharedState.h | dc7e9c6509b06dedd35d05238ad1a9e9ebb96b61 | [] | no_license | drivehappy/tlmp | fd1510f48ffea4020a277f28a1c4525dffb0397e | 223c07c6a6b83e4242a5e8002885e23d0456f649 | refs/heads/master | 2021-01-10T20:45:15.629061 | 2011-07-07T00:43:00 | 2011-07-07T00:43:00 | 32,191,389 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,122 | h | #pragma once
#include "tlapi.h"
using namespace TLAPI;
#include "NetworkEntity.h"
#include "Network.h"
using namespace TLMP::Network;
#include "raknet/include/RakNetTypes.h"
using namespace RakNet;
#include <map>
using std::map;
#include <vector>
using std::vector;
/*
This file contains global variables that store state information used
across both the server and clients.
**/
namespace TLMP {
extern vector<NetworkEntity*>* NetworkSharedEquipment;
extern vector<NetworkEntity*>* NetworkSharedCharacters;
extern vector<NetworkEntity*>* ClientTemporaryEquipment;
extern vector<NetworkEntity*>* ServerEquipmentOnGround;
extern vector<NetworkEntity*>* NetworkSharedLevelItems;
extern map<SystemAddress, vector<NetworkEntity*>*>* Server_ClientCharacterMapping;
extern map<SystemAddress, NetworkEntity*>* Server_ClientUnequipMapping;
extern map<CCharacter*, Vector3>* CharacterNetworkPositionBuffer;
extern map<CCharacter*, u32> *CharacterVisibilityBuffer;
extern vector<CBaseUnit*>* OutsideBaseUnits; // Represents a list of BaseUnits created outside our singleplayer game
extern vector<CCharacter*> *ClientDuplicateCharacters;
extern map<CCharacter*, CCharacter*>* CharacterTargetBuffer;
extern CGameClient* gameClient;
//
// Clear all network ids
void clearAllNetworkIDs();
//
// Handle other characters
static void removeAllNetworkBaseUnits() {
/*
vector<NetworkEntity*>::iterator itr;
vector<CCharacter*>::iterator itr2;
vector<CCharacter*>* minions = gameClient->pCPlayer->GetMinions();
for (itr = NetworkSharedCharacters->begin(); itr != NetworkSharedCharacters->end(); itr++) {
CCharacter *character = (CCharacter *)(*itr)->getInternalObject();
if (character != gameClient->pCPlayer) {
for (itr2 = minions->begin(); itr2 != minions->end(); itr2++) {
if (character != (*itr2)) {
character->Destroy();
}
}
}
}
NetworkSharedCharacters->clear();
*/
vector<CBaseUnit*>::iterator itr;
// Search for an existing address
for (itr = OutsideBaseUnits->begin(); itr != OutsideBaseUnits->end(); itr++) {
CBaseUnit *baseUnit = (*itr);
if (baseUnit) {
baseUnit->Destroy();
}
}
OutsideBaseUnits->clear();
}
//
// Client Temprorary Equipment helpers
static NetworkEntity* searchEquipmentClientByInternalObject(PVOID internalObject) {
vector<NetworkEntity*>::iterator itr;
for (itr = ClientTemporaryEquipment->begin(); itr != ClientTemporaryEquipment->end(); itr++) {
if ((*itr)->getInternalObject() == internalObject) {
return (*itr);
}
}
return NULL;
};
static NetworkEntity* addEquipmentClientTemporary(PVOID equipment) {
NetworkEntity *entity = searchEquipmentClientByInternalObject(equipment);
if (!entity) {
NetworkEntity *newEntity = new NetworkEntity(equipment);
ClientTemporaryEquipment->push_back(newEntity);
return newEntity;
}
return entity;
}
static NetworkEntity* searchEquipmentByClientID(u32 clientId) {
vector<NetworkEntity*>::iterator itr;
for (itr = ClientTemporaryEquipment->begin(); itr != ClientTemporaryEquipment->end(); itr++) {
if ((*itr)->getCommonId() == clientId) {
return (*itr);
}
}
return NULL;
};
static void removeEquipmentByClientID(u32 client_id) {
vector<NetworkEntity*>::iterator itr;
for (itr = ClientTemporaryEquipment->begin(); itr != ClientTemporaryEquipment->end(); itr++) {
if ((*itr)->getCommonId() == client_id) {
ClientTemporaryEquipment->erase(itr);
break;
}
}
}
//
// Item helpers
static NetworkEntity* searchItemByInternalObject(PVOID internalObject) {
vector<NetworkEntity*>::iterator itr;
for (itr = NetworkSharedLevelItems->begin(); itr != NetworkSharedLevelItems->end(); itr++) {
if ((*itr)->getInternalObject() == internalObject) {
return (*itr);
}
}
return NULL;
};
static NetworkEntity* searchItemByCommonID(u32 commondId) {
vector<NetworkEntity*>::iterator itr;
for (itr = NetworkSharedLevelItems->begin(); itr != NetworkSharedLevelItems->end(); itr++) {
if ((*itr)->getCommonId() == commondId) {
return (*itr);
}
}
return NULL;
};
static NetworkEntity* addItem(PVOID equipment) {
NetworkEntity *entity = searchItemByInternalObject(equipment);
if (!entity) {
NetworkEntity *newEntity = new NetworkEntity(equipment);
NetworkSharedLevelItems->push_back(newEntity);
return newEntity;
}
return entity;
}
static NetworkEntity* addItem(PVOID equipment, u32 commonId) {
NetworkEntity *entity = searchItemByCommonID(commonId);
if (!entity) {
NetworkEntity *newEntity = new NetworkEntity(equipment, commonId);
NetworkSharedLevelItems->push_back(newEntity);
return newEntity;
} else {
//log(L"Error: Could not add Item to SharedLevelItems, CommonID of %x already exists!", commonId);
log(L"CommonID Item already exists, replacing %x with entity %p", commonId, ((CItem *)entity->getInternalObject()));
//log(L" Entity name: %s", ((CItem *)entity->getInternalObject())->nameReal.c_str());
entity->SetNewInternalObject(equipment);
}
return entity;
}
static void removeItem(PVOID equipment) {
vector<NetworkEntity *>::iterator itr;
for (itr = NetworkSharedLevelItems->begin(); itr != NetworkSharedLevelItems->end(); ++itr) {
if ((*itr)->getInternalObject() == equipment) {
NetworkSharedLevelItems->erase(itr);
break;
}
}
}
//
// Equipment helpers
static NetworkEntity* searchEquipmentByInternalObject(PVOID internalObject) {
vector<NetworkEntity*>::iterator itr;
for (itr = NetworkSharedEquipment->begin(); itr != NetworkSharedEquipment->end(); itr++) {
if ((*itr)->getInternalObject() == internalObject) {
return (*itr);
}
}
return NULL;
};
static NetworkEntity* searchEquipmentByCommonID(u32 commondId) {
vector<NetworkEntity*>::iterator itr;
for (itr = NetworkSharedEquipment->begin(); itr != NetworkSharedEquipment->end(); itr++) {
if ((*itr)->getCommonId() == commondId) {
return (*itr);
}
}
return NULL;
};
static NetworkEntity* addEquipment(PVOID equipment) {
NetworkEntity *entity = searchEquipmentByInternalObject(equipment);
if (!entity) {
NetworkEntity *newEntity = new NetworkEntity(equipment);
NetworkSharedEquipment->push_back(newEntity);
return newEntity;
}
return entity;
}
static NetworkEntity* addEquipment(PVOID equipment, u32 commonId) {
NetworkEntity *entity = searchEquipmentByInternalObject(equipment);
if (!entity) {
NetworkEntity *newEntity = new NetworkEntity(equipment, commonId);
NetworkSharedEquipment->push_back(newEntity);
return newEntity;
}
return entity;
}
static void removeEquipment(PVOID equipment) {
vector<NetworkEntity *>::iterator itr;
for (itr = NetworkSharedEquipment->begin(); itr != NetworkSharedEquipment->end(); ++itr) {
if ((*itr)->getInternalObject() == equipment) {
NetworkSharedEquipment->erase(itr);
break;
}
}
}
//
// Character helpers
static NetworkEntity* searchCharacterByInternalObject(PVOID internalObject) {
vector<NetworkEntity*>::iterator itr;
for (itr = NetworkSharedCharacters->begin(); itr != NetworkSharedCharacters->end(); itr++) {
if ((*itr)->getInternalObject() == internalObject) {
return (*itr);
}
}
return NULL;
};
static NetworkEntity* searchCharacterByCommonID(u32 commondId) {
vector<NetworkEntity*>::iterator itr;
for (itr = NetworkSharedCharacters->begin(); itr != NetworkSharedCharacters->end(); itr++) {
if ((*itr)->getCommonId() == commondId) {
return (*itr);
}
}
return NULL;
};
// Create a network ID to identify this character later
static NetworkEntity* addCharacter(PVOID character) {
NetworkEntity *entity = searchCharacterByInternalObject(character);
if (!entity) {
NetworkEntity *newEntity = new NetworkEntity(character);
NetworkSharedCharacters->push_back(newEntity);
return newEntity;
}
return entity;
}
// Create a network ID to identify this character later
static NetworkEntity* addCharacter(PVOID character, u32 commonId) {
NetworkEntity *entity = searchCharacterByInternalObject(character);
if (!entity) {
NetworkEntity *newEntity = new NetworkEntity(character, commonId);
NetworkSharedCharacters->push_back(newEntity);
return newEntity;
}
return entity;
}
};
| [
"drivehappy@7af81de8-dd64-11de-95c9-073ad895b44c"
] | [
[
[
1,
305
]
]
] |
f932b503b9f4d86c3c7ba6a410c696e06e881af8 | 9361e066ce2779086228bdd02a41247548782a48 | /include/Node.h | cd017081901e207ef564cd5aaaaa23344a6a7c11 | [] | no_license | VLambret/libASM | 49a58bd27a2adc2f7091d0adf7d55891d2ab26de | e1ac0f54bdf9b9965744e006bd08f8c7a3001368 | refs/heads/master | 2020-05-31T07:49:46.695631 | 2011-09-08T12:19:40 | 2011-09-08T12:19:40 | 1,495,313 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 710 | h | #ifndef _Node_H
#define _Node_H
/** \file Node.h
\brief Node class
\author Hajjem
*/
#include <Line.h>
#include <string>
#include <Enum_type.h>
using namespace std;
/** \class Node
\brief class representing a Node in list
*/
class Node{
public:
/** \brief Node constructor
*/
Node(Line * content);
/** \brief Node destructor
*/
~Node();
/** \brief get the next node
*/
Node * get_next();
/** \brief set the next node
*/
void set_next(Node * newsuccessor);
/** \brief get the currently line
*/
Line * get_line();
/** \brief set the currently line
*/
void set_line(Line * newline);
private:
Node * _next;
Line * _content;
};
#endif
| [
"teddy@teddy-1000he.(none)",
"hajjem@hajjem-laptop.(none)",
"[email protected]"
] | [
[
[
1,
6
],
[
15,
15
]
],
[
[
7,
14
],
[
17,
22
],
[
24,
26
],
[
28,
30
],
[
32,
34
],
[
36,
38
],
[
40,
42
],
[
44,
53
]
],
[
[
16,
16
],
[
23,
23
],
[
27,
27
],
[
31,
31
],
[
35,
35
],
[
39,
39
],
[
43,
43
]
]
] |
cc3e626c9957a78c3597da963ab6a84a2c2d49bc | 1599a23c594b6d9d19ecaef701d9aafdce17a7a3 | /source/plimdp/computer/simple.cpp | 7c8563bfde58a5b6a19863bf9e8005e9b6ebbe25 | [] | no_license | pavelkryukov/plimdp-plus | 6c5a201cc8df2c7a1754320e7305040051d81441 | 953b378f771d22b3a52186e67c1d7eb74b10c71c | refs/heads/master | 2020-05-15T12:31:16.861244 | 2011-11-17T16:41:19 | 2011-11-17T16:41:19 | 32,184,827 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 829 | cpp | /*
* simple.cpp
*
* PlimDP+ simple computer
*
* Copyright 2009 (C) Boris Belousov
* Copyright 2011 (C) Pavel Kryukov (remastering)
*/
#include "./simple.h"
#include <plimdp/cpu/core.h>
#include <plimdp/devices/memory.h>
#include <plimdp/devices/loader.h>
namespace PlimDP {
namespace Computer {
Simple::Simple() {
core = new PlimDP::CPU::Core();
mem = new PlimDP::Devices::Memory<64 * K>();
loader = new PlimDP::Devices::Loader();
io = new PlimDP::Devices::IO();
core->setMemory(mem);
core->setIO(io);
loader->setMemory(mem);
}
Simple::~Simple() {
delete core;
delete mem;
delete loader;
delete io;
}
void Simple::load(const std::string & file) {
loader->load(file);
}
void Simple::start() {
core->start();
}
}
} | [
"[email protected]"
] | [
[
[
1,
45
]
]
] |
9f71252890e5993c41e0085ba4efe35953c81c53 | 91ac219c4cde8c08a6b23ac3d207c1b21124b627 | /common/interleaver/BlockInterleaver.cpp | 2f5cc2e74244d28422e409760d397b505a077a0b | [] | no_license | DazDSP/hamdrm-dll | e41b78d5f5efb34f44eb3f0c366d7c1368acdbac | 287da5949fd927e1d3993706204fe4392c35b351 | refs/heads/master | 2023-04-03T16:21:12.206998 | 2008-01-05T19:48:59 | 2008-01-05T19:48:59 | 354,168,520 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,493 | cpp | /******************************************************************************\
* Technische Universitaet Darmstadt, Institut fuer Nachrichtentechnik
* Copyright (c) 2001
*
* Author(s):
* Volker Fischer
*
* Description:
*
******************************************************************************
*
* 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 the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
#include "BlockInterleaver.h"
/* Implementation *************************************************************/
/******************************************************************************\
* Block-interleaver base class *
\******************************************************************************/
void CBlockInterleaver::MakeTable(CVector<int>& veciIntTable, int iFrameSize,
int it_0)
{
int i;
int iHighestOne;
int is, iq;
/* The following equations are taken directly from the DRM-standard paper
(7.3.3 and 7.6) */
iHighestOne = iFrameSize;
/* s = 2 ^ ceil(log2(iFrameSize)), means: find the highest "1" of
iFrameSize. The result of the equation is only one "1" at position
"highest position of "1" in iFrameSize plus one". Therefore:
"1 << (16 + 1)".
This implementation: shift bits in iHighestOne to the left until a
"1" reaches position 16. Simultaneously the bit in "is" is
right-shifted */
is = 1 << (16 + 1);
while (!(iHighestOne & (1 << 16)))
{
iHighestOne <<= 1;
is >>= 1;
}
iq = is / 4 - 1;
veciIntTable[0] = 0;
for (i = 1; i < iFrameSize; i++)
{
veciIntTable[i] = (it_0 * veciIntTable[i - 1] + iq) % is;
while (veciIntTable[i] >= iFrameSize)
veciIntTable[i] = (it_0 * veciIntTable[i] + iq) % is;
}
}
| [
"[email protected]"
] | [
[
[
1,
69
]
]
] |
cb82da6e04689839030445bab653d8c8e398e16a | 28b097d96e87de603d75faf24e56394ac16d239f | /logger/myIDDrawSurface1.cpp | d8dc224251ed96fd5a0673a30c1267c24147011c | [] | no_license | RazorbladeByte/ddhack | ecfe5845c24110daf5a89d6937612f5243bc9883 | b564e26ad89e112426a0c08e12040eef130bf826 | refs/heads/master | 2016-09-11T02:41:34.702359 | 2011-08-17T13:58:14 | 2011-08-17T13:58:14 | 2,220,900 | 9 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 9,041 | cpp | #include "StdAfx.h"
#include <varargs.h>
myIDDrawSurface1::myIDDrawSurface1(LPDIRECTDRAWSURFACE pOriginal)
{
logf(this, "myIDDrawSurface1 Constructor");
m_pIDDrawSurface = pOriginal;
}
myIDDrawSurface1::~myIDDrawSurface1(void)
{
logf(this, "myIDDrawSurface1 Destructor");
}
HRESULT __stdcall myIDDrawSurface1::QueryInterface (REFIID, LPVOID FAR * b)
{
logf(this, "myIDDrawSurface1::QueryInterface");
*b = NULL;
return E_NOTIMPL;
}
ULONG __stdcall myIDDrawSurface1::AddRef(void)
{
logf(this, "myIDDrawSurface1::AddRef");
return(m_pIDDrawSurface->AddRef());
}
ULONG __stdcall myIDDrawSurface1::Release(void)
{
logf(this, "myIDDrawSurface1::Release");
// call original routine
ULONG count = m_pIDDrawSurface->Release();
logf(this, "Object Release.");
// in case no further Ref is there, the Original Object has deleted itself
// so do we here
if (count == 0)
{
m_pIDDrawSurface = NULL;
delete(this);
}
return(count);
}
HRESULT __stdcall myIDDrawSurface1::AddAttachedSurface(LPDIRECTDRAWSURFACE a)
{
logf(this, "myIDDrawSurface1::AddAttachedSurface");
return m_pIDDrawSurface->AddAttachedSurface(((myIDDrawSurface1*)a)->m_pIDDrawSurface);
}
HRESULT __stdcall myIDDrawSurface1::AddOverlayDirtyRect(LPRECT a)
{
logf(this, "myIDDrawSurface1::AddOverlayDirtyRect");
return m_pIDDrawSurface->AddOverlayDirtyRect(a);
}
HRESULT __stdcall myIDDrawSurface1::Blt(LPRECT a,LPDIRECTDRAWSURFACE b, LPRECT c,DWORD d, LPDDBLTFX e)
{
if (a && c)
logf(this, "myIDDrawSurface1::Blt([%d,%d,%d,%d],%08x,[%d,%d,%d,%d],%d,%08x)",
a->top,a->left,a->bottom,a->right,
b,
c->top,c->left,c->bottom,c->right,
d,
e->dwDDFX);
else
if (a)
logf(this, "myIDDrawSurface1::Blt([%d,%d,%d,%d],%08x,[null],%d,%08x)",
a->top,a->left,a->bottom,a->right,
b,
d,
e->dwDDFX);
else
if (c)
logf(this, "myIDDrawSurface1::Blt([null],%08x,[%d,%d,%d,%d],%d,%08x)",
b,
c->top,c->left,c->bottom,c->right,
d,
e->dwDDFX);
else
logf(this, "myIDDrawSurface1::Blt([null],%08x,[null],%d,%08x)",
b,
d,
e->dwDDFX);
if (b) b = ((myIDDrawSurface1*)b)->m_pIDDrawSurface;
return m_pIDDrawSurface->Blt(a,b,c,d,e);
}
HRESULT __stdcall myIDDrawSurface1::BltBatch(LPDDBLTBATCH a, DWORD b, DWORD c)
{
logf(this, "myIDDrawSurface1::BltBatch");
return m_pIDDrawSurface->BltBatch(a,b,c);
}
HRESULT __stdcall myIDDrawSurface1::BltFast(DWORD a,DWORD b,LPDIRECTDRAWSURFACE c, LPRECT d,DWORD e)
{
logf(this, "myIDDrawSurface1::BltFast");
return m_pIDDrawSurface->BltFast(a,b,((myIDDrawSurface1*)c)->m_pIDDrawSurface,d,e);
}
HRESULT __stdcall myIDDrawSurface1::DeleteAttachedSurface(DWORD a,LPDIRECTDRAWSURFACE b)
{
logf(this, "myIDDrawSurface1::DeleteAttachedSurface");
return m_pIDDrawSurface->DeleteAttachedSurface(a,((myIDDrawSurface1*)b)->m_pIDDrawSurface);
}
HRESULT __stdcall myIDDrawSurface1::EnumAttachedSurfaces(LPVOID a,LPDDENUMSURFACESCALLBACK b)
{
logf(this, "myIDDrawSurface1::EnumAttachedSurfaces");
return m_pIDDrawSurface->EnumAttachedSurfaces(a,b);
}
HRESULT __stdcall myIDDrawSurface1::EnumOverlayZOrders(DWORD a,LPVOID b,LPDDENUMSURFACESCALLBACK c)
{
logf(this, "myIDDrawSurface1::EnumOverlayZOrders");
return m_pIDDrawSurface->EnumOverlayZOrders(a,b,c);
}
HRESULT __stdcall myIDDrawSurface1::Flip(LPDIRECTDRAWSURFACE a, DWORD b)
{
logf(this, "myIDDrawSurface1::Flip(%08x,%d)", a, b);
if (a) a = ((myIDDrawSurface1*)a)->m_pIDDrawSurface;
return m_pIDDrawSurface->Flip(a,b);
}
HRESULT __stdcall myIDDrawSurface1::GetAttachedSurface(LPDDSCAPS a, LPDIRECTDRAWSURFACE FAR * b)
{
HRESULT r = m_pIDDrawSurface->GetAttachedSurface(a,b);
*b = new myIDDrawSurface1(*b);
logf(this, "myIDDrawSurface1::GetAttachedSurface([%d], %08x) return %d",
a->dwCaps, b, r);
return r;
}
HRESULT __stdcall myIDDrawSurface1::GetBltStatus(DWORD a)
{
logf(this, "myIDDrawSurface1::GetBltStatus");
return m_pIDDrawSurface->GetBltStatus(a);
}
HRESULT __stdcall myIDDrawSurface1::GetCaps(LPDDSCAPS a)
{
logf(this, "myIDDrawSurface1::GetCaps");
return m_pIDDrawSurface->GetCaps(a);
}
HRESULT __stdcall myIDDrawSurface1::GetClipper(LPDIRECTDRAWCLIPPER FAR* a)
{
logf(this, "myIDDrawSurface1::GetClipper");
return m_pIDDrawSurface->GetClipper(a);
}
HRESULT __stdcall myIDDrawSurface1::GetColorKey(DWORD a, LPDDCOLORKEY b)
{
logf(this, "myIDDrawSurface1::GetColorKey");
return m_pIDDrawSurface->GetColorKey(a,b);
}
HRESULT __stdcall myIDDrawSurface1::GetDC(HDC FAR *a)
{
logf(this, "myIDDrawSurface1::GetDC");
return m_pIDDrawSurface->GetDC(a);
}
HRESULT __stdcall myIDDrawSurface1::GetFlipStatus(DWORD a)
{
logf(this, "myIDDrawSurface1::GetFlipStatus");
return m_pIDDrawSurface->GetFlipStatus(a);
}
HRESULT __stdcall myIDDrawSurface1::GetOverlayPosition(LPLONG a, LPLONG b)
{
logf(this, "myIDDrawSurface1::GetOverlayPosition");
return m_pIDDrawSurface->GetOverlayPosition(a,b);
}
HRESULT __stdcall myIDDrawSurface1::GetPalette(LPDIRECTDRAWPALETTE FAR*a)
{
logf(this, "myIDDrawSurface1::GetPalette");
return m_pIDDrawSurface->GetPalette(a);
}
HRESULT __stdcall myIDDrawSurface1::GetPixelFormat(LPDDPIXELFORMAT a)
{
logf(this, "myIDDrawSurface1::GetPixelFormat");
return m_pIDDrawSurface->GetPixelFormat(a);
}
HRESULT __stdcall myIDDrawSurface1::GetSurfaceDesc(LPDDSURFACEDESC a)
{
HRESULT r = m_pIDDrawSurface->GetSurfaceDesc(a);
logf(this, "myIDDrawSurface1::GetSurfaceDesc([%x %x %x %x %x %x %x %x %x [%x %x %x %x %x %x %x %x] %x]) return %d",
a->dwSize,
a->dwFlags,
a->dwWidth,
a->dwHeight,
a->lPitch,
a->dwBackBufferCount,
a->dwRefreshRate,
a->dwAlphaBitDepth,
a->lpSurface,
a->ddpfPixelFormat.dwSize,
a->ddpfPixelFormat.dwFlags,
a->ddpfPixelFormat.dwFourCC,
a->ddpfPixelFormat.dwRGBBitCount,
a->ddpfPixelFormat.dwRBitMask,
a->ddpfPixelFormat.dwGBitMask,
a->ddpfPixelFormat.dwBBitMask,
a->ddpfPixelFormat.dwRGBAlphaBitMask,
a->ddsCaps.dwCaps, r);
return r;
}
HRESULT __stdcall myIDDrawSurface1::Initialize(LPDIRECTDRAW a, LPDDSURFACEDESC b)
{
logf(this, "myIDDrawSurface1::Initialize");
return m_pIDDrawSurface->Initialize(a,b);
}
HRESULT __stdcall myIDDrawSurface1::IsLost()
{
logf(this, "myIDDrawSurface1::IsLost");
return m_pIDDrawSurface->IsLost();
}
HRESULT __stdcall myIDDrawSurface1::Lock(LPRECT a,LPDDSURFACEDESC b,DWORD c,HANDLE d)
{
if (a)
logf(this, "myIDDrawSurface1::Lock([%d,%d,%d,%d],%08x,%d,%d)",a->top,a->left,a->bottom,a->right,b,c,d);
else
logf(this, "myIDDrawSurface1::Lock([null],%08x,%d,%d)",b,c,d);
HRESULT r = m_pIDDrawSurface->Lock(a,b,c,d);
logf(this, "Locked surface data: %d,%d,%d,%d,%d,%08x,%d,%d",
b->dwSize,
b->dwFlags,
b->dwHeight,
b->dwWidth,
b->lPitch,
b->lpSurface,
b->ddsCaps,
b->ddpfPixelFormat);
return r;
}
HRESULT __stdcall myIDDrawSurface1::ReleaseDC(HDC a)
{
logf(this, "myIDDrawSurface1::ReleaseDC");
return m_pIDDrawSurface->ReleaseDC(a);
}
HRESULT __stdcall myIDDrawSurface1::Restore()
{
logf(this, "myIDDrawSurface1::Restore");
return m_pIDDrawSurface->Restore();
}
HRESULT __stdcall myIDDrawSurface1::SetClipper(LPDIRECTDRAWCLIPPER a)
{
logf(this, "myIDDrawSurface1::SetClipper");
return m_pIDDrawSurface->SetClipper(a);
}
HRESULT __stdcall myIDDrawSurface1::SetColorKey(DWORD a, LPDDCOLORKEY b)
{
logf(this, "myIDDrawSurface1::SetColorKey");
return m_pIDDrawSurface->SetColorKey(a,b);
}
HRESULT __stdcall myIDDrawSurface1::SetOverlayPosition(LONG a, LONG b)
{
logf(this, "myIDDrawSurface1::SetOverlayPosition");
return m_pIDDrawSurface->SetOverlayPosition(a,b);
}
HRESULT __stdcall myIDDrawSurface1::SetPalette(LPDIRECTDRAWPALETTE a)
{
logf(this, "myIDDrawSurface1::SetPalette(%08x)",a);
if (a) a = ((myIDDrawPalette*)a)->m_pIDDrawPalette;
return m_pIDDrawSurface->SetPalette(a);
}
HRESULT __stdcall myIDDrawSurface1::Unlock(LPVOID a)
{
logf(this, "myIDDrawSurface1::Unlock(%08x)",a);
return m_pIDDrawSurface->Unlock(a);
}
HRESULT __stdcall myIDDrawSurface1::UpdateOverlay(LPRECT a, LPDIRECTDRAWSURFACE b,LPRECT c,DWORD d, LPDDOVERLAYFX e)
{
logf(this, "myIDDrawSurface1::UpdateOverlay");
return m_pIDDrawSurface->UpdateOverlay(a,((myIDDrawSurface1*)b)->m_pIDDrawSurface,c,d,e);
}
HRESULT __stdcall myIDDrawSurface1::UpdateOverlayDisplay(DWORD a)
{
logf(this, "myIDDrawSurface1::UpdateOverlayDisplay");
return m_pIDDrawSurface->UpdateOverlayDisplay(a);
}
HRESULT __stdcall myIDDrawSurface1::UpdateOverlayZOrder(DWORD a, LPDIRECTDRAWSURFACE b)
{
logf(this, "myIDDrawSurface1::UpdateOverlayZOrder");
return m_pIDDrawSurface->UpdateOverlayZOrder(a,((myIDDrawSurface1*)b)->m_pIDDrawSurface);
}
| [
"[email protected]@ca3b60c3-ba86-2864-2f26-32acf34adade"
] | [
[
[
1,
387
]
]
] |
5e04284686c418ac6080fa338daded9d368cee17 | bd37f7b494990542d0d9d772368239a2d44e3b2d | /client/src/Fantasma.cpp | 9af22cd9c2ad4a657bf892c02105085b1d44c8f5 | [] | no_license | nicosuarez/pacmantaller | b559a61355517383d704f313b8c7648c8674cb4c | 0e0491538ba1f99b4420340238b09ce9a43a3ee5 | refs/heads/master | 2020-12-11T02:11:48.900544 | 2007-12-19T21:49:27 | 2007-12-19T21:49:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,523 | cpp | ///////////////////////////////////////////////////////////
// Fantasma.cpp
// Implementation of the Class Fantasma
// Created on: 21-Nov-2007 23:40:19
///////////////////////////////////////////////////////////
#include "Fantasma.h"
Fantasma::Fantasma(){
this->visible=true;
coord = Coordenada(0.0f, 0.0f, 0.0f);
rotacion = Coordenada(0.0f, -75.0f, 0.0f);
}
Fantasma::Fantasma(Posicion& posicion):Personaje(posicion){
this->visible=true;
coord = Coordenada(0.0f, 0.0f, 0.0f);
rotacion = Coordenada(0.0f, -75.0f, 0.0f);
}
Fantasma::~Fantasma(){
}
/**
* Identificador del rol de personaje
*/
int Fantasma::GetRol()const{
return Fantasma::FANTASMA_TYPE;
}
/**
* Velocidad del personaje
*/
int Fantasma::GetVelocidad(){
return velocidadInicial;
}
/**
* Determina si el fantasma esta en estado invisible que ocurre cuando un pacman
* en estado powerUp como el fantasma. Cuando el mismo se encuentra invisible no
* puede volver entrar en juego hasta que no haya pasado por la casa.
*/
bool Fantasma::IsVisible(){
return visible;
}
/**
* Determina si el fantasma esta en estado invisible que ocurre cuando un pacman
* en estado powerUp como el fantasma. Cuando el mismo se encuentra invisible no
* puede volver entrar en juego hasta que no haya pasado por la casa.
*/
void Fantasma::SetVisible(bool visible){
visible = visible;
}
bool Fantasma::operator==( int tipo )const
{
return tipo == FANTASMA_TYPE;
}
| [
"nicolas.suarez@5682bcf5-5c3f-0410-a8fd-ab24993f6fe8",
"scamjayi@5682bcf5-5c3f-0410-a8fd-ab24993f6fe8",
"rencat@5682bcf5-5c3f-0410-a8fd-ab24993f6fe8"
] | [
[
[
1,
10
],
[
14,
15
],
[
24,
27
],
[
32,
32
],
[
35,
40
],
[
42,
70
]
],
[
[
11,
11
],
[
16,
17
],
[
28,
31
],
[
33,
34
],
[
41,
41
]
],
[
[
12,
13
],
[
18,
23
]
]
] |
bcee3dfb016a1beb02c7acc4f14329d26e7e5a51 | 028d79ad6dd6bb4114891b8f4840ef9f0e9d4a32 | /src/drivers/tp84.cpp | bb5809a33ad4dd78031915f08323c9340f492b33 | [] | no_license | neonichu/iMame4All-for-iPad | 72f56710d2ed7458594838a5152e50c72c2fb67f | 4eb3d4ed2e5ccb5c606fcbcefcb7c5a662ace611 | refs/heads/master | 2020-04-21T07:26:37.595653 | 2011-11-26T12:21:56 | 2011-11-26T12:21:56 | 2,855,022 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,080 | cpp | #include "../vidhrdw/tp84.cpp"
/***************************************************************************
Time Pilot 84 Memory Map (preliminary)
driver by Marc Lafontaine
TODO:
- the slave CPU multiplexes sprites. We are cheating now, and reading them
from somewhere else.
The schematics are available on the net.
There is 3 CPU for this game.
Two 68A09E for the game.
A Z80A for the sound
As I understand it, the second 6809 is for displaying
the sprites. If we do not emulate him, all work well, except
that the player cannot die.
Address 57ff must read 0 to pass the RAM test if the second CPU
is not emulated.
---- Master 6809 ------
Write
2000-27ff MAFR Watch dog ?
2800 COL0 a register that index the colors Proms
3000 reset IRQ
3001 OUT2 Coin Counter 2
3002 OUT1 Coin Counter 1
3003 MUT
3004 HREV
3005 VREV
3006 -
3007 GMED
3800 SON Sound on
3A00 SDA Sound data
3C00 SHF0 SHF1 J2 J3 J4 J5 J6 J7 background Y position
3E00 L0 - L7 background X position
Read:
2800 in0 Buttons 1
2820 in1 Buttons 2
2840 in2 Buttons 3
2860 in3 Dip switches 1
3000 in4 Dip switches 2
3800 in5 Dip switches 3 (not used)
Read/Write
4000-47ff Char ram, 2 pages
4800-4fff Background character ram, 2 pages
5000-57ff Ram (Common for the Master and Slave 6809) 0x5000-0x517f sprites data
6000-ffff Rom (only from $8000 to $ffff is used in this game)
------ Slave 6809 --------
0000-1fff SAFR Watch dog ?
2000 seem to be the beam position (if always 0, no player collision is detected)
4000 enable or reset IRQ
6000-67ff DRA
8000-87ff Ram (Common for the Master and Slave 6809)
E000-ffff Rom
------ Sound CPU (Z80) -----
There are 3 or 4 76489AN chips driven by the Z80
0000-1fff Rom program (A6)
2000-3fff Rom Program (A4) (not used or missing?)
4000-43ff Ram
6000-7fff Sound data in
8000-9fff Timer
A000-Bfff Filters
C000 Store Data that will go to one of the 76489AN
C001 76489 #1 trigger
C002 76489 #2 (optional) trigger
C003 76489 #3 trigger
C004 76489 #4 trigger
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
extern unsigned char *tp84_videoram2;
extern unsigned char *tp84_colorram2;
extern unsigned char *tp84_scrollx;
extern unsigned char *tp84_scrolly;
WRITE_HANDLER( tp84_videoram2_w );
WRITE_HANDLER( tp84_colorram2_w );
WRITE_HANDLER( tp84_col0_w );
void tp84_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
int tp84_vh_start(void);
void tp84_vh_stop(void);
void tp84_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
static unsigned char *sharedram;
static READ_HANDLER( sharedram_r )
{
return sharedram[offset];
}
static WRITE_HANDLER( sharedram_w )
{
sharedram[offset] = data;
}
/* JB 970829 - just give it what it wants
F104: LDX $6400
F107: LDU $6402
F10A: LDA $640B
F10D: BEQ $F13B
F13B: LDX $6404
F13E: LDU $6406
F141: LDA $640C
F144: BEQ $F171
F171: LDA $2000 ; read beam
F174: ADDA #$20
F176: BCC $F104
*/
static READ_HANDLER( tp84_beam_r )
{
// return cpu_getscanline();
return 255; /* always return beam position 255 */ /* JB 970829 */
}
/* JB 970829 - catch a busy loop for CPU 1
E0ED: LDA #$01
E0EF: STA $4000
E0F2: BRA $E0ED
*/
static WRITE_HANDLER( tp84_catchloop_w )
{
if( cpu_get_pc()==0xe0f2 ) cpu_spinuntil_int();
}
static READ_HANDLER( tp84_sh_timer_r )
{
/* main xtal 14.318MHz, divided by 4 to get the CPU clock, further */
/* divided by 2048 to get this timer */
/* (divide by (2048/2), and not 1024, because the CPU cycle counter is */
/* incremented every other state change of the clock) */
return (cpu_gettotalcycles() / (2048/2)) & 0x0f;
}
static WRITE_HANDLER( tp84_filter_w )
{
int C;
/* 76489 #0 */
C = 0;
if (offset & 0x008) C += 47000; /* 47000pF = 0.047uF */
if (offset & 0x010) C += 470000; /* 470000pF = 0.47uF */
set_RC_filter(0,1000,2200,1000,C);
/* 76489 #1 (optional) */
C = 0;
if (offset & 0x020) C += 47000; /* 47000pF = 0.047uF */
if (offset & 0x040) C += 470000; /* 470000pF = 0.47uF */
// set_RC_filter(1,1000,2200,1000,C);
/* 76489 #2 */
C = 0;
if (offset & 0x080) C += 470000; /* 470000pF = 0.47uF */
set_RC_filter(1,1000,2200,1000,C);
/* 76489 #3 */
C = 0;
if (offset & 0x100) C += 470000; /* 470000pF = 0.47uF */
set_RC_filter(2,1000,2200,1000,C);
}
static WRITE_HANDLER( tp84_sh_irqtrigger_w )
{
cpu_cause_interrupt(2,0xff);
}
/* CPU 1 read addresses */
static struct MemoryReadAddress readmem[] =
{
{ 0x2800, 0x2800, input_port_0_r },
{ 0x2820, 0x2820, input_port_1_r },
{ 0x2840, 0x2840, input_port_2_r },
{ 0x2860, 0x2860, input_port_3_r },
{ 0x3000, 0x3000, input_port_4_r },
{ 0x4000, 0x4fff, MRA_RAM },
{ 0x5000, 0x57ff, sharedram_r },
{ 0x8000, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
/* CPU 1 write addresses */
static struct MemoryWriteAddress writemem[] =
{
{ 0x2000, 0x2000, MWA_RAM }, /*Watch dog?*/
{ 0x2800, 0x2800, tp84_col0_w },
{ 0x3000, 0x3000, MWA_RAM },
{ 0x3800, 0x3800, tp84_sh_irqtrigger_w },
{ 0x3a00, 0x3a00, soundlatch_w },
{ 0x3c00, 0x3c00, MWA_RAM, &tp84_scrollx }, /* Y scroll */
{ 0x3e00, 0x3e00, MWA_RAM, &tp84_scrolly }, /* X scroll */
{ 0x4000, 0x43ff, videoram_w, &videoram , &videoram_size},
{ 0x4400, 0x47ff, tp84_videoram2_w, &tp84_videoram2 },
{ 0x4800, 0x4bff, colorram_w, &colorram },
{ 0x4c00, 0x4fff, tp84_colorram2_w, &tp84_colorram2 },
{ 0x5000, 0x57ff, sharedram_w, &sharedram },
{ 0x5000, 0x5177, MWA_RAM, &spriteram, &spriteram_size }, /* FAKE (see below) */
{ 0x8000, 0xffff, MWA_ROM },
{ -1 } /* end of table */
};
/* CPU 2 read addresses */
static struct MemoryReadAddress readmem_cpu2[] =
{
{ 0x0000, 0x0000, MRA_RAM },
{ 0x2000, 0x2000, tp84_beam_r }, /* beam position */
{ 0x6000, 0x67ff, MRA_RAM },
{ 0x8000, 0x87ff, sharedram_r },
{ 0xe000, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
/* CPU 2 write addresses */
static struct MemoryWriteAddress writemem_cpu2[] =
{
{ 0x0000, 0x0000, MWA_RAM }, /* Watch dog ?*/
{ 0x4000, 0x4000, tp84_catchloop_w }, /* IRQ enable */ /* JB 970829 */
{ 0x6000, 0x67ff, MWA_RAM },
// { 0x67a0, 0x67ff, MWA_RAM, &spriteram, &spriteram_size }, /* REAL (multiplexed) */
{ 0x8000, 0x87ff, sharedram_w },
{ 0xe000, 0xffff, MWA_ROM },
{ -1 } /* end of table */
};
static struct MemoryReadAddress sound_readmem[] =
{
{ 0x0000, 0x3fff, MRA_ROM },
{ 0x4000, 0x43ff, MRA_RAM },
{ 0x6000, 0x6000, soundlatch_r },
{ 0x8000, 0x8000, tp84_sh_timer_r },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress sound_writemem[] =
{
{ 0x0000, 0x3fff, MWA_ROM },
{ 0x4000, 0x43ff, MWA_RAM },
{ 0xa000, 0xa1ff, tp84_filter_w },
{ 0xc000, 0xc000, MWA_NOP },
{ 0xc001, 0xc001, SN76496_0_w },
{ 0xc003, 0xc003, SN76496_1_w },
{ 0xc004, 0xc004, SN76496_2_w },
{ -1 } /* end of table */
};
INPUT_PORTS_START( tp84 )
PORT_START /* IN0 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN1 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN2 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* DSW0 */
PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
PORT_DIPSETTING( 0x02, DEF_STR( 4C_1C ) )
PORT_DIPSETTING( 0x05, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x04, DEF_STR( 3C_2C ) )
PORT_DIPSETTING( 0x01, DEF_STR( 4C_3C ) )
PORT_DIPSETTING( 0x0f, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x03, DEF_STR( 3C_4C ) )
PORT_DIPSETTING( 0x07, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x0e, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x06, DEF_STR( 2C_5C ) )
PORT_DIPSETTING( 0x0d, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x0c, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0x0b, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x0a, DEF_STR( 1C_6C ) )
PORT_DIPSETTING( 0x09, DEF_STR( 1C_7C ) )
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )
PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
PORT_DIPSETTING( 0x20, DEF_STR( 4C_1C ) )
PORT_DIPSETTING( 0x50, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x80, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x40, DEF_STR( 3C_2C ) )
PORT_DIPSETTING( 0x10, DEF_STR( 4C_3C ) )
PORT_DIPSETTING( 0xf0, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x30, DEF_STR( 3C_4C ) )
PORT_DIPSETTING( 0x70, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0xe0, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x60, DEF_STR( 2C_5C ) )
PORT_DIPSETTING( 0xd0, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0xc0, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0xb0, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0xa0, DEF_STR( 1C_6C ) )
PORT_DIPSETTING( 0x90, DEF_STR( 1C_7C ) )
PORT_DIPSETTING( 0x00, "Invalid" )
PORT_START /* DSW1 */
PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )
PORT_DIPSETTING( 0x03, "2" )
PORT_DIPSETTING( 0x02, "3" )
PORT_DIPSETTING( 0x01, "5" )
PORT_DIPSETTING( 0x00, "7" )
PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
PORT_DIPSETTING( 0x00, DEF_STR( Upright ) )
PORT_DIPSETTING( 0x04, DEF_STR( Cocktail ) )
PORT_DIPNAME( 0x18, 0x18, "Bonus" )
PORT_DIPSETTING( 0x18, "10000 50000" )
PORT_DIPSETTING( 0x10, "20000 60000" )
PORT_DIPSETTING( 0x08, "30000 70000" )
PORT_DIPSETTING( 0x00, "40000 80000" )
PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )
PORT_DIPSETTING( 0x60, "Easy" )
PORT_DIPSETTING( 0x40, "Normal" )
PORT_DIPSETTING( 0x20, "Medium" )
PORT_DIPSETTING( 0x00, "Hard" )
PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
INPUT_PORTS_END
static struct GfxLayout charlayout =
{
8,8, /* 8*8 characters */
1024, /* 1024 characters */
2, /* 2 bits per pixel */
{ 4, 0 }, /* the two bitplanes for 4 pixels are packed into one byte */
{ 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3 }, /* bits are packed in groups of four */
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
16*8 /* every char takes 16 bytes */
};
static struct GfxLayout spritelayout =
{
16,16, /* 16*16 sprites */
256, /* 256 sprites */
4, /* 4 bits per pixel */
{ 256*64*8+4, 256*64*8+0, 4 ,0 },
{ 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3,
16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 },
64*8 /* every sprite takes 64 bytes */
};
static struct GfxDecodeInfo gfxdecodeinfo[] =
{
{ REGION_GFX1, 0, &charlayout, 0, 64*8 },
{ REGION_GFX2, 0, &spritelayout, 64*4*8, 16*8 },
{ -1 } /* end of array */
};
static struct SN76496interface sn76496_interface =
{
3, /* 3 chips */
{ 14318180/8, 14318180/8, 14318180/8 },
{ 75, 75, 75 }
};
static struct MachineDriver machine_driver_tp84 =
{
/* basic machine hardware */
{
{
CPU_M6809,
1500000, /* ??? */
readmem,writemem,0,0,
interrupt,1
},
{
CPU_M6809,
1500000, /* ??? */
readmem_cpu2,writemem_cpu2,0,0,
interrupt,1
},
{
CPU_Z80 | CPU_AUDIO_CPU,
14318180/4,
sound_readmem,sound_writemem,0,0,
ignore_interrupt,1 /* interrupts are triggered by the main CPU */
}
},
60, DEFAULT_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */
100, /* 100 CPU slices per frame - an high value to ensure proper */
/* synchronization of the CPUs */
0,
/* video hardware */
32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
gfxdecodeinfo, /* GfxDecodeInfo * */
256,4096, /* see tp84_vh_convert_color_prom for explanation */
tp84_vh_convert_color_prom, /* convert color prom routine */
VIDEO_TYPE_RASTER,
0, /* vh_init routine */
tp84_vh_start, /* vh_start routine */
tp84_vh_stop, /* vh_stop routine */
tp84_vh_screenrefresh, /* vh_update routine */
/* sound hardware */
0,0,0,0,
{
{
SOUND_SN76496,
&sn76496_interface
}
}
};
/***************************************************************************
Game driver(s)
***************************************************************************/
ROM_START( tp84 )
ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */
ROM_LOAD( "tp84_7j.bin", 0x8000, 0x2000, 0x605f61c7 )
ROM_LOAD( "tp84_8j.bin", 0xa000, 0x2000, 0x4b4629a4 )
ROM_LOAD( "tp84_9j.bin", 0xc000, 0x2000, 0xdbd5333b )
ROM_LOAD( "tp84_10j.bin", 0xe000, 0x2000, 0xa45237c4 )
ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the second CPU */
ROM_LOAD( "tp84_10d.bin", 0xe000, 0x2000, 0x36462ff1 )
ROM_REGION( 0x10000, REGION_CPU3 ) /* 64k for code of sound cpu Z80 */
ROM_LOAD( "tp84s_6a.bin", 0x0000, 0x2000, 0xc44414da )
ROM_REGION( 0x4000, REGION_GFX1 | REGIONFLAG_DISPOSE )
ROM_LOAD( "tp84_2j.bin", 0x0000, 0x2000, 0x05c7508f ) /* chars */
ROM_LOAD( "tp84_1j.bin", 0x2000, 0x2000, 0x498d90b7 )
ROM_REGION( 0x8000, REGION_GFX2 | REGIONFLAG_DISPOSE )
ROM_LOAD( "tp84_12a.bin", 0x0000, 0x2000, 0xcd682f30 ) /* sprites */
ROM_LOAD( "tp84_13a.bin", 0x2000, 0x2000, 0x888d4bd6 )
ROM_LOAD( "tp84_14a.bin", 0x4000, 0x2000, 0x9a220b39 )
ROM_LOAD( "tp84_15a.bin", 0x6000, 0x2000, 0xfac98397 )
ROM_REGION( 0x0500, REGION_PROMS )
ROM_LOAD( "tp84_2c.bin", 0x0000, 0x0100, 0xd737eaba ) /* palette red component */
ROM_LOAD( "tp84_2d.bin", 0x0100, 0x0100, 0x2f6a9a2a ) /* palette green component */
ROM_LOAD( "tp84_1e.bin", 0x0200, 0x0100, 0x2e21329b ) /* palette blue component */
ROM_LOAD( "tp84_1f.bin", 0x0300, 0x0100, 0x61d2d398 ) /* char lookup table */
ROM_LOAD( "tp84_16c.bin", 0x0400, 0x0100, 0x13c4e198 ) /* sprite lookup table */
ROM_END
ROM_START( tp84a )
ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */
ROM_LOAD( "tp84_7j.bin", 0x8000, 0x2000, 0x605f61c7 )
ROM_LOAD( "f05", 0xa000, 0x2000, 0xe97d5093 )
ROM_LOAD( "tp84_9j.bin", 0xc000, 0x2000, 0xdbd5333b )
ROM_LOAD( "f07", 0xe000, 0x2000, 0x8fbdb4ef )
ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the second CPU */
ROM_LOAD( "tp84_10d.bin", 0xe000, 0x2000, 0x36462ff1 )
ROM_REGION( 0x10000, REGION_CPU3 ) /* 64k for code of sound cpu Z80 */
ROM_LOAD( "tp84s_6a.bin", 0x0000, 0x2000, 0xc44414da )
ROM_REGION( 0x4000, REGION_GFX1 | REGIONFLAG_DISPOSE )
ROM_LOAD( "tp84_2j.bin", 0x0000, 0x2000, 0x05c7508f ) /* chars */
ROM_LOAD( "tp84_1j.bin", 0x2000, 0x2000, 0x498d90b7 )
ROM_REGION( 0x8000, REGION_GFX2 | REGIONFLAG_DISPOSE )
ROM_LOAD( "tp84_12a.bin", 0x0000, 0x2000, 0xcd682f30 ) /* sprites */
ROM_LOAD( "tp84_13a.bin", 0x2000, 0x2000, 0x888d4bd6 )
ROM_LOAD( "tp84_14a.bin", 0x4000, 0x2000, 0x9a220b39 )
ROM_LOAD( "tp84_15a.bin", 0x6000, 0x2000, 0xfac98397 )
ROM_REGION( 0x0500, REGION_PROMS )
ROM_LOAD( "tp84_2c.bin", 0x0000, 0x0100, 0xd737eaba ) /* palette red component */
ROM_LOAD( "tp84_2d.bin", 0x0100, 0x0100, 0x2f6a9a2a ) /* palette green component */
ROM_LOAD( "tp84_1e.bin", 0x0200, 0x0100, 0x2e21329b ) /* palette blue component */
ROM_LOAD( "tp84_1f.bin", 0x0300, 0x0100, 0x61d2d398 ) /* char lookup table */
ROM_LOAD( "tp84_16c.bin", 0x0400, 0x0100, 0x13c4e198 ) /* sprite lookup table */
ROM_END
GAMEX( 1984, tp84, 0, tp84, tp84, 0, ROT90, "Konami", "Time Pilot '84 (set 1)", GAME_NO_COCKTAIL )
GAMEX( 1984, tp84a, tp84, tp84, tp84, 0, ROT90, "Konami", "Time Pilot '84 (set 2)", GAME_NO_COCKTAIL )
| [
"[email protected]"
] | [
[
[
1,
528
]
]
] |
3e6b84c28c0fa15c42532ba855eb32ef25fba5dc | 940a846f0685e4ca0202897a60c58c4f77dd94a8 | /demo/FireFox/plugin/test/nprt3/nprt/ScriptablePluginObjectBase.h | 78ecd2d4c36f50d60c56c75ee58c2750f58d2fce | [] | no_license | grharon/tpmbrowserplugin | be33fbe89e460c9b145e86d7f03be9c4e3b73c14 | 53a04637606f543012c0d6d18fa54215123767f3 | refs/heads/master | 2016-09-05T15:46:55.064258 | 2010-09-04T12:05:31 | 2010-09-04T12:05:31 | 35,827,176 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,800 | h | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
#ifndef SCRIPTABLEPLUGINOBJECTBASE_H
#define SCRIPTABLEPLUGINOBJECTBASE_H
/*
CODE FROM "plugin.cpp"
Helper class that can be used to map calls to the NPObject hooks into
virtual methods on instances of classes that derive from this class.
*/
#include "npapi.h"
#include "npruntime.h"
class ScriptablePluginObjectBase : public NPObject
{
public:
ScriptablePluginObjectBase(NPP npp)
: mNpp(npp)
{
}
virtual ~ScriptablePluginObjectBase()
{
}
// Virtual NPObject hooks called through this base class. Override
// as you see fit.
virtual void Invalidate();
virtual bool HasMethod(NPIdentifier name);
virtual bool Invoke(NPIdentifier name, const NPVariant *args,
uint32_t argCount, NPVariant *result);
virtual bool InvokeDefault(const NPVariant *args, uint32_t argCount,
NPVariant *result);
virtual bool HasProperty(NPIdentifier name);
virtual bool GetProperty(NPIdentifier name, NPVariant *result);
virtual bool SetProperty(NPIdentifier name, const NPVariant *value);
virtual bool RemoveProperty(NPIdentifier name);
virtual bool Enumerate(NPIdentifier **identifier, uint32_t *count);
virtual bool Construct(const NPVariant *args, uint32_t argCount,
NPVariant *result);
public:
static void _Deallocate(NPObject *npobj);
static void _Invalidate(NPObject *npobj);
static bool _HasMethod(NPObject *npobj, NPIdentifier name);
static bool _Invoke(NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
static bool _InvokeDefault(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result);
static bool _HasProperty(NPObject * npobj, NPIdentifier name);
static bool _GetProperty(NPObject *npobj, NPIdentifier name,
NPVariant *result);
static bool _SetProperty(NPObject *npobj, NPIdentifier name,
const NPVariant *value);
static bool _RemoveProperty(NPObject *npobj, NPIdentifier name);
static bool _Enumerate(NPObject *npobj, NPIdentifier **identifier,
uint32_t *count);
static bool _Construct(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result);
protected:
NPP mNpp;
};
#define DECLARE_NPOBJECT_CLASS_WITH_BASE(_class, ctor) \
static NPClass s##_class##_NPClass = { \
NP_CLASS_STRUCT_VERSION_CTOR, \
ctor, \
ScriptablePluginObjectBase::_Deallocate, \
ScriptablePluginObjectBase::_Invalidate, \
ScriptablePluginObjectBase::_HasMethod, \
ScriptablePluginObjectBase::_Invoke, \
ScriptablePluginObjectBase::_InvokeDefault, \
ScriptablePluginObjectBase::_HasProperty, \
ScriptablePluginObjectBase::_GetProperty, \
ScriptablePluginObjectBase::_SetProperty, \
ScriptablePluginObjectBase::_RemoveProperty, \
ScriptablePluginObjectBase::_Enumerate, \
ScriptablePluginObjectBase::_Construct \
}
#define GET_NPOBJECT_CLASS(_class) &s##_class##_NPClass
#endif | [
"stlt1sean@aa5d9edc-7c6f-d5c9-3e23-ee20326b5c4f"
] | [
[
[
1,
84
]
]
] |
b30450749d0334a61e130a38012c2a2f5d42d969 | 36bf908bb8423598bda91bd63c4bcbc02db67a9d | /Include/CThread.h | 43846164d4c15335f275b799c20c35fca6398e4e | [] | no_license | code4bones/crawlpaper | edbae18a8b099814a1eed5453607a2d66142b496 | f218be1947a9791b2438b438362bc66c0a505f99 | refs/heads/master | 2021-01-10T13:11:23.176481 | 2011-04-14T11:04:17 | 2011-04-14T11:04:17 | 44,686,513 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,150 | h | /*
CThread.h
Classe per il thread.
Luca Piergentili, 19/11/02
[email protected]
*/
#ifndef _CTHREAD_H
#define _CTHREAD_H 1
#include "window.h"
/*
PTHREADPROC
tipo per il puntatore alla funzione per il thread
*/
typedef UINT (__cdecl *PTHREADPROC)(LPVOID);
/*
THREADPARAMS
struttura per il passaggio dei parametri
*/
struct THREADPARAMS {
LPVOID lpVoid;
PTHREADPROC pfnProc;
LPVOID pParam;
};
/*
THREAD_STATE
enum per gli stati del thread
*/
enum THREAD_STATE {
THREAD_UNDEFINED,
THREAD_RUNNING,
THREAD_DONE
};
/*
CThread
Classe per la creazione del thread, non usare direttamente ma chiamare la BeginThread() per
creare un nuovo thread. Non eliminare il puntatore restituito da BeginThread() con una
delete a meno che non si imposti il flag m_bAutoDelete su TRUE.
*/
class CThread
{
public:
CThread();
virtual ~CThread();
void SetAutoDelete (BOOL bAutoDelete);
const HANDLE GetHandle (void) const;
const UINT GetId (void) const;
const THREAD_STATE GetStatus (void) const;
DWORD GetPriority (void);
BOOL SetPriority (DWORD nPriority);
BOOL Suspend (void);
BOOL Resume (void);
BOOL Abort (void);
HANDLE Create (
PTHREADPROC pfnThreadProc,
LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,
UINT nStackSize = 0L,
DWORD dwCreateFlags = 0L,
LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL
);
private:
static UINT APIENTRY ThreadProc (LPVOID lpVoid);
BOOL m_bAutoDelete;
HANDLE m_hHandle;
UINT m_nID;
THREAD_STATE m_nState;
int m_nPriority;
THREADPARAMS m_ThreadParams;
};
/*
BeginThread()
Crea un nuovo thread restituendo il puntatore all'oggetto.
Non eliminare l'oggetto con una delete a meno che non si imposti il flag m_bAutoDelete su TRUE.
*/
CThread* BeginThread(
PTHREADPROC pfnThreadProc,
LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,
UINT nStackSize = 0L,
DWORD dwCreateFlags = 0L,
LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL
);
#endif // _CTHREAD_H
| [
"[email protected]"
] | [
[
[
1,
99
]
]
] |
4e1365801454dbad62ead85604d438261d42f458 | c3ae23286c2e8268355241f8f06cd1309922a8d6 | /rateracerlib/Ray.h | 89e8c81e4f3d7ab4a2d59bf3385da2a493408dcc | [] | no_license | BackupTheBerlios/rateracer-svn | 2f43f020ecdd8a3528880d474bec1c0464879597 | 838ad3f326962028ce8d493d2c06f6af6ea4664c | refs/heads/master | 2020-06-04T03:31:51.633612 | 2005-05-30T06:38:01 | 2005-05-30T06:38:01 | 40,800,078 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 967 | h | #pragma once
#include <float.h>
#include "mathlib.h"
class Vec3;
//const float cEpsilon = 0.000001f;
const float cEpsilon = 0.001f;
//enum { LAMBDA_RGB, LAMBDA_R, LAMBDA_G, LAMBDA_B};
class Ray
{
public:
Ray()
{
dimRet = 1;
refractInsideCounter = 0;
//transmitColor.assign(1,1,1);
//lambda = LAMBDA_RGB;
}
Ray(const Vec3& o, const Vec3& d /*, byte wavelength = LAMBDA_RGB*/)
{
ori = o;
dir = d;
dimRet = 1;
refractInsideCounter = 0;
//transmitColor.assign(1,1,1);
//lambda = wavelength;
}
inline void offset(float amount, const Vec3& direction)
{
ori += amount * direction;
}
inline Vec3 hitPoint() { return ori + tHit * dir; }
inline Vec3 pointAtT(float t) { return ori + t * dir; }
Vec3 ori;
Vec3 dir;
float tHit;
float dimRet; // diminishing return...
int refractInsideCounter;
//Vec3 transmitColor;
//byte lambda;
// Debug stuff...
Vec3 color;
};
| [
"gweronimo@afd64b18-8dda-0310-837d-b02fe5df315d"
] | [
[
[
1,
58
]
]
] |
2a84afcebf5cd2b72e7e0a79a78d648f0a275ff9 | d54d8b1bbc9575f3c96853e0c67f17c1ad7ab546 | /hlsdk-2.3-p3/singleplayer/utils/vgui/include/VGUI_Label.h | b0f3dc8a96c16799da4b530e55c46b56baae48e6 | [] | no_license | joropito/amxxgroup | 637ee71e250ffd6a7e628f77893caef4c4b1af0a | f948042ee63ebac6ad0332f8a77393322157fa8f | refs/heads/master | 2021-01-10T09:21:31.449489 | 2010-04-11T21:34:27 | 2010-04-11T21:34:27 | 47,087,485 | 1 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 2,150 | h | //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_LABEL_H
#define VGUI_LABEL_H
#include<VGUI.h>
#include<VGUI_Panel.h>
#include<VGUI_Scheme.h>
//TODO: this should use a TextImage for the text
namespace vgui
{
class Panel;
class TextImage;
class VGUIAPI Label : public Panel
{
public:
enum Alignment
{
a_northwest=0,
a_north,
a_northeast,
a_west,
a_center,
a_east,
a_southwest,
a_south,
a_southeast,
};
public:
Label(int textBufferLen,const char* text,int x,int y,int wide,int tall);
Label(const char* text,int x,int y,int wide,int tall);
Label(const char* text,int x,int y);
Label(const char* text);
inline Label() : Panel(0,0,10,10)
{
init(1,"",true);
}
private:
void init(int textBufferLen,const char* text,bool textFitted);
public:
virtual void setImage(Image* image);
virtual void setText(int textBufferLen,const char* text);
virtual void setText(const char* format,...);
virtual void setFont(Scheme::SchemeFont schemeFont);
virtual void setFont(Font* font);
virtual void getTextSize(int& wide,int& tall);
virtual void getContentSize(int& wide,int& tall);
virtual void setTextAlignment(Alignment alignment);
virtual void setContentAlignment(Alignment alignment);
virtual Panel* createPropertyPanel();
virtual void setFgColor(int r,int g,int b,int a);
virtual void setFgColor(vgui::Scheme::SchemeColor sc);
virtual void setContentFitted(bool state);
protected:
virtual void computeAlignment(int& tx0,int& ty0,int& tx1,int& ty1,int& ix0,int& iy0,int& ix1,int& iy1,int& minX,int& minY,int& maxX,int& maxY);
virtual void paint();
virtual void recomputeMinimumSize();
protected:
bool _textEnabled;
bool _imageEnabled;
bool _contentFitted;
Alignment _textAlignment;
Alignment _contentAlignment;
TextImage* _textImage;
Image* _image;
};
}
#endif | [
"joropito@23c7d628-c96c-11de-a380-73d83ba7c083"
] | [
[
[
1,
80
]
]
] |
aa44348169a8d9634e7a379b879ac9fadebcda2d | 96ae76a21d65bb48d04f74a2ae8d705b47d1d969 | /pongar/src/Game.h | 13b92317a2ed6f3b169764f08a6c84e06573a0d1 | [] | no_license | tedwp/pongar | d48b9112bb2bfe27428a8df5e9b3bad31c03347e | de96ae581684874e96d562122008b4acd313ebbd | refs/heads/master | 2021-01-10T02:58:43.849201 | 2011-02-07T01:11:46 | 2011-02-07T01:11:46 | 48,293,673 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,401 | h | #pragma once
#include "conf.h"
#include <vector>
#include "Marker.h"
#include "Capture.h"
#include "Graphics.h"
#include "PlayingField.h"
#include "Ball.h"
class Game
{
public:
static Game& getInstance(void);
void init( int argc, char* argv[] );
void idle( void );
void cleanup( void );
void start(void);
int getGameStage();
void setGameStage(int stage);
void registerMarkers(void);
static void timer(int value);
static std::vector<Marker*> getMarkers(void);
static Marker* getMarkerById(int id);
static Marker* getMarkerByPurpose(int purpose);
void end(void);
bool isMarkerPresent(int purpose);
//IplImage* m_markerImage;
static const int PURPOSE_PADDLE1 = 1;
static const int PURPOSE_PADDLE2 = 2;
static const int PURPOSE_PLAYINGFIELD = 3;
static const int PURPOSE_PAUSE = 4;
static const int PURPOSE_REINIT = 5;
static const int PURPOSE_RESTARTGAME = 6;
static const int PURPOSE_ACTION_INCREASESIZE_LEFTPADDLE = 101;
static const int PURPOSE_ACTION_INCREASESIZE_RIGHTPADDLE = 102;
static const int PURPOSE_ACTION_DECREASESIZE_LEFTPADDLE = 103;
static const int PURPOSE_ACTION_DECREASESIZE_RIGHTPADDLE = 104;
static const int PURPOSE_ACTION_INCREASESPEED_BALL = 105;
static const int PURPOSE_ACTION_INCREASESIZE_BALL = 106;
static const int PURPOSE_ACTION_DECREASESIZE_BALL = 107;
static const int PURPOSE_ACTION_DECREASESPEED_BALL = 108;
static const int STAGE_BEAMERCALIBRATION = 1;
static const int STAGE_STARTUP = 2;
static const int STAGE_INITIALIZATION = 3;
static const int STAGE_RUNNING = 4;
static const int STAGE_PAUSE = 5;
static const int STAGE_WON_LEFT = 6;
static const int STAGE_WON_RIGHT = 7;
private:
static Game& m_instance;
std::vector<Marker*> m_markers;
int m_gameStage;
long int timerStart;
Game(void);
Game(const Game&);
~Game(void);
void registerMarker(int id, int purpose);
void registerMarker(int id, int purpose, float size);
void updateMarkerOffsets(void);
void arrayToCvMat(float* transform, CvMat* mat);
void performInitialization(void);
bool isActionMarkerPresent(void);
void performStageBeamerCalibration(void);
void performStageStartup(void);
void performStageInitialization(void);
void performStageRunning(void);
void performStagePause(void);
void performStageWon(bool isLeft);
void performRestart(void);
};
| [
"[email protected]",
"[email protected]",
"[email protected]",
"salatgurke00@cd860a2f-db29-0b79-333e-049c8ca359aa"
] | [
[
[
1,
1
],
[
10,
12
],
[
14,
14
],
[
16,
17
],
[
81,
82
]
],
[
[
2,
9
],
[
13,
13
],
[
15,
15
],
[
18,
18
],
[
21,
21
],
[
23,
25
],
[
28,
57
],
[
59,
61
],
[
63,
69
],
[
73,
80
],
[
83,
83
]
],
[
[
19,
20
],
[
22,
22
],
[
26,
26
],
[
58,
58
],
[
62,
62
],
[
70,
72
]
],
[
[
27,
27
]
]
] |
1f2cd660ed509d5b7fa82131639aeacee25aca8b | 8bbbcc2bd210d5608613c5c591a4c0025ac1f06b | /nes/mapper/082.cpp | 233525e124645cd869f922292ca35af26da15c52 | [] | no_license | PSP-Archive/NesterJ-takka | 140786083b1676aaf91d608882e5f3aaa4d2c53d | 41c90388a777c63c731beb185e924820ffd05f93 | refs/heads/master | 2023-04-16T11:36:56.127438 | 2008-12-07T01:39:17 | 2008-12-07T01:39:17 | 357,617,280 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,686 | cpp | #ifdef _NES_MAPPER_CPP_
/////////////////////////////////////////////////////////////////////
// Mapper 82
void NES_mapper82_Init()
{
g_NESmapper.Reset = NES_mapper82_Reset;
g_NESmapper.MemoryWriteSaveRAM = NES_mapper82_MemoryWriteSaveRAM;
}
void NES_mapper82_Reset()
{
// set CPU bank pointers
g_NESmapper.set_CPU_banks4(0,1,g_NESmapper.num_8k_ROM_banks-2,g_NESmapper.num_8k_ROM_banks-1);
// set PPU bank pointers
if(g_NESmapper.num_1k_VROM_banks)
{
g_NESmapper.set_PPU_banks8(0,1,2,3,4,5,6,7);
}
// set Mirroring
g_NESmapper.set_mirroring2(NES_PPU_MIRROR_VERT);
g_NESmapper.Mapper82.regs[0] = 0;
}
void NES_mapper82_MemoryWriteSaveRAM(uint32 addr, uint8 data)
{
switch (addr)
{
case 0x7EF0:
/* Switch 2k VROM at $0000 or $1000 */
{
if(g_NESmapper.Mapper82.regs[0])
{
g_NESmapper.set_PPU_bank4((data & 0xFE)+0);
g_NESmapper.set_PPU_bank5((data & 0xFE)+1);
}
else
{
g_NESmapper.set_PPU_bank0((data & 0xFE)+0);
g_NESmapper.set_PPU_bank1((data & 0xFE)+1);
}
}
break;
case 0x7EF1:
{
if(g_NESmapper.Mapper82.regs[0])
{
g_NESmapper.set_PPU_bank6((data & 0xFE)+0);
g_NESmapper.set_PPU_bank7((data & 0xFE)+1);
}
else
{
g_NESmapper.set_PPU_bank2((data & 0xFE)+0);
g_NESmapper.set_PPU_bank3((data & 0xFE)+1);
}
}
break;
case 0x7EF2:
{
if(!g_NESmapper.Mapper82.regs[0])
{
g_NESmapper.set_PPU_bank4(data);
}
else
{
g_NESmapper.set_PPU_bank0(data);
}
}
break;
case 0x7EF3:
{
if(!g_NESmapper.Mapper82.regs[0])
{
g_NESmapper.set_PPU_bank5(data);
}
else
{
g_NESmapper.set_PPU_bank1(data);
}
}
break;
case 0x7EF4:
{
if(!g_NESmapper.Mapper82.regs[0])
{
g_NESmapper.set_PPU_bank6(data);
}
else
{
g_NESmapper.set_PPU_bank2(data);
}
}
break;
case 0x7EF5:
{
if(!g_NESmapper.Mapper82.regs[0])
{
g_NESmapper.set_PPU_bank7(data);
}
else
{
g_NESmapper.set_PPU_bank3(data);
}
}
break;
case 0x7EF6:
{
g_NESmapper.Mapper82.regs[0] = data & 0x02;
if(data & 0x01)
{
g_NESmapper.set_mirroring2(NES_PPU_MIRROR_VERT);
}
else
{
g_NESmapper.set_mirroring2(NES_PPU_MIRROR_HORIZ);
}
}
break;
case 0x7EFA:
{
g_NESmapper.set_CPU_bank4(data >> 2);
}
break;
case 0x7EFB:
{
g_NESmapper.set_CPU_bank5(data >> 2);
}
break;
case 0x7EFC:
{
g_NESmapper.set_CPU_bank6(data >> 2);
}
break;
}
}
/////////////////////////////////////////////////////////////////////
#endif
| [
"takka@e750ed6d-7236-0410-a570-cc313d6b6496"
] | [
[
[
1,
150
]
]
] |
da1030b54b10df1951ef4b1107a309658cf356fb | 6c8c4728e608a4badd88de181910a294be56953a | /InventoryModule/InventoryFolder.cpp | 187cb40187f29248c8b94ca7b23a99a367deb665 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | caocao/naali | 29c544e121703221fe9c90b5c20b3480442875ef | 67c5aa85fa357f7aae9869215f840af4b0e58897 | refs/heads/master | 2021-01-21T00:25:27.447991 | 2010-03-22T15:04:19 | 2010-03-22T15:04:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,370 | cpp | // For conditions of distribution and use, see copyright notice in license.txt
/**
* @file InventoryFolder.cpp
* @brief A class representing folder in the inventory item tre model.
*/
#include "StableHeaders.h"
#include "DebugOperatorNew.h"
#include "InventoryFolder.h"
#include "InventoryAsset.h"
#include "RexUUID.h"
#include "MemoryLeakCheck.h"
namespace Inventory
{
InventoryFolder::InventoryFolder(const QString &id, const QString &name, InventoryFolder *parent, const bool &editable) :
AbstractInventoryItem(id, name, parent, editable), itemType_(AbstractInventoryItem::Type_Folder), dirty_(false),
libraryItem_(false)
{
}
// virtual
InventoryFolder::~InventoryFolder()
{
qDeleteAll(children_);
}
AbstractInventoryItem *InventoryFolder::AddChild(AbstractInventoryItem *child)
{
child->SetParent(this);
children_.append(child);
return children_.back();
}
bool InventoryFolder::RemoveChildren(int position, int count)
{
if (position < 0 || position + count > children_.size())
return false;
for(int row = 0; row < count; ++row)
delete children_.takeAt(position);
return true;
}
/*
void InventoryFolder::DeleteChild(InventoryItemBase *child)
{
QListIterator<InventoryItemBase *> it(childItems_);
while(it.hasNext())
{
InventoryItemBase *item = it.next();
if (item == child)
SAFE_DELETE(item);
}
}
void InventoryFolder::DeleteChild(const RexUUID &id)
{
QListIterator<InventoryItemBase *> it(childItems_);
while(it.hasNext())
{
InventoryItemBase *item = it.next();
if (item->GetID() == id)
SAFE_DELETE(item);
}
}
const bool InventoryFolder::IsChild(InventoryFolder *child)
{
QListIterator<InventoryItemBase *> it(childItems_);
while(it.hasNext())
{
InventoryItemBase *item = it.next();
InventoryFolder *folder = dynamic_cast<InventoryFolder *>(item);
if (folder)
{
if (folder == child)
return true;
if (folder->IsChild(child))
return true;
}
}
return false;
}
*/
InventoryFolder *InventoryFolder::GetFirstChildFolderByName(const QString &searchName)
{
if (GetName() == searchName)
return this;
QListIterator<AbstractInventoryItem *> it(children_);
while(it.hasNext())
{
AbstractInventoryItem *item = it.next();
InventoryFolder *folder = 0;
if (item->GetItemType() == Type_Folder)
folder = static_cast<InventoryFolder *>(item);
else
continue;
if (folder->GetName() == searchName)
return folder;
InventoryFolder *folder2 = folder->GetFirstChildFolderByName(searchName);
if (folder2)
if (folder2->GetName() == searchName)
return folder2;
}
return 0;
}
InventoryFolder *InventoryFolder::GetChildFolderById(const QString &searchId)
{
QListIterator<AbstractInventoryItem *> it(children_);
while(it.hasNext())
{
AbstractInventoryItem *item = it.next();
InventoryFolder *folder = 0;
if (item->GetItemType() == Type_Folder)
folder = static_cast<InventoryFolder *>(item);
else
continue;
if (folder->GetID() == searchId)
return folder;
InventoryFolder *folder2 = folder->GetChildFolderById(searchId);
if (folder2)
if (folder2->GetID() == searchId)
return folder2;
}
return 0;
}
InventoryAsset *InventoryFolder::GetChildAssetById(const QString &searchId)
{
QListIterator<AbstractInventoryItem *> it(children_);
while(it.hasNext())
{
AbstractInventoryItem *item = it.next();
InventoryAsset *asset = 0;
if (item->GetItemType() == Type_Asset)
asset = static_cast<InventoryAsset *>(item);
else
continue;
if (asset->GetID() == searchId)
return asset;
///\todo Recursion, if needed.
/*
InventoryFolder *folder = folder->GetChildFolderById(searchId);
if (folder)
if (asset->GetID() == searchId)
return folder2;
*/
}
return 0;
}
AbstractInventoryItem *InventoryFolder::GetChildById(const QString &searchId)
{
QListIterator<AbstractInventoryItem *> it(children_);
while(it.hasNext())
{
AbstractInventoryItem *item = it.next();
assert(item);
if (item->GetID() == searchId)
return item;
if (item->GetItemType() == Type_Folder)
{
InventoryFolder *folder = checked_static_cast<InventoryFolder *>(item);
AbstractInventoryItem *item2 = folder->GetChildById(searchId);
if (item2)
return item2;
}
}
return 0;
}
bool InventoryFolder::IsDescendentOf(AbstractInventoryItem *searchFolder)
{
forever
{
AbstractInventoryItem *parent = GetParent();
if (parent)
{
if (parent == searchFolder)
return true;
else
return parent->IsDescendentOf(searchFolder);
}
return false;
}
}
AbstractInventoryItem *InventoryFolder::Child(int row)
{
if (row < 0 || row > children_.size() - 1)
return 0;
return children_.value(row);
}
int InventoryFolder::Row() const
{
if (GetParent())
{
InventoryFolder *folder = static_cast<InventoryFolder *>(GetParent());
return folder->children_.indexOf(const_cast<InventoryFolder *>(this));
}
return 0;
}
#ifdef _DEBUG
void InventoryFolder::DebugDumpInventoryFolderStructure(int indentationLevel)
{
for(int i = 0; i < indentationLevel; ++i)
std::cout << " ";
std::cout << GetName().toStdString() << " " << std::endl;
QListIterator<AbstractInventoryItem *> it(children_);
while(it.hasNext())
{
InventoryFolder *folder = dynamic_cast<InventoryFolder *>(it.next());
if (folder)
folder->DebugDumpInventoryFolderStructure(indentationLevel + 3);
}
}
#endif
}
| [
"jaakkoallander@5b2332b8-efa3-11de-8684-7d64432d61a3",
"Stinkfist0@5b2332b8-efa3-11de-8684-7d64432d61a3"
] | [
[
[
1,
8
],
[
10,
12
],
[
14,
19
],
[
21,
246
]
],
[
[
9,
9
],
[
13,
13
],
[
20,
20
]
]
] |
56b1b5a5aa38456291556b35f175382d6cfc5589 | 502efe97b985c69d6378d9c428c715641719ee03 | /src/moaicore/MOAIDraw.h | 42ad6191378a5a5917a30791aa3005f7af39c0c4 | [] | no_license | neojjang/moai-beta | c3933bca2625bca4f4da26341de6b855e41b9beb | 6bc96412d35192246e35bff91df101bd7c7e41e1 | refs/heads/master | 2021-01-16T20:33:59.443558 | 2011-09-19T23:45:06 | 2011-09-19T23:45:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,601 | h | // Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#ifndef MOAIDRAW_H
#define MOAIDRAW_H
class MOAITexture;
//================================================================//
// MOAIDraw
//================================================================//
class MOAIDraw :
public USGlobalClass < MOAIDraw, USLuaObject > {
private:
//----------------------------------------------------------------//
static int _drawAxisGrid ( lua_State* L );
static int _drawCircle ( lua_State* L );
static int _drawEllipse ( lua_State* L );
static int _drawGrid ( lua_State* L );
static int _drawLine ( lua_State* L );
static int _drawPoints ( lua_State* L );
static int _drawRay ( lua_State* L );
static int _drawRect ( lua_State* L );
static int _fillCircle ( lua_State* L );
static int _fillEllipse ( lua_State* L );
static int _fillFan ( lua_State* L );
static int _fillRect ( lua_State* L );
//----------------------------------------------------------------//
static void DrawLuaParams ( lua_State* L, u32 primType );
public:
DECL_LUA_SINGLETON ( MOAIDraw )
//----------------------------------------------------------------//
static void Bind ();
static void DrawAxisGrid ( USVec2D loc, USVec2D vec, float size );
static void DrawEllipseFill ( USRect& rect, u32 steps );
static void DrawEllipseFill ( float x, float y, float xRad, float yRad, u32 steps );
static void DrawEllipseOutline ( USRect& rect, u32 steps );
static void DrawEllipseOutline ( float x, float y, float xRad, float yRad, u32 steps );
static void DrawGrid ( USRect& rect, u32 xCells, u32 yCells );
static void DrawLine ( USVec2D& v0, USVec2D& v1 );
static void DrawLine ( float x0, float y0, float x1, float y1 );
static void DrawPoint ( USVec2D& loc );
static void DrawPoint ( float x, float y );
static void DrawRay ( float x, float y, float dx, float dy );
static void DrawRectEdges ( USRect rect, u32 edges );
static void DrawRectFill ( USRect rect );
static void DrawRectFill ( float left, float top, float right, float bottom );
static void DrawRectOutline ( USRect& rect );
static void DrawRectOutline ( float left, float top, float right, float bottom );
static void DrawVertexArray ( USVec2D* verts, u32 count, u32 color, u32 primType );
MOAIDraw ();
~MOAIDraw ();
void RegisterLuaClass ( USLuaState& state );
};
#endif
| [
"[email protected]"
] | [
[
[
1,
61
]
]
] |
433e2068cb64819953dc13b4bb443bfcb257dea7 | e1e91d163c2bbee8f3082dccec012bf779d006f8 | /checkers/check_doubles.cpp | 76f0b36a0188905f27116bf532a7d0019eaec8d2 | [] | no_license | aplavin/olympchecker.gui | 88c88e98b9329c0e47cc02da67aa3944d2e95cb0 | 0aa23713a43dba2384795848a1bdb23b5b61e28a | refs/heads/master | 2021-01-23T12:16:53.436796 | 2011-05-01T19:32:27 | 2011-05-01T19:32:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 832 | cpp | #include "testlib.h"
#include <cmath>
using namespace std;
#define EPS 1E-6
string ending(int x)
{
x %= 100;
if (x / 10 == 1)
return "th";
if (x % 10 == 1)
return "st";
if (x % 10 == 2)
return "nd";
if (x % 10 == 3)
return "rd";
return "th";
}
int main(int argc, char * argv[])
{
setName("compare two sequences of doubles, maximal absolute error = %.10lf", EPS);
registerTestlibCmd(argc, argv);
int n = 0;
while (!ans.seekEof())
{
n++;
double j = ans.readDouble();
double p = ouf.readDouble();
if (fabs(j - p) / max(1.0, fabs(j)) > EPS)
quitf(_wa, "%d%s numbers differ - expected: '%.10lf', found: '%.10lf'", n, ending(n).c_str(), j, p);
}
quitf(_ok, "%d numbers", n);
}
| [
"[email protected]"
] | [
[
[
1,
38
]
]
] |
2bfb8ec99f7d814e4b715a4859ee753e5cddb3d1 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /libs/genregmgr/genregmgr.h | 501097a21437efe185854e7b388eb2921ea08dbe | [] | no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,755 | h | #ifndef __GENREGMGR_H
#define __GENREGMGR_H
#ifdef USE_PRAGMA_LIB
#pragma comment (lib, "GenRegMgr.lib")
#endif
class CGenRegMgr
{
public:
CGenRegMgr() { m_pKeys = NULL; m_nKeys = 0; }
~CGenRegMgr() { if (m_pKeys) delete [] m_pKeys; }
// in all of the following functions, the first part of the "path" in
// the string must be one of the following or the function will fail:
//
// HKEY_CLASSES_ROOT
// HKEY_CURRENT_USER
// HKEY_LOCAL_MACHINE
// HKEY_USERS
//
// Example key string: "HKEY_CURRENT_USER/Software/Microsoft/Games/Riot/1.00"
//
// creates the key, creating any necessary intermediate keys
BOOL CreateKey (LPCSTR strKey);
// deletes the specified key, deleting any sub-keys it may contain
BOOL DeleteKey (LPCSTR strKey);
// set registry values
BOOL SetStringValue (LPCSTR strKey, LPCSTR strValueName, LPCSTR strValue);
BOOL SetDwordValue (LPCSTR strKey, LPCSTR strValueName, unsigned int dwValue);
BOOL SetBinaryValue (LPCSTR strKey, LPCSTR strValueName, void* pData, unsigned int dwDataSize);
BOOL SetStringBoolValue (LPCSTR strKey, LPCSTR strValueName, BOOL bValue);
// retrieve registry value sizes
unsigned int GetValueSize (LPCSTR strKey, LPCSTR strValueName);
// retrieve registry values
BOOL GetValue (LPCSTR strKey, LPCSTR strValueName, void* pBuffer, unsigned int dwBufferSize);
BOOL GetDwordValue (LPCSTR strKey, LPCSTR strValueName, unsigned int *pdwBuffer);
BOOL GetStringBoolValue (LPCSTR strKey, LPCSTR strValueName, BOOL *pbBuffer);
protected:
HKEY OpenKey (LPCSTR strKey);
void CloseKey (HKEY hKey);
BOOL RecurseAndDeleteKey (HKEY hKeyParent, LPCSTR strKey);
protected:
HKEY* m_pKeys;
unsigned int m_nKeys;
};
#endif
| [
"[email protected]"
] | [
[
[
1,
59
]
]
] |
cad144ac1bef79c88dc0ed2944f08571cd62ff4e | 854ee643a4e4d0b7a202fce237ee76b6930315ec | /arcemu_svn/src/arcemu-shared/Log.h | ba73f28cc41f89cbcd5b4bbe776a22c3f1e2da57 | [] | no_license | miklasiak/projekt | df37fa82cf2d4a91c2073f41609bec8b2f23cf66 | 064402da950555bf88609e98b7256d4dc0af248a | refs/heads/master | 2021-01-01T19:29:49.778109 | 2008-11-10T17:14:14 | 2008-11-10T17:14:14 | 34,016,391 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,225 | h | /*
* ArcEmu MMORPG Server
* Copyright (C) 2008 <http://www.ArcEmu.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef WOWSERVER_LOG_H
#define WOWSERVER_LOG_H
#include "Common.h"
#include "Singleton.h"
class WorldPacket;
class WorldSession;
#ifdef WIN32
#define TRED FOREGROUND_RED | FOREGROUND_INTENSITY
#define TGREEN FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define TYELLOW FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY
#define TNORMAL FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE
#define TWHITE TNORMAL | FOREGROUND_INTENSITY
#define TBLUE FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#else
#define TRED 1
#define TGREEN 2
#define TYELLOW 3
#define TNORMAL 4
#define TWHITE 5
#define TBLUE 6
#endif
std::string FormatOutputString(const char * Prefix, const char * Description, bool useTimeStamp);
class SERVER_DECL oLog : public Singleton< oLog > {
public:
void outString( const char * str, ... );
void outError( const char * err, ... );
void outBasic( const char * str, ... );
void outDetail( const char * str, ... );
void outDebug( const char * str, ... );
void outMenu( const char * str, ... );
void outTime( );
void fLogText(const char *text);
void SetLogging(bool enabled);
void Init(int32 fileLogLevel, int32 screenLogLevel);
void SetFileLoggingLevel(int32 level);
void SetScreenLoggingLevel(int32 level);
void outColor(uint32 colorcode, const char * str, ...);
#ifdef WIN32
HANDLE stdout_handle, stderr_handle;
#endif
int32 m_fileLogLevel;
int32 m_screenLogLevel;
FILE *m_file;
};
class SessionLogWriter
{
FILE * m_file;
char * m_filename;
public:
SessionLogWriter(const char * filename, bool open);
~SessionLogWriter();
void write(const char* format, ...);
void writefromsession(WorldSession* session, const char* format, ...);
ARCEMU_INLINE bool IsOpen() { return (m_file != NULL); }
void Open();
void Close();
};
extern SessionLogWriter * Anticheat_Log;
extern SessionLogWriter * GMCommand_Log;
extern SessionLogWriter * Player_Log;
#define sLog oLog::getSingleton()
#define sCheatLog (*Anticheat_Log)
#define sGMLog (*GMCommand_Log)
#define sPlrLog (*Player_Log)
class WorldLog : public Singleton<WorldLog>
{
public:
WorldLog();
~WorldLog();
void LogPacket(uint32 len, uint16 opcode, const uint8* data, uint8 direction);
void Enable();
void Disable();
private:
FILE * m_file;
Mutex mutex;
bool bEnabled;
};
#define sWorldLog WorldLog::getSingleton()
#endif
| [
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef",
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef"
] | [
[
[
1,
1
],
[
4,
57
],
[
59,
73
],
[
76,
87
],
[
89,
120
]
],
[
[
2,
3
],
[
58,
58
],
[
74,
75
],
[
88,
88
]
]
] |
c35f1c4ed430c8ccc500cac94ea7d60c37ff896f | a1e5c0a674084927ef5b050ebe61a89cd0731bc6 | /OpenGL_SceneGraph_Stussman/Code/Aufgabe4/include/nodes/shadownode.h | c3d214e5c886a7d2b6252edece3f4f8ac8dead42 | [] | no_license | danielkummer/scenegraph | 55d516dc512e1b707b6d75ec2741f48809d8797f | 6c67c41a38946ac413333a84c76340c91b87dc96 | refs/heads/master | 2016-09-01T17:36:02.995636 | 2008-06-05T09:45:24 | 2008-06-05T09:45:24 | 32,327,185 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 809 | h | #ifndef _H_SHADOWNODE
#define _H_SHADOWNODE
#ifdef WIN32
#include <windows.h>
#else
#include <GL/glx.h>
#include <stdarg.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#include "nodes/abstractnode.h"
class ShadowNode:public AbstractNode{
public:
ShadowNode(float* aLightPos, float* aNormal, float* aPointInPlane, float* aColor);
virtual ~ShadowNode();
virtual void accept(AbstractVisitor &aVisitor);
void setNodeToShadow(AbstractNode* aNode);
AbstractNode* getNodeToShadow();
void draw(AbstractVisitor &aVisitor);
private:
void buildShadowMatrix(float* shadowMatrix, float* lightPos, float* normal, float* p);
AbstractNode* mNode;
float* mLightPos;
float* mNormal;
float* mPointInPlane;
float* mColor;
};
#endif // _H_SHADOWNODE
| [
"dr0iddr0id@fe886383-234b-0410-a1ab-e127868e2f45"
] | [
[
[
1,
37
]
]
] |
5a5959c2ac57ea991a3f0f730385cfa57db59c67 | 77aa13a51685597585abf89b5ad30f9ef4011bde | /dep/src/boost/boost/exception/to_string_stub.hpp | b371b00bf03a9b578625719ca0e2434a44f1a46b | [] | no_license | Zic/Xeon-MMORPG-Emulator | 2f195d04bfd0988a9165a52b7a3756c04b3f146c | 4473a22e6dd4ec3c9b867d60915841731869a050 | refs/heads/master | 2021-01-01T16:19:35.213330 | 2009-05-13T18:12:36 | 2009-05-14T03:10:17 | 200,849 | 8 | 10 | null | null | null | null | UTF-8 | C++ | false | false | 2,575 | hpp | //Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef UUID_E788439ED9F011DCB181F25B55D89593
#define UUID_E788439ED9F011DCB181F25B55D89593
#include <boost/exception/to_string.hpp>
#include <boost/exception/detail/object_hex_dump.hpp>
#include <boost/assert.hpp>
namespace
boost
{
namespace
exception_detail
{
template <bool ToStringAvailable>
struct
to_string_dispatcher
{
template <class T,class Stub>
static
std::string
convert( T const & x, Stub )
{
return to_string(x);
}
};
template <>
struct
to_string_dispatcher<false>
{
template <class T,class Stub>
static
std::string
convert( T const & x, Stub s )
{
return s(x);
}
template <class T>
static
std::string
convert( T const & x, std::string s )
{
return s;
}
template <class T>
static
std::string
convert( T const & x, char const * s )
{
BOOST_ASSERT(s!=0);
return s;
}
};
namespace
to_string_dispatch
{
template <class T,class Stub>
inline
std::string
dispatch( T const & x, Stub s )
{
return to_string_dispatcher<has_to_string<T>::value>::convert(x,s);
}
}
template <class T>
inline
std::string
string_stub_dump( T const & x )
{
return "[ " + exception_detail::object_hex_dump(x) + " ]";
}
}
template <class T>
inline
std::string
to_string_stub( T const & x )
{
return exception_detail::to_string_dispatch::dispatch(x,&exception_detail::string_stub_dump<T>);
}
template <class T,class Stub>
inline
std::string
to_string_stub( T const & x, Stub s )
{
return exception_detail::to_string_dispatch::dispatch(x,s);
}
}
#endif
| [
"pepsi1x1@a6a5f009-272a-4b40-a74d-5f9816a51f88"
] | [
[
[
1,
100
]
]
] |
82aafc9fceccb43345c5236606b0d1f4d167189f | 28aa23d9cb8f5f4e8c2239c70ef0f8f6ec6d17bc | /mytesgnikrow --username hotga2801/SELAB/Dongle/Source/HID_Client/HIDClient.cpp | 6d41277cc1303ed1fa75eada16e9a0ac7fae9ec3 | [] | no_license | taicent/mytesgnikrow | 09aed8836e1297a24bef0f18dadd9e9a78ec8e8b | 9264faa662454484ade7137ee8a0794e00bf762f | refs/heads/master | 2020-04-06T04:25:30.075548 | 2011-02-17T13:37:16 | 2011-02-17T13:37:16 | 34,991,750 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,073 | cpp | // HIDClient.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "HIDClient.h"
#include "HIDClientDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHIDClientApp
BEGIN_MESSAGE_MAP(CHIDClientApp, CWinApp)
//{{AFX_MSG_MAP(CHIDClientApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHIDClientApp construction
CHIDClientApp::CHIDClientApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CHIDClientApp object
CHIDClientApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CHIDClientApp initialization
BOOL CHIDClientApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
//Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CHIDClientDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
| [
"hotga2801@ecd9aaca-b8df-3bf4-dfa7-576663c5f076"
] | [
[
[
1,
72
]
]
] |
3b0dcad256089fa5632b32f4637c3c160c0e8bf0 | 6c8c4728e608a4badd88de181910a294be56953a | /TextureDecoderModule/TextureService.h | fe2ba0c4856cbfe9b954b1eb743abaaf6b1749da | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | caocao/naali | 29c544e121703221fe9c90b5c20b3480442875ef | 67c5aa85fa357f7aae9869215f840af4b0e58897 | refs/heads/master | 2021-01-21T00:25:27.447991 | 2010-03-22T15:04:19 | 2010-03-22T15:04:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,087 | h | // For conditions of distribution and use, see copyright notice in license.txt
#ifndef incl_TextureDecoder_Decoder_h
#define incl_TextureDecoder_Decoder_h
#include "TextureRequest.h"
#include "TextureServiceInterface.h"
namespace Foundation
{
class Framework;
class AssetServiceInterface;
}
namespace TextureDecoder
{
//! Texture decoder. Implements TextureServiceInterface.
class TextureService : public Foundation::TextureServiceInterface
{
public:
//! Constructor
TextureService(Foundation::Framework* framework);
//! Destructor
virtual ~TextureService();
//! Queues a texture request
/*! \param asset_id asset ID of texture
\return request tag, will be used in eventual RESOURCE_READY event
*/
virtual request_tag_t RequestTexture(const std::string& asset_id);
//! Updates texture requests. Called by TextureDecoderModule
void Update(f64 frametime);
//! Handles an asset event. Called by TextureDecoderModule
bool HandleAssetEvent(event_id_t event_id, Foundation::EventDataInterface* data);
//! Handles a thread task event. Called by TextureDecoderModule
bool HandleTaskEvent(event_id_t event_id, Foundation::EventDataInterface* data);
private:
//! Updates a texture request
/*! Polls the asset service & queues decode requests to the decode thread as necessary
*/
void UpdateRequest(TextureRequest& request, Foundation::AssetServiceInterface* asset_service);
typedef std::map<std::string, TextureRequest> TextureRequestMap;
//! Framework we belong to
Foundation::Framework* framework_;
//! Resource event category
event_category_id_t resource_event_category_;
//! Ongoing texture requests
TextureRequestMap requests_;
//! Max decodes per frame
int max_decodes_per_frame_;
};
}
#endif
| [
"cadaver@5b2332b8-efa3-11de-8684-7d64432d61a3"
] | [
[
[
1,
64
]
]
] |
22d39639245c9950dbc26d77d63a15e429b61926 | 5a05acb4caae7d8eb6ab4731dcda528e2696b093 | /GameEngine/Gfx/Geometry.cpp | 9f9d6ea22a256ab10af289df5e295d54c76187f4 | [] | no_license | andreparker/spiralengine | aea8b22491aaae4c14f1cdb20f5407a4fb725922 | 36a4942045f49a7255004ec968b188f8088758f4 | refs/heads/master | 2021-01-22T12:12:39.066832 | 2010-05-07T00:02:31 | 2010-05-07T00:02:31 | 33,547,546 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,592 | cpp | #include "Geometry.hpp"
#include "VertexBuffer.hpp"
#include "IndexBuffer.hpp"
#include "VertexFormatImpl.hpp"
using namespace Spiral;
using namespace boost;
void Geometry::Bind()
{
if( m_vertexBuffer )
{
m_vertexBuffer->Bind();
}
if( m_indexBuffer )
{
m_indexBuffer->Bind();
}
}
void Geometry::UnBind()
{
if( m_vertexBuffer )
{
m_vertexBuffer->UnBind();
}
if( m_indexBuffer )
{
m_indexBuffer->UnBind();
}
}
Geometry::Geometry():
m_vertexBuffer(),
m_indexBuffer()
{
}
Geometry::~Geometry()
{
}
bool Geometry::CreateHWVertexBuffer( const VertexFormat& format, boost::int32_t elementSize, boost::int32_t vertexCount, bool bManaged )
{
return DoCreateHWVertexBuffer( format, elementSize, vertexCount, bManaged );
}
bool Geometry::CreateSWVertexBuffer( const VertexFormat& format, boost::int32_t elementSize, boost::int32_t vertexCount, bool bManaged )
{
return DoCreateSWVertexBuffer( format, elementSize, vertexCount, bManaged );
}
void Geometry::ReleaseVertexBuffer()
{
m_vertexBuffer.reset();
}
void Geometry::ReleaseIndexBuffer()
{
m_indexBuffer.reset();
}
void Geometry::ReleaseBuffers()
{
ReleaseVertexBuffer();
ReleaseIndexBuffer();
}
bool Geometry::CreateSWIndexBuffer( const IndexFormat& format, int32_t indexCount, bool bManaged )
{
return DoCreateSWIndexBuffer( format, indexCount, bManaged );
}
bool Geometry::CreateHWIndexBuffer( const IndexFormat& format, int32_t indexCount, bool bManaged )
{
return DoCreateHWIndexBuffer( format, indexCount, bManaged );
} | [
"DreLnBrown@e933ee44-1dc6-11de-9e56-bf19dc6c588e"
] | [
[
[
1,
81
]
]
] |
e76e9e0247db765fadd3f67be6d46832911b35ae | 54cacc105d6bacdcfc37b10d57016bdd67067383 | /trunk/source/level/nav/AdjacencyList.cpp | 4607be1422e31d22449d8f332c9104e5623187c5 | [] | no_license | galek/hesperus | 4eb10e05945c6134901cc677c991b74ce6c8ac1e | dabe7ce1bb65ac5aaad144933d0b395556c1adc4 | refs/heads/master | 2020-12-31T05:40:04.121180 | 2009-12-06T17:38:49 | 2009-12-06T17:38:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,455 | cpp | /***
* hesperus: AdjacencyList.cpp
* Copyright Stuart Golodetz, 2009. All rights reserved.
***/
#include "AdjacencyList.h"
#include <source/exceptions/Exception.h>
#include "NavLink.h"
#include "NavMesh.h"
#include "NavPolygon.h"
namespace hesp {
//#################### CONSTRUCTORS ####################
/**
Constructs an empty adjacency list for a graph with the specified size in nodes.
@param size The number of nodes in the graph
*/
AdjacencyList::AdjacencyList(int size)
: m_size(size), m_adjacentEdges(size)
{}
/**
Constructs an adjacency list representation of the graph for a navigation mesh.
The nodes of this graph are the links of the navmesh, and appropriate edges are
added between links in the same polygon.
@param navMesh The navigation mesh
*/
AdjacencyList::AdjacencyList(const NavMesh_Ptr& navMesh)
{
const std::vector<NavLink_Ptr> links = navMesh->links();
const std::vector<NavPolygon_Ptr> polygons = navMesh->polygons();
m_size = static_cast<int>(links.size());
m_adjacentEdges.resize(m_size);
size_t polyCount = polygons.size();
for(size_t i=0; i<polyCount; ++i)
{
const std::vector<int>& inLinks = polygons[i]->in_links();
const std::vector<int>& outLinks = polygons[i]->out_links();
// Add edges from each in link to each out link in this polygon.
int inLinkCount = static_cast<int>(inLinks.size());
int outLinkCount = static_cast<int>(outLinks.size());
for(int j=0; j<inLinkCount; ++j)
{
const NavLink& inLink = *links[inLinks[j]];
for(int k=0; k<outLinkCount; ++k)
{
const NavLink& outLink = *links[outLinks[k]];
float length = static_cast<float>(inLink.dest_position().distance(outLink.source_position()));
if(outLink.dest_poly() != inLink.source_poly())
{
m_adjacentEdges[inLinks[j]].push_back(Edge(outLinks[k], length));
}
}
}
}
}
//#################### PUBLIC METHODS ####################
void AdjacencyList::add_edge(int fromNode, const Edge& edge)
{
if(fromNode < 0 || fromNode >= m_size) throw Exception("add_edge: From node index out of range");
m_adjacentEdges[fromNode].push_back(edge);
}
const std::list<AdjacencyList::Edge>& AdjacencyList::adjacent_edges(int node) const
{
if(node < 0 || node >= m_size) throw Exception("adjacent_edges: Node index out of range");
return m_adjacentEdges[node];
}
int AdjacencyList::size() const
{
return m_size;
}
}
| [
"[email protected]"
] | [
[
[
1,
84
]
]
] |
82820851edea75a012d69e93ab805f10b4a350fd | 8cb7e0602c79f0c946b791e5405defb9fc68faf1 | /Rap3d/RapAniBoard.cpp | 3d44915ca014920a0c9d224c103c05d6b5160438 | [] | no_license | dtbinh/rap3d | 97db38c9d025e12d2b754ee5e5146b39c85a43ed | dfcb94d38bf3be3bb18b366d878be6ab43dd219f | refs/heads/master | 2021-01-18T07:44:47.990016 | 2009-07-24T14:54:13 | 2009-07-24T14:54:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,530 | cpp | /****************************************
Rap3D Engine
File: RapAniBoard.cpp
Desc: BillBoard With Animations
Author: Bill Hsu (C) All Rights Reserved
http://www.graptor.com
MSN/Email: [email protected]
*****************************************/
#include "Rap3d.h"
#include "RapBillBoard.h"
#include "RapTexManager.h"
#include "RapAniBoard.h"
#include <fstream>
void RapAniBoard::init()
{
if (m_pRap3d==NULL) MessageBox(NULL,"SetEngine Please","Error",MB_OK);
if (m_pTexMan==NULL) MessageBox(NULL,"SetTexManager Please","Error",MB_OK);
m_pBlBd=new RapBillBoard;
m_pBlBd->SetEngine(m_pRap3d);
dwLastTime=timeGetTime();
TexList.clear();
}
void RapAniBoard::LoadAni(std::string FileName,D3DCOLOR alpha)
{
TexList.clear();
std::ifstream in(FileName.c_str());
in>>times;
in>>interval;
in>>iCount;
std::string str;
for (int i=0;i<iCount;++i)
{
in>>str;
m_pTexMan->LoadTex(str,"AniBoardTex-"+str,alpha);
TexList.push_back("AniBoardTex-"+str);
}
}
void RapAniBoard::Render(D3DCOLOR Color)
{
if (iTimesCount<times||times==0)
{
m_pBlBd->SetTexture(m_pTexMan->GetTex(TexList[iRenderCount]));
m_pBlBd->Render(NULL,Color);
DWORD currTime = timeGetTime();
DWORD timeDelta = currTime - dwLastTime;
if (timeDelta>=interval)
{
++iRenderCount;
dwLastTime = currTime;
}
if (iRenderCount==iCount)
{
++iTimesCount;
iRenderCount=0;
}
}
}
void RapAniBoard::CloseDown()
{
TexList.clear();
if(m_pBlBd!=NULL)
{
m_pBlBd->CloseDown();
m_pBlBd=NULL;
}
}
| [
"[email protected]@9eece350-6645-11de-b007-7558a4ed3f48"
] | [
[
[
1,
86
]
]
] |
940d6fdba20ebe277af6c9895dfd9033c79a13fd | 7c4e18dc769ebc3b87d6f45d82812984b7eb6608 | /source/application.h | ee58df0fc15836c390d25796c84f73f096718363 | [] | no_license | ishahid/smartmap | 5bce0ca5690efb5b8e28c561d86321c8c5dcc794 | 195b1ebb03cd786d38167d622e7a46c7603e9094 | refs/heads/master | 2020-03-27T05:43:49.428923 | 2010-07-06T08:24:59 | 2010-07-06T08:24:59 | 10,093,280 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,729 | h | #ifndef APPLICATION_H
#define APPLICATION_H
#include <qmainwindow.h>
class QToolBar;
class QToolBox;
class QToolButton;
class QWorkspace;
class QPopupMenu;
class LayerPanel;
class ProjectWindow;
class ApplicationWindow : public QMainWindow {
Q_OBJECT
public:
ApplicationWindow();
~ApplicationWindow();
protected:
void closeEvent( QCloseEvent * );
private slots:
ProjectWindow* newProj();
void load();
void save();
void saveAs();
void print();
void closeWindow();
void tileHorizontal();
void cut();
void copy();
void paste();
void del();
void copyImageToFile();
void addLayer();
void addCosmeticLayer();
void removeLayer();
void layerManager();
void zoomFull();
void zoomIn();
void zoomOut();
void pan();
void identify();
void drawPoint();
void drawLine();
void drawCircle();
void drawPolygon();
void helpContents();
void about();
void aboutQt();
void windowsMenuAboutToShow();
void windowsMenuActivated( int id );
void windowFocused();
void changeVisibility( int, bool );
void showShapeTools( bool flag );
private:
QPrinter *printer;
QWorkspace* ws;
QToolBar *fileTools;
QPopupMenu* windowsMenu;
QToolBar *editTools;
QToolBar *layerTools;
QToolBar *toolsTools;
QToolBar *whatsThisTools;
QToolBar *shapesTools;
LayerPanel *layerPanel;
QToolButton *toolsZoomFull;
QToolButton *toolsZoomIn;
QToolButton *toolsZoomOut;
QToolButton *toolsPan;
QToolButton *toolsIdentify;
QToolButton *shapesPoint;
QToolButton *shapesLine;
QToolButton *shapesCircle;
QToolButton *shapesPolygon;
};
#endif
| [
"none@none"
] | [
[
[
1,
87
]
]
] |
f65c33cb5e08c6596f6e1c6d63282a201c67babb | a51ac532423cf58c35682415c81aee8e8ae706ce | /CameraAPI/Driver.h | 9ce3aeaaa7663a8d61bb2f93a526a309ae42838a | [] | no_license | anderslindmark/PickNPlace | b9a89fb2a6df839b2b010b35a0c873af436a1ab9 | 00ca4f6ce2ecfeddfea7db5cb7ae8e9d0023a5e1 | refs/heads/master | 2020-12-24T16:59:20.515351 | 2008-05-25T01:32:31 | 2008-05-25T01:32:31 | 34,914,321 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,485 | h | #ifndef __DRIVER_H__
#define __DRIVER_H__
#include "Camera.h"
#include <vector>
namespace camera
{
class Driver
{
public:
Driver();
virtual ~Driver();
///
/// \brief Returns an identifier string for this driver. For example "MyDriver".
///
virtual std::string getIdentifier() = 0;
///
/// \brief Returns the readable name for this driver. For example "My driver".
///
virtual std::string getName() = 0;
///
/// \brief Returns the major version number.
///
virtual int getVersionMajor() = 0;
///
/// \brief Returns the minor version number.
///
virtual int getVersionMinor() = 0;
///
/// \brief Returns a full version string using getName and getVersion*. For example "My driver v1.2".
///
std::string getVersionString();
///
/// \brief Updates the drivers internal list of cameras. This method is typicaly called before listing cameras
///
virtual void updateCameraIdentifiers() = 0;
///
/// \brief Returns the number of cameras this driver have found
///
virtual int getCameraIdentifierCount() = 0;
///
/// \brief Returns a identifier string for camera with index index
///
virtual std::string getCameraIdentifier(int index) = 0;
///
/// \brief Create a Camera
/// \return A pointer to the created camera.
///
virtual Camera *createCamera(const std::string &identifier) = 0;
};
} // namespace camera
#endif
| [
"kers@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7",
"js@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7"
] | [
[
[
1,
6
],
[
9,
65
]
],
[
[
7,
8
]
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.