blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 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
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1a40eedd3ce736dd59db939e8f0fd13a5fa22218 | b4bff7f61d078e3dddeb760e21174a781ed7f985 | /Source/Contrib/UserInterface/src/Component/ComponentContainer/ColorChooser/OSGDefaultColorSelectionModel.cpp | 1a1b8b82979a302fd8417da1b97532e5c0ca5a3f | []
| no_license | Langkamp/OpenSGToolbox | 8283edb6074dffba477c2c4d632e954c3c73f4e3 | 5a4230441e68f001cdf3e08e9f97f9c0f3c71015 | refs/heads/master | 2021-01-16T18:15:50.951223 | 2010-05-19T20:24:52 | 2010-05-19T20:24:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,121 | cpp | /*---------------------------------------------------------------------------*\
* OpenSG ToolBox UserInterface *
* *
* *
* *
* *
* www.vrac.iastate.edu *
* *
* Authors: David Kabala, Alden Peterson, Lee Zaniewski, Jonathan Flory *
* *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
* 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. *
* *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
* Changes *
* *
* *
* *
* *
* *
* *
\*---------------------------------------------------------------------------*/
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include "OSGConfig.h"
#include "OSGDefaultColorSelectionModel.h"
OSG_BEGIN_NAMESPACE
/***************************************************************************\
* Description *
\***************************************************************************/
/*! \class OSG::DefaultColorSelectionModel
A DefaultColorSelectionModel.
*/
/***************************************************************************\
* Class variables *
\***************************************************************************/
/***************************************************************************\
* Class methods *
\***************************************************************************/
/***************************************************************************\
* Instance methods *
\***************************************************************************/
Color4f DefaultColorSelectionModel::getSelectedColor(void) const
{
return _SelectedColor;
}
void DefaultColorSelectionModel::setSelectedColor(const Color4f& Value, bool isValueAdjusting)
{
if(_SelectedColor != Value)
{
_SelectedColor = Value;
ChangeEventUnrecPtr TheEvent(ChangeEvent::create(NULL, getSystemTime()));
produceStateChanged(TheEvent);
}
}
/*-------------------------------------------------------------------------*\
- private -
\*-------------------------------------------------------------------------*/
/*----------------------- constructors & destructors ----------------------*/
/*----------------------------- class specific ----------------------------*/
OSG_END_NAMESPACE
| [
"[email protected]"
]
| [
[
[
1,
96
]
]
]
|
6d98491b7785f5d9aec3d6461921de17ebf43a65 | 2982a765bb21c5396587c86ecef8ca5eb100811f | /util/wm5/LibCore/DataTypes/Wm5Tuple.inl | 77b86e69f27c2e5a3e0d8e3c81c5d7403db50c7c | []
| no_license | evanw/cs224final | 1a68c6be4cf66a82c991c145bcf140d96af847aa | af2af32732535f2f58bf49ecb4615c80f141ea5b | refs/heads/master | 2023-05-30T19:48:26.968407 | 2011-05-10T16:21:37 | 2011-05-10T16:21:37 | 1,653,696 | 27 | 9 | null | null | null | null | UTF-8 | C++ | false | false | 3,806 | inl | // Geometric Tools, LLC
// Copyright (c) 1998-2010
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
//
// File Version: 5.0.1 (2011/03/27)
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
Tuple<DIMENSION,TYPE>::Tuple ()
{
// Uninitialized for native data. Initialized for class data as long as
// TYPE's default constructor initializes its own data.
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
Tuple<DIMENSION,TYPE>::Tuple (const Tuple& tuple)
{
for (int i = 0; i < DIMENSION; ++i)
{
mTuple[i] = tuple.mTuple[i];
}
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
Tuple<DIMENSION,TYPE>::~Tuple ()
{
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
inline Tuple<DIMENSION,TYPE>::operator const TYPE* () const
{
return mTuple;
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
inline Tuple<DIMENSION,TYPE>::operator TYPE* ()
{
return mTuple;
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
inline const TYPE& Tuple<DIMENSION,TYPE>::operator[] (int i) const
{
return mTuple[i];
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
inline TYPE& Tuple<DIMENSION,TYPE>::operator[] (int i)
{
return mTuple[i];
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
Tuple<DIMENSION,TYPE>& Tuple<DIMENSION,TYPE>::operator= (const Tuple& tuple)
{
for (int i = 0; i < DIMENSION; ++i)
{
mTuple[i] = tuple.mTuple[i];
}
return *this;
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
bool Tuple<DIMENSION,TYPE>::operator== (const Tuple& tuple) const
{
return memcmp(mTuple, tuple.mTuple, DIMENSION*sizeof(TYPE)) == 0;
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
bool Tuple<DIMENSION,TYPE>::operator!= (const Tuple& tuple) const
{
return memcmp(mTuple, tuple.mTuple, DIMENSION*sizeof(TYPE)) != 0;
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
bool Tuple<DIMENSION,TYPE>::operator< (const Tuple& tuple) const
{
return memcmp(mTuple, tuple.mTuple, DIMENSION*sizeof(TYPE)) < 0;
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
bool Tuple<DIMENSION,TYPE>::operator<= (const Tuple& tuple) const
{
return memcmp(mTuple, tuple.mTuple, DIMENSION*sizeof(TYPE)) <= 0;
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
bool Tuple<DIMENSION,TYPE>::operator> (const Tuple& tuple) const
{
return memcmp(mTuple, tuple.mTuple, DIMENSION*sizeof(TYPE)) > 0;
}
//----------------------------------------------------------------------------
template <int DIMENSION, typename TYPE>
bool Tuple<DIMENSION,TYPE>::operator>= (const Tuple& tuple) const
{
return memcmp(mTuple, tuple.mTuple, DIMENSION*sizeof(TYPE)) >= 0;
}
//----------------------------------------------------------------------------
| [
"[email protected]"
]
| [
[
[
1,
100
]
]
]
|
636979abdfa8526d9227a0173da2e9097f2b3611 | 7b4c786d4258ce4421b1e7bcca9011d4eeb50083 | /_统计专用/C++Primer中文版(第4版)/第一次-代码集合-20090414/第二章 变量和基本类型/20090115_习题2.20_语句作用域.cpp | 7b8d09dcaf64c9faf8d2d3a859f7702a34521afd | []
| no_license | lzq123218/guoyishi-works | dbfa42a3e2d3bd4a984a5681e4335814657551ef | 4e78c8f2e902589c3f06387374024225f52e5a92 | refs/heads/master | 2021-12-04T11:11:32.639076 | 2011-05-30T14:12:43 | 2011-05-30T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 153 | cpp | #include <iostream>
int main()
{
int i=100,sum=0;
for(int i=0;i!=10;i++)
sum+=i;
std::cout << i << " " << sum << std::endl;
return 0;
} | [
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
]
| [
[
[
1,
11
]
]
]
|
6e4dcb4541a6f4e98a09c62a5ddfdadd754e3ae1 | 994d3e64acd5dd5b325b8f11cdd4ea4c159e8087 | /LoveTest/src/ButtonClass.hpp | 028d3b6c07d277a91962dd333b2e6368f08317c3 | []
| no_license | csyfek/sdl-sparks | 56a3e9ee4f5dfb7fb2b6d3e505db07f96600242d | 390e799eec008d3b726dc489fc7626b474f81a1f | refs/heads/master | 2020-04-19T05:33:21.575362 | 2010-06-21T04:35:55 | 2010-06-21T04:35:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,095 | hpp | //UVi Soft ( 2008 )
//Long Fei ( lf426 ), E-mail: [email protected]
//Laboratory of ZaiBieLiunNian
//http://www.cppblog.com/lf426/
//FileName: ButtonClass.hpp
#ifndef BUTTON_CLASS_HPP
#define BUTTON_CLASS_HPP
#include "SurfaceClass.hpp"
#include "MixSoundClass.hpp"
class BaseButton
{
private:
//sound effect
static EffectSound es;
protected:
int atX;
int atY;
int offset;
int w;
int h;
//ButtonEffect
bool inBox;
bool clickDown;
bool clickUp;
public:
BaseButton();
virtual ~BaseButton();
void setup(int at_x, int at_y, int _offset = 0);
virtual void colorKey(Uint8 r, Uint8 g, Uint8 b) = 0;
virtual void blitOut() const = 0;
virtual void blitOver() const = 0;
virtual void blitDown() const = 0;
virtual void addText(const TextSurface& out_text, const TextSurface& over_text) = 0;
bool mouseOver(const SDL_Event& gameEvent) const;
bool mouseDown(const SDL_Event& gameEvent) const;
bool mouseUp(const SDL_Event& gameEvent) const;
bool mouseUpOutside(const SDL_Event& gameEvent) const;
bool effectiveClick(const SDL_Event& game_event);
};
class Button: public BaseButton
{
private:
//
protected:
BaseSurface outImg;
BaseSurface overImg;
public:
Button(const std::string& outImg_fileName, const std::string& overImg_fileName, const ScreenSurface& screen);
Button(const BaseSurface& out_img, const BaseSurface& over_img);
Button(const std::string buttonText, const ScreenSurface& screen,
Uint8 out_r = 0xFF, Uint8 out_g = 0xFF, Uint8 out_b = 0xFF, Uint8 on_r = 0, Uint8 on_g = 0, Uint8 on_b = 0xFF,
int ttf_size = 28, const std::string& ttf_fileName = "./fonts/gkai00mp.ttf");
virtual ~Button();
virtual void colorKey(Uint8 r = 0, Uint8 g = 0xFF, Uint8 b = 0xFF);
virtual void blitOut() const;
virtual void blitOver() const;
virtual void blitDown() const;
virtual void addText(const TextSurface& out_text, const TextSurface& over_text);
};
class ButtonPlus: public Button
{
private:
BaseSurface downImg;
public:
ButtonPlus(const std::string& outImg_fileName, const std::string& overImg_fileName, const std::string& downImg_fileName,
const ScreenSurface& screen);
ButtonPlus(const BaseSurface& out_img, const BaseSurface& over_img, const BaseSurface& down_img);
virtual void colorKey(Uint8 r = 0, Uint8 g = 0xFF, Uint8 b = 0xFF);
virtual void blitDown() const;
virtual void addText(const TextSurface& out_text, const TextSurface& over_text);
};
class SpriteButton: public BaseButton
{
private:
PictureSurface spriteSheet;
int outX;
int outY;
int overX;
int overY;
int downX;
int downY;
public:
SpriteButton(const std::string& spriteSheet_fileName, const ScreenSurface& screen,
int button_w, int button_h,
int out_x, int out_y, int over_x, int over_y, int down_x, int down_y);
virtual void colorKey(Uint8 r = 0, Uint8 g = 0xFF, Uint8 b = 0xFF);
virtual void blitOut() const;
virtual void blitOver() const;
virtual void blitDown() const;
virtual void addText(const TextSurface& out_text, const TextSurface& over_text);
};
#endif
| [
"s3e(at)gmail.com@localhost"
]
| [
[
[
1,
101
]
]
]
|
697c98992e37f108de50d2bd8cda608ac75e07b8 | b8ac0bb1d1731d074b7a3cbebccc283529b750d4 | /Code/controllers/RecollectionBenchmark/robotapi/real/RealDifferentialWheels.h | 4c4d391cd4deabdd0b19160981201be32c4318ef | []
| no_license | dh-04/tpf-robotica | 5efbac38d59fda0271ac4639ea7b3b4129c28d82 | 10a7f4113d5a38dc0568996edebba91f672786e9 | refs/heads/master | 2022-12-10T18:19:22.428435 | 2010-11-05T02:42:29 | 2010-11-05T02:42:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,708 | h | #ifndef robotapi_real_RealDifferentialWheels_h
#define robotapi_real_RealDifferentialWheels_h
#include <robotapi/IDifferentialWheels.h>
#include <robotapi/DifferentialWheelsWOdometry.h>
#include <protocol/handlers/DCMotorBoardPacketHandler.h>
#include <robotapi/real/RealDevice.h>
#include <WorldInfo.h>
namespace robotapi {
namespace real {
class RealDifferentialWheels : public robotapi::DifferentialWheelsWOdometry , public robotapi::real::RealDevice {
public:
RealDifferentialWheels(WorldInfo * wi, protocol::handlers::DCMotorBoardPacketHandler * dcmbphl,
protocol::handlers::DCMotorBoardPacketHandler * dcmbphr,
std::string name);
~RealDifferentialWheels();
void setSpeed(double left, double right);
double getLeftSpeed();
double getRightSpeed();
void enableEncoders(int ms);
void disableEncoders();
double getLeftEncoder();
double getRightEncoder();
void moveWheels(double left, double right);
void moveLeftWheel(double left);
void moveRightWheel(double right);
void moveLeftWheel(double left, double speed);
void moveRightWheel(double right, double speed);
double getLeftMotorConsumption();
double getRightMotorConsumption();
bool isAlarmPresent();
bool isAlarmPresent(bool left);
bool motorIsOff();
bool motorIsOff(bool left);
void refresh();
private:
protocol::handlers::DCMotorBoardPacketHandler * leftBoard;
protocol::handlers::DCMotorBoardPacketHandler * rightBoard;
};
} /* End of namespace robotapi::real */
} /* End of namespace robotapi */
#endif // robotapi_real_RealDifferentialWheels_h
| [
"guicamest@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a",
"nuldiego@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a"
]
| [
[
[
1,
56
],
[
59,
69
]
],
[
[
57,
58
]
]
]
|
70b86c32ebd98e49a9fdcf86e44369f550681fb9 | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/persistence2/engine/ai/src/Dialog.cpp | 2641e785c0fee3b5a3ed37152392d2e4e2f5b013 | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,144 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* 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
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include "stdinc.h"
#include "Dialog.h"
#include "DialogResponse.h"
using namespace std;
namespace rl
{
const Ogre::String Dialog::PROP_EXIT_REQUESTED = "exit_requested";
Dialog::Dialog()
{
}
Dialog::~Dialog()
{
}
DialogResponse* Dialog::getDialogStart() const
{
return mDialogStart;
}
void Dialog::setStartResponse(DialogResponse* start)
{
mDialogStart = start;
}
void Dialog::initialize() ///@todo hand over NPCs and party
{
mExitRequested = false;
}
void Dialog::addVariable(DialogVariable* variable)
{
//mVariables[vkey] = variable;
}
const Property Dialog::getProperty(const CeGuiString& key) const
{
///@todo dialog's state
if (key == Dialog::PROP_EXIT_REQUESTED)
{
return mExitRequested;
}
return mPropertyVariables.getProperty(key);
}
void Dialog::setProperty(const CeGuiString& key, const Property& value)
{
if (key == Dialog::PROP_EXIT_REQUESTED)
{
mExitRequested = value;
}
///@todo dialog's state
mPropertyVariables.setProperty(key, value);
}
PropertyKeys Dialog::getAllPropertyKeys() const
{
PropertyKeys keys;
keys.insert(Dialog::PROP_EXIT_REQUESTED);
///@todo dialog's state
PropertyKeys varKeys = mPropertyVariables.getAllPropertyKeys();
keys.insert(varKeys.begin(), varKeys.end());
return keys;
}
bool Dialog::isExitRequested() const
{
return mExitRequested;
}
CeGuiString Dialog::getVariableValue(const Ogre::String& key) const
{
return getProperty(key).getAsString();
}
void Dialog::addParticipant(const CeGuiString& personId, Creature* person)
{
mParticipantMap[personId] = person;
mAllParticipants.push_back(person);
}
const CreatureList& Dialog::getParticipants() const
{
return mAllParticipants;
}
Creature* Dialog::getParticipant(const CeGuiString& personId) const
{
map<CeGuiString, Creature*>::const_iterator it = mParticipantMap.find(personId);
if (it == mParticipantMap.end())
{
LOG_ERROR("Dialog", "Could not find participant with ID '" + personId + "'");
return NULL;
}
return it->second;
}
}
| [
"timm@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
120
]
]
]
|
5d02a8a183ddbab8b512d35e6c19c19af090da3b | a6364718e205f8a83f180f5f06703e8964d6eafe | /foo_lyricsgrabber2/foo_lyricsgrabber2/main.cpp | 65ab2d4d6e4f5950925822012b980e8295d9f47f | [
"MIT"
]
| permissive | LWain83/lyricsgrabber2 | b40f56303b7de120a8f12292e194faac661a79e3 | b71765433d6ac0c1d1b85b6b1d82de705c6d5718 | refs/heads/master | 2016-08-12T18:53:51.990628 | 2010-08-28T07:13:29 | 2010-08-28T07:13:29 | 52,316,826 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24 | cpp | #include "stdafx.h"
| [
"qudeid@d0561270-fede-e5e2-f771-9cccb1c17e5b"
]
| [
[
[
1,
3
]
]
]
|
6d8c3f98c80c2a03bf859ae307d3f0c9b8563e02 | 1e01b697191a910a872e95ddfce27a91cebc57dd | /GrfIncrementIndentLevel.cpp | 85dd9af3ec8b282263255e953546525a8115711d | []
| 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 | 1,854 | cpp | /* "CodeWorker": a scripting language for parsing and generating text.
Copyright (C) 1996-1997, 1999-2010 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]
*/
#ifdef WIN32
#pragma warning (disable : 4786)
#endif
#include "ScpStream.h"
#include "CppCompilerEnvironment.h"
#include "CGRuntime.h"
#include "ExprScriptExpression.h"
#include "GrfIncrementIndentLevel.h"
namespace CodeWorker {
GrfIncrementIndentLevel::~GrfIncrementIndentLevel() {
delete _pLevel;
}
SEQUENCE_INTERRUPTION_LIST GrfIncrementIndentLevel::executeInternal(DtaScriptVariable& visibility) {
std::string sLevel = _pLevel->getValue(visibility);
int iLevel = atoi(sLevel.c_str());
return CGRuntime::incrementIndentLevel(iLevel);
}
void GrfIncrementIndentLevel::populateDefaultParameters() {
if (_pLevel == NULL) _pLevel = new ExprScriptConstant(1);
}
void GrfIncrementIndentLevel::compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_INDENT << "CGRuntime::incrementIndentLevel(";
_pLevel->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ");";
CW_BODY_ENDL;
}
}
| [
"cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4"
]
| [
[
[
1,
53
]
]
]
|
9e4b0344f3c82bbc618b32f04c2b8336f36bca2a | 45c0d7927220c0607531d6a0d7ce49e6399c8785 | /GlobeFactory/src/ui/ui_loader/ui_loader.cc | 666f1da16a537561d8719ef91756e9bbada4e3a3 | []
| no_license | wavs/pfe-2011-scia | 74e0fc04e30764ffd34ee7cee3866a26d1beb7e2 | a4e1843239d9a65ecaa50bafe3c0c66b9c05d86a | refs/heads/master | 2021-01-25T07:08:36.552423 | 2011-01-17T20:23:43 | 2011-01-17T20:23:43 | 39,025,134 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,658 | cc | #include "ui_loader.hh"
#include "../ui_component.hh"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
std::map<std::string, UILoader*> UILoader::MLoaders;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
UILoader::UILoader(const std::string& parName)
: MName(parName)
{
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
UILoader::~UILoader()
{
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
UILoader* UILoader::GetLoader(const std::string& parName)
{
LOG_ASSERT(MLoaders.count(parName) > 0);
LOG_ASSERT(MLoaders[parName]->MName == parName);
return MLoaders[parName];
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool UILoader::ExtractBase(XmlNode* parNode, Vector2f& parPos, Vector2f& parSz)
{
bool good = true;
good = good && XmlHelper::ExtractPosition2f(parNode, parPos);
good = good && XmlHelper::ExtractSize2f(parNode, parSz);
return good;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
| [
"creteur.c@8e971d8e-9cf3-0c36-aa0f-a7c54ab41ffc"
]
| [
[
[
1,
46
]
]
]
|
53b88a2fed101376e6e21c74303796ac46399012 | d8b5e52952981db6f6279ae401339f553db253a1 | /plugin_Fireworks.cpp | ba9cad534f00b8941d2e7d987bf646bca0131f6a | []
| no_license | pulni/myqlock | 1591cf05cbdcb99091518f75eda1db0bd974c2dd | c6d7ddd181559972deb1fc21debd0be84e00faa1 | refs/heads/master | 2021-01-18T09:35:57.147708 | 2011-08-22T20:06:57 | 2011-08-22T20:06:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,589 | cpp | /**
* Fireworks.cpp
* Kleine Klasse zum Anzeigen eines Feuerwerks.
*
* @mc Arduino/RBBB
* @autor Andreas Muttscheller
* @version 1.0
* @datum 18.3.2011
*/
#include "plugin_Fireworks.h"
#include "DisplayMatrix.h"
// Die Feuerwerksstatusdefinitionen
#define NEW 0
#define OFFSET 1
#define FLIGHT 2
#define EXPLODE 3
#define DONE 9
#define MAXCLASSES 3
// H�he und Breite der Matrix
int Fireworks_matrixX;
int Fireworks_matrixY;
int Fireworks_randomClasses;
// Fireworks Klassen
classFirework cFireworks[MAXCLASSES];
boolean Fireworks_alldone;
// Diese Funktionen werden von der QlockThree aufgerufen.
// Nun werden die eigentlichen Funktionen f�r alle Objekte aufgerufen
void initFireworks(int x, int y)
{
int i;
Fireworks_matrixX = x;
Fireworks_matrixY = y;
// die Klassen erstellen
for (i=0;i<MAXCLASSES;i++)
{
cFireworks[i].initFireworks(x, y);
}
Fireworks_alldone = false;
Fireworks_randomClasses = random(1, MAXCLASSES + 1); // random gibt max-1 zur�ck!
return;
}
void updateFireworks(int timeDiff)
{
int i;
// nun f�r jede Klasse die Funktion ausf�hren
for (i=0;i<Fireworks_randomClasses;i++)
{
cFireworks[i].updateFireworks(timeDiff);
}
return;
}
void showFireworks()
{
int i;
clearMatrix();
// nun f�r jede Klasse die Funktion ausf�hren
for (i=0;i<Fireworks_randomClasses;i++)
{
cFireworks[i].showFireworks();
Fireworks_alldone = true;
if (!cFireworks[i].done)
{
Fireworks_alldone = false;
}
}
if (Fireworks_alldone == true)
{
for (i=0;i<Fireworks_randomClasses;i++)
{
cFireworks[i].resetStatus();
}
Fireworks_alldone = false;
Fireworks_randomClasses = random(1, MAXCLASSES + 1);
}
// Die Matrix auf die LEDs multiplexen
writeMatrix();
return;
}
void buttonFireworks(Button btn, byte id)
{
}
//********************************************************************************************
// Classenfunktionen
//********************************************************************************************
void classFirework::initFireworks(int x, int y)
{
memset(&firework, 0, sizeof(firework));
firework.status = NEW;
done = false;
return;
}
int classFirework::getX()
{
return firework.x;
}
void classFirework::resetStatus()
{
memset(&firework, 0, sizeof(firework));
firework.status = NEW;
done = false;
}
boolean classFirework::validateXY(int x, int y)
{
if (x < 0 || x > (Fireworks_matrixX - 1) || y < 0 || y > (Fireworks_matrixY - 1))
{
return false;
}
else
{
return true;
}
}
boolean classFirework::getMatrixShow(int x, int y)
{
if (validateXY(x, y))
{
return intMatrix[x][y];
}
return false;
}
void classFirework::setMatrixShow(int x, int y)
{
if (validateXY(x, y))
{
intMatrix[x][y] = true;
}
return;
}
//********************************************************************************************
// Update Funktionen
//********************************************************************************************
// Das Feuerwerk initialisieren
void classFirework::initializeFirework()
{
// wo soll gestartet werden?
// random(min, max) gibt direkt Maximal "max-1" zur�ck
// Prüfen, ob eine andere Klasse schon die Spalte nutzt
int i;
int classX[Fireworks_randomClasses];
boolean usable;
done = false;
// nun f�r jede Klasse die Funktion ausf�hren
for (i=0;i<Fireworks_randomClasses;i++)
{
classX[i] = cFireworks[i].getX();
}
do
{
usable = true;
firework.x = random(0, Fireworks_matrixX);
for (i=0;i<Fireworks_randomClasses;i++)
{
if (classX[i] == firework.x)
{
usable = false;
}
}
} while (usable == false);
// Die H�he ermitteln, da die Rakete nicht direkt am Anfang explodieren soll,
// -4 Rechnen. D.h. die Rakete explodiert erst ab der 3. Reihe
firework.explosionY = random(0, Fireworks_matrixY - 3);
// die H�he ist am Anfang immer die unterste Zeile
firework.y = Fireworks_matrixY - 1;
firework.explosionCount = 0;
// Radius!
firework.maxExplosion = random(2, 4);
// start Offset
firework.startOffset = random(1, 4);
// Status updaten
firework.status = OFFSET;
return;
}
void classFirework::updateOffset()
{
firework.startOffset--;
// Ist das Offset erreicht, dann ist der Status FLIGHT
if (firework.startOffset == 0)
{
firework.status = FLIGHT;
}
return;
}
// Die Flugbahn updaten
void classFirework::updateFlight()
{
firework.y--;
// Explosion erreicht?
if (firework.y <= firework.explosionY)
{
firework.status = EXPLODE;
}
return;
}
// Die Explosion steuern
void classFirework::updateExplosion()
{
int w;
int h;
// interne Matrix initialisieren
memset(&intMatrix, 0, sizeof(intMatrix));
// Hier muss einfach nur der Count hochgez�hlt werden
firework.explosionCount++;
if (firework.explosionCount > firework.maxExplosion)
{
firework.status = DONE;
}
for (w=0;w<=firework.explosionCount;w++)
{
for (h=0;h<=firework.explosionCount;h++)
{
if (random(0, 2) == 1)
{
setMatrixShow(firework.x + w, firework.y + h);
}
if (random(0, 2) == 1)
{
setMatrixShow(firework.x - w, firework.y - h);
}
if (random(0, 2) == 1)
{
setMatrixShow(firework.x + w, firework.y - h);
}
if (random(0, 2) == 1)
{
setMatrixShow(firework.x - w, firework.y + h);
}
}
}
return;
}
void classFirework::updateFireworks(int timeDiff)
{
// je nach status erstmal was anderes machen
switch (firework.status)
{
case NEW: initializeFirework();
break;
case OFFSET: updateOffset();
break;
case FLIGHT: updateFlight();
break;
case EXPLODE: updateExplosion();
break;
// beim DONE wird einmal nichts angezeigt
case DONE: done = true;
break;
// Für den Fall, dass was kaputtgegangen ist die Rakete auf DONE
// setzen. Später wird es dann alles initialisiert.
default: firework.status = DONE;
done = true;
break;
}
return;
}
//********************************************************************************************
// Show Funktionen
//********************************************************************************************
void classFirework::showFlight()
{
// Die Rakete soll zwei Balken lang sein
int rocketLen = 2;
int i = 0;
// Die Rakete zeichen
for (i=0;i<rocketLen;i++)
{
setLED(firework.x, firework.y + i);
}
return;
}
void classFirework::showExplosion()
{
int h = 0;
int w = 0;
// die Explosion zeichnen
for (w=0;w<=firework.explosionCount;w++)
{
for (h=0;h<=firework.explosionCount;h++)
{
if (getMatrixShow(firework.x + w, firework.y + h))
{
setLED(firework.x + w, firework.y + h);
}
if (getMatrixShow(firework.x - w, firework.y - h))
{
setLED(firework.x - w, firework.y - h);
}
if (getMatrixShow(firework.x + w, firework.y - h))
{
setLED(firework.x + w, firework.y - h);
}
if (getMatrixShow(firework.x - w, firework.y + h))
{
setLED(firework.x - w, firework.y + h);
}
}
}
return;
}
void classFirework::showFireworks()
{
switch (firework.status)
{
// NEW macht nichts (1 sek Pause zwischen den einzelnen Rakten)
case NEW: break;
case FLIGHT: showFlight();
break;
case EXPLODE: showExplosion();
break;
// beim DONE wird einmal nichts angezeigt (1 sek pause)
case DONE: break;
}
return;
}
| [
"[email protected]"
]
| [
[
[
1,
368
]
]
]
|
9f46517b50d8d47dafa4cef6f8efe39a208a82dd | a6504bc8ff329278fadb67f62a329d806aa28812 | /Hatching/main.cpp | ef51adfd5a501737b913b1784dbf4269a6d8cb8d | []
| no_license | hillsalex/Darkon | 7a3eab4d7e69c8e920fb2788e2fd0b39c4c3de4a | 12964f830c081381b0007875ab305d00d6a29a4b | refs/heads/master | 2020-05-27T19:40:28.888822 | 2011-05-10T08:08:28 | 2011-05-10T08:08:28 | 1,632,571 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 316 | cpp | #include <QtGui/QApplication>
#include <iostream>
#include "qgl.h"
#include <pty.h>
#include "mainwindow.h"
using std::cout;
using std::endl;
int main(int argc, char *argv[]) {
//Q_INIT_RESOURCE(resources);
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
| [
"[email protected]"
]
| [
[
[
1,
16
]
]
]
|
820a88fb85edb0f4408ad2e66c019398fed3c184 | aa825896cc7c672140405ab51634d00d28fad09b | /zomgatron/Button.cpp | e8153fb97c354632456f63b39a5ffbe3b07b0a9f | []
| no_license | kllrnohj/zomgatron | 856fa6693b924d629f166c82cdd4db7524f3255d | 099955f0ab84eb432ab87d351b8defd3123a8991 | refs/heads/master | 2021-01-10T08:26:13.826555 | 2009-01-27T17:21:45 | 2009-01-27T17:21:45 | 46,742,521 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,990 | cpp | #include "Button.h"
Button::Button(void (*clickResponse)(UIBase*), std::string text): text(text), UIBase(NULL, clickResponse){
//D3DXCreateTexture(DirectXObjects::D3DDEV, 256, 256, D3DX_DEFAULT, /*D3DUSAGE_RENDERTARGET D3DUSAGE_DYNAMIC*/ NULL, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &this->background);
//DirectXObjects::D3DDEV->SetRender
if(buttonImage == NULL){
buttonImage = EngineStatics::Engine->LoadImageFromFile(IMAGE_FN_BUTTON);
/*D3DXCreateTextureFromFile(DirectXObjects::D3DDEV, IMAGE_FN_BUTTON, &buttonImage);*/
}
background = buttonImage;
color = BUTTON_DEFAULT_COLOR;
clickStarted = false;
}
void Button::Draw(float drawDepth){
EngineStatics::Engine->DrawTexture(this->background, itemRect, drawDepth, color);
EngineStatics::Engine->DrawString(text, itemRect, COLORARGB(255, 255, 255, 255), (ALIGNMENT)(JHCENTER|JVCENTER));
/*D3DXMATRIX old;
DirectXObjects::D3DSPR->GetTransform(&old);
DirectXObjects::D3DSPR->SetTransform(&mat);
DirectXObjects::D3DSPR->Draw(this->background, NULL, NULL, &D3DXVECTOR3(itemRect.left, itemRect.top, drawDepth), color);*/
//DirectXObjects::FONT->DrawTextA(NULL, text.c_str(), -1, &itemRect, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(255, 255, 255));
//DirectXObjects::D3DSPR->SetTransform(&old);
}
void Button::DoInput(unsigned char keystate[256], MouseState* mousestate, Vector2 mousePos){
// A BUTTON SHOULD NOT HAVE CHILDREN.
if(mousePos.x >= itemRect.left && mousePos.x <= itemRect.right && mousePos.y >= itemRect.top && mousePos.y <= itemRect.bottom){
// mouse is on button
if(!mousestate->left && clickStarted){
clickStarted = false;
clickResponse(this);
}
if(mousestate->left && !clickStarted){
clickStarted = true;
}
if(clickStarted)
color = BUTTON_CLICK_COLOR;
else
color = BUTTON_HIGHLIGHT_COLOR;
}else{
if(!mousestate->left && clickStarted){
clickStarted = false;
}
color = BUTTON_DEFAULT_COLOR;
}
}
void* Button::buttonImage = NULL; | [
"Kivu.Rako@54144a58-e977-11dd-a550-c997509ed985"
]
| [
[
[
1,
48
]
]
]
|
f0fdc40db1f891ef0205ac9fdf8f843a93acc1b2 | 0bc54f5f742e587e40c4212445abe1600ba1eedd | /QSW/ThreadObject.h | 54cee1a6db63d241b2ee7c6d2257bfde0ed2a75f | []
| no_license | Dramacydal/QSW | c9c4b4e074d4f22044c1e4cd7958f627a9f71d3a | 32ea86770fe6ed80802ad829c32db2a2507ffaad | refs/heads/master | 2021-01-19T03:23:37.128543 | 2011-01-30T21:31:18 | 2011-01-30T21:31:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 373 | h | #ifndef THREADOBJ_H
#define THREADOBJ_H
#include <iostream>
#include "SpellWork.h"
class ObjThread: public QThread
{
friend class SpellWork;
public:
ObjThread(quint8 id = 0, SpellWork *obj = NULL);
~ObjThread();
virtual void run();
quint8 GetId() { return t_id; }
private:
quint8 t_id;
SpellWork *_iFace;
};
#endif | [
"devnull@localhost"
]
| [
[
[
1,
23
]
]
]
|
66996d2dc0c8c3e8975cf2a27d527362df399c26 | 6f8721dafe2b841f4eb27237deead56ba6e7a55b | /src/WorldOfAnguis/Controllers/GameController.h | 6a7e5423f002ffb747a88e8fad3b532945e0e7da | []
| no_license | worldofanguis/WoA | dea2abf6db52017a181b12e9c0f9989af61cfa2a | 161c7bb4edcee8f941f31b8248a41047d89e264b | refs/heads/master | 2021-01-19T10:25:57.360015 | 2010-02-19T16:05:40 | 2010-02-19T16:05:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,207 | h | /*
* ___ ___ __
* \ \ / / / \
* \ \ / / / \
* \ \ /\ / /___ / /\ \
* \ \/ \/ /| | / ____ \
* \___/\___/ |___|/__/ \__\
* World Of Anguis
*
*/
/* Class: GameController
* Description: This class is dedicated to handle all 'ingame' events
* like initializing the world, players
* reading the keyboard, moving the camera, etc.
* So its the main loop of the program while 'ingame'.
*
* Functions: The only public function is the constructor,
* so all we have to do is creating the object if we want to start he game
*/
#pragma once
#include "Common.h"
#include "KeyboardController.h"
#include "Units/Unit.h"
class GameController : KeyboardController
{
public:
GameController();
~GameController();
private:
void Run();
void Render();
void FollowUnit(Unit *unit); // Follows the specified unit with the camera //
int ViewWidth; // Screen width (BackBuffer width) //
int ViewHeight; // Screen height (BackBuffer height) //
int ViewLeft; // Left coord of the screen //
int ViewTop; // Top coord of the screen //
}; | [
"[email protected]"
]
| [
[
[
1,
46
]
]
]
|
018232bead489d26d76849f21d0aaa53c124f558 | 5210c96be32e904a51a0f32019d6be4abdb62a6d | /SutureMass.cpp | 9647390e4421784ede570398e0c2a3d20104827a | []
| no_license | Russel-Root/knot-trying-FTL | 699cec27fcf3f2b766a4beef6a58176c3cbab33e | 2c1a7992855927689ad1570dd7c5998a73728504 | refs/heads/master | 2021-01-15T13:18:35.661929 | 2011-04-02T07:51:51 | 2011-04-02T07:51:51 | 1,554,271 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 868 | cpp | #include "SutureMass.h"
double SutureMass::statdoubDelta = 0.001; // $$$
SutureMass::~SutureMass(){}
void SutureMass::init(){
this->vecForce.x = 0.0;
this->vecForce.y = 0.0;
this->vecForce.z = 0.0;
}
void SutureMass::applyForce(Vector3f force){
this->vecForce += force;
}
void SutureMass::simulate(float dt){
dirty = false; // 默认情况是 dt时间内 质点移动距离在指定范围内,不需要纠正,因此dirty默认是false
vecVelocity += vecForce / fMass * dt; // v = v + f / m * dt, 这里t是delta t
if ( (vecVelocity * dt).getLength() > statdoubDelta ){ // $$$ 如果在dt时间内质点运动距离(即v * dt)过大(超过statdoubDelta),则需要纠正,这里用dirty表示是否需要纠正
vecOldPos = vecPos;
dirty = true;
}
vecPos += vecVelocity * dt; // position = position + v * dt
} | [
"[email protected]"
]
| [
[
[
1,
27
]
]
]
|
3a7d369dcc3df3aa625afd418e98221ababf6085 | 95a3e8914ddc6be5098ff5bc380305f3c5bcecb2 | /src/FusionForever_lib/Random.h | 40f469917350a1b38e800114069c3b19d1d639dd | []
| no_license | danishcake/FusionForever | 8fc3b1a33ac47177666e6ada9d9d19df9fc13784 | 186d1426fe6b3732a49dfc8b60eb946d62aa0e3b | refs/heads/master | 2016-09-05T16:16:02.040635 | 2010-04-24T11:05:10 | 2010-04-24T11:05:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 464 | h | #pragma once
class Random
{
private:
Random(void);
public:
~Random(void);
static float RandomRange(float _min, float _max);
static float RandomCentered(float _center, float _range);
static float RandomFactor();
static float RandomFactorPM();
static bool RandomChance(float _chance);
static void Seed();
static void Seed(unsigned int _seed);
static int RandomIndex(int _array_size);
static int RandomQuantity(int _min, int _max);
};
| [
"Edward Woolhouse@e6f1df29-e57c-d74d-9e6e-27e3b006b1a7",
"[email protected]"
]
| [
[
[
1,
17
],
[
19,
19
]
],
[
[
18,
18
]
]
]
|
354eafa72fcfb72e25d124129a555653b76c7bd4 | 20c74d83255427dd548def97f9a42112c1b9249a | /src/roadfighter/misc.cpp | 6c84faaa30593d20411ba2b8332f61ecebb29175 | []
| no_license | jonyzp/roadfighter | 70f5c7ff6b633243c4ac73085685595189617650 | d02cbcdcfda1555df836379487953ae6206c0703 | refs/heads/master | 2016-08-10T15:39:09.671015 | 2011-05-05T12:00:34 | 2011-05-05T12:00:34 | 54,320,171 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,034 | cpp | #include "misc.h"
/*LPDIRECTDRAWSURFACE7 bitmap_surface(LPCSTR file_name)
{
HDC hdc;
HBITMAP bit;
LPDIRECTDRAWSURFACE7 surf;
bit=(HBITMAP)LoadImage(NULL,file_name,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
if(!bit)
{
return NULL;
}
BITMAP bitmap;
GetObject(bit,sizeof(BITMAP),&bitmap);
int surf_width=bitmap.bmWidth;
int surf_height=bitmap.bmHeight;
HRESULT ddrval;
DDSURFACEDESC2 ddsd;
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
ddsd.dwFlags=DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY;
ddsd.dwWidth=surf_width;
ddsd.dwHeight=surf_height;
ddrval=lpDD->CreateSurface(&ddsd,&surf,NULL);
if(ddrval!=DD_OK)
{
DeleteObject(bit);
return NULL;
}
else
{
surf->GetDC(&hdc);
HDC bit_dc=CreateCompatibleDC(hdc);
SelectObject(bit_dc,bit);
BitBlt(hdc,0,0,surf_width,surf_height,bit_dc,0,0,SRCCOPY);
surf->ReleaseDC(hdc);
DeleteObject(bit_dc);
}
DeleteObject(bit);
return surf;
}*/
| [
"[email protected]"
]
| [
[
[
1,
42
]
]
]
|
d8b30333b198af10d2840c568eca83761e1c59f1 | 6131815bf1b62accfc529c2bc9db21194c7ba545 | /FrameworkApp/App/Render Targets/DrawableTex2D.h | 21fcdb380217238241427fa6bedbd68825fbba0b | []
| no_license | dconefourseven/honoursproject | b2ee664ccfc880c008f29d89aad03d9458480fc8 | f26b967fda8eb6937f574fd6f3eb76c8fecf072a | refs/heads/master | 2021-05-29T07:14:35.261586 | 2011-05-15T18:27:49 | 2011-05-15T18:27:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,897 | h | //=============================================================================
// DrawableTex2D.h by Frank Luna (C) 2005 All Rights Reserved.
//=============================================================================
#ifndef DRAWABLE_TEX2D_H
#define DRAWABLE_TEX2D_H
#include "../../App Framework/Utilities/d3dUtil.h"
struct VertexRenderTex2D
{
VertexRenderTex2D()
:pos(0.0f, 0.0f, 0.0f),
tex0(0.0f, 0.0f){}
VertexRenderTex2D(float x, float y, float z,
float u, float v):pos(x,y,z), tex0(u,v){}
VertexRenderTex2D(const D3DXVECTOR3& v, const D3DXVECTOR2& uv)
:pos(v), tex0(uv){}
D3DXVECTOR3 pos;
D3DXVECTOR2 tex0;
static IDirect3DVertexDeclaration9* Decl;
};
// Our custom FVF, which describes our custom vertex structure
#define D3DFVF_SHADOWMAPVERTEX (D3DFVF_XYZ|D3DFVF_TEX1)
class DrawableTex2D
{
public:
DrawableTex2D(LPDIRECT3DDEVICE9 device, UINT width, UINT height, UINT mipLevels,
D3DFORMAT texFormat, bool useDepthBuffer,
D3DFORMAT depthFormat, D3DVIEWPORT9& viewport, bool autoGenMips);
~DrawableTex2D();
IDirect3DTexture9* d3dTex();
void Draw(D3DXMATRIX proj);
void Draw(D3DXMATRIX proj, IDirect3DTexture9* tex);
void beginScene();
void endScene();
void onLostDevice();
void onResetDevice();
void Release();
private:
// This class is not designed to be copied.
DrawableTex2D(const DrawableTex2D& rhs);
DrawableTex2D& operator=(const DrawableTex2D& rhs);
private:
IDirect3DVertexBuffer9* mRadarVB;
IDirect3DTexture9* mTex;
ID3DXRenderToSurface* mRTS;
IDirect3DSurface9* mTopSurf;
IDirect3DDevice9* gd3dDevice;
UINT mWidth;
UINT mHeight;
UINT mMipLevels;
D3DFORMAT mTexFormat;
bool mUseDepthBuffer;
D3DFORMAT mDepthFormat;
D3DVIEWPORT9 mViewPort;
bool mAutoGenMips;
};
#endif // DRAWABLE_TEX2D_H | [
"davidclarke1990@fa56ba20-0011-6cdf-49b4-5b20436119f6"
]
| [
[
[
1,
74
]
]
]
|
d8b7209a9d645bacf99fd36555ab74551ddbf85d | 465943c5ffac075cd5a617c47fd25adfe496b8b4 | /ENVIRONM.H | 0ef62b37081f029bf5c1a9efc2e368055d94c9c0 | []
| no_license | paulanthonywilson/airtrafficcontrol | 7467f9eb577b24b77306709d7b2bad77f1b231b7 | 6c579362f30ed5f81cabda27033f06e219796427 | refs/heads/master | 2016-08-08T00:43:32.006519 | 2009-04-09T21:33:22 | 2009-04-09T21:33:22 | 172,292 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 962 | h | /* Class to describe an environment that initilises a simulator name
flight paths,landmarks and timings
check landmarks of different types do not occupy the same position in the
arena.
Nick Papa
ver 0.0
01/04/96 */
# ifndef _ENVIRONMENT_H
# define _ENVIRONMENT_H
# include <assert.h>
# include "position.h"
# include "landmars.h"
# include "timings.h"
class Environment {
private:
Landmarks *Lmarks_c;
Timings *TParameters_c;
char * SimName_c;
public:
Environment ( Landmarks *l, Timings *t, char *s ){
Lmarks_c=l;
TParameters_c=t;
SimName_c=s;
}
~Environment () {
delete Lmarks_c;
delete TParameters_c;
delete SimName_c;
}
Landmarks *Lmarks(void){ return Lmarks_c; }
//FlightPaths *Paths(void){ return Paths_c; }
Timings *TParameters(void){ return TParameters_c; }
char *SimName(void){return SimName_c;}
};
# endif _ENVIRONMENT_H
| [
"[email protected]"
]
| [
[
[
1,
49
]
]
]
|
eff3cbcbd21554b79f2c4d0e3e7e943bcb289dde | e68cf672cdb98181db47dab9fb8c45e69b91e256 | /src/VertexPosition4f.cpp | 629c1ace43e7e92a26f3a884fd24f67cbd303a0e | []
| no_license | jiawen/QD3D11 | 09fc794f580db59bfc2faffbe3373a442180e0a5 | c1411967bd2da8d012eddf640eeb5f7b86e66374 | refs/heads/master | 2021-01-21T13:52:48.111246 | 2011-12-19T19:07:17 | 2011-12-19T19:07:17 | 2,549,080 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 607 | cpp | #include "VertexPosition4f.h"
VertexPosition4f::VertexPosition4f()
{
}
VertexPosition4f::VertexPosition4f( float x, float y, float z, float w ) :
m_position( x, y, z, w )
{
}
VertexPosition4f::VertexPosition4f( Vector4f position ) :
m_position( position )
{
}
// static
int VertexPosition4f::numElements()
{
return 1;
}
// static
int VertexPosition4f::sizeInBytes()
{
return 4 * sizeof( float );
}
// static
D3D11_INPUT_ELEMENT_DESC VertexPosition4f::s_layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};
| [
"[email protected]"
]
| [
[
[
1,
36
]
]
]
|
be72c4c8cfd63ee78bbea15b750f9c23004973c6 | ef25bd96604141839b178a2db2c008c7da20c535 | /src/src/AIToolkit/states.h | c261536e03ffab012eb39b5175de8d2d4017966c | []
| no_license | OtterOrder/crock-rising | fddd471971477c397e783dc6dd1a81efb5dc852c | 543dc542bb313e1f5e34866bd58985775acf375a | refs/heads/master | 2020-12-24T14:57:06.743092 | 2009-07-15T17:15:24 | 2009-07-15T17:15:24 | 32,115,272 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 133 | h | #ifndef _states_H_
#define _states_H_
class states
{
public:
enum statesGZip { IDLE, MOVE, ATTACK, EVADE };
};
#endif | [
"olivier.levaque@7c6770cc-a6a4-11dd-91bf-632da8b6e10b"
]
| [
[
[
1,
12
]
]
]
|
46a82d41b2ec6bff231a802b9cd7f6fd129ddc9a | 9b3df03cb7e134123cf6c4564590619662389d35 | /InputStream.cpp | 1529d696edadcbd5b9d72e03498f3bc1dcebb409 | []
| no_license | CauanCabral/Computacao_Grafica | a32aeff2745f40144a263c16483f53db7375c0ba | d8673aed304573415455d6a61ab31b68420b6766 | refs/heads/master | 2016-09-05T16:48:36.944139 | 2010-12-09T19:32:05 | 2010-12-09T19:32:05 | null | 0 | 0 | null | null | null | null | ISO-8859-10 | C++ | false | false | 6,053 | cpp | //[]------------------------------------------------------------------------[]
//| |
//| GVSG Foundation Classes |
//| Version 1.0 |
//| |
//| CopyrightŪ 2007, Paulo Aristarco Pagliosa |
//| All Rights Reserved. |
//| |
//[]------------------------------------------------------------------------[]
//
// OVERVIEW: InputStream.cpp
// ========
// Source file for input streams.
#include <memory.h>
#ifndef __InputStream_h
#include "InputStream.h"
#endif
using namespace System;
//////////////////////////////////////////////////////////
//
// InputStream implementation
// ============
InputStream::~InputStream()
//[]---------------------------------------------------[]
//| Destructor |
//[]---------------------------------------------------[]
{
// do nothing
}
//////////////////////////////////////////////////////////
//
// FilterInputStream implementation
// =================
FilterInputStream::~FilterInputStream()
//[]---------------------------------------------------[]
//| Destructor |
//[]---------------------------------------------------[]
{
close();
}
long
FilterInputStream::available() const
//[]---------------------------------------------------[]
//| Available |
//[]---------------------------------------------------[]
{
ensureOpen();
return in->available();
}
void
FilterInputStream::close()
//[]---------------------------------------------------[]
//| Close |
//[]---------------------------------------------------[]
{
if (in == 0)
return;
in->close();
delete in;
in = 0;
}
long
FilterInputStream::read(void* buf, long len)
//[]---------------------------------------------------[]
//| Read |
//[]---------------------------------------------------[]
{
ensureOpen();
return in->read(buf, len);
}
long
FilterInputStream::skip(long len)
//[]---------------------------------------------------[]
//| Skip |
//[]---------------------------------------------------[]
{
ensureOpen();
return in->skip(len);
}
//////////////////////////////////////////////////////////
//
// BufferedInputStream implementation
// ===================
long
BufferedInputStream::available() const
//[]---------------------------------------------------[]
//| Available |
//[]---------------------------------------------------[]
{
ensureOpen();
return count - position + in->available();
}
void
BufferedInputStream::close()
//[]---------------------------------------------------[]
//| Close |
//[]---------------------------------------------------[]
{
FilterInputStream::close();
BufferedStream::close();
position = 0;
}
long
BufferedInputStream::read(void* buf, long len)
//[]---------------------------------------------------[]
//| Read |
//[]---------------------------------------------------[]
{
ensureOpen();
if (len <= 0)
return 0;
long count = readBytes(buf, len);
if (count > 0)
while (count < len)// && in->available() > 0)
{
long n = readBytes((char*)buf + count, len - count);
if (n <= 0)
break;
count += n;
}
return count;
}
long
BufferedInputStream::skip(long len)
//[]---------------------------------------------------[]
//| Skip |
//[]---------------------------------------------------[]
{
ensureOpen();
if (len <= 0)
return 0;
long avail = count - position;
if (avail <= 0)
return in->skip(len);
if (avail < len)
len = avail;
position += len;
return len;
}
long
BufferedInputStream::fillBuffer()
//[]---------------------------------------------------[]
//| Fill buffer |
//[]---------------------------------------------------[]
{
position = 0;
return count = in->read(buffer, size);
}
long
BufferedInputStream::readBytes(void* buf, long len)
//[]---------------------------------------------------[]
//| Read bytes |
//[]---------------------------------------------------[]
{
long avail = count - position;
if (avail <= 0)
{
if (len >= long(size))
return in->read(buf, len);
if ((avail = fillBuffer()) <= 0)
return -1;
}
if (avail < len)
len = avail;
memmove(buf, buffer + position, len);
position += len;
return len;
}
//////////////////////////////////////////////////////////
//
// DataInputStream implementation
// ===============
wchar_t*
DataInputStream::readWString()
//[]---------------------------------------------------[]
//| Read wide string |
//[]---------------------------------------------------[]
{
int32 len = readInt32();
if (len == -1)
return 0;
wchar_t* s = new wchar_t[len + 1];
read(s, len * sizeof(wchar_t));
s[len] = 0;
return s;
}
char*
DataInputStream::readString()
//[]---------------------------------------------------[]
//| Read string |
//[]---------------------------------------------------[]
{
int32 len = readInt32();
if (len == -1)
return 0;
char* s = new char[len + 1];
read(s, len);
s[len] = 0;
return s;
}
| [
"[email protected]"
]
| [
[
[
1,
234
]
]
]
|
d3d57bbd3d63cb3cd393e0d24ad7fc603a2f66c3 | 138a353006eb1376668037fcdfbafc05450aa413 | /source/ogre/OgreNewt/boost/mpl/logical.hpp | 2c0eb4f59ed99726cba8f1b6eee422428494fccf | []
| no_license | sonicma7/choreopower | 107ed0a5f2eb5fa9e47378702469b77554e44746 | 1480a8f9512531665695b46dcfdde3f689888053 | refs/heads/master | 2020-05-16T20:53:11.590126 | 2009-11-18T03:10:12 | 2009-11-18T03:10:12 | 32,246,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 633 | hpp |
#ifndef BOOST_MPL_LOGICAL_HPP_INCLUDED
#define BOOST_MPL_LOGICAL_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Source: /cvsroot/ogre/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/logical.hpp,v $
// $Date: 2006/04/17 23:49:40 $
// $Revision: 1.1 $
#include <boost/mpl/or.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/not.hpp>
#endif // BOOST_MPL_LOGICAL_HPP_INCLUDED
| [
"Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e"
]
| [
[
[
1,
21
]
]
]
|
57b614afe714df41159305c48fec504860e6d285 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Common/ModelsC/QALMdls/QPRECIPD.H | 2146b3bb3336231bf43b6c0ce43de159d0dd62c1 | []
| 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 | 4,320 | h | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#ifndef __QPRECIPD_H
#define __QPRECIPD_H
#define WithSzStuff 0
#if WithSzStuff
#define SIZEDST1
#endif
#include "Models.h"
#ifdef __QPRECIPD_CPP
#define DllImportExport DllExport
#elif !defined(QALMDLS)
#define DllImportExport DllImport
#else
#define DllImportExport
#endif
// -------------------------------------------------------------------------
const int PF_Ignore=0;
const int PF_ConstG=1;
const int PF_ConstD=2;
const int PF_LinearG=3;
const int PF_LinearD=4;
class PrecipFn
{
public:
// Common
byte iType;
// Constant
double C;
// Linear
double A, B;
PrecipFn()
{
iType=PF_Ignore;
C=0.0;
A=B=0.0;
};
};
// -------------------------------------------------------------------------
class PrecipFnArray : public CArray <PrecipFn, PrecipFn&> {};
// ==========================================================================
DEFINE_TAGOBJ(QPrecipD);
class DllImportExport QPrecipD : public MN_Surge
{
public:
// Params
static byte iMethod; //global
byte iSecSplitMethod;
flag bOnLine;
double TankVol;
double ActivationEnergy;
double K0; // Rate Equation Constant
double PoisonFactor; //
double PercM45; // % < 45 Microns
double ACin;
double ACeq;
double ACout;
double ThermalConst;
double AmbientTemp;
double SplitRqd;
// new method Params
double k_TOC; //Rate term for TOC effect on rate - current value is 0.0023
double n_s; //exponent for soda-dependence of rate constant, current value is -1
double n_fc; //exponent for free-caustic-dependence of rate constant, current value is -2
double n_eq; //exponent for equilibrium-A/C-dependence of rate constant, current value is 0
double n_; //exponent for ?
double n_sol; //exponent for solids-dependence of precipitation rate, current value is 1
double n_ssa; //exponent for SSA-dependence of precipitation rate, current value is 0.6
double n_s2; //exponent for soda-dependence of rate constant, current value is ?
double n_fc2; //exponent for free-caustic-dependence of rate constant, current value is ?
double Damping;//damping factor
double PrecRateDamping;
byte MaxACIter;
double dMaxT; //max temp for ranging
double dMinC; //min caustic for ranging
double Sol;
double S_out;
// Results
double SSA;
double TSA;
double Yield;
double BoundSoda;
double IonicStrength;
double Aeq;
double ResidenceTime;
double dSolPrecip;
double dThermalLoss;
double dExtraDuty;
flag bWithHOR;
double dReactionHeat;
double dPrevTout;
flag fBoundSpcsOK;
flag fDoBoundStuff;
double dK1;
double dBndOrgSoda;
double dSSAAdj;
// Locals
double dPrecipRate;
// Size Distribution Stuff
PrecipFnArray Fn;
QPrecipD(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach);
virtual ~QPrecipD();
virtual void BuildDataDefn(DataDefnBlk & DDB);
virtual flag DataXchg(DataChangeBlk & DCB);
virtual flag ValidateData(ValidateDataBlk & VDB);
virtual void EvalSteadyState();
virtual void EvalJoinPressures(long JoinMask);
virtual void EvalJoinFlows(int JoinNo);
virtual void EvalProducts(CNodeEvalIndex & NEI);
virtual void ClosureInfo();
// ConditionBlk Override
DEFINE_CI(QPrecipD, MN_Surge, 16);
private:
};
//===========================================================================
#undef DllImportExport
#endif
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
23
],
[
29,
127
],
[
129,
141
]
],
[
[
24,
28
],
[
128,
128
]
]
]
|
24039b047b1ccf068d1b8e42d2911598b5c82ad9 | c9e79ff6101e9f8b70454762fa93e01fa1590cc7 | /prim.cpp | 46fbc3deab06171b949bba38eb4e54b4829a5de2 | []
| no_license | eraldoluis/mst-algorithms | 6e4a9048ebb14c23711dbc4470002e93ada31a9c | d4198e3df86f186e714cc327386bb23b3ec5df18 | refs/heads/master | 2016-09-03T06:22:34.744841 | 2011-04-04T10:46:47 | 2011-04-04T10:46:47 | 1,566,356 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,734 | cpp | #include "prim.h"
#include "binomial.h"
#include "fibonacci.h"
#include <limits.h>
struct tVertex
{
bool operator<(const tVertex& v) const
{
return Weight < v.Weight;
}
bool operator>(const tVertex& v) const
{
return Weight > v.Weight;
}
bool operator<=(const tVertex& v) const
{
return Weight <= v.Weight;
}
bool operator>=(const tVertex& v) const
{
return Weight >= v.Weight;
}
bool InQ;
int Vertex;
int Weight;
int Parent;
tStub* HeapStub;
};
tGraph*
PrimSpanningTree(const tGraph* g, int r, tHeap<tVertex>* heap)
{
int i;
tVertex* v = new tVertex[g->N];
for (i = 0; i < g->N; ++i) {
v[i].Vertex = i;
v[i].Weight = INT_MAX;
v[i].InQ = true;
v[i].Parent = -1;
if (i == r)
v[i].Weight = 0;
v[i].HeapStub = heap->Insert(&(v[i]));
}
while (heap->Minimum()) {
tVertex* u = heap->ExtractMin();
tAdjacency* a = g->Adjacency[u->Vertex];
while (a) {
if (v[a->Vertex].InQ && a->Weight < v[a->Vertex].Weight) {
v[a->Vertex].Weight = a->Weight;
v[a->Vertex].Parent = u->Vertex;
heap->DecreaseKey(v[a->Vertex].HeapStub);
}
a = a->Next;
}
u->InQ = false;
}
// constroi a arvore geradora minima a partir dos 'Parent's dos
// vertices
tGraph* tree = new tGraph(g->N);
for (i = 0; i < g->N; ++i) {
if (v[i].Parent >= 0)
tree->CreateEdge(i, v[i].Parent, v[i].Weight);
}
return tree;
}
tGraph*
BinomialPrimSpanningTree(const tGraph* g, int r)
{
tBinomialHeap<tVertex> heap;
return PrimSpanningTree(g, r, &heap);
}
tGraph*
FibonacciPrimSpanningTree(const tGraph* g, int r)
{
tFibonacciHeap<tVertex> heap;
return PrimSpanningTree(g, r, &heap);
}
| [
"[email protected]"
]
| [
[
[
1,
95
]
]
]
|
362a851d9b29ae314f772e13b1a301421ff53a0b | 5dd0d48b279823c791ba070e1db53f0137055c29 | /LTPInspectors.h | 60bfc0a6638679247ab0a7a42abaa4401a6231b5 | []
| no_license | ralex1975/pstviewtool | 4b93349cf54ac7d93abbe199462f7eada44c752e | 52f59893ad4390358053541b0257b4a7f2767024 | refs/heads/master | 2020-05-22T01:53:13.553501 | 2010-02-16T22:52:47 | 2010-02-16T22:52:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,889 | h | #pragma once
#include "customcontrols.h"
#include "afxwin.h"
#include "NDBViewChildDlg.h"
#include "afxcmn.h"
// HNInspector dialog
class HNInspector : public CNDBViewChildDlg
{
DECLARE_DYNAMIC(HNInspector)
public:
HNInspector(NID nidParent, NID nid, LTPViewer * pLTPViewer, CNDBViewDlg * pNDBViewDlg, CWnd* pParent = NULL);
virtual ~HNInspector();
// Dialog Data
enum { IDD = IDD_HN_INSPECTOR };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CFileRangeControl m_frc;
public:
CListBox m_pageList;
public:
CListBox m_allocationList;
private:
LTPViewer * m_pLTPViewer;
NID m_nidParent;
NID m_nid;
virtual BOOL OnInitDialog();
afx_msg void OnLbnSelchangeList2();
afx_msg void OnLbnDblclkList2();
afx_msg void OnLbnDblclkList4();
afx_msg void OnLbnSelchangeList4();
};
#pragma once
// BTHInspector dialog
class BTHInspector : public CNDBViewChildDlg
{
DECLARE_DYNAMIC(BTHInspector)
public:
BTHInspector(NID nidParent, NID nid, HID hidRoot, LTPViewer * pLTPViewer, CNDBViewDlg * pNDBViewDlg, CWnd* pParent = NULL); virtual ~BTHInspector();
// Dialog Data
enum { IDD = IDD_BTH_INSPECTOR };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
private:
LTPViewer * m_pLTPViewer;
NID m_nidParent;
NID m_nid;
HID m_hidRoot;
CFileRangeControl m_frc;
CImageList m_il;
CTreeCtrl m_tree;
virtual BOOL OnInitDialog();
afx_msg void OnNMDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult);
};
#pragma once
// IndexRootInspector dialog
class IndexRootInspector : public CNDBViewChildDlg
{
DECLARE_DYNAMIC(IndexRootInspector)
public:
IndexRootInspector(NID nid, LTPViewer * pLTPViewer, CNDBViewDlg * pNDBViewDlg, CWnd* pParent = NULL); // standard constructor
virtual ~IndexRootInspector();
// Dialog Data
enum { IDD = IDD_INDEXROOT };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
private:
LTPViewer * m_pLTPViewer;
NID m_nid;
virtual BOOL OnInitDialog();
CTreeCtrl m_tree;
afx_msg void OnNMDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult);
};
#pragma once
// PCInspector dialog
class PCInspector : public CNDBViewChildDlg
{
DECLARE_DYNAMIC(PCInspector)
public:
PCInspector(NID nidParent, NID nid, LTPViewer * pLTPViewer, CNDBViewDlg * pNDBViewDlg, CWnd* pParent = NULL); // standard constructor
virtual ~PCInspector();
// Dialog Data
enum { IDD = IDD_PC_INSPECTOR };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
NID m_nidParent;
NID m_nid;
LTPViewer * m_pLTPViewer;
DECLARE_MESSAGE_MAP()
public:
CFileRangeControl m_frc;
public:
virtual BOOL OnInitDialog();
public:
CListCtrl m_lc;
};
| [
"terrymah@localhost"
]
| [
[
[
1,
130
]
]
]
|
97a4592ca76fe0e9e1b5ff67bac8adca0fbea995 | 96e96a73920734376fd5c90eb8979509a2da25c0 | /C3DE/TextureOnlyFX.cpp | 0b7f9a7ec73cf877eb6541020084b17f47b9e41f | []
| no_license | lianlab/c3de | 9be416cfbf44f106e2393f60a32c1bcd22aa852d | a2a6625549552806562901a9fdc083c2cacc19de | refs/heads/master | 2020-04-29T18:07:16.973449 | 2009-11-15T10:49:36 | 2009-11-15T10:49:36 | 32,124,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,479 | cpp | #include "TextureOnlyFX.h"
#include "DebugMemory.h"
TextureOnlyFX::TextureOnlyFX(ID3DXEffect *effect):
FX(effect)
{
m_hTex = m_effect->GetParameterByName(0, "gTex");
}
TextureOnlyFX::~TextureOnlyFX()
{
}
void TextureOnlyFX::ResetHandlers()
{
D3DXMATRIX T;
D3DXMatrixIdentity(&T);
SetTransformMatrix(T);
}
void TextureOnlyFX::SetObjectMaterials(D3DXCOLOR ambientMaterial, D3DXCOLOR diffuseMaterial,
D3DXCOLOR specularMaterial, float specularPower)
{
}
void TextureOnlyFX::SetLightHandlers( D3DXCOLOR ambientLightColor, D3DXCOLOR diffuseLightColor,
D3DXCOLOR specularLightColor, D3DXVECTOR3 lightVector)
{
}
void TextureOnlyFX::SetObjectTexture(IDirect3DTexture9 *texture)
{
if(texture)
{
HR(m_effect->SetTexture(m_hTex, texture));
}
}
void TextureOnlyFX::SetWorldHandlers(D3DXVECTOR3 cameraPosition, D3DXMATRIX worldViewProjection)
{
D3DXMATRIX W;
D3DXMatrixIdentity(&W);
D3DXMATRIX WIT;
D3DXMatrixInverse(&WIT, 0, &W);
D3DXMatrixTranspose(&WIT, &WIT);
HR(m_effect->SetMatrix(m_shaderWorldMatrix, &W));
HR(m_effect->SetMatrix(m_shaderViewMatrix, &worldViewProjection));
HR(m_effect->SetMatrix(m_shaderWorldInverseTransposeMatrix, &WIT));
//HR(m_effect->SetValue(m_shaderEyePosition, cameraPosition, sizeof(D3DXVECTOR3)));
}
void TextureOnlyFX::SetAlpha(float alpha)
{
//HR(m_effect->SetFloat(m_shaderAlpha, alpha));
} | [
"caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158"
]
| [
[
[
1,
69
]
]
]
|
cb2e70848173899cf91534e49f5792ecaa089793 | 8de934041a2416f97542d3a30defd31545485b65 | /cpp/str.cpp | d44f475a7e6dc4b4e9788406bc3932310788d969 | []
| no_license | deccico/lib | 0b93aea15d97c890dd9d22787deedc4ef1b392b9 | 073e21b7b6a4d5423b0ea05fa4a58b32bfcf2c48 | refs/heads/master | 2023-07-28T04:56:33.466613 | 2008-03-09T23:07:21 | 2008-03-09T23:07:21 | 403,967,299 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 12,957 | cpp | //---------------------------------------------------------------------------
#include <vcl\vcl.h>
#include <stdio.h>
#pragma hdrstop
#include "str.h"
//---------------------------------------------------------------------------
namespace str_util
{
//---------------------------------------------------------------------------
//reemplaza un caracter por otro en una cadena dada
//sString: cadena a reemplazar
//sBuscar: cadena a buscar
//sReemplazar: cadena que reemplazará la cadena a buscar
AnsiString __fastcall sReemplazar(AnsiString sString, AnsiString sBuscar, AnsiString sReemplazar)
{
AnsiString sAux;
for (int i=1; i<sString.Length()+1; i++){
if ( sString.SubString(i,sBuscar.Length())==sBuscar){
sAux += sReemplazar;
i += sBuscar.Length() - 1;
}
else
sAux += sString.SubString(i,1);
}
return sAux;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//verifica si el argumento str es un mail válido
//pre: cadena
//post: true o false según el email es o no válido
bool __fastcall isEmail(AnsiString str)
{
int j = str.Pos("@"),
nP= str.Pos(".");
if (j < 2 || // la arroba debe estar en la posicion 2 como mínimo
nP < 2 || // el punto debe estar en la posición 2 como mínimo
str.Length() < 5){ //el largo total del email debe ser de 5 como mínimo
return false;
}
else
return true; //el email es válido
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//encripta un string, mediante un algoritmo simple de corrimiento
AnsiString sEncriptar(AnsiString str, int c)
{
AnsiString sCript;
char *cCar;
for (int i=1; i<str.Length()+1; i++){
sCript = str.SubString(i,1);
cCar = sCript.c_str();
*cCar += c;
sCript = AnsiString(cCar);
str = str.SubString(1,i-1) + sCript + str.SubString(i+1,str.Length()-i);
}
return str;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//desencripta un string, mediante un algoritmo simple de corrimiento
AnsiString sDesEncriptar(AnsiString str, int c)
{
AnsiString sCript;
char *cCar;
for (int i=1; i<str.Length()+1; i++){
sCript = str.SubString(i,1);
cCar = sCript.c_str();
*cCar -= c;
sCript = AnsiString(cCar);
str = str.SubString(1,i-1) + sCript + str.SubString(i+1,str.Length()-i);
}
return str;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
AnsiString sValidarPorcentaje(AnsiString sStr)
{
AnsiString s,sIVA = sStr;
sIVA = sIVA.Trim();
if (sIVA.Length() > 5)
sIVA = sIVA.SubString(1,5);
//sIVA = sIVA.SubString(sIVA.Length()-4,5);
bool bSep = false;
for (int i=1; i< sIVA.Length()+1; i++) {
s = sIVA.SubString(i,1);
if ((s < "0" || s > "9")) {
if (!bSep && i > 1 && i < sIVA.Length()) {
s = DecimalSeparator;
bSep = true;
}
else {
s = "0";
}
sIVA = sIVA.SubString(1,i-1) + s + sIVA.SubString(i+1,sIVA.Length());
}
}
sStr = sIVA.ToDouble();
return sStr;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//verifica la validez del CUIT
bool bEsCuitValido(AnsiString sCuit)
{
//return true;
bool validacion=true ;
int coc;
int resto ;
int Digito_Ver;
int v3;
if ((sCuit.Trim().IsEmpty())||(sCuit.SubString(3,1)!="-")||(sCuit.SubString(12,1)!="-"))
validacion = false;
else
{
for (int XX=1;XX<=sCuit.Length();XX++)
{
if ((XX!=3)&&(XX!=12))
{
if ((sCuit.SubString(XX,1)<"0")||(sCuit.SubString(XX,1)>"9"))
{
validacion = false;
XX=sCuit.Length();
};
};
};
};
if (validacion)
{
int suma = (sCuit.SubString(1,1) * 5 +
sCuit.SubString(2,1) * 4 +
sCuit.SubString(4,1) * 3 +
sCuit.SubString(5,1) * 2 +
sCuit.SubString(6,1) * 7 +
sCuit.SubString(7,1) * 6 +
sCuit.SubString(8,1) * 5 +
sCuit.SubString(9,1) * 4 +
sCuit.SubString(10,1) * 3 +
sCuit.SubString(11,1) * 2);
coc= suma / 11;
resto = suma-(coc*11);
Digito_Ver=StrToInt(sCuit.SubString(13,1));
if (resto >1)
{
resto = 11- resto;
};
if (resto!=Digito_Ver)
{
return false;
}
else
{
return true;
};
}
else
{
return false;
};
}
//---------------------------------------------------------------------------
bool RemoveODBCAlias(AnsiString sAlias)
{
typedef BOOL (__stdcall *pSQLConfigDataSource)(HWND, WORD, LPCSTR, LPCSTR);
pSQLConfigDataSource SQLConfigDataSource;
HINSTANCE hLib;
bool bRet = false;
hLib = LoadLibrary("odbccp32.dll");
if (hLib)
{
SQLConfigDataSource =
(pSQLConfigDataSource) GetProcAddress(hLib, "SQLConfigDataSource");
if (SQLConfigDataSource)
{
char szParam[1024];
sprintf(szParam, "DSN=%s;\0", sAlias.c_str());
bRet = SQLConfigDataSource(NULL, 3 /*ODBC_REMOVE_DSN*/,
"Microsoft Access Driver (*.mdb)", szParam);
}
FreeLibrary(hLib);
} // Devuelve true si se borra o false en caso contrario
return bRet;
}
//--------------------------------------------------------------------------------
//---------------------------------------------------------------------------
bool CreateODBCAlias(AnsiString sAlias, AnsiString sDB, AnsiString sDir, AnsiString sDescription)
{
typedef BOOL (__stdcall *pSQLConfigDataSource)(HWND, WORD, LPCSTR, LPCSTR);
pSQLConfigDataSource SQLConfigDataSource;
HINSTANCE hLib;
bool bRet = false;
hLib = LoadLibrary("odbccp32.dll");
if (hLib)
{
SQLConfigDataSource =
(pSQLConfigDataSource) GetProcAddress(hLib, "SQLConfigDataSource");
if (SQLConfigDataSource)
{
char szParam[1024];
sprintf(szParam, "DSN=%s; Description=%s; DefaultDir=%s; DBQ=%s\0",
sAlias.c_str(), sDescription.c_str(), sDir.c_str(), sDB.c_str());
bRet = SQLConfigDataSource(NULL, 1 /*ODBC_ADD_DSN*/,
"Microsoft Access Driver (*.mdb)", szParam);
}
FreeLibrary(hLib);
} // Devuelve true si se crea o false en caso contrario
return bRet;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//devuelve el nro de campo pedido es un .csv dado
const AnsiString GetCSVField(AnsiString sLinea, int nField=1)
{
int nCurField = 1;
AnsiString sResult="";
for (int i=0; i<sLinea.Length(); i++){
if (sLinea.SubString(i,1)==",") nCurField++;
if (nCurField==nField){
for (int j=i+1; sLinea.SubString(j,1) != "," && j<sLinea.Length(); j++){
sResult += sLinea.SubString(j,1);
}
break;
}
}
return sResult;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//devuelve el nro de campo pedido es un .csv dado
const AnsiString GetCSVField(AnsiString sLinea, AnsiString sSep, int nField=1)
{
int nCurField = 1;
AnsiString sResult="";
for (int i=0; i<sLinea.Length(); i++){
if (sLinea.SubString(i,1)==sSep) nCurField++;
if (nCurField==nField){
for (int j=i+1; sLinea.SubString(j,1) != sSep && j<sLinea.Length(); j++){
sResult += sLinea.SubString(j,1);
}
break;
}
}
return sResult;
}
//------------------------------------------------------------------------------
//---------------------------------------------------------------------------
void Encriptar(char *instr, char *outstr, int size)
{
int ii;
for (ii=0; ii<size; ii++) {
outstr[ii] = instr[ii] ^ ii;
}
outstr[size] = NULL;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void ToMime64(char *instr, char *outstr, int size)
{
int ii;
for (ii=0; ii<size; ii++) {
outstr[ii] = instr[ii] ^ ii;
}
outstr[size] = NULL;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
AnsiString Encomillar(AnsiString s)
{
return "\"" + s + "\"";
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
AnsiString __fastcall DameUsuario(const AnsiString &nombre, const AnsiString &apellido)
{
AnsiString n = nombre.Trim(), a = apellido.Trim();
n = n.SubString(1,1) + a;
n = sReemplazar(n," ","_");
return (n);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
AnsiString __fastcall DameFlotante(AnsiString str)
{
str = sReemplazar(str, ",", DecimalSeparator);
str = sReemplazar(str, ".", DecimalSeparator);
//..valido monto con número flotante correcto
try{
str.ToDouble();
}
catch(EConvertError &E)
{
throw Exception (str + "no es un número decimal válido");
}
return str;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
double __fastcall DameFlotanteDec(AnsiString str)
{
str = sReemplazar(str, ",", DecimalSeparator);
str = sReemplazar(str, ".", DecimalSeparator);
//..valido monto con número flotante correcto
try{
str.ToDouble();
}
catch(EConvertError &E)
{
throw Exception (str + "no es un número decimal válido");
}
return str.ToDouble();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
AnsiString GenerarTextoAlAzar(int len)
{
AnsiString resultado;
randomize();
for(int i=0; i<len/2; ++i)
resultado += AnsiString::IntToHex(rand() % 100,2);
return resultado;
}
//---------------------------------------------------------------------------
AnsiString __fastcall EncriptarConMime64(const AnsiString &text)
{
int len = text.Length();
AnsiString ret;
char *resultado = (char *) malloc(len * 2);
char *pivote = (char *) malloc(len * 2);
Encriptar(text.c_str(), pivote, len);
ToMime64(pivote, resultado, strlen(pivote));
ret = mEmpaquetar(resultado);
free(pivote);
free(resultado);
return ret;
}
//---------------------------------------------------------------------------
AnsiString __fastcall mEmpaquetar(AnsiString sComando)
{
AnsiString sTop,sCmd,sFSN;
AnsiString sPaquete,sHeader,sTail,sProcess,s,sData;
int nTop,msg;
int j;
char *c,car;
//sComando=sComando.UpperCase(); //mayusculas
//sComando=mChauCaracter(sComando,' '); //quita blancos
if (sComando.IsEmpty())
return "-1";
sData=sComando;
s.SetLength(1);
for (int i=1;i<=sData.Length();i++){
s= sData.SubString(i,1);
c= s.c_str();
car = (char) *c;
j=toascii(car);
sProcess = sProcess + sProcess.IntToHex(j,2);
}
return sProcess;
}
//---------------------------------------------------------------------------
}
| [
"[email protected]"
]
| [
[
[
1,
482
]
]
]
|
787876eb16dd41a31a817a4233e013c18da72562 | f177993b13e97f9fecfc0e751602153824dfef7e | /ImProSln/TouchLibFilter/Touchlib/include/TouchScreenDevice.h | 2526b1d41dbb2495a1c09fa56890329abb873e93 | []
| no_license | svn2github/imtophooksln | 7bd7412947d6368ce394810f479ebab1557ef356 | bacd7f29002135806d0f5047ae47cbad4c03f90e | refs/heads/master | 2020-05-20T04:00:56.564124 | 2010-09-24T09:10:51 | 2010-09-24T09:10:51 | 11,787,598 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 390 | h | #ifndef __TOUCHLIB_TOUCHSCREENDEVICE__
#define __TOUCHLIB_TOUCHSCREENDEVICE__
#include <touchlib_platform.h>
#include <ITouchScreen.h>
namespace touchlib
{
class CTouchScreen;
class TouchScreenDevice
{
public:
static ITouchScreen *getTouchScreen(int cw = 640, int ch = 480.0);
static void destroy();
private:
static CTouchScreen *tscreen;
};
}
#endif
| [
"ndhumuscle@fa729b96-8d43-11de-b54f-137c5e29c83a"
]
| [
[
[
1,
21
]
]
]
|
0058f8bc26af59d9ebf539b0aa71a61b82e2e7db | 87cfed8101402f0991cd2b2412a5f69da90a955e | /daq/daq/src/mwnidaq/labio.cpp | f8c090c3922022276c28388501ee4798f2d0260b | []
| no_license | dedan/clock_stimulus | d94a52c650e9ccd95dae4fef7c61bb13fdcbd027 | 890ec4f7a205c8f7088c1ebe0de55e035998df9d | refs/heads/master | 2020-05-20T03:21:23.873840 | 2010-06-22T12:13:39 | 2010-06-22T12:13:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,933 | cpp | //
// LABIO.CPP
// Class to represent the 1200 series cards
// Copyright 1998-2004 The MathWorks, Inc.
// $Revision: 1.2.4.2 $ $Date: 2004/04/08 20:49:44 $
//
#include "stdafx.h"
#include "mwnidaq.h"
#include "nia2d.h"
#include "daqmex.h"
#include "daqtypes.h"
#include "errors.h"
#include "nidaq.h"
#include "nidaqcns.h"
#include "nidaqerr.h"
#include <crtdbg.h>
#include <sarrayaccess.h>
#include <math.h>
#define AUTO_LOCK TAtlLock<Cnia2d> _lock(*this)
HRESULT CLabInput::Open(IDaqEngine *engine,int id,DevCaps* DeviceCaps)
{
RETURN_HRESULT(Cnia2d::Open(engine, id,DeviceCaps));
if (GetDevCaps()->Is700())
{
_chanSkewMode->ClearEnumValues();
_chanSkewMode->AddMappedEnumValue(EQUISAMPLE, L"Equisample");
_chanSkewMode=EQUISAMPLE;
_chanSkewMode->put_DefaultValue(CComVariant(EQUISAMPLE));
UpdateTimeing(FORSET);
}
return S_OK;
}
STDMETHODIMP CLabInput::SetProperty(long User, VARIANT *newVal)
{
if (User==(long)&_chanSkew && GetDevCaps()->Is700())
{
return Error(L"Channel skew may not be set on LPM type devices because ChannelSkewMode must be Equisample.");
}
return Cnia2d::SetProperty(User,newVal);
}
STDMETHODIMP CLabInput::SetChannelProperty(long User,NESTABLEPROP * pChan, VARIANT * NewValue)
{
HRESULT status=Cnia2d::SetChannelProperty(User,pChan,NewValue);
if (User==INPUTRANGE && status==S_OK)
{
// change the default value
}
return status;
}
STDMETHODIMP CLabInput::GetSingleValues(VARIANT* values)
{
AUTO_LOCK; // Should not be needed inserted on a whim
if (!_isConfig)
DAQ_CHECK(Configure(FORSINGLEVALUE));
// 3 SCANS IS THE MIN with scan_op
SAFEARRAY *ps = SafeArrayCreateVector(VT_I2, 0, _nChannels*2);
if (ps==NULL) return E_SAFEARRAY_ERR;
// set the data type and values
V_ARRAY(values)=ps;
V_VT(values)=VT_ARRAY | VT_I2;
TSafeArrayAccess <short > binarray(values);
if (_nChannels<=2)
{
for (int i=0;i<_nChannels;i++)
{
DAQ_CHECK(AI_Read(_id, _chanList[i], _gainList[i], &binarray[i]));
}
}
else
{
// setup the channels to read and scan them
DAQ_TRACE(Set_DAQ_Device_Info(_id, ND_DATA_XFER_MODE_AI, ND_INTERRUPTS));
short *dummy=(short*)_alloca(_nChannels*sizeof(short));
DAQ_CHECK(Lab_ISCAN_Op(_id,static_cast<i16>(_nChannels),_gainList[0],&binarray[0],
_nChannels, 1.0/_chanSkew,0,dummy));
}
return S_OK;
}
STDMETHODIMP CLabInput::ChildChange(DWORD typeofchange, NESTABLEPROP *pChan)
{
if ((typeofchange & CHILDCHANGE_REASON_MASK)== ADD_CHILD)
{
int MaxChannels=_chanType.Value==DIFFERENTIAL ? GetDevCaps()->nDIInputIDs : GetDevCaps()->nSEInputIDs;
if (_nChannels>=MaxChannels)
return Error(L"Lab and LPM boards may not scan more channels then are present on the board.");
}
return Cnia2d::ChildChange( typeofchange, pChan);
}
int CLabInput::TriggerSetup()
{
short starttrig=0;
_ASSERTE(!GetDevCaps()->IsESeries()); // E series not supported by this function
if (_triggerType & TRIG_TRIGGER_IS_HARDWARE)
{
switch(_triggerType)
{
case HW_DIGITAL:
starttrig=1;
break;
default:
return E_E_SERIES_ONLY;
}
}
return(DAQ_Config(_id, starttrig, (short)_clockSrc));
}
double CLabInput::RoundRate(double SourceRate)
{
double clockfreq=1.0/Timebase2ClockResolution(_scanTB);
long clockdiv=static_cast<long>(floor(clockfreq/SourceRate+.01)); // spec says one percent tol (of what?)
return clockfreq/ clockdiv ;
}
HRESULT CLabInput::UpdateTimeing(ConfigReason reason)
{
double newChanSkew=_chanSkew;
double newRate=GetTargetSampleRate();
newRate=GetDevCaps()->FindRate(newRate,&_scanTB,&_scanInterval); // base from samplerate
if (_nChannels<2)
{
newChanSkew=(GetDevCaps()->settleTime+10)*1e-6;
}
else
{
switch (_chanSkewMode)
{
case CHAN_SKEW_MIN:
{
// settleTime is in uSec
// we use a 10 uSec slop factor at the advice of NI
double settleTime = GetDevCaps()->settleTime + 10;
if (settleTime/1e6*(_nChannels+2) > 1.0/GetTargetSampleRate())
{
// switch to equalsample
newChanSkew=1.0/RoundRate(_sampleRate*_nChannels);
if (newChanSkew* (_nChannels+2) >= 1.0/GetTargetSampleRate())
// if no time to scan then use equal sample
{
_scanInterval=0;
newChanSkew=1/(GetDevCaps()->FindRate(GetTargetSampleRate()*_nChannels,&_scanTB,&_sampleInterval));
// now fix up sample rate
newRate=1.0/ (newChanSkew *_nChannels);
}
}
else
{ // using min
// DAQ_ Rate(settleTime/1e6, 1, &_sampleTB, &_sampleInterval);
// *chanSkew=_sampleInterval*Timebase2ClockResolution(_sampleTB);
double clockfreq=1.0/Timebase2ClockResolution(_scanTB);
_sampleInterval=static_cast<unsigned short>(floor(clockfreq*settleTime/1e6+.01)); // spec says one percent tol (of what?)
newChanSkew=_sampleInterval/clockfreq;
}
}
break;
case EQUISAMPLE:
{
newChanSkew=1/(GetDevCaps()->FindRate(GetTargetSampleRate()*_nChannels,&_scanTB,&_sampleInterval));
_scanInterval=0;
// now fix up sample rate
newRate=1.0/ (newChanSkew *_nChannels);
}
break;
case CHAN_SKEW_MANUAL:
{
double clockfreq=1.0/Timebase2ClockResolution(_scanTB);
_sampleInterval=static_cast<unsigned short>(floor(clockfreq*newChanSkew+.01)); // spec says one percent tol (of what?)
newChanSkew=_sampleInterval/clockfreq; }
break;
default:
break;
}
}
// put the new value back to the engine.
if (_chanSkew!=newChanSkew)
{
_chanSkew=newChanSkew;
}
if (newRate!=_sampleRate)
{
_sampleRate=newRate;
}
return S_OK;
}
HRESULT CLabInput::Configure(ConfigReason reason)
{
// all channels must have the same range need to find the range
// 1200 and lab boards have gains 700 boards do not
if (reason>FORSET)
{
_ASSERTE(_nChannels!=0);
CurrentRange=FindRangeFromGainInt(_gainList[0], _polarityList[0]);
_ASSERTE(CurrentRange!=NULL);
short inputRange=0;
// Check all channels for correct input range;
for (int i=0; i<_nChannels; i++)
{
// 700 and lpm boards do not have gains but do have multiple ranges
// 1200 boards have gains
if (_gainList[i]!=CurrentRange->GainInt || _polarityList[i] !=CurrentRange->polarity)
{
return Error(L"Your hardware does not support different input ranges on two or more channels.");
}
}
DAQ_CHECK(AI_Configure( _id,-1, GET_ADAPTOR_ENUM_VALUE(_chanType),
static_cast<i16>(CurrentRange->maxVal-CurrentRange->minVal),
CurrentRange->polarity, _driveAIS));
// done with input range
UpdateTimeing(reason);
}
DAQ_CHECK(TriggerSetup());
// Clear any previously configured messages
// ClearEventMessages(_id);
_isConfig = true;
return S_OK;
}
STDMETHODIMP CLabInput::Trigger()
{
/*
* Start the acquisition
*/
AUTO_LOCK;
if (_nChannels==1)
{
// Convert the sample rate to a timebase and sample interval
// DAQ_CHECK(DAQ_ Rate(_sampleRate, 0, &_scanTB, &_scanInterval));
DAQ_CHECK(DAQ_Start(_id, _chanList[0], _gainList[0], _CircBuff.GetPtr(),
_CircBuff.GetBufferSize(), _scanTB, _scanInterval));
}
else
{ //
DAQ_CHECK(Lab_ISCAN_Start(_id, static_cast<i16>(_nChannels), _gainList[0],
_CircBuff.GetPtr(), _CircBuff.GetBufferSize(), _scanTB, _sampleInterval,
_scanInterval));
}
_running=true;
_callTrigger=true;
return S_OK;
}
| [
"[email protected]"
]
| [
[
[
1,
274
]
]
]
|
ab529b8bd1cc1e7e547b3a5f4ba089fc7f79f24c | 4c7ed342d9d1d083475734a891e4e8df3918e36e | /KeyMan/inc/shared.h | 5d8d8e855786fefdae6f4f984562f1df05436c43 | []
| no_license | pety3bi/keymans60 | c1c72630d0f6be2f3353f1f7c4eaff7760a5ef3c | 38202208483e5767ef49159c1da9d48998611171 | refs/heads/master | 2021-01-10T21:10:33.448842 | 2010-11-08T03:37:43 | 2010-11-08T03:37:43 | 34,176,487 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,389 | h | // Reconstructed from commonengine.lib with dumpbin
// by Alex Yakovlev:
// [email protected],
// http://alexgraf.com/alex/
#ifndef _RSHARED_DATA_
#define _RSHARED_DATA_
class RSharedDataClient
{
public:
RSharedDataClient(class MSharedDataNotifyHandler *);
RSharedDataClient(void);
int Assign(class TUid) const;
int AssignToTemporaryFile(class TUid) const;
void CancelAllNotifies(void);
void CancelNotify(class TUid,class TDesC16 const *);
void Close(void);
int Connect(int);
int Flush(void) const;
int GetInt(class TDesC16 const &,int &) const;
int GetReal(class TDesC16 const &,double &) const;
int GetString(class TDesC16 const &,class TDes16 &) const;
int NotifyChange(class TUid,class TDesC16 const *);
int NotifySet(class TUid,class TDesC16 const *);
int RestoreOriginal(class TUid,class MDesC16Array const *);
int SetInt(class TDesC16 const &,int);
int SetReal(class TDesC16 const &,double);
int SetString(class TDesC16 const &,class TDesC16 const &);
void CancelFreeDiskSpaceRequest(void) const;
void RequestFreeDiskSpace(int) const;
void RequestFreeDiskSpaceLC(int) const;
int AddToValue(class TDesC16 const &,int);
void CancelAllSignals(void);
void CancelSignal(class TDesC16 const &);
int Signal(class TDesC16 const &);
private:
void *v1,*v2,*v3,*v4;
};
#endif // _RSHARED_DATA_
| [
"[email protected]@7ae75f86-5c51-0410-bd6e-896d651d5528"
]
| [
[
[
1,
41
]
]
]
|
7974a27506b190655c0ccf00394d053de225c41a | 6581dacb25182f7f5d7afb39975dc622914defc7 | /CrashRpt/crashrpt/src/zlibcpp.h | c9170f1ec8b7cac554c6a7d74d3e06071a73edaa | [
"Zlib"
]
| permissive | dice2019/alexlabonline | caeccad28bf803afb9f30b9e3cc663bb2909cc4f | 4c433839965ed0cff99dad82f0ba1757366be671 | refs/heads/master | 2021-01-16T19:37:24.002905 | 2011-09-21T15:20:16 | 2011-09-21T15:20:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 919 | h | ///////////////////////////////////////////////////////////////////////////////
//
// Module: zlibcpp.h
//
// Desc: Basic class wrapper for the zlib dll
//
// Copyright (c) 2003 Automatic Data Processing, Inc. All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _ZLIBCPP_H_
#define _ZLIBCPP_H_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef ZLIB_DLL
#define ZLIB_DLL
#endif // !ZLIB_DLL
#ifndef _WINDOWS
#define _WINDOWS
#endif // !_WINDOWS
#ifndef _zip_H
#include "../../zlib/include/zip.h"
#pragma comment(lib, "../../zlib/lib/zlib.lib")
#endif // _zip_H
#include <atlmisc.h>
class CZLib
{
public:
CZLib();
virtual ~CZLib();
BOOL Open(CString f_file, int f_nAppend = 0);
BOOL AddFile(CString f_file);
void Close();
protected:
zipFile m_zf;
};
#endif // !_ZLIBCPP_H
| [
"damoguyan8844@3a4e9f68-f5c2-36dc-e45a-441593085838"
]
| [
[
[
1,
46
]
]
]
|
fb380ef00282a1fe0278e7e4ca8c9ee69842c3b3 | 4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61 | /CleanProject/luabind/detail/class_rep.hpp | acaebc428b5287803749f736a27ef806c346dad6 | []
| no_license | bahao247/apeengine2 | 56560dbf6d262364fbc0f9f96ba4231e5e4ed301 | f2617b2a42bdf2907c6d56e334c0d027fb62062d | refs/heads/master | 2021-01-10T14:04:02.319337 | 2009-08-26T08:23:33 | 2009-08-26T08:23:33 | 45,979,392 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 13,128 | hpp | // Copyright (c) 2003 Daniel Wallin and Arvid Norberg
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef LUABIND_CLASS_REP_HPP_INCLUDED
#define LUABIND_CLASS_REP_HPP_INCLUDED
#include <boost/limits.hpp>
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <utility>
#include <list>
#include <luabind/config.hpp>
#include <luabind/detail/object_rep.hpp>
#include <luabind/detail/construct_rep.hpp>
#include <luabind/detail/garbage_collector.hpp>
#include <luabind/detail/operator_id.hpp>
#include <luabind/detail/class_registry.hpp>
#include <luabind/detail/find_best_match.hpp>
#include <luabind/detail/get_overload_signature.hpp>
#include <luabind/error.hpp>
#include <luabind/handle.hpp>
#include <luabind/detail/primitives.hpp>
namespace luabind
{
template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(LUABIND_MAX_BASES, class A, detail::null_type)>
struct bases {};
typedef bases<detail::null_type> no_bases;
}
namespace luabind { namespace detail
{
LUABIND_API std::string stack_content_by_name(lua_State* L, int start_index);
struct class_registration;
struct conversion_storage;
// This function is used as a tag to identify "properties".
LUABIND_API int property_tag(lua_State*);
// this is class-specific information, poor man's vtable
// this is allocated statically (removed by the compiler)
// a pointer to this structure is stored in the lua tables'
// metatable with the name __classrep
// it is used when matching parameters to function calls
// to determine possible implicit casts
// it is also used when finding the best match for overloaded
// methods
class LUABIND_API class_rep
{
friend struct class_registration;
friend int super_callback(lua_State*);
//TODO: avoid the lua-prefix
friend int lua_class_gettable(lua_State*);
friend int lua_class_settable(lua_State*);
friend int static_class_gettable(lua_State*);
public:
enum class_type
{
cpp_class = 0,
lua_class = 1
};
// destructor is a lua callback function that is hooked as garbage collector event on every instance
// of this class (including those that is not owned by lua). It gets an object_rep as argument
// on the lua stack. It should delete the object pointed to by object_rep::ptr if object_pre::flags
// is object_rep::owner (which means that lua owns the object)
// EXPECTS THE TOP VALUE ON THE LUA STACK TO
// BE THE USER DATA WHERE THIS CLASS IS BEING
// INSTANTIATED!
class_rep(LUABIND_TYPE_INFO type
, const char* name
, lua_State* L
, void(*destructor)(void*)
, void(*const_holder_destructor)(void*)
, LUABIND_TYPE_INFO holder_type
, LUABIND_TYPE_INFO const_holder_type
, void*(*extractor)(void*)
, const void*(*const_extractor)(void*)
, void(*const_converter)(void*,void*)
, void(*construct_holder)(void*,void*)
, void(*construct_const_holder)(void*,void*)
, void(*default_construct_holder)(void*)
, void(*default_construct_const_holder)(void*)
, void(*adopt_fun)(void*)
, int holder_size
, int holder_alignment);
// used when creating a lua class
// EXPECTS THE TOP VALUE ON THE LUA STACK TO
// BE THE USER DATA WHERE THIS CLASS IS BEING
// INSTANTIATED!
class_rep(lua_State* L, const char* name);
~class_rep();
std::pair<void*,void*> allocate(lua_State* L) const;
// called from the metamethod for __index
// the object pointer is passed on the lua stack
int gettable(lua_State* L);
// called from the metamethod for __newindex
// the object pointer is passed on the lua stack
bool settable(lua_State* L);
// this is called as __index metamethod on every instance of this class
static int gettable_dispatcher(lua_State* L);
// this is called as __newindex metamethod on every instance of this class
static int settable_dispatcher(lua_State* L);
static int operator_dispatcher(lua_State* L);
// this is called as metamethod __call on the class_rep.
static int constructor_dispatcher(lua_State* L);
static int function_dispatcher(lua_State* L);
struct base_info
{
int pointer_offset; // the offset added to the pointer to obtain a basepointer (due to multiple-inheritance)
class_rep* base;
};
void add_base_class(const base_info& binfo);
const std::vector<base_info>& bases() const throw() { return m_bases; }
void set_type(LUABIND_TYPE_INFO t) { m_type = t; }
LUABIND_TYPE_INFO type() const throw() { return m_type; }
LUABIND_TYPE_INFO holder_type() const throw() { return m_holder_type; }
LUABIND_TYPE_INFO const_holder_type() const throw() { return m_const_holder_type; }
bool has_holder() const throw() { return m_construct_holder != 0; }
const char* name() const throw() { return m_name; }
// the lua reference to this class_rep
// TODO: remove
// int self_ref() const throw() { return m_self_ref; }
// the lua reference to the metatable for this class' instances
int metatable_ref() const throw() { return m_instance_metatable; }
void get_table(lua_State* L) const { m_table.push(L); }
void get_default_table(lua_State* L) const { m_default_table.push(L); }
void(*construct_holder() const)(void*, void*) { return m_construct_holder; }
void(*destructor() const)(void*) { return m_destructor; }
void(*const_holder_destructor() const)(void*) { return m_const_holder_destructor; }
typedef const void*(*t_const_extractor)(void*);
t_const_extractor const_extractor() const { return m_const_extractor; }
typedef void*(*t_extractor)(void*);
t_extractor extractor() const { return m_extractor; }
void(*const_converter() const)(void*,void*) { return m_const_converter; }
class_type get_class_type() const { return m_class_type; }
void add_static_constant(const char* name, int val);
// takes a pointer to the instance object
// and if it has a wrapper, the wrapper
// will convert its weak_ptr into a strong ptr.
void adopt(bool const_obj, void* obj);
static int super_callback(lua_State* L);
static int lua_settable_dispatcher(lua_State* L);
// called from the metamethod for __index
// obj is the object pointer
static int lua_class_gettable(lua_State* L);
// called from the metamethod for __newindex
// obj is the object pointer
static int lua_class_settable(lua_State* L);
// called from the metamethod for __index
// obj is the object pointer
static int static_class_gettable(lua_State* L);
void* convert_to(
LUABIND_TYPE_INFO target_type
, const object_rep* obj, conversion_storage&) const;
bool has_operator_in_lua(lua_State*, int id);
// this is used to describe setters and getters
struct callback
{
boost::function2<int, lua_State*, int> func;
#ifndef LUABIND_NO_ERROR_CHECKING
int (*match)(lua_State*, int);
typedef void(*get_sig_ptr)(lua_State*, std::string&);
get_sig_ptr sig;
#endif
int pointer_offset;
};
const std::map<const char*, callback, ltstr>& properties() const;
typedef std::map<const char*, callback, ltstr> property_map;
int holder_alignment() const
{
return m_holder_alignment;
}
int holder_size() const
{
return m_holder_size;
}
void set_holder_alignment(int n)
{
m_holder_alignment = n;
}
void set_holder_size(int n)
{
m_holder_size = n;
}
void derived_from(const class_rep* base)
{
m_holder_alignment = base->m_holder_alignment;
m_holder_size = base->m_holder_size;
m_holder_type = base->m_holder_type;
m_const_holder_type = base->m_const_holder_type;
m_extractor = base->m_extractor;
m_const_extractor = base->m_const_extractor;
m_const_converter = base->m_const_converter;
m_construct_holder = base->m_construct_holder;
m_construct_const_holder = base->m_construct_const_holder;
m_default_construct_holder = base->m_default_construct_holder;
m_default_construct_const_holder = base->m_default_construct_const_holder;
}
struct operator_callback: public overload_rep_base
{
inline void set_fun(int (*f)(lua_State*)) { func = f; }
inline int call(lua_State* L) { return func(L); }
inline void set_arity(int arity) { m_arity = arity; }
private:
int(*func)(lua_State*);
};
private:
void cache_operators(lua_State*);
// this is a pointer to the type_info structure for
// this type
// warning: this may be a problem when using dll:s, since
// typeid() may actually return different pointers for the same
// type.
LUABIND_TYPE_INFO m_type;
LUABIND_TYPE_INFO m_holder_type;
LUABIND_TYPE_INFO m_const_holder_type;
// this function pointer is used if the type is held by
// a smart pointer. This function takes the type we are holding
// (the held_type, the smart pointer) and extracts the actual
// pointer.
void*(*m_extractor)(void*);
const void*(*m_const_extractor)(void*);
void(*m_const_converter)(void*, void*);
// this function is used to construct the held_type
// (the smart pointer). The arguments are the memory
// in which it should be constructed (with placement new)
// and the raw pointer that should be wrapped in the
// smart pointer
typedef void(*construct_held_type_t)(void*,void*);
construct_held_type_t m_construct_holder;
construct_held_type_t m_construct_const_holder;
typedef void(*default_construct_held_type_t)(void*);
default_construct_held_type_t m_default_construct_holder;
default_construct_held_type_t m_default_construct_const_holder;
typedef void(*adopt_t)(void*);
adopt_t m_adopt_fun;
// this is the size of the userdata chunk
// for each object_rep of this class. We
// need this since held_types are constructed
// in the same memory (to avoid fragmentation)
int m_holder_size;
int m_holder_alignment;
// a list of info for every class this class derives from
// the information stored here is sufficient to do
// type casts to the base classes
std::vector<base_info> m_bases;
// the class' name (as given when registered to lua with class_)
const char* m_name;
// contains signatures and construction functions
// for all constructors
construct_rep m_constructor;
// a reference to this structure itself. Since this struct
// is kept inside lua (to let lua collect it when lua_close()
// is called) we need to lock it to prevent collection.
// the actual reference is not currently used.
detail::lua_reference m_self_ref;
// this should always be used when accessing
// members in instances of a class.
// this table contains c closures for all
// member functions in this class, they
// may point to both static and virtual functions
handle m_table;
// this table contains default implementations of the
// virtual functions in m_table.
handle m_default_table;
// the type of this class.. determines if it's written in c++ or lua
class_type m_class_type;
// this is a lua reference that points to the lua table
// that is to be used as meta table for all instances
// of this class.
int m_instance_metatable;
// ***** the maps below contains all members in this class *****
// datamembers, some members may be readonly, and
// only have a getter function
std::map<const char*, callback, ltstr> m_getters;
std::map<const char*, callback, ltstr> m_setters;
std::vector<operator_callback> m_operators[number_of_operators]; // the operators in lua
void(*m_destructor)(void*);
void(*m_const_holder_destructor)(void*);
std::map<const char*, int, ltstr> m_static_constants;
// the first time an operator is invoked
// we check the associated lua table
// and cache the result
int m_operator_cache;
};
bool is_class_rep(lua_State* L, int index);
}}
//#include <luabind/detail/overload_rep_impl.hpp>
#endif // LUABIND_CLASS_REP_HPP_INCLUDED
| [
"pablosn@06488772-1f9a-11de-8b5c-13accb87f508"
]
| [
[
[
1,
384
]
]
]
|
2035a81decf22e2f28c2cb6c53bb04c584642861 | 33f59b1ba6b12c2dd3080b24830331c37bba9fe2 | /Depend/Foundation/Mathematics/Wm4BandedMatrix.h | bfe8cc0994a7fe6ae3adc7c889b35fef7ace7f52 | []
| no_license | daleaddink/flagship3d | 4835c223fe1b6429c12e325770c14679c42ae3c6 | 6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a | refs/heads/master | 2021-01-15T16:29:12.196094 | 2009-11-01T10:18:11 | 2009-11-01T10:18:11 | 37,734,654 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,673 | h | // Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// The Wild Magic Version 4 Foundation Library source code is supplied
// under the terms of the license agreement
// http://www.geometrictools.com/License/Wm4FoundationLicense.pdf
// and may not be copied or disclosed except in accordance with the terms
// of that agreement.
#ifndef WM4BANDEDMATRIX_H
#define WM4BANDEDMATRIX_H
#include "Wm4FoundationLIB.h"
#include "Wm4System.h"
namespace Wm4
{
template <class Real>
class BandedMatrix
{
public:
BandedMatrix (int iSize, int iLBands, int iUBands);
BandedMatrix (const BandedMatrix& rkM);
~BandedMatrix ();
BandedMatrix& operator= (const BandedMatrix& rkM);
int GetSize () const;
int GetLBands () const;
int GetUBands () const;
Real* GetDBand ();
const Real* GetDBand () const;
int GetLBandMax (int i) const; // LBand(i): 0 <= index < LBandMax
Real* GetLBand (int i);
const Real* GetLBand (int i) const;
int GetUBandMax (int i) const; // UBand(i): 0 <= index < UBandMax
Real* GetUBand (int i);
const Real* GetUBand (int i) const;
Real& operator() (int iRow, int iCol);
Real operator() (int iRow, int iCol) const;
void SetZero ();
void SetIdentity ();
private:
void Allocate ();
void Deallocate ();
int m_iSize, m_iLBands, m_iUBands;
Real* m_afDBand;
Real** m_aafLBand;
Real** m_aafUBand;
};
#include "Wm4BandedMatrix.inl"
typedef BandedMatrix<float> BandedMatrixf;
typedef BandedMatrix<double> BandedMatrixd;
}
#endif
| [
"yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa"
]
| [
[
[
1,
68
]
]
]
|
fa0c7ebbfed114bf6d38562af8caf25fe901f9b6 | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /tags/release-2006-01-18/cvpcb/cvframe.cpp | 36c509bf32019f40389f7263ef765ab444d8a1d2 | []
| 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 | UTF-8 | C++ | false | false | 12,304 | cpp | /*********************/
/* File: cvframe.cpp */
/*********************/
#include "fctsys.h"
#include "common.h"
#include <wx/fontdlg.h>
#include "cvpcb.h"
#include "gr_basic.h"
#include "pcbnew.h"
#include "bitmaps.h"
#include "protos.h"
#include "id.h"
#define FRAME_MIN_SIZE_X 450
#define FRAME_MIN_SIZE_Y 300
/*******************************************************/
/* Constructeur de WinEDA_CvpcbFrame: la fenetre generale */
/*******************************************************/
WinEDA_CvpcbFrame::WinEDA_CvpcbFrame(WinEDA_App *parent, const wxString & title ):
WinEDA_BasicFrame(NULL, CVPCB_FRAME, parent, title, wxDefaultPosition, wxDefaultSize )
{
m_FrameName = wxT("CvpcbFrame");
m_ListCmp = NULL;
m_ListMod = NULL;
DrawFrame = NULL;
m_FilesMenu = NULL;
m_HToolBar = NULL;
// Give an icon
SetIcon( wxICON(icon_cvpcb));
SetFont(*g_StdFont);
SetAutoLayout(TRUE);
GetSettings();
if ( m_FrameSize.x < FRAME_MIN_SIZE_X ) m_FrameSize.x = FRAME_MIN_SIZE_X;
if ( m_FrameSize.y < FRAME_MIN_SIZE_Y ) m_FrameSize.y = FRAME_MIN_SIZE_Y;
// create the status bar
int dims[3] = { -1, -1, 150};
CreateStatusBar(3);
SetStatusWidths(3,dims);
ReCreateMenuBar();
ReCreateHToolbar();
// Creation des listes de modules disponibles et des composants du schema
// Create child subwindows.
BuildCmpListBox();
BuildModListBox();
/* Creation des contraintes de dimension de la fenetre d'affichage des composants
du schema */
wxLayoutConstraints * linkpos = new wxLayoutConstraints;
linkpos->top.SameAs(this,wxTop);
linkpos->bottom.SameAs(this,wxBottom);
linkpos->left.SameAs(this,wxLeft);
linkpos->width.PercentOf(this,wxWidth,66);
m_ListCmp->SetConstraints(linkpos);
/* Creation des contraintes de dimension de la fenetre d'affichage des modules
de la librairie */
linkpos = new wxLayoutConstraints;
linkpos->top.SameAs(m_ListCmp,wxTop);
linkpos->bottom.SameAs(m_ListCmp,wxBottom);
linkpos->right.SameAs(this,wxRight);
linkpos->left.SameAs(m_ListCmp,wxRight);
m_ListMod->SetConstraints(linkpos);
SetSizeHints(FRAME_MIN_SIZE_X,FRAME_MIN_SIZE_Y, -1,-1, -1,-1); // Set minimal size to w,h
SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y);
}
/************************************************/
void WinEDA_CvpcbFrame::OnSize(wxSizeEvent& event)
/************************************************/
{
event.Skip();
}
/***************************************************************/
/* Construction de la table des evenements pour WinEDA_CvpcbFrame */
/***************************************************************/
BEGIN_EVENT_TABLE(WinEDA_CvpcbFrame, wxFrame)
EVT_MENU_RANGE(ID_LOAD_PROJECT,ID_LOAD_FILE_10,
WinEDA_CvpcbFrame::LoadNetList)
EVT_MENU(ID_SAVE_PROJECT, WinEDA_CvpcbFrame::SaveQuitCvpcb)
EVT_MENU(ID_CVPCB_QUIT, WinEDA_CvpcbFrame::OnQuit)
EVT_MENU(ID_CVPCB_DISPLAY_HELP, WinEDA_CvpcbFrame::GetKicadHelp)
EVT_MENU(ID_CVPCB_DISPLAY_LICENCE, WinEDA_CvpcbFrame::GetKicadAbout)
EVT_MENU(ID_CONFIG_REQ,WinEDA_CvpcbFrame::ConfigCvpcb)
EVT_MENU(ID_CONFIG_SAVE,WinEDA_CvpcbFrame::Update_Config)
EVT_MENU_RANGE(ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END,
WinEDA_CvpcbFrame::ProcessFontPreferences)
EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
WinEDA_CvpcbFrame::SetLanguage)
EVT_TOOL(ID_CVPCB_QUIT, WinEDA_CvpcbFrame::OnQuit)
EVT_TOOL(ID_CVPCB_READ_INPUT_NETLIST, WinEDA_CvpcbFrame::LoadNetList)
EVT_TOOL(ID_CVPCB_SAVEQUITCVPCB, WinEDA_CvpcbFrame::SaveQuitCvpcb)
EVT_TOOL(ID_CVPCB_CREATE_CONFIGWINDOW,WinEDA_CvpcbFrame::ConfigCvpcb)
EVT_TOOL(ID_CVPCB_CREATE_SCREENCMP, WinEDA_CvpcbFrame::DisplayModule)
EVT_TOOL(ID_CVPCB_GOTO_FIRSTNA, WinEDA_CvpcbFrame::ToFirstNA)
EVT_TOOL(ID_CVPCB_GOTO_PREVIOUSNA, WinEDA_CvpcbFrame::ToPreviousNA)
EVT_TOOL(ID_CVPCB_DEL_ASSOCIATIONS, WinEDA_CvpcbFrame::DelAssociations)
EVT_TOOL(ID_CVPCB_AUTO_ASSOCIE, WinEDA_CvpcbFrame::AssocieModule)
EVT_TOOL(ID_CVPCB_CREATE_STUFF_FILE, WinEDA_CvpcbFrame::WriteStuffList)
EVT_TOOL(ID_PCB_DISPLAY_FOOTPRINT_DOC, WinEDA_CvpcbFrame::DisplayDocFile)
EVT_CHAR_HOOK(WinEDA_CvpcbFrame::OnChar)
EVT_CLOSE(WinEDA_CvpcbFrame::OnCloseWindow)
EVT_SIZE( WinEDA_CvpcbFrame::OnSize)
END_EVENT_TABLE()
/************************************************************/
/* Fonctions de base de WinEDA_CvpcbFrame: la fenetre generale */
/************************************************************/
/* Sortie de CVPCB */
void WinEDA_CvpcbFrame::OnQuit(wxCommandEvent& event)
{
Close(TRUE);
}
/**********************************************************/
void WinEDA_CvpcbFrame::OnCloseWindow(wxCloseEvent & Event)
/**********************************************************/
{
int diag;
if( modified )
{
unsigned ii;
wxMessageDialog dialog(this, _("Netlist and Cmp list modified, Save before exit ?"),
_("Confirmation"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT);
ii = dialog.ShowModal();
switch ( ii )
{
case wxID_CANCEL:
Event.Veto();
return;
case wxID_NO:
break;
case wxID_OK:
case wxID_YES:
diag = SaveNetList(wxEmptyString);
if( diag > 0 ) modified = 0;
else if ( diag == 0 )
{
if( ! IsOK(this, _("Problem when saving files, Exit anyway") ) )
{
Event.Veto(); return;
}
}
break;
}
}
// Close the help frame
if ( m_Parent->m_HtmlCtrl )
{
if ( m_Parent->m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
m_Parent->m_HtmlCtrl->GetFrame()->Close(TRUE);
}
if ( ! NetInNameBuffer.IsEmpty() )
{
SetLastProject(NetInNameBuffer);
}
FreeMemoryModules();
FreeMemoryComponants();
modified = 0;
SaveSettings();
Destroy();
return;
}
/************************************************/
void WinEDA_CvpcbFrame::OnChar(wxKeyEvent& event)
/************************************************/
{
event.Skip();
}
/*******************************************************/
void WinEDA_CvpcbFrame::ToFirstNA(wxCommandEvent& event)
/*******************************************************/
{
STORECMP * Composant;
int ii, selection;;
Composant = BaseListeCmp;
selection= m_ListCmp->GetSelection();
if(selection < 0) selection = 0;
for (ii = 0 ; Composant != NULL; Composant = Composant->Pnext)
{
if( Composant->m_Module.IsEmpty() && (ii > selection) )
break;
ii++;
}
if ( Composant == NULL )
{
wxBell(); ii = selection;
}
if ( BaseListeCmp ) m_ListCmp->SetSelection(ii);
}
/**********************************************************/
void WinEDA_CvpcbFrame::ToPreviousNA(wxCommandEvent& event)
/**********************************************************/
{
STORECMP * Composant;
int ii, selection;
Composant = BaseListeCmp;
selection = m_ListCmp->GetSelection();
if(selection < 0) selection = 0;
for (ii = 0 ; Composant != NULL; Composant = Composant->Pnext)
{
if( ii == selection ) break;
ii ++;
}
for ( ; Composant != NULL ; Composant = Composant->Pback)
{
if( Composant->m_Module.IsEmpty() && (ii != selection) )
break;
ii--;
}
if ( Composant == NULL )
{
wxBell(); ii = selection;
}
if ( BaseListeCmp ) m_ListCmp->SetSelection(ii);
}
/**********************************************************/
void WinEDA_CvpcbFrame::SaveQuitCvpcb(wxCommandEvent& event)
/**********************************************************/
{
if( SaveNetList(wxEmptyString) > 0)
{
modified = 0;
Close(TRUE);
}
}
/*************************************************************/
void WinEDA_CvpcbFrame::DelAssociations(wxCommandEvent& event)
/*************************************************************/
/* Supprime toutes les associations deja faites
*/
{
int ii;
STORECMP * Composant;
wxString Line;
if( IsOK(this, _("Delete selections")) )
{
Composant = BaseListeCmp;
g_CurrentPkg.Empty();
for ( ii = 0; Composant != NULL; Composant = Composant->Pnext, ii++)
{
Composant->m_Module.Empty();
m_ListCmp->SetSelection(ii);
SetNewPkg();
}
m_ListCmp->SetSelection(0);
composants_non_affectes = nbcomp;
}
Line.Printf( _("Componants: %d (free: %d)"), nbcomp, composants_non_affectes);
SetStatusText(Line,1);
}
/***********************************************************/
void WinEDA_CvpcbFrame::LoadNetList(wxCommandEvent& event)
/***********************************************************/
/* Fonction liee au boutton "Load"
Lit la netliste
*/
{
int id = event.GetId();
wxString fullfilename;
wxString oldfilename;
bool newfile;
if ( ! NetInNameBuffer.IsEmpty() )
{
oldfilename = NetInNameBuffer;
}
switch ( id )
{
case ID_LOAD_FILE_1:
case ID_LOAD_FILE_2:
case ID_LOAD_FILE_3:
case ID_LOAD_FILE_4:
case ID_LOAD_FILE_5:
case ID_LOAD_FILE_6:
case ID_LOAD_FILE_7:
case ID_LOAD_FILE_8:
case ID_LOAD_FILE_9:
case ID_LOAD_FILE_10:
id -= ID_LOAD_FILE_1;
fullfilename = GetLastProject(id);
break;
}
newfile = ReadInputNetList(fullfilename);
if (newfile && ! oldfilename.IsEmpty() )
{
SetLastProject(NetInNameBuffer);
ReCreateMenuBar();
}
}
/***********************************************************/
void WinEDA_CvpcbFrame::ConfigCvpcb(wxCommandEvent& event)
/***********************************************************/
/* Fonction liee au boutton "Config"
Affiche le panneau de configuration
*/
{
CreateConfigWindow();
}
/************************************************************/
void WinEDA_CvpcbFrame::DisplayModule(wxCommandEvent& event)
/************************************************************/
/* Fonction liee au boutton "Visu"
Affiche l'ecran de visualisation des modules
*/
{
CreateScreenCmp();
DrawFrame->AdjustScrollBars();
DrawFrame->Recadre_Trace(FALSE);
}
/****************************************************************/
void WinEDA_CvpcbFrame::AddFontSelectionMenu(wxMenu * main_menu)
/*****************************************************************/
/* create the submenu for fonte selection and setup fonte size
*/
{
wxMenu * fontmenu = new wxMenu();
ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_DIALOG, _("font for dialog boxes"),
fonts_xpm );
ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_INFOSCREEN, _("font for Lists"),
fonts_xpm );
ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_STATUS, _("font for Status Line"),
fonts_xpm );
ADD_MENUITEM_WITH_HELP_AND_SUBMENU(main_menu, fontmenu,
ID_PREFERENCES_FONT, _("&Font selection"),
_("Choose font type and size for dialogs, infos and status box"),
fonts_xpm);
}
/********************************************************/
void WinEDA_CvpcbFrame::SetLanguage(wxCommandEvent& event)
/********************************************************/
{
int id = event.GetId();
m_Parent->SetLanguageIdentifier(id );
m_Parent->SetLanguage();
}
/*************************************************************/
void WinEDA_CvpcbFrame::DisplayDocFile(wxCommandEvent & event)
/*************************************************************/
{
wxString msg = FindKicadHelpPath();
msg += wxT("pcbnew/footprints.pdf");
GetAssociatedDocument(this, wxEmptyString, msg);
}
/********************************************************************/
void WinEDA_CvpcbFrame::ProcessFontPreferences(wxCommandEvent& event)
/********************************************************************/
{
int id = event.GetId();
wxFont font;
switch (id)
{
case ID_PREFERENCES_FONT:
case ID_PREFERENCES_FONT_DIALOG:
case ID_PREFERENCES_FONT_STATUS:
WinEDA_BasicFrame::ProcessFontPreferences(id);
break;
case ID_PREFERENCES_FONT_INFOSCREEN:
{
font = wxGetFontFromUser(this, *g_FixedFont);
if ( font.Ok() )
{
int pointsize = font.GetPointSize();
*g_FixedFont = font;
g_FixedFontPointSize = pointsize;
m_ListMod->SetFont(*g_FixedFont);
m_ListCmp->SetFont(*g_FixedFont);
}
break;
}
default: DisplayError(this, wxT("WinEDA_DrawFrame::ProcessFontPreferences Internal Error") );
break;
}
}
| [
"bokeoa@244deca0-f506-0410-ab94-f4f3571dea26"
]
| [
[
[
1,
439
]
]
]
|
025a52bef6a92e05738607115ba0519c6935bf64 | acf0e8a6d8589532d5585b28ec61b44b722bf213 | /new_gp_daemon/template_utils.h | d58437af32e34b2572458e81ddd6c089e71b5a80 | []
| no_license | mchouza/ngpd | 0f0e987a95db874b3cde4146364bf1d69cf677cb | 5cca5726910bfc97844689f1f40c94b27e0fb9f9 | refs/heads/master | 2016-09-06T02:09:32.007855 | 2008-04-06T14:17:55 | 2008-04-06T14:17:55 | 35,064,755 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 2,617 | h | //
// Copyright (c) 2008, Mariano M. Chouza
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * 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.
//
// * The names of the contributors 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.
//
//=============================================================================
// template_utils.h
//-----------------------------------------------------------------------------
// Creado por Mariano M. Chouza | Empezado el 1 de abril de 2008
//=============================================================================
#ifndef TEMPLATE_UTILS_H
#define TEMPLATE_UTILS_H
#include "utils_fwd.h"
#include <string>
namespace Utils
{
namespace Template
{
/// Rellena el header en el diccionario del template
void fillHeader(google::TemplateDictionary& dict,
const std::string& pageTitle, const std::string& scriptSrc = "");
/// Rellena el header de la página en el diccionario del template
void fillPageHeader(google::TemplateDictionary& dict);
/// Rellena el menú en el diccionario del template
void fillMenu(google::TemplateDictionary& dict);
/// Rellena el pie en el diccionario del template
void fillFooter(google::TemplateDictionary& dict);
}
}
#endif
| [
"mchouza@b858013c-4649-0410-a850-dde43e08a396"
]
| [
[
[
1,
63
]
]
]
|
e03f49aa74298cd96f84e5570d2d3b6374e65931 | ed15e434a34bc8b425c7cbf37dd28d1039660d31 | /proj/cudpp/src/cudpp_manager.cpp | b8ce91f23f4e8346d32ba3d8888f5a5ace7bfa96 | []
| no_license | edvelezg/unb-pdp2 | 7cc235be2e729a398ae2c413fd001271c4f58082 | 8cffcb97138e23e16230530a0ec18caab64ddab5 | refs/heads/master | 2021-01-22T09:46:59.349485 | 2010-09-26T20:42:55 | 2010-09-26T20:42:55 | 33,192,950 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,389 | cpp | // -------------------------------------------------------------
// cuDPP -- CUDA Data Parallel Primitives library
// -------------------------------------------------------------
// $Revision: 3572$
// $Date: 2007-11-19 13:58:06 +0000 (Mon, 19 Nov 2007) $
// -------------------------------------------------------------
// This source code is distributed under the terms of license.txt
// in the root directory of this source distribution.
// -------------------------------------------------------------
#include "cudpp.h"
#include "cudpp_plan.h"
#include "cudpp_manager.h"
#include "cudpp_maximal_launch.h"
typedef void* KernelPointer;
/** @addtogroup publicInterface
* @{
*/
/**
* @brief Creates an instance of the CUDPP library, and returns a handle.
*
* cudppCreate() must be called before any other CUDPP function. In a
* multi-GPU application that uses multiple CUDA context, cudppCreate() must
* be called once for each CUDA context. Each call returns a different handle,
* because each CUDA context (and the host thread that owns it) must use a
* separate instance of the CUDPP library.
*
* @param[in,out] theCudpp a pointer to the CUDPPHandle for the created CUDPP instance.
*/
CUDPP_DLL
CUDPPResult cudppCreate(CUDPPHandle* theCudpp)
{
CUDPPManager *mgr = new CUDPPManager();
*theCudpp = mgr->getHandle();
return CUDPP_SUCCESS;
}
/**
* @brief Destroys an instance of the CUDPP library given its handle.
*
* cudppDestroy() should be called once for each handle created using cudppCreate(),
* to ensure proper resource cleanup of all library instances.
*
* @param[in] theCudpp the handle to the CUDPP instance to destroy.
*/
CUDPP_DLL
CUDPPResult cudppDestroy(CUDPPHandle theCudpp)
{
CUDPPManager *mgr = CUDPPManager::getManagerFromHandle(theCudpp);
delete mgr;
mgr = 0;
return CUDPP_SUCCESS;
}
/** @} */ // end publicInterface
//! @brief CUDPP Manager constructor
CUDPPManager::CUDPPManager()
{
}
/** @brief CUDPP Manager destructor
*/
CUDPPManager::~CUDPPManager()
{
}
| [
"EdVelez.G@3271b04e-0b8f-11df-b76f-33ad6b24dacb"
]
| [
[
[
1,
69
]
]
]
|
5dce2c8bd10a4d3b5f1fe0b1a4795e3b982dad0c | 81e051c660949ac0e89d1e9cf286e1ade3eed16a | /quake3ce/code/splines/util_str.cpp | ded3d652728faee87986e8a5c6246395fa898592 | []
| no_license | crioux/q3ce | e89c3b60279ea187a2ebcf78dbe1e9f747a31d73 | 5e724f55940ac43cb25440a65f9e9e12220c9ada | refs/heads/master | 2020-06-04T10:29:48.281238 | 2008-11-16T15:00:38 | 2008-11-16T15:00:38 | 32,103,416 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,040 | cpp | /*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include"splines_pch.h"
#ifdef _WIN32
#pragma warning(disable : 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data
#pragma warning(disable : 4710) // function 'blah' not inlined
#endif
static const int STR_ALLOC_GRAN = 20;
char *idStr::toLower
(
char *s1
)
{
char *s;
s = s1;
while( *s )
{
*s = ::tolower( *s );
s++;
}
return s1;
}
char *idStr::toUpper
(
char *s1
)
{
char *s;
s = s1;
while( *s )
{
*s = ::toupper( *s );
s++;
}
return s1;
}
int idStr::icmpn
(
const char *s1,
const char *s2,
int n
)
{
int c1;
int c2;
do
{
c1 = *s1++;
c2 = *s2++;
if ( !n-- )
{
// idStrings are equal until end point
return 0;
}
if ( c1 != c2 )
{
if ( c1 >= 'a' && c1 <= 'z' )
{
c1 -= ( 'a' - 'A' );
}
if ( c2 >= 'a' && c2 <= 'z' )
{
c2 -= ( 'a' - 'A' );
}
if ( c1 < c2 )
{
// strings less than
return -1;
}
else if ( c1 > c2 )
{
// strings greater than
return 1;
}
}
}
while( c1 );
// strings are equal
return 0;
}
int idStr::icmp
(
const char *s1,
const char *s2
)
{
int c1;
int c2;
do
{
c1 = *s1++;
c2 = *s2++;
if ( c1 != c2 )
{
if ( c1 >= 'a' && c1 <= 'z' )
{
c1 -= ( 'a' - 'A' );
}
if ( c2 >= 'a' && c2 <= 'z' )
{
c2 -= ( 'a' - 'A' );
}
if ( c1 < c2 )
{
// strings less than
return -1;
}
else if ( c1 > c2 )
{
// strings greater than
return 1;
}
}
}
while( c1 );
// strings are equal
return 0;
}
int idStr::cmpn
(
const char *s1,
const char *s2,
int n
)
{
int c1;
int c2;
do
{
c1 = *s1++;
c2 = *s2++;
if ( !n-- )
{
// strings are equal until end point
return 0;
}
if ( c1 < c2 )
{
// strings less than
return -1;
}
else if ( c1 > c2 )
{
// strings greater than
return 1;
}
}
while( c1 );
// strings are equal
return 0;
}
int idStr::cmp
(
const char *s1,
const char *s2
)
{
int c1;
int c2;
do
{
c1 = *s1++;
c2 = *s2++;
if ( c1 < c2 )
{
// strings less than
return -1;
}
else if ( c1 > c2 )
{
// strings greater than
return 1;
}
}
while( c1 );
// strings are equal
return 0;
}
/*
============
IsNumeric
Checks a string to see if it contains only numerical values.
============
*/
bool idStr::isNumeric
(
const char *str
)
{
int len;
int i;
bool dot;
if ( *str == '-' )
{
str++;
}
dot = false;
len = strlen( str );
for( i = 0; i < len; i++ )
{
if ( !isdigit( str[ i ] ) )
{
if ( ( str[ i ] == '.' ) && !dot )
{
dot = true;
continue;
}
return false;
}
}
return true;
}
idStr operator+
(
const idStr& a,
const gfixed b
)
{
char text[ 20 ];
idStr result( a );
sprintf( text, "%f", FIXED_TO_DOUBLE(b) );
result.append( text );
return result;
}
idStr operator+
(
const idStr& a,
const int b
)
{
char text[ 20 ];
idStr result( a );
sprintf( text, "%d", b );
result.append( text );
return result;
}
idStr operator+
(
const idStr& a,
const unsigned b
)
{
char text[ 20 ];
idStr result( a );
sprintf( text, "%u", b );
result.append( text );
return result;
}
idStr& idStr::operator+=
(
const gfixed a
)
{
char text[ 20 ];
sprintf( text, "%f", FIXED_TO_DOUBLE(a) );
append( text );
return *this;
}
idStr& idStr::operator+=
(
const int a
)
{
char text[ 20 ];
sprintf( text, "%d", a );
append( text );
return *this;
}
idStr& idStr::operator+=
(
const unsigned a
)
{
char text[ 20 ];
sprintf( text, "%u", a );
append( text );
return *this;
}
void idStr::CapLength
(
int newlen
)
{
assert ( m_data );
if ( length() <= newlen )
return;
EnsureDataWritable ();
m_data->data[newlen] = 0;
m_data->len = newlen;
}
void idStr::EnsureDataWritable
(
void
)
{
assert ( m_data );
strdata *olddata;
int len;
if ( !m_data->refcount )
return;
olddata = m_data;
len = length();
m_data = new strdata;
EnsureAlloced ( len + 1, false );
strncpy ( m_data->data, olddata->data, len+1 );
m_data->len = len;
olddata->DelRef ();
}
void idStr::EnsureAlloced (int amount, bool keepold) {
if ( !m_data ) {
m_data = new strdata();
}
// Now, let's make sure it's writable
EnsureDataWritable ();
char *newbuffer;
bool wasalloced = ( m_data->alloced != 0 );
if ( amount < m_data->alloced ) {
return;
}
assert ( amount );
if ( amount == 1 ) {
m_data->alloced = 1;
} else {
int newsize, mod;
mod = amount % STR_ALLOC_GRAN;
if ( !mod ) {
newsize = amount;
} else {
newsize = amount + STR_ALLOC_GRAN - mod;
}
m_data->alloced = newsize;
}
newbuffer = new char[m_data->alloced];
if ( wasalloced && keepold ) {
strcpy ( newbuffer, m_data->data );
}
if ( m_data->data ) {
delete [] m_data->data;
}
m_data->data = newbuffer;
}
void idStr::BackSlashesToSlashes
(
void
)
{
int i;
EnsureDataWritable ();
for ( i=0; i < m_data->len; i++ )
{
if ( m_data->data[i] == '\\' )
m_data->data[i] = '/';
}
}
void idStr::snprintf
(
char *dst,
int size,
const char *fmt,
...
)
{
char buffer[0x10000];
int len;
va_list argptr;
va_start (argptr,fmt);
len = vsprintf (buffer,fmt,argptr);
va_end (argptr);
assert ( len < size );
strncpy (dst, buffer, size-1);
}
#ifdef _WIN32
#pragma warning(disable : 4189) // local variable is initialized but not referenced
#endif
/*
=================
TestStringClass
This is a fairly rigorous test of the idStr class's functionality.
Because of the fairly global and subtle ramifications of a bug occuring
in this class, it should be run after any changes to the class.
Add more tests as functionality is changed. Tests should include
any possible bounds violation and NULL data tests.
=================
*/
void TestStringClass
(
void
)
{
char ch; // ch == ?
idStr *t; // t == ?
idStr a; // a.len == 0, a.data == "\0"
idStr b; // b.len == 0, b.data == "\0"
idStr c( "test" ); // c.len == 4, c.data == "test\0"
idStr d( c ); // d.len == 4, d.data == "test\0"
idStr e( reinterpret_cast<const char *>(NULL) );
// e.len == 0, e.data == "\0" ASSERT!
int i; // i == ?
i = a.length(); // i == 0
i = c.length(); // i == 4
// TTimo: not used
// const char *s1 = a.c_str(); // s1 == "\0"
// const char *s2 = c.c_str(); // s2 == "test\0"
t = new idStr(); // t->len == 0, t->data == "\0"
delete t; // t == ?
b = "test"; // b.len == 4, b.data == "test\0"
t = new idStr( "test" ); // t->len == 4, t->data == "test\0"
delete t; // t == ?
a = c; // a.len == 4, a.data == "test\0"
// a = "";
a = NULL; // a.len == 0, a.data == "\0" ASSERT!
a = c + d; // a.len == 8, a.data == "testtest\0"
a = c + "wow"; // a.len == 7, a.data == "testwow\0"
a = c + reinterpret_cast<const char *>(NULL);
// a.len == 4, a.data == "test\0" ASSERT!
a = "this" + d; // a.len == 8, a.data == "thistest\0"
a = reinterpret_cast<const char *>(NULL) + d;
// a.len == 4, a.data == "test\0" ASSERT!
a += c; // a.len == 8, a.data == "testtest\0"
a += "wow"; // a.len == 11, a.data == "testtestwow\0"
a += reinterpret_cast<const char *>(NULL);
// a.len == 11, a.data == "testtestwow\0" ASSERT!
a = "test"; // a.len == 4, a.data == "test\0"
ch = a[ 0 ]; // ch == 't'
ch = a[ -1 ]; // ch == 0 ASSERT!
ch = a[ 1000 ]; // ch == 0 ASSERT!
ch = a[ 0 ]; // ch == 't'
ch = a[ 1 ]; // ch == 'e'
ch = a[ 2 ]; // ch == 's'
ch = a[ 3 ]; // ch == 't'
ch = a[ 4 ]; // ch == '\0' ASSERT!
ch = a[ 5 ]; // ch == '\0' ASSERT!
a[ 1 ] = 'b'; // a.len == 4, a.data == "tbst\0"
a[ -1 ] = 'b'; // a.len == 4, a.data == "tbst\0" ASSERT!
a[ 0 ] = '0'; // a.len == 4, a.data == "0bst\0"
a[ 1 ] = '1'; // a.len == 4, a.data == "01st\0"
a[ 2 ] = '2'; // a.len == 4, a.data == "012t\0"
a[ 3 ] = '3'; // a.len == 4, a.data == "0123\0"
a[ 4 ] = '4'; // a.len == 4, a.data == "0123\0" ASSERT!
a[ 5 ] = '5'; // a.len == 4, a.data == "0123\0" ASSERT!
a[ 7 ] = '7'; // a.len == 4, a.data == "0123\0" ASSERT!
a = "test"; // a.len == 4, a.data == "test\0"
b = "no"; // b.len == 2, b.data == "no\0"
i = ( a == b ); // i == 0
i = ( a == c ); // i == 1
i = ( a == "blow" ); // i == 0
i = ( a == "test" ); // i == 1
i = ( a == NULL ); // i == 0 ASSERT!
i = ( "test" == b ); // i == 0
i = ( "test" == a ); // i == 1
i = ( NULL == a ); // i == 0 ASSERT!
i = ( a != b ); // i == 1
i = ( a != c ); // i == 0
i = ( a != "blow" ); // i == 1
i = ( a != "test" ); // i == 0
i = ( a != NULL ); // i == 1 ASSERT!
i = ( "test" != b ); // i == 1
i = ( "test" != a ); // i == 0
i = ( NULL != a ); // i == 1 ASSERT!
a = "test"; // a.data == "test"
b = a; // b.data == "test"
a = "not"; // a.data == "not", b.data == "test"
a = b; // a.data == b.data == "test"
a += b; // a.data == "testtest", b.data = "test"
a = b;
a[1] = '1'; // a.data = "t1st", b.data = "test"
}
#ifdef _WIN32
#pragma warning(default : 4189) // local variable is initialized but not referenced
#pragma warning(disable : 4514) // unreferenced inline function has been removed
#endif
| [
"jack.palevich@684fc592-8442-0410-8ea1-df6b371289ac"
]
| [
[
[
1,
616
]
]
]
|
81b36b980eacda87037247239d38353717ab8fe2 | 6bdb3508ed5a220c0d11193df174d8c215eb1fce | /Codes/Halak/UIMarkupText.inl | e371a712afa2b565972eab22090e556bbc499abb | []
| 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,494 | inl | namespace Halak
{
const String& UIMarkupText::GetOriginalText() const
{
return originalText;
}
const String& UIMarkupText::GetDisplayText() const
{
return displayText;
}
const UIMarkupText::PhraseCollection& UIMarkupText::GetPhrases() const
{
return phrases;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
UIMarkupText::PhraseType UIMarkupText::Phrase::GetType() const
{
return type;
}
int UIMarkupText::Phrase::GetIndex() const
{
return index;
}
int UIMarkupText::Phrase::GetLength() const
{
return length;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
Color UIMarkupText::ColorPhrase::GetColor() const
{
return color;
}
bool UIMarkupText::ColorPhrase::HasColor() const
{
return hasColor;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const String& UIMarkupText::ContentPhrase::GetContentType() const
{
return contentType;
}
const String& UIMarkupText::ContentPhrase::GetContentName() const
{
return contentName;
}
const SequenceDictionary& UIMarkupText::ContentPhrase::GetAttributes() const
{
return attributes;
}
} | [
"[email protected]"
]
| [
[
[
1,
63
]
]
]
|
a77e320b29228e3bf5d943203f3d30e2a143a300 | ad5b5739ebb4e193e2457094117aa9870f8e8a2e | /src/MemParseHandlers.cpp | f2afe05ee54c628b391930d114fe5b1ec54cce22 | [
"BSD-3-Clause"
]
| permissive | mjmwired/feed-reader-lib | b6d4933cf7f36dab45ef19268ec5c2b0be9f950f | 504eb9f95d87757c7044cdac062ed55efb14f849 | refs/heads/master | 2021-01-10T06:40:41.399526 | 2009-04-09T12:47:15 | 2009-04-09T12:47:15 | 48,585,024 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,965 | cpp | /*
Copyright (c) 2009, Yoav Aviram
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the author nor the names of its
contributors may 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.hpp"
#include "MemParseHandlers.hpp"
MemParseHandlers::MemParseHandlers() :
xercesc_2_8::HandlerBase(),
_success(true)
{
}
bool MemParseHandlers::GetSuccess()
{
return _success;
}
void MemParseHandlers::error(const xercesc_2_8::SAXParseException& ex)
{
_success = false;
}
void MemParseHandlers::fatalError(const xercesc_2_8::SAXParseException& ex)
{
const XMLCh* foo = ex.getMessage();
_success = false;
}
| [
"yoav.aviram@d1f0c036-2492-11de-a9c7-870926ae914a"
]
| [
[
[
1,
56
]
]
]
|
a2f8c148333732be1dce94cf505327a59698a249 | 91ac219c4cde8c08a6b23ac3d207c1b21124b627 | /common/resample/Resample.cpp | f9ef5f1d6f310ac00ffadb1971c21db245cf78b4 | []
| 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 | 5,264 | cpp | /******************************************************************************\
* Technische Universitaet Darmstadt, Institut fuer Nachrichtentechnik
* Copyright (c) 2002
*
* Author(s):
* Volker Fischer
*
* Description:
* Resample routine for arbitrary sample-rate conversions in a low range (for
* frequency offset correction).
* The algorithm is based on a polyphase structure. We upsample the input
* signal with a factor INTERP_DECIM_I_D and calculate two successive samples
* whereby we perform a linear interpolation between these two samples to get
* an arbitraty sample grid.
* The polyphase filter is calculated with Matlab(TM), the associated file
* is ResampleFilter.m.
*
******************************************************************************
*
* 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 "Resample.h"
/* Implementation *************************************************************/
int CResample::Resample(CVector<_REAL>* prInput, CVector<_REAL>* prOutput,
_REAL rRation)
{
/* Move old data from the end to the history part of the buffer and
add new data (shift register) */
vecrIntBuff.AddEnd((*prInput), iInputBlockSize);
/* Sample-interval of new sample frequency in relation to interpolated
sample-interval */
rTStep = (_REAL) INTERP_DECIM_I_D / rRation;
/* Init output counter */
int im = 0;
/* Main loop */
do
{
/* Quantize output-time to interpolated time-index */
const int ik = (int) rtOut;
/* Calculate convolutions for the two interpolation-taps ------------ */
/* Phase for the linear interpolation-taps */
const int ip1 = ik % INTERP_DECIM_I_D;
const int ip2 = (ik + 1) % INTERP_DECIM_I_D;
/* Sample positions in input vector */
const int in1 = (int) (ik / INTERP_DECIM_I_D);
const int in2 = (int) ((ik + 1) / INTERP_DECIM_I_D);
/* Convolution */
_REAL ry1 = (_REAL) 0.0;
_REAL ry2 = (_REAL) 0.0;
for (int i = 0; i < NUM_TAPS_PER_PHASE; i++)
{
ry1 += fResTaps1To1[ip1][i] * vecrIntBuff[in1 - i];
ry2 += fResTaps1To1[ip2][i] * vecrIntBuff[in2 - i];
}
/* Linear interpolation --------------------------------------------- */
/* Get numbers after the comma */
const _REAL rxInt = rtOut - (int) rtOut;
(*prOutput)[im] = (ry2 - ry1) * rxInt + ry1;
/* Increase output counter */
im++;
/* Increase output-time and index one step */
rtOut = rtOut + rTStep;
}
while (rtOut < rBlockDuration);
/* Set rtOut back */
rtOut -= iInputBlockSize * INTERP_DECIM_I_D;
return im;
}
void CResample::Init(int iNewInputBlockSize)
{
iInputBlockSize = iNewInputBlockSize;
/* History size must be one sample larger, because we use always TWO
convolutions */
iHistorySize = NUM_TAPS_PER_PHASE + 1;
/* Calculate block duration */
rBlockDuration = (iInputBlockSize + iHistorySize - 1) * INTERP_DECIM_I_D;
/* Allocate memory for internal buffer, clear sample history */
vecrIntBuff.Init(iInputBlockSize + iHistorySize, (_REAL) 0.0);
/* Init absolute time for output stream (at the end of the history part */
rtOut = (_REAL) (iHistorySize - 1) * INTERP_DECIM_I_D;
}
void CAudioResample::Resample(CVector<_REAL>& rInput, CVector<_REAL>& rOutput)
{
int j;
if (rRation == (_REAL) 1.0)
{
/* If ratio is 1, no resampling is needed, just copy vector */
for (j = 0; j < iOutputBlockSize; j++)
rOutput[j] = rInput[j];
}
else
{
/* Move old data from the end to the history part of the buffer and
add new data (shift register) */
vecrIntBuff.AddEnd(rInput, iInputBlockSize);
/* Main loop */
for (j = 0; j < iOutputBlockSize; j++)
{
/* Phase for the linear interpolation-taps */
const int ip =
(int) (j * INTERP_DECIM_I_D / rRation) % INTERP_DECIM_I_D;
/* Sample position in input vector */
const int in = (int) (j / rRation) + NUM_TAPS_PER_PHASE;
/* Convolution */
_REAL ry = (_REAL) 0.0;
for (int i = 0; i < NUM_TAPS_PER_PHASE; i++)
ry += fResTaps1To1[ip][i] * vecrIntBuff[in - i];
rOutput[j] = ry;
}
}
}
void CAudioResample::Init(int iNewInputBlockSize, _REAL rNewRation)
{
rRation = rNewRation;
iInputBlockSize = iNewInputBlockSize;
iOutputBlockSize = (int) (iInputBlockSize * rNewRation);
/* Allocate memory for internal buffer, clear sample history */
vecrIntBuff.Init(iInputBlockSize + NUM_TAPS_PER_PHASE, (_REAL) 0.0);
}
| [
"[email protected]"
]
| [
[
[
1,
162
]
]
]
|
ff580f7ca7cea4ea9a0fd9c8713243b76556f603 | 3eb83d1b36fb5ada2c7bcd35607f1ead259e283f | /DS/Libraries/BTNlib.h | 12b65ce24036ded9efdc34da80a0139a6e0cce22 | []
| no_license | mickvangelderen/uwars | 2235b8883649843ed9dc2dca34260649132aa306 | 2cc4f6380f5046afa533b6a898b5513c1ab43af6 | refs/heads/master | 2021-01-01T18:18:44.665224 | 2010-03-23T15:43:17 | 2010-03-23T15:43:17 | 32,515,782 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 982 | h | #pragma once
///////////////////////////////////
//Button System by Prozix //
//Stable version 1.0 //
//Release date: 9 Jan 2010, 00:03//
///////////////////////////////////
#include <PA9.h>
#include "STDfunctions.h"
class buttonGfx{
private:
u8 m_screen;
u8 m_palId;
void* m_sprites[3];
public:
buttonGfx(u8 screen, void* spriteLeft, void* spriteMiddle, void* spriteRight, void* paletteName);
~buttonGfx();
u8 GetScreen();
void* GetButtonLeft();
void* GetButtonMiddle();
void* GetButtonRight();
u8 GetPalId();
};
class button{
private:
u8 m_x, m_y;
char * m_text;
buttonGfx * m_gfx;
u8 * m_spriteIds;
u8 m_spriteIdsLength;
public:
button();
button(u8 x, u8 y, const char * const text, u8 size, buttonGfx* buttonGraphics);
~button();
void Set(u8 x, u8 y, const char * const text, u8 size, buttonGfx* buttonGraphics);
void Reset();
void RefreshText();
bool IsTouched();
bool StylusOn();
};
| [
"mickfreeze@097d8bfe-0ac2-11df-beaf-bb271b2086c6"
]
| [
[
[
1,
49
]
]
]
|
53bcfd47aa6bcb4acc0311d31ce647795820929c | 465943c5ffac075cd5a617c47fd25adfe496b8b4 | /INASCEND.H | d2793eb6ef0af3d774df1655054a5b0e3dda4550 | []
| no_license | paulanthonywilson/airtrafficcontrol | 7467f9eb577b24b77306709d7b2bad77f1b231b7 | 6c579362f30ed5f81cabda27033f06e219796427 | refs/heads/master | 2016-08-08T00:43:32.006519 | 2009-04-09T21:33:22 | 2009-04-09T21:33:22 | 172,292 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 407 | h | /*
Input a change altitude command
Paul Wilson
*/
# ifndef _INASCEND_H
# define _INASCEND_H
# include "withplan.h"
# include "complete.h"
class InAscend :public WithPlaneStep {
public:
InAscend(const WithPlaneStep &Last_i) :
WithPlaneStep (Last_i)
{
PromptMsg();
}
void ProcessInput (char KeyHit_i);
void Undo();
virtual void PromptMsg ();
};
# endif | [
"[email protected]"
]
| [
[
[
1,
32
]
]
]
|
186608b955a800d4c8b205ba20e3166dcd08c6b4 | 906e87b1936397339734770be45317f06fe66e6e | /src/TGControl.cpp | a0cc5bb3353a4b22a341d8c583936425fc40b100 | []
| no_license | kcmohanprasad/tgui | 03c1ab47e9058bc763b7e6ffc21a37b4358369bf | 9f9cf391fa86b99c7d606c4d196e512a7b06be95 | refs/heads/master | 2021-01-10T08:52:18.629088 | 2007-05-17T04:42:58 | 2007-05-17T04:42:58 | 52,069,498 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 42,070 | cpp | //-----------------------------------------------------------------------------
// This source file is part of TGUI (Tiny GUI)
//
// Copyright (c) 2006-2007 Tubras Software, Ltd
// Also see acknowledgements in Readme.html
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to
// do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//-----------------------------------------------------------------------------
#include <tgui.h>
namespace TGUI
{
int TGControl::m_controlNumber=1;
//-----------------------------------------------------------------------
// T G C o n t r o l
//-----------------------------------------------------------------------
TGControl::TGControl(TGControl *parent, TGString name) : m_systemCache(TGSystem::getSingleton().getCache())
, m_theme(TGTheme())
, m_frameEnabled(true)
, m_backgroundEnabled(true)
, m_renderer(TGSystem::getSingleton().getRenderer())
, m_system(TGSystem::getSingletonPtr())
, m_minWidth(0), m_minHeight(0)
, m_maxWidth(0x7FFFFFFF), m_maxHeight(0x7FFFFFFF)
, m_focusedChild(0)
, m_isComposite(false)
, m_parent(parent)
, m_redraw(true)
, m_popupMenu(NULL)
, x1(0), y1(0), x2(0), y2(0)
, m_padLeft(0), m_padTop(0), m_padRight(0), m_padBottom(0)
, xShift(0), yShift(0)
, m_performLayout(true)
, m_mouseOverControl(false)
, m_isVisible(true)
, m_exclusiveChild(NULL)
, m_font(TGSystem::getSingleton().getCurrentFont())
, m_texture(TGSystem::getSingleton().getDefaultTexture())
{
if(name.empty())
{
Ogre::StringUtil::StrStreamType genName;
genName << "_noname_" << m_controlNumber++;
m_name = genName.str();
}
else m_name = name;
if (m_parent)
{
m_parent->addChild(this);
setTheme(m_parent->getTheme());
}
else
{
setTheme(TGSystem::getSingleton().getTheme());
}
}
//-----------------------------------------------------------------------
// ~ T G C o n t r o l
//-----------------------------------------------------------------------
TGControl::~TGControl()
{
invalidateControl(this);
removeAllChildren();
removeAllHandlers(this);
if(m_popupMenu)
delete m_popupMenu;
if (m_parent)
{
if (m_parent->m_exclusiveChild == this)
m_parent->m_exclusiveChild = NULL;
m_parent->removeChild(this);
}
}
//-----------------------------------------------------------------------
// g e t R e n d e r e r
//-----------------------------------------------------------------------
TGRenderer* TGControl::getRenderer()
{
return m_renderer;
}
//-----------------------------------------------------------------------
// s e t N a m e
//-----------------------------------------------------------------------
void TGControl::setName(TGString value)
{
m_name = value;
}
//-----------------------------------------------------------------------
// f i n d C h i l d
//-----------------------------------------------------------------------
TGControl *TGControl::findChild(TGString name)
{
if (name.empty())
return NULL;
if (!name.compare(m_name))
return this;
for (TGControlListItr itr = m_children.begin();itr != m_children.end(); ++itr)
{
TGControl *r = (*itr)->findChild(name);
if (r)
return r;
}
return NULL;
}
//-----------------------------------------------------------------------
// a d d C h i l d
//-----------------------------------------------------------------------
void TGControl::addChild(TGControl *child)
{
if (!child)
return;
if (child->m_parent)
child->m_parent->removeChild(child);
child->m_parent = this;
m_focusedChild = child;
m_children.push_back(child);
m_performLayout = true;
}
//-----------------------------------------------------------------------
// r e m o v e C h i l d
//-----------------------------------------------------------------------
void TGControl::removeChild(TGControl *child)
{
if (!child || child->m_parent != this)
return;
child->m_parent = NULL;
//child->removeAllChildren();
m_children.remove(child);
if(child == m_focusedChild)
{
if(m_children.size())
m_focusedChild = m_children.back();
else m_focusedChild = NULL;
}
m_performLayout = true;
}
//-----------------------------------------------------------------------
// r e m o v e A l l C h i l d r e n
//-----------------------------------------------------------------------
void TGControl::removeAllChildren()
{
while(m_children.size())
{
TGControl* child = *m_children.begin();
delete child; // this will remove from the parent child list
}
}
//-----------------------------------------------------------------------
// c h i l d A t
//-----------------------------------------------------------------------
TGControl *TGControl::childAt(TGReal x, TGReal y)
{
int x1, y1, x2, y2;
getBounds(x1, y1, x2, y2);
if(!pointInControl(x,y))
return this;
TGControlListRevItr ritr = m_children.rbegin();
for (ritr = m_children.rbegin();ritr != m_children.rend(); ++ritr)
{
if(!(*ritr)->isVisible())
continue;
if(!(*ritr)->pointInControl(x,y))
continue;
return (*ritr)->childAt(x, y);
}
return this;
}
//-----------------------------------------------------------------------
// p o i n t I n C o n t r o l
//-----------------------------------------------------------------------
bool TGControl::pointInControl(TGReal x, TGReal y)
{
int x1, y1, x2, y2;
getBounds(x1, y1, x2, y2);
if ((x >= x1 && y >= y1 && x <= x2 && y <= y2))
return true;
return false;
}
//-----------------------------------------------------------------------
// g e t S c r e e n
//-----------------------------------------------------------------------
TGScreen *TGControl::getScreen()
{
TGControl* control = this;
while (control->m_parent)
control = control->m_parent;
return (TGScreen*)control;
}
//-----------------------------------------------------------------------
// m a k e E x c l u s i v e
//-----------------------------------------------------------------------
void TGControl::makeExclusive(bool value)
{
TGScreen* ascreen = TGSystem::getSingleton().getActiveScreen();
TGControl* parent = m_parent;
if (parent)
{
if(value)
{
ascreen->m_exclusiveChild = this;
}
else
{
if(ascreen->m_exclusiveChild == this)
ascreen->m_exclusiveChild = NULL;
}
}
}
//-----------------------------------------------------------------------
// p u l s e
//-----------------------------------------------------------------------
void TGControl::pulse(TGReal timeElapsed)
{
if(!isVisible())
return;
if (m_performLayout)
{
layout();
m_performLayout = false;
}
//
// pulse the child controls
//
for (TGControlListItr itr = m_children.begin();itr != m_children.end(); ++itr)
{
(*itr)->pulse(timeElapsed);
}
}
//-----------------------------------------------------------------------
// f o c u s
//-----------------------------------------------------------------------
void TGControl::focus()
{
if (!m_parent)
return;
m_parent->focus();
//if (m_parent->getLastChild() == this)
// return;
TGControl *oldFocus = m_parent->getLastChild()->getFocusedChild();
if(!oldFocus)
oldFocus = m_parent->getLastChild();
m_parent->setFocusedChild(this);
if(oldFocus)
{
if(oldFocus->m_parent)
oldFocus->m_parent->redraw();
oldFocus->onFocusExit();
}
onFocusEnter(this);
}
//-----------------------------------------------------------------------
// f o c u s e d
//-----------------------------------------------------------------------
bool TGControl::focused()
{
if (!m_parent)
return true;
return (m_parent->getFocusedChild() == this && m_parent->focused());
}
//-----------------------------------------------------------------------
// s e t B o u n d s
//-----------------------------------------------------------------------
void TGControl::setBounds(TGReal fx1, TGReal fy1, TGReal fx2, TGReal fy2)
{
int x1,x2,y1,y2;
TGReal sw,sh;
redraw();
if(!m_parent)
{
sw = m_renderer->getWidth();
sh = m_renderer->getHeight();
}
else
{
int iw,ih;
m_parent->getWidth(iw);
m_parent->getHeight(ih);
sw = iw;
sh = ih;
}
x1 = sw * fx1;
x2 = sw * fx2;
y1 = sh * fy1;
y2 = sh * fy2;
int oldX1 = this->x1;
int oldY1 = this->y1;
int oldW = this->x2 - this->x1;
int oldH = this->y2 - this->y1;
if (x2 - x1 + 1 < m_minWidth)
x2 = x1 + m_minWidth - 1;
if (y2 - y1 + 1 < m_minHeight)
y2 = y1 + m_minHeight - 1;
if (x2 - x1 + 1 > m_maxWidth)
x2 = x1 + m_maxWidth - 1;
if (y2 - y1 + 1 > m_maxHeight)
y2 = y1 + m_maxHeight - 1;
this->x1 = x1;
this->y1 = y1;
this->x2 = x2;
this->y2 = y2;
if (x2 - x1 != oldW || y2 - y1 != oldH)
{
m_performLayout = true;
fireEvent(TGEvent::Resized,TGEventArgs(this));
}
if (x1 != oldX1 || y1 != oldY1)
fireEvent(TGEvent::Moved,TGEventArgs(this));
}
//-----------------------------------------------------------------------
// s e t B o u n d s
//-----------------------------------------------------------------------
void TGControl::setBounds(int x1, int y1, int x2, int y2)
{
redraw();
int oldX1 = this->x1;
int oldY1 = this->y1;
int oldW = this->x2 - this->x1;
int oldH = this->y2 - this->y1;
if (x2 - x1 + 1 < m_minWidth)
x2 = x1 + m_minWidth - 1;
if (y2 - y1 + 1 < m_minHeight)
y2 = y1 + m_minHeight - 1;
if (x2 - x1 + 1 > m_maxWidth)
x2 = x1 + m_maxWidth - 1;
if (y2 - y1 + 1 > m_maxHeight)
y2 = y1 + m_maxHeight - 1;
this->x1 = x1;
this->y1 = y1;
this->x2 = x2;
this->y2 = y2;
if (x2 - x1 != oldW || y2 - y1 != oldH)
{
m_performLayout = true;
fireEvent(TGEvent::Resized,TGEventArgs(this));
}
if (x1 != oldX1 || y1 != oldY1)
fireEvent(TGEvent::Moved,TGEventArgs(this));
}
//-----------------------------------------------------------------------
// s e t P o s
//-----------------------------------------------------------------------
void TGControl::setPos(int x1, int y1)
{
moveRel(x1,y1);
}
//-----------------------------------------------------------------------
// s e t P o s
//-----------------------------------------------------------------------
void TGControl::setPos(TGReal x1, TGReal y1)
{
moveRel(x1,y1);
}
//-----------------------------------------------------------------------
// g e t P o s
//-----------------------------------------------------------------------
void TGControl::getPos(int &x1, int &y1)
{
x1 = this->x1;
y1 = this->y1;
}
//-----------------------------------------------------------------------
// g e t P o s
//-----------------------------------------------------------------------
void TGControl::getPos(TGReal &x1, TGReal &y1)
{
}
//-----------------------------------------------------------------------
// m o v e R e l
//-----------------------------------------------------------------------
void TGControl::moveRel(int x, int y)
{
int w = x2 - x1, h = y2 - y1;
setBounds(x, y, x + w, y + h);
}
//-----------------------------------------------------------------------
// m o v e R e l
//-----------------------------------------------------------------------
void TGControl::moveRel(TGReal x, TGReal y)
{
TGReal sw,sh;
if(!m_parent)
{
sw = m_renderer->getWidth();
sh = m_renderer->getHeight();
}
else
{
int iw,ih;
m_parent->getWidth(iw);
m_parent->getHeight(ih);
sw = iw;
sh = ih;
}
int nx1 = sw * x;
int ny1 = sh * y;
moveRel(nx1,ny1);
}
//-----------------------------------------------------------------------
// r e s i z e
//-----------------------------------------------------------------------
void TGControl::resize(int width, int height)
{
setBounds(x1, y1, x1 + width - 1, y1 + height - 1);
}
//-----------------------------------------------------------------------
// c e n t e r
//-----------------------------------------------------------------------
void TGControl::center(bool horizontal, bool vertical)
{
int w, h, pw, ph;
if (!m_parent)
return;
m_parent->getClientSize(pw, ph);
getClientSize(w, h);
if (horizontal)
moveRel(pw/2 - w/2, y1);
if (vertical)
moveRel(x1, ph/2 - h/2);
}
//-----------------------------------------------------------------------
// t r a n s l a t e
//-----------------------------------------------------------------------
void TGControl::translate(int &x, int &y)
{
for (TGControl *parent = m_parent;parent;parent=parent->m_parent)
{
x += parent->x1 + parent->m_padLeft;
y += parent->y1 + parent->m_padTop;
}
}
//-----------------------------------------------------------------------
// g e t B o u n d s
//-----------------------------------------------------------------------
void TGControl::getBounds(int &x1, int &y1, int &x2, int &y2)
{
x1 = this->x1 - xShift;
y1 = this->y1 - yShift;
x2 = this->x2 - xShift;
y2 = this->y2 - yShift;
translate(x1, y1);
translate(x2, y2);
}
//-----------------------------------------------------------------------
// g e t B o u n d s
//-----------------------------------------------------------------------
void TGControl::getBounds(TGReal &x1, TGReal &y1, TGReal &x2, TGReal &y2)
{
int ix1,iy1,ix2,iy2;
getBounds(ix1,iy1,ix2,iy2);
TGReal sw = m_renderer->getWidth();
TGReal sh = m_renderer->getHeight();
x1 = (TGReal)ix1 / sw;
x2 = (TGReal)ix2 / sw;
y1 = (TGReal)iy1 / sh;
y2 = (TGReal)iy2 / sh;
}
//-----------------------------------------------------------------------
// s e t W i d t h
//-----------------------------------------------------------------------
void TGControl::setWidth(int width)
{
setBounds(x1,y1,x1+width,y2);
}
//-----------------------------------------------------------------------
// s e t W i d t h
//-----------------------------------------------------------------------
void TGControl::setWidth(TGReal width)
{
int w,nw;
if(!m_parent)
{
w = m_renderer->getWidth();
}
else m_parent->getWidth(w);
nw = (TGReal)w * width;
setWidth(nw);
}
//-----------------------------------------------------------------------
// g e t W i d t h
//-----------------------------------------------------------------------
void TGControl::getWidth(int &width)
{
width = x2-x1;
}
//-----------------------------------------------------------------------
// g e t W i d t h
//-----------------------------------------------------------------------
void TGControl::getWidth(TGReal &width)
{
TGReal fx1,fx2,fy1,fy2;
getBounds(fx1,fy1,fx2,fy2);
width = fx2-fx1;
}
//-----------------------------------------------------------------------
// s e t H e i g h t
//-----------------------------------------------------------------------
void TGControl::setHeight(int height)
{
setBounds(x1,y1,x2,y1+height);
}
//-----------------------------------------------------------------------
// s e t H e i g h t
//-----------------------------------------------------------------------
void TGControl::setHeight(TGReal height)
{
int h,nh;
if(!m_parent)
{
h = m_renderer->getHeight();
}
else m_parent->getHeight(h);
nh = (TGReal)h * height;
setHeight(nh);
}
//-----------------------------------------------------------------------
// g e t H e i g h t
//-----------------------------------------------------------------------
void TGControl::getHeight(int &height)
{
height = y2-y1;
}
//-----------------------------------------------------------------------
// g e t H e i g h t
//-----------------------------------------------------------------------
void TGControl::getHeight(TGReal &height)
{
TGReal fx1,fx2,fy1,fy2;
getBounds(fx1,fy1,fx2,fy2);
height = fy2-fy1;
}
//-----------------------------------------------------------------------
// s e t P a d d i n g
//-----------------------------------------------------------------------
void TGControl::setPadding(int left, int top, int right, int bottom)
{
if (left != -1)
m_padLeft = left;
if (top != -1)
m_padTop = top;
if (right != -1)
m_padRight = right;
if (bottom != -1)
m_padBottom = bottom;
redraw();
}
//-----------------------------------------------------------------------
// g e t C l i e n t S i z e
//-----------------------------------------------------------------------
void TGControl::getClientSize(int &w, int &h)
{
w = x2 - x1 - m_padLeft - m_padRight + 1;
h = y2 - y1 - m_padTop - m_padBottom + 1;
}
//-----------------------------------------------------------------------
// d r a w O w n F r a m e
//-----------------------------------------------------------------------
void TGControl::drawOwnFrame()
{
int x1, y1, x2, y2;
getBounds(x1, y1, x2, y2);
drawFrame(x1, y1, x2, y2);
}
//-----------------------------------------------------------------------
// d r a w O w n F o c u s
//-----------------------------------------------------------------------
void TGControl::drawOwnFocus()
{
int x1, y1, x2, y2;
getBounds(x1, y1, x2, y2);
drawRect(x1 + 3, y1 + 3, x2 - 3, y2 - 3,m_theme.getFrameSelectedBrush());
}
//-----------------------------------------------------------------------
// o n M o u s e E n t e r
//-----------------------------------------------------------------------
void TGControl::onMouseEnter()
{
m_mouseOverControl = true;
}
//-----------------------------------------------------------------------
// o n M o u s e E x i t
//-----------------------------------------------------------------------
void TGControl::onMouseExit(int x, int y)
{
m_mouseOverControl = false;
}
//-----------------------------------------------------------------------
// o n M o u s e M o v e d
//-----------------------------------------------------------------------
void TGControl::onMouseMoved(int x, int y)
{
}
//-----------------------------------------------------------------------
// o n M o u s e D o w n
//-----------------------------------------------------------------------
void TGControl::onMouseDown(int x, int y, int b)
{
if (b == LeftButton)
{
setKeyboardFocusControl(this);
focus();
fireEvent(TGEvent::MouseClicked,TGEventArgs(this));
}
if (b == RightButton)
{
if (m_popupMenu)
m_popupMenu->run();
}
}
//-----------------------------------------------------------------------
// o n M o u s e U p
//-----------------------------------------------------------------------
void TGControl::onMouseUp(int x, int y, int b)
{
}
//-----------------------------------------------------------------------
// o n K e y D o w n
//-----------------------------------------------------------------------
void TGControl::onKeyDown(int key, unsigned char ascii)
{
}
//-----------------------------------------------------------------------
// o n K e y U p
//-----------------------------------------------------------------------
void TGControl::onKeyUp(int key, unsigned char ascii)
{
}
//-----------------------------------------------------------------------
// s e t M o u s e T r a c k i n g C o n t r o l
//-----------------------------------------------------------------------
void TGControl::setMouseTrackingControl(TGControl *control)
{
TGSystem::getSingleton().setMouseTrackingControl(control);
}
//-----------------------------------------------------------------------
// s e t K e y b o a r d F o c u s C o n t r o l
//-----------------------------------------------------------------------
void TGControl::setKeyboardFocusControl(TGControl *control)
{
TGSystem::getSingleton().setKeyboardFocusControl(control);
}
//-----------------------------------------------------------------------
// h a s K e y b o a r d F o c u s
//-----------------------------------------------------------------------
bool TGControl::hasKeyboardFocus(TGControl *control)
{
return TGSystem::getSingleton().hasKeyboardFocus(control);
}
//-----------------------------------------------------------------------
// i n v a l i d a t e C o n t r o l
//-----------------------------------------------------------------------
void TGControl::invalidateControl(TGControl *control)
{
TGSystem::getSingleton().invalidateControl(control);
}
//-----------------------------------------------------------------------
// g e t A c t i v e S c r e e n
//-----------------------------------------------------------------------
TGScreen* TGControl::getActiveScreen()
{
return TGSystem::getSingleton().getActiveScreen();
}
//-----------------------------------------------------------------------
// d r a w R e c t
//-----------------------------------------------------------------------
void TGControl::drawRect(int x1, int y1, int x2, int y2,TGSBrush brush, int thickness)
{
if(!m_isVisible)
return;
drawLine(x1-1,y1,x2,y1,brush,thickness);
drawLine(x2,y1,x2,y2,brush,thickness);
drawLine(x1,y2,x2,y2,brush,thickness);
drawLine(x1,y1,x1,y2,brush,thickness);
}
//-----------------------------------------------------------------------
// f i l l R e c t
//-----------------------------------------------------------------------
void TGControl::fillRect(int x1, int y1, int x2, int y2, TGSBrush brush)
{
if(!m_isVisible)
return;
TGRect r(x1,y1,x2,y2);
TGQuadInfo qi = m_renderer->addQuad(r,0,brush);
m_systemCache.push_back(qi);
m_quadCache.push_back(qi);
}
//-----------------------------------------------------------------------
// d r a w L i n e
//-----------------------------------------------------------------------
void TGControl::drawLine(int x1, int y1, int x2, int y2,TGSBrush brush, int thickness)
{
if(!m_isVisible)
return;
TGRect r(x1,y1,x2,y2);
TGQuadInfo qi = m_renderer->addLine(r,0,brush,thickness);
m_systemCache.push_back(qi);
m_quadCache.push_back(qi);
}
//-----------------------------------------------------------------------
// d r a w T r i
//-----------------------------------------------------------------------
void TGControl::drawTri(int x1, int y1, int x2, int y2,TGSBrush brush, int pointDir)
{
if(!m_isVisible)
return;
TGRect r(x1,y1,x2,y2);
TGQuadInfo qi = m_renderer->addTri(r,0,brush,pointDir);
m_systemCache.push_back(qi);
m_quadCache.push_back(qi);
}
//-----------------------------------------------------------------------
// d r a w F r a m e
//-----------------------------------------------------------------------
void TGControl::drawFrame(int x1, int y1, int x2, int y2, TGFrameStyle s,int thickness)
{
if(!m_isVisible)
return;
TGSBrush brush;
brush = m_theme.getBaseOpaque();
fillRect(x1, y1, x2, y2, brush);
if (!s)
{
return;
}
switch (s)
{
case FS_FLAT:
brush = m_theme.getFrameBrush();
drawRect(x1, y1, x2, y2, brush );
break;
case FS_RAISED:
brush = m_theme.getFrameFocusedBrush();
drawRect(x1, y1, x2, y2, brush);
break;
case FS_LOWERED:
brush = m_theme.getFrameSelectedBrush();
drawRect(x1, y1, x2, y2, brush);
break;
default:
break;
}
}
//-----------------------------------------------------------------------
// d r a w S t r i n g
//-----------------------------------------------------------------------
void TGControl::drawString(int x, int y, TGString str, TGSBrush brush, int length)
{
if(!m_isVisible)
return;
TGFont* font = m_font;
if(!font)
return;
int cHeight=font->getHeight();
TGReal cx = x;
if (length == -1)
length = (int)str.length();
for (int i=0;i<length;i++)
{
char ch=str[i];
if (ch == ' ')
{
cx += 5;
continue;
}
int x2,y2;
int cWidth = font->m_font->getGlyphAspectRatio(ch) * cHeight;
x2 = cx + cWidth;
y2 = y+cHeight;
TGRect r(cx,y,x2,y2);
Ogre::Font::CodePoint cp = ch;
const Ogre::Font::UVRect uvr = font->m_font->getGlyphTexCoords(cp);
brush->m_uv.d_left = uvr.left;
brush->m_uv.d_top = uvr.top;
brush->m_uv.d_right = uvr.right;
brush->m_uv.d_bottom = uvr.bottom;
TGQuadInfo qi = m_renderer->addQuad(r,0,brush);
m_systemCache.push_back(qi);
m_quadCache.push_back(qi);
cx += cWidth + 1.0f;
}
}
//-----------------------------------------------------------------------
// s t r i n g W i d t h
//-----------------------------------------------------------------------
int TGControl::stringWidth(TGString str, size_t length)
{
TGFont* font = m_font;
if(!font)
return 0;
TGReal cx = 0;
if (length == -1)
length = str.length();
for (size_t i=0;i<length;i++)
{
if (str[i] == ' ')
{
cx += 5;
continue;
}
int cWidth = font->m_font->getGlyphAspectRatio(str[i]) * font->getHeight();
cx += cWidth + 1;
}
return (int)cx;
}
//-----------------------------------------------------------------------
// s t r i n g H e i g h t
//-----------------------------------------------------------------------
int TGControl::stringHeight()
{
TGFont* font = TGSystem::getSingleton().getCurrentFont();
if(!font)
return 0;
return font->getHeight();
}
//-----------------------------------------------------------------------
// o p e n C l i p
//-----------------------------------------------------------------------
void TGControl::openClip()
{
int x1, y1, x2, y2;
getBounds(x1, y1, x2, y2);
openClipArea(x1, y1, x2, y2);
}
//-----------------------------------------------------------------------
// c l o s e C l i p
//-----------------------------------------------------------------------
void TGControl::closeClip()
{
closeClipArea();
}
//-----------------------------------------------------------------------
// r e s e t C l i p p i n g
//-----------------------------------------------------------------------
void TGControl::resetClipping()
{
m_renderer->resetClipping();
}
//-----------------------------------------------------------------------
// o p e n C l i p A r e a
//-----------------------------------------------------------------------
void TGControl::openClipArea(int x1, int y1, int x2, int y2)
{
m_renderer->openClipArea(x1,y1,x2,y2);
}
//-----------------------------------------------------------------------
// c l o s e C l i p A r e a
//-----------------------------------------------------------------------
void TGControl::closeClipArea()
{
m_renderer->closeClipArea();
}
//-----------------------------------------------------------------------
// g e t F i r s t C h i l d
//-----------------------------------------------------------------------
TGControl* TGControl::getFirstChild()
{
if(m_children.size())
return m_children.front();
else return NULL;
}
//-----------------------------------------------------------------------
// g e t L a s t C h i l d
//-----------------------------------------------------------------------
TGControl* TGControl::getLastChild()
{
return m_children.back();
}
//-----------------------------------------------------------------------
// s e t F o c u s e d C h i l d
//-----------------------------------------------------------------------
void TGControl::setFocusedChild(TGControl* child)
{
m_focusedChild = child;
//
// put the "focused" child at the back of the list
//
for (TGControlListItr itr = m_children.begin();itr != m_children.end(); ++itr)
{
TGControl *c = *itr;
if (c == child)
{
m_children.erase(itr);
m_children.push_back(c);
break;
}
}
}
//-----------------------------------------------------------------------
// a d d E v e n t H a n d l e r
//-----------------------------------------------------------------------
void TGControl::addEventHandler(TGString eventID, TGEventHandler* handler)
{
TGEventMap::iterator itr;
itr = m_handlers.find(eventID);
//
// if not found, then create a new handler map entry
//
if(itr == m_handlers.end())
{
m_handlers[eventID] = TGEventHandlers();
itr = m_handlers.find(eventID);
}
itr->second.push_back(handler);
}
//-----------------------------------------------------------------------
// r e m o v e E v e n t H a n d l e r
//-----------------------------------------------------------------------
void TGControl::removeEventHandler(TGString eventID, TGEventHandler* handler)
{
}
//-----------------------------------------------------------------------
// r e m o v e A l l H a n d l e r s
//-----------------------------------------------------------------------
void TGControl::removeAllHandlers(void* obj)
{
}
//-----------------------------------------------------------------------
// r e m o v e A l l H a n d l e r s
//-----------------------------------------------------------------------
void TGControl::removeAllHandlers(TGControl* control)
{
TGEventMap::iterator itr;
itr = m_handlers.begin();
while(itr != m_handlers.end())
{
for(size_t i=0; i<itr->second.size(); i++)
{
TGEventHandler* eh = itr->second[i];
delete eh;
}
itr->second.clear();
++itr;
}
}
//-----------------------------------------------------------------------
// l o g M e s s a g e
//-----------------------------------------------------------------------
void TGControl::logMessage(TGString message)
{
TGSystem::getSingleton().logMessage(message);
}
//-----------------------------------------------------------------------
// s e t T h e m e
//-----------------------------------------------------------------------
void TGControl::setTheme(TGTheme theme,bool updateChildren)
{
m_theme = theme;
if(m_popupMenu)
m_popupMenu->setTheme(theme,true);
if(!updateChildren)
return;
for (TGControlListItr itr = m_children.begin();itr != m_children.end(); ++itr)
{
(*itr)->setTheme(theme,true);
}
redraw();
}
//-----------------------------------------------------------------------
// r e P a r e n t
//-----------------------------------------------------------------------
void TGControl::reParent(TGControl* newParent)
{
if(m_parent)
m_parent->removeChild(this);
m_parent = newParent;
if(m_parent)
m_parent->addChild(this);
}
//-----------------------------------------------------------------------
// f i r e E v e n t
//-----------------------------------------------------------------------
bool TGControl::fireEvent(TGString eventID,TGEventArgs& args)
{
bool rc=false;
args.m_eventID = eventID;
if(m_system->eventHook(args))
return true;
TGEventMap::iterator itr;
itr = m_handlers.find(eventID);
//
// map entry?
//
if(itr == m_handlers.end())
return false;
for(size_t i=0;i<itr->second.size();i++)
{
TGEventHandler* eh = itr->second[i];
rc = (*eh)(args);
if(rc)
return true;
}
return rc;
}
//-----------------------------------------------------------------------
// r e d r a w
//-----------------------------------------------------------------------
void TGControl::redraw(bool value)
{
m_redraw = value;
for (TGControlListItr itr = m_children.begin();itr != m_children.end(); ++itr)
{
(*itr)->redraw(value);
}
};
//-----------------------------------------------------------------------
// i s R e n d e r C a c h e d
//-----------------------------------------------------------------------
bool TGControl::isRenderCached()
{
if(!m_isVisible)
return true;
if(m_redraw)
{
m_quadCache.clear();
m_redraw = false;
return false;
}
for(size_t i=0; i<m_quadCache.size(); i++)
{
m_systemCache.push_back(m_quadCache[i]);
}
TGControl::render();
return true;
}
//-----------------------------------------------------------------------
// r e n d e r
//-----------------------------------------------------------------------
void TGControl::render()
{
int x1, y1, x2, y2;
if(!isVisible())
return;
getBounds(x1, y1, x2, y2);
openClipArea(x1 + m_padLeft, y1 + m_padTop, x2 - m_padRight,
y2 - m_padBottom);
for (TGControlListItr itr = m_children.begin();itr != m_children.end(); ++itr)
{
if (*itr == m_exclusiveChild)
continue;
(*itr)->render();
(*itr)->redraw(false);
}
if (m_exclusiveChild)
{
TGControl::fillRect(x1, y1, x2, y2, m_theme.getExclusiveOverlay());
m_exclusiveChild->render();
m_exclusiveChild->redraw(false);
}
closeClipArea();
m_redraw = false;
}
} | [
"pc0der@a5263bde-0223-0410-8bbb-1954fdd97a2f"
]
| [
[
[
1,
1239
]
]
]
|
3329ba9640e501f812f784b3f61e04503b1f3a79 | ab41c2c63e554350ca5b93e41d7321ca127d8d3a | /glm/gtx/vector_access.inl | 88d38ea6eeb044b548c7d3ff6a15ba4b10f98ecb | []
| no_license | burner/e3rt | 2dc3bac2b7face3b1606ee1430e7ecfd4523bf2e | 775470cc9b912a8c1199dd1069d7e7d4fc997a52 | refs/heads/master | 2021-01-11T08:08:00.665300 | 2010-04-26T11:42:42 | 2010-04-26T11:42:42 | 337,021 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,238 | inl | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2006-01-16
// Updated : 2008-10-07
// Licence : This source is under MIT License
// File : glm/gtx/vector_access.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{
namespace gtx{
namespace vector_access{
template <typename valType>
inline void set
(
detail::tvec2<valType>& v,
valType const & x,
valType const & y
)
{
v.x = x;
v.y = y;
}
template <typename valType>
inline void set
(
detail::tvec3<valType>& v,
valType const & x,
valType const & y,
valType const & z
)
{
v.x = x;
v.y = y;
v.z = z;
}
template <typename valType>
inline void set
(
detail::tvec4<valType>& v,
valType const & x,
valType const & y,
valType const & z,
valType const & w
)
{
v.x = x;
v.y = y;
v.z = z;
v.w = w;
}
}//namespace vector_access
}//namespace gtx
}//namespace glm
| [
"[email protected]"
]
| [
[
[
1,
58
]
]
]
|
739565751c2919d9418e611a6c52fe791937384c | fac8de123987842827a68da1b580f1361926ab67 | /inc/physics/Physics/Utilities/Constraint/Chain/hkpPoweredChainMapper.h | be586eedcbbfc390f3caf391d513fc58774915a1 | []
| no_license | blockspacer/transporter-game | 23496e1651b3c19f6727712a5652f8e49c45c076 | 083ae2ee48fcab2c7d8a68670a71be4d09954428 | refs/heads/master | 2021-05-31T04:06:07.101459 | 2009-02-19T20:59:59 | 2009-02-19T20:59:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,960 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HK_UTILITIES_POWERED_CHAIN_MAPPER_H
#define HK_UTILITIES_POWERED_CHAIN_MAPPER_H
#include <Common/Base/hkBase.h>
#include <Common/Base/Container/Array/hkObjectArray.h>
#include <Common/Base/Container/PointerMap/hkPointerMap.h>
class hkpConstraintInstance;
class hkpEntity;
class hkpConstraintMotor;
class hkQuaternion;
class hkpConstraintChainData;
class hkpPoweredChainData;
class hkpConstraintChainInstance;
extern const hkClass hkpPoweredChainMapperClass;
/// This class allows you to manage several overlapping powered chains. It allows you to set max forces and target orientations for motors.
class hkpPoweredChainMapper : public hkReferencedObject
{
public:
HK_DECLARE_REFLECTION();
HK_DECLARE_CLASS_ALLOCATOR(HK_MEMORY_CLASS_CONSTRAINT);
private:
// You should only create the mapper with the buildChainMapper() function.
hkpPoweredChainMapper() {}
public:
virtual ~hkpPoweredChainMapper();
/// Holds parameters for the mapper-building function.
struct Config
{
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_UTILITIES, hkpPoweredChainMapper::Config );
/// Tells whether limit constraints should be created in parallel with the chains.
///
/// Limit constraints use information from the existing powered/non-powered ragdoll/hinge constraints only.
/// No limit constraints are created for any other types of constraints.
hkBool m_createLimitConstraints;
/// Should the chains clone motors or reuse the ones from the original constraints.
hkBool m_cloneMotors;
Config()
{
m_createLimitConstraints = false;
m_cloneMotors = false;
}
};
/// Used to specify the first and the last entity of a new chain.
struct ChainEndpoints
{
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_UTILITIES, hkpPoweredChainMapper::ChainEndpoints );
/// First entity in the chain.
hkpEntity* m_start;
/// Last entity in the chain.
hkpEntity* m_end;
};
/// Builds a mapper with chains specified by entity pairs in the ChainEndpoints array.
/// Returns HK_NULL upon failure.
static hkpPoweredChainMapper* HK_CALL buildChainMapper(const Config config, const hkArray<hkpConstraintInstance*>& allConstraints, const hkArray<ChainEndpoints>& pairs, hkArray<hkpConstraintInstance*>* unusedConstraints = HK_NULL);
//
// Setting link properties
//
/// Sets min/max force for one motor (specifed by the coordinateIndex) in all chains overlapping at the specified link (linkIndex)
void setForceLimits(int linkIndex, int coordinageIndex /*motorIndex*/, hkReal minForce, hkReal maxForce);
/// This appends the motors related to a given link to the motorsOut array.
/// Note: there may be only one motor for a given link/coordinate index pair in a chain; but there may be several chains overlapping at the specified link.
void getMotors(int linkIndex, int coordinateIndex, hkArray<hkpConstraintMotor*>& motorsOut);
/// Return the total number of links.
/// Note: as links order is a one-to-one match with the constraintArray passed to the buildChainMapper function,
/// some of the links might not lead to any target chains.
inline int getNumLinks() { return m_links.getSize(); }
/// Set motor for the given link/coordinate index
void setMotors(int linkIndex, int coordinateIndex, hkpConstraintMotor* newMotor);
/// Sets target orientations for all chains overlapping at the specified link.
void setTargetOrientation(int linkIndex, const hkQuaternion& newTarget);
//
// Internal
//
/// Specifies a chain/index referenced by a link.
struct Target
{
HK_DECLARE_REFLECTION();
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_CONSTRAINT, Target );
/// Targeted powered chain
hkpPoweredChainData* m_chain;
/// Index of the targeted ConstraintInfo in the chain
int m_infoIndex;
};
/// Holds information about a single link of the mapper.
/// One link may point to none, one, or a few chains.
/// Also a link may have a limit constraint associated with it.
struct LinkInfo
{
HK_DECLARE_REFLECTION();
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_CONSTRAINT, LinkInfo );
/// This specifies the index of the first target for this link. All targets for a given link are groupped together.
/// Those targets are set, when you call setMaxForce() or setTargetOrientation() for that link.
int m_firstTargetIdx;
/// Specifies the number of targets for this link.
int m_numTargets;
/// A limit constraint that functions in parallel with the chains.
/// It is direcly related to using chains, and should be added/removed to/from the world when chains are removed.
hkpConstraintInstance* m_limitConstraint;
LinkInfo() : m_firstTargetIdx(-1), m_numTargets(0), m_limitConstraint(HK_NULL) {}
LinkInfo(const LinkInfo& info) { m_firstTargetIdx = info.m_firstTargetIdx; m_numTargets = info.m_numTargets; m_limitConstraint = info.m_limitConstraint; }
};
/// Matches 1-1 the hkpConstraintInstance array passed to buildChainMapper()
/// Note that some m_links may have no targets -- when a certain constraint is not used by the mapper.
hkArray<struct LinkInfo> m_links;
/// Combined array of targets for all the links.
hkArray<struct Target> m_targets;
/// Just an extra array listing directly all the chains owned by the mapper.
hkArray<class hkpConstraintChainInstance*> m_chains;
/// Finish up ctor.
hkpPoweredChainMapper( hkFinishLoadedObjectFlag f ) : m_links(f), m_targets(f), m_chains(f) {}
};
#endif // HK_UTILITIES_POWERED_CHAIN_MAPPER_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok. (C) Copyright 1999-2008
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
| [
"uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4"
]
| [
[
[
1,
174
]
]
]
|
4a374790a350b866a701fdf11fdf7089fa32e74d | 5210c96be32e904a51a0f32019d6be4abdb62a6d | /Material.cpp | 33e267b1c015cce2c3d7d80da811f288f6246191 | []
| no_license | Russel-Root/knot-trying-FTL | 699cec27fcf3f2b766a4beef6a58176c3cbab33e | 2c1a7992855927689ad1570dd7c5998a73728504 | refs/heads/master | 2021-01-15T13:18:35.661929 | 2011-04-02T07:51:51 | 2011-04-02T07:51:51 | 1,554,271 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,778 | cpp | #include "Material.h"
Material::Material(){
ambientR = ambientG = ambientB = ambientA = 0.0f;
diffuseR = diffuseG = diffuseB = diffuseA = 0.0f;
specularR = specularG = specularB = specularA = 0.0f;
shininess = 0.0f;
current = 0;
}
Material::~Material(){}
void Material::setAmbient(GLfloat r, GLfloat g, GLfloat b, GLfloat a){
ambientR = r;
ambientG = g;
ambientB = b;
ambientA = a;
}
void Material::setDiffuse(GLfloat r, GLfloat g, GLfloat b, GLfloat a){
diffuseR = r;
diffuseG = g;
diffuseB = b;
diffuseA = a;
}
void Material::setSpecular(GLfloat r, GLfloat g, GLfloat b, GLfloat a){
specularR = r;
specularG = g;
specularB = b;
specularA = a;
}
void Material::setShininess(GLfloat s){
shininess = s;
}
void Material::setMaterial(){
GLfloat mat_ambient[] = {ambientR, ambientG, ambientB, ambientA};
GLfloat mat_diffuse[] = {diffuseR, diffuseG, diffuseB, diffuseA};
GLfloat mat_specular[] = {specularR, specularG, specularB, specularA};
GLfloat mat_shininess[] = {shininess};
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
}
void Material::setTransparent(bool transp){
if (transp){
glEnable(GL_BLEND); // 启动纹理混合
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // 基于源像素alpha通道值的半透明混合函数
glDepthMask(GL_FALSE);
}
else{
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
}
}
void Material::setNum(int n){
num = n;
g_texture = new GLuint[n];
}
bool Material::addTexture(const char* filename){
if ( !g_texture )
return false;
Image* temp = loadBMP(filename);
// 如果该贴图不存在,返回false
if ( !temp )
return false;
// bind the texture
glGenTextures(1, &g_texture[current]);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, g_texture[current]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, temp->height, temp->width, 0, GL_RGB, GL_UNSIGNED_BYTE, temp->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//gluBuild2DMipmaps(GL_TEXTURE_2D, 3, temp->height, temp->width, GL_RGB, GL_UNSIGNED_BYTE, temp->pixels);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// deinit the memory
if (temp){
if (temp->pixels)
free(temp->pixels);
free(temp);
}
current++;
return true;
}
void Material::enableTexture(int k){
glEnable(GL_TEXTURE_2D);
if ( k < current )
glBindTexture(GL_TEXTURE_2D, g_texture[k]);
} | [
"[email protected]"
]
| [
[
[
1,
101
]
]
]
|
ac3e183225dfa657550338b2012e12ba10cc32b8 | 989aa92c9dab9a90373c8f28aa996c7714a758eb | /HydraIRC/include/HydraControls/HydraSplitter.h | 509ab111b4d08af32ffb31ea5578f7d3c02752af | []
| no_license | john-peterson/hydrairc | 5139ce002e2537d4bd8fbdcebfec6853168f23bc | f04b7f4abf0de0d2536aef93bd32bea5c4764445 | refs/heads/master | 2021-01-16T20:14:03.793977 | 2010-04-03T02:10:39 | 2010-04-03T02:10:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 741 | h | #pragma once
template <bool t_bVertical = true>
class CHydraSplitterWindowT : public CSplitterWindowImpl<CHydraSplitterWindowT<t_bVertical>, t_bVertical>
{
public:
DECLARE_WND_CLASS_EX(_T("WTL_HydraSplitterWindow"), CS_DBLCLKS, COLOR_WINDOW)
// Overrides
void DrawSplitterBar(CDCHandle dc)
{
RECT rect;
if(GetSplitterBarRect(&rect))
{
dc.FillRect(&rect, COLOR_3DFACE);
// draw FLAT edge if needed
if((GetExStyle() & WS_EX_CLIENTEDGE) != 0)
dc.DrawEdge(&rect, EDGE_RAISED, BF_FLAT | t_bVertical ? (BF_LEFT | BF_RIGHT) : (BF_TOP | BF_BOTTOM));
}
}
};
typedef CHydraSplitterWindowT<true> CHydraSplitterWindow;
typedef CHydraSplitterWindowT<false> CHydraHorSplitterWindow;
| [
"hydra@b2473a34-e2c4-0310-847b-bd686bddb4b0"
]
| [
[
[
1,
25
]
]
]
|
21ea76e22337c2edd9849c8542580a4776dd6f34 | 6c8c4728e608a4badd88de181910a294be56953a | /UiModule/Inworld/NotificationManager.cpp | f557ef2bb5dd1e476fa73d6fd701858ca11c236c | [
"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,679 | cpp | // For conditions of distribution and use, see copyright notice in license.txt
#include "StableHeaders.h"
#include "DebugOperatorNew.h"
#include "NotificationManager.h"
#include "InworldSceneController.h"
#include "Inworld/ControlPanelManager.h"
#include "Inworld/Notifications/NotificationBaseWidget.h"
#include "Inworld/Notifications/NotificationBrowserWidget.h"
#include "Inworld/ControlPanel/ControlPanelButton.h"
#include "Common/ControlButtonAction.h"
#include <QGraphicsScene>
#include <QDebug>
#include "MemoryLeakCheck.h"
namespace UiServices
{
NotificationManager::NotificationManager(InworldSceneController *inworld_scene_controller) :
QObject(),
inworld_scene_controller_(inworld_scene_controller),
scene_(inworld_scene_controller->GetInworldScene()),
notice_max_width_(200),
notice_start_pos_(QPointF()),
browser_widget_(new CoreUi::NotificationBrowserWidget()),
panel_(inworld_scene_controller_->GetControlPanelManager())
{
InitSelf();
}
NotificationManager::~NotificationManager()
{
// Clean up whole notification history
foreach(CoreUi::NotificationBaseWidget *notification, notifications_history_)
SAFE_DELETE(notification);
}
// Private
void NotificationManager::InitSelf()
{
browser_widget_->hide();
scene_->addItem(browser_widget_);
CoreUi::ControlPanelButton *button = inworld_scene_controller_->GetControlPanelManager()->GetButtonForType(UiDefines::Notifications);
if (button)
{
CoreUi::ControlButtonAction *notification_action = new CoreUi::ControlButtonAction(button, browser_widget_, this);
inworld_scene_controller_->GetControlPanelManager()->SetHandler(UiDefines::Notifications, notification_action);
connect(notification_action, SIGNAL(toggled(bool)), SLOT(ToggleNotificationBrowser()));
connect(scene_, SIGNAL(sceneRectChanged(const QRectF&)), SLOT(UpdatePosition(const QRectF &)));
}
}
void NotificationManager::UpdatePosition(const QRectF &scene_rect)
{
notice_start_pos_.setY(panel_->GetContentHeight());
notice_start_pos_.setX(scene_rect.right()-notice_max_width_);
if (browser_widget_->isVisible())
{
qreal padding = 10;
browser_widget_->setPos(scene_->sceneRect().right() - browser_widget_->size().width() - padding,
panel_->GetContentHeight() + padding);
}
else
UpdateStack();
}
void NotificationManager::UpdateStack()
{
if (visible_notifications_.isEmpty())
return;
// Iterate from start of stack and animate all items to correct positions
QPointF next_position = notice_start_pos_;
foreach(CoreUi::NotificationBaseWidget *notification, visible_notifications_)
{
notification->AnimateToPosition(next_position);
next_position.setY(next_position.y()+notification->size().height());
}
}
void NotificationManager::NotificationHideHandler(CoreUi::NotificationBaseWidget *completed_notification)
{
if (visible_notifications_.contains(completed_notification))
{
visible_notifications_.removeOne(completed_notification);
UpdateStack();
}
}
void NotificationManager::ToggleNotificationBrowser()
{
if (!browser_widget_->isVisible())
{
// Hide visible notification stack
foreach (CoreUi::NotificationBaseWidget *notification, visible_notifications_)
notification->hide();
visible_notifications_.clear();
// Pass history to browser and clear local list
qreal padding = 10;
browser_widget_->resize(panel_->GetContentWidth(), browser_widget_->size().height());
browser_widget_->setPos(scene_->sceneRect().right() - browser_widget_->size().width() - padding, panel_->GetContentHeight() + padding);
browser_widget_->ShowNotifications(notifications_history_);
notifications_history_.clear();
}
else
browser_widget_->AnimatedHide();
}
// Public
void NotificationManager::ShowNotification(CoreUi::NotificationBaseWidget *notification_widget)
{
if (browser_widget_->isVisible())
{
browser_widget_->InsertNotifications(notification_widget);
}
else
{
// Don't show same item twice before first is hidden
if (visible_notifications_.contains(notification_widget))
return;
UpdatePosition(scene_->sceneRect());
QPointF add_position = notice_start_pos_;
// Get stacks last notifications y position
if (!visible_notifications_.isEmpty())
{
CoreUi::NotificationBaseWidget *last_notification = visible_notifications_.last();
add_position.setY(last_notification->mapRectToScene(last_notification->rect()).bottom());
}
// Set position and add to scene
notification_widget->setPos(add_position);
scene_->addItem(notification_widget);
// Connect completed (hide) signal to managers handler
connect(notification_widget, SIGNAL(Completed(CoreUi::NotificationBaseWidget *)),
SLOT(NotificationHideHandler(CoreUi::NotificationBaseWidget *)));
// Append to internal lists
notifications_history_.append(notification_widget);
visible_notifications_.append(notification_widget);
// Start notification
notification_widget->Start();
}
}
void NotificationManager::SetConnectionState(UiDefines::ConnectionState connection_state)
{
switch (connection_state)
{
case UiDefines::Connected:
break;
case UiDefines::Disconnected:
{
foreach(CoreUi::NotificationBaseWidget *notification, notifications_history_)
SAFE_DELETE(notification);
notifications_history_.clear();
visible_notifications_.clear();
browser_widget_->hide();
browser_widget_->ClearAllContent();
break;
}
}
}
} | [
"[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3",
"jujjyl@5b2332b8-efa3-11de-8684-7d64432d61a3",
"[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3"
]
| [
[
[
1,
3
],
[
5,
16
],
[
18,
19
],
[
22,
33
],
[
35,
35
],
[
38,
180
]
],
[
[
4,
4
],
[
20,
21
]
],
[
[
17,
17
],
[
34,
34
],
[
36,
37
]
]
]
|
81871025fa1546db36d4d038a23dfbecc3bb8956 | 4d5ee0b6f7be0c3841c050ed1dda88ec128ae7b4 | /src/nvmesh/MeshAdjacency.cpp | 74f746f9dac815bb61b6a0cbcab2302a2a98590d | []
| no_license | saggita/nvidia-mesh-tools | 9df27d41b65b9742a9d45dc67af5f6835709f0c2 | a9b7fdd808e6719be88520e14bc60d58ea57e0bd | refs/heads/master | 2020-12-24T21:37:11.053752 | 2010-09-03T01:39:02 | 2010-09-03T01:39:02 | 56,893,300 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 600 | cpp | // This code is in the public domain -- [email protected]
#include "MeshAdjacency.h"
using namespace nv;
void TriMeshAdjacency::buildAdjacency(TriMesh * mesh)
{
nvCheck(mesh != NULL);
// Check out Eric Lengyel's code.
}
// Proximal methods.
void TriMeshAdjacency::computeProximals()
{
}
void TriMeshAdjacency::addProximal(uint r, uint v)
{
}
bool TriMeshAdjacency::hasProximal(uint v) const
{
return false;
}
uint TriMeshAdjacency::countProximals(uint v) const
{
return 1;
}
uint TriMeshAdjacency::firstProximal(uint v) const
{
return v;
}
| [
"castano@0f2971b0-9fc2-11dd-b4aa-53559073bf4c"
]
| [
[
[
1,
39
]
]
]
|
1cf056d19cf3558b11780e8f6bd2663418845bf9 | 6581dacb25182f7f5d7afb39975dc622914defc7 | /CodeProject/ExcelAddinInEasyIF/GridFromCellWiz.h | 8044f4ad9ba1caf91056d81e6be63c3608f34a3d | []
| no_license | dice2019/alexlabonline | caeccad28bf803afb9f30b9e3cc663bb2909cc4f | 4c433839965ed0cff99dad82f0ba1757366be671 | refs/heads/master | 2021-01-16T19:37:24.002905 | 2011-09-21T15:20:16 | 2011-09-21T15:20:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,634 | h | #if !defined(AFX_GRIDFROMCELLWIZ_H__C938CA66_1EA9_474A_8ED5_0903B6795E43__INCLUDED_)
#define AFX_GRIDFROMCELLWIZ_H__C938CA66_1EA9_474A_8ED5_0903B6795E43__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// GridFromCellWiz.h : header file
//
#include "FldProps.h"
#include "GFCMatrixDetails.h"
/////////////////////////////////////////////////////////////////////////////
// GridFromCellWiz
class GridFromCellWiz : public CPropertySheet
{
DECLARE_DYNAMIC(GridFromCellWiz)
CObArray m_oFldProps;
CObArray *m_pFields;
GFCMatrixDetails *m_pGridInfo;
// Construction
public:
GridFromCellWiz(CObArray *pFields, UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
GridFromCellWiz(CObArray *pFields, LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(GridFromCellWiz)
public:
virtual int DoModal();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~GridFromCellWiz();
// Generated message map functions
protected:
//{{AFX_MSG(GridFromCellWiz)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GRIDFROMCELLWIZ_H__C938CA66_1EA9_474A_8ED5_0903B6795E43__INCLUDED_)
| [
"damoguyan8844@3a4e9f68-f5c2-36dc-e45a-441593085838"
]
| [
[
[
1,
60
]
]
]
|
30efa97cbd3e825d2698c8a6500b508d5ba8582f | c1b7571589975476405feab2e8b72cdd2a592f8f | /chopshop10/Vision166.h | 67c418fceefa2d137ac622037559abc5d981e77f | []
| no_license | chopshop-166/frc-2010 | ea9cd83f85c9eb86cc44156f21894410a9a4b0b5 | e15ceff05536768c29fad54fdefe65dba9a5fab5 | refs/heads/master | 2021-01-21T11:40:07.493930 | 2010-12-10T02:04:05 | 2010-12-10T02:04:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,227 | h | /*******************************************************************************
* Project : chopshop10 - 2010 Chopshop Robot Controller Code
* File Name : Vision166.h
* Owner : Software Group (FIRST Chopshop Team 166)
* Creation Date : January 18, 2010
* Revision History : From Explorer with TortoiseSVN, Use "Show log" menu item
* File Description : Robot code header which handles vision of camera
*******************************************************************************/
/*----------------------------------------------------------------------------*/
/* Copyright (c) MHS Chopshop Team 166, 2010. All Rights Reserved. */
/*----------------------------------------------------------------------------*/
#ifndef _VISION166_H
#define _VISION166_H
#include "semLib.h"
#include "WPILib.h"
#include "Team166Task.h"
#include "MemoryLog166.h"
#include "Target166.h"
#include "Target.h"
// WPILib include files for vision
#include "TrackAPI.h"
#include "Vision/AxisCamera.h"
#include "Vision/HSLImage.h"
#define FLIP_SERVO_VERTICAL true
#define PI 3.14159265358979
#define DEFAULT_VERTICAL_PAN_POSITION 0
#define CAMERA_SPAWN_TRY_WAIT 0.5 // seconds to wait for each thread
#define CAMERA_SPAWN_WAIT_MAX 20.0 // seconds to wait for the camera to come up.
/** ratio of horizontal image field of view (54 degrees) to horizontal servo (180) */
#define HORIZONTAL_IMAGE_TO_SERVO_ADJUSTMENT (54.0/180.0) // this seems to work
/** ratio of vertical image field of view (40.5 degrees) to vertical servo (180) */
#define VERTICAL_IMAGE_TO_SERVO_ADJUSTMENT (40.5/180.0) // this seems to work
#define DAMPING_FACTOR 0.75
#define SERVO_DEADBAND 0.01
#define SCORE_MINIMUM 0.01
#define SCORE_GOOD 0.4
#define DISTORTION_DELTA_MAX 0.25
//
// This constant defines how often we want this task to run in the form
// of miliseconds. Max allowed time is 999 miliseconds.
//
#define VISION_CYCLE_TIME (100) // 100ms
class DashboardDataSender;
/*
* Team 166 Vision Class
*
*/
class Team166Vision : public Team166Task
{
public:
Team166Vision(void);
virtual ~Team166Vision(void);
//! Main function of the Vision task
virtual int Main(int a2, int a3, int a4, int a5,
int a6, int a7, int a8, int a9, int a10);
/**
* @return bool Whether the target has been acquired.
*/
bool IsTargetAcquired(void);
/**
* The bearing to the target in degrees.
* @return float Degrees to the angle, 0 being full left and 180 being full right.
*/
float GetBearing(void);
/**
* @brief Tries to start the camera using vxWorks threads, since
* StartCamera() will hang the thread if it can't successfully start
* the camera. Will try to start the camera several times, timing out
* after a predefined amount of time.
*/
void TryStartCamera(bool);
/**
* Allocates a pointer, and stores a captured image into it.
* @return ColorImage Captured image.
*/
ColorImage *GetImage();
/**
* Gets the score horizontally to the target.
* @return float Score value, -1.0 being full left and 1.0 being full right.
*/
float GetScoreToTargetX();
/**
* Gets the score vertically to the target.
* @return float Score value, -1.0 being down and 1.0 being up.
*/
float GetScoreToTargetY();
// Private functions and attributes
private:
ColorMode colorMode;
//! Target has been acquired since last run
bool targetAcquired;
//! Whether the image ( Proxy166::GetImage() ) is new or not.
bool staleFlag;
//! Angle horizontally to the target
float bearing;
//! Angle vertically to the target
float tilt;
//! -1.0 to 1.0 score to target x-axis bearing, independent of servo positions, to be passed to the drive functions.
float score_to_target_x;
//! -1.0 to 1.0 score to target y-axis tilt, independent of servo positions, to be passed to the drive functions.
float score_to_target_y;
Servo horizontalServo;
Servo verticalServo;
DashboardDataSender *dds;
/**
* @brief The main function of the threads spawned in TryStartCamera().
* Spawned via taskSpawn vxWorks function.
* Calls StartCamera(), which will hang the calling thread in a variety of circumstances.
*/
static int _StartCameraThreadFunc(void *this_p,int a2, int a3, int a4, int a5,
int a6, int a7, int a8, int a9, int a10);
/**
* @brief Tries to find the target in the current view of the camera.
* @param matches A vector to store the matches for elipses in.
* @param psx Previous servo X value. Will be used later for smoothing movement.
* @param psy Previous servo Y value. Will be used later for smoothing movement.
*/
void AcquireTarget(vector<Target>& matches,float& psx,float& psy);
//! Sets the servo positions directly.
void SetServoPositions(float normalizedHorizontal, float normalizedVertical);
//! Sets the servo positinos from image x and y values.
void AdjustServoPositions(float normDeltaHorizontal, float normDeltaVertical);
//! Directly maps x and y to servo X and Y values.
void _SetServoPositions(float servoHorizontal, float servoVertical);
};
#endif // !defined(_VISION166_H)
| [
"[email protected]"
]
| [
[
[
1,
146
]
]
]
|
2fddc3d6d7535d9c97628276e5d4270df26e5eb2 | 8a8873b129313b24341e8fa88a49052e09c3fa51 | /src/ActiveIncomingCallObserver.cpp | d1116f1704e72631d5e46c6471fedd851ce01083 | []
| no_license | flaithbheartaigh/wapbrowser | ba09f7aa981d65df810dba2156a3f153df071dcf | b0d93ce8517916d23104be608548e93740bace4e | refs/heads/master | 2021-01-10T11:29:49.555342 | 2010-03-08T09:36:03 | 2010-03-08T09:36:03 | 50,261,329 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,609 | cpp | /*
============================================================================
Name : ActiveIncomingCallObserver.cpp
Author :
Version :
Copyright : Your copyright notice
Description : CActiveIncomingCallObserver implementation
============================================================================
*/
#include "ActiveIncomingCallObserver.h"
//--------------------------------------------
// CActiveIncomingCallObserver(MIncomingCallObserverInterface* aObserver)
//--------------------------------------------
#ifdef __SERIES60_3X__
CActiveIncomingCallObserver::CActiveIncomingCallObserver(MIncomingCallObserverInterface* aObserver)
: CActive(20),iCurrentStatusPckg(iCurrentStatus),iPhoneIdV1Pckg(iPhoneIdV1),iFlag(0),iObserver(aObserver)
{
}
#else
CActiveIncomingCallObserver::CActiveIncomingCallObserver(MIncomingCallObserverInterface* aObserver)
: CActive(0),iObserver(aObserver)
{
iLineInited = EFalse;
iCallActive = EFalse;
}
#endif
//--------------------------------------------
// ~CActiveIncomingCallObserver()
//--------------------------------------------
CActiveIncomingCallObserver::~CActiveIncomingCallObserver()
{
// Cancel any request, if outstanding
Cancel();
#ifdef __SERIES60_3X__
delete iTelephony;
#endif
}
//--------------------------------------------
// void ConstructL()
//--------------------------------------------
void CActiveIncomingCallObserver::ConstructL()
{
#ifdef __SERIES60_3X__
iTelephony = CTelephony::NewL();
#endif
CActiveScheduler::Add(this);
}
//--------------------------------------------
// void DoCancel()
//--------------------------------------------
void CActiveIncomingCallObserver::DoCancel()
{
ReleasePhone();
}
//--------------------------------------------
// void RunL()
//--------------------------------------------
void CActiveIncomingCallObserver::RunL()
{
if( iStatus==KErrNone )
{
#ifdef __SERIES60_3X__
if(iFlag==0)
{
m_nIMEI.Zero();
m_nIMEI.Append(iPhoneIdV1.iSerialNumber);
iCurrentStatus.iStatus = CTelephony::EStatusUnknown;
iObserver->IncomingCallObserverInterface_HandleItL(2,m_nIMEI);
ReleasePhone();
iFlag=1;
}
else
{
if( iCurrentStatus.iStatus == CTelephony::EStatusIdle)
{
iObserver->IncomingCallObserverInterface_HandleItL(0,_L("idle"));
}
else
{
iObserver->IncomingCallObserverInterface_HandleItL(1,_L("incoming"));
}
}
StartObserver();
#else
if (iCallActive)
{
// We are polling for the RCall status
if (iCallStatus == RCall::EStatusIdle)
{
iCallActive = EFalse;
iCall.Close();
iLine.NotifyIncomingCall(iStatus, iName);
if (iObserver)
{
iObserver->IncomingCallObserverInterface_HandleItL(0,_L("phone idle"));
}
}
else
{
iCall.NotifyStatusChange(iStatus, iCallStatus);
}
}
else
{
// There's an incoming call!
iCallActive = ETrue;
iCall.OpenExistingCall(iLine, iName);
iCall.NotifyStatusChange(iStatus, iCallStatus);
if (iObserver)
{
iObserver->IncomingCallObserverInterface_HandleItL(1,_L("phone incoming"));
}
}
// And we re-enable the polling
SetActive();
#endif
}
}
//--------------------------------------------
// void StartObserver()
//--------------------------------------------
void CActiveIncomingCallObserver::StartObserver()
{
#ifdef __SERIES60_3X__
if(iFlag==0)
iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
else
iTelephony->NotifyChange(iStatus,CTelephony::EVoiceLineStatusChange,iCurrentStatusPckg);
SetActive();
#else
Cancel();
if (InitializePhone() == KErrNone)
{
SetActive();
}
#endif
}
#ifndef __SERIES60_3X__
//--------------------------------------------
// TInt InitializePhone()
//--------------------------------------------
TInt CActiveIncomingCallObserver::InitializePhone()
{
TInt theError;
if (iLineInited)
{
return KErrNone;
}
theError = iTelServer.Connect();
if (theError)
{
return theError;
}
// Find the number of phones available from the tel server
TInt numberPhones;
theError = iTelServer.EnumeratePhones(numberPhones);
if (theError)
{
iTelServer.Close();
return theError;
}
// Check there are available phones
if (numberPhones < 1)
{
iTelServer.Close();
return KErrNotFound;
}
// Read the TSY module name
theError = iTelServer.GetTsyName(0, iTsyName);
if (theError != KErrNone)
{
iTelServer.Close();
return theError;
}
// Load in the phone device driver
theError = iTelServer.LoadPhoneModule(iTsyName);
if (theError)
{
iTelServer.Close();
return theError;
}
// Get info about the first available phone
RTelServer::TPhoneInfo info;
theError = iTelServer.GetPhoneInfo(0, info);
if (theError)
{
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
// Use this info to open a connection to the phone, the phone is identified by its name
theError = iPhone.Open(iTelServer, info.iName);
if (theError)
{
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
// Get info about the first line from the phone
RPhone::TLineInfo lineInfo;
theError = iPhone.GetLineInfo(0, lineInfo);
if (theError)
{
iPhone.Close();
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
// Use this to open a line
theError = iLine.Open(iPhone, lineInfo.iName);
if (theError)
{
iPhone.Close();
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
iLine.NotifyIncomingCall(iStatus, iName);
iLineInited = ETrue;
return KErrNone;
}
#endif
// ---------------------------------------------------------
// void ReleasePhone()
// ---------------------------------------------------------
void CActiveIncomingCallObserver::ReleasePhone()
{
#ifdef __SERIES60_3X__
if(iFlag==0)
iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
else
iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
#else
if (iLineInited)
{
if (iCallActive)
{
iCall.NotifyStatusChangeCancel();
iCall.Close();
}
else
{
iLine.NotifyIncomingCallCancel();
}
iLine.Close();
iPhone.Close();
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
iLineInited = EFalse;
}
#endif
}
| [
"sungrass.xp@37a08ede-ebbd-11dd-bd7b-b12b6590754f"
]
| [
[
[
1,
282
]
]
]
|
ab5971f679bb08cc7a3707c7eb68910731175d5c | b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2 | /sample/0130guitest/textboxsample.cpp | 71f99eaa41dd6a20a51f4b7f4ecfe7366c4ae1c5 | []
| no_license | roxygen/maid2 | 230319e05d6d6e2f345eda4c4d9d430fae574422 | 455b6b57c4e08f3678948827d074385dbc6c3f58 | refs/heads/master | 2021-01-23T17:19:44.876818 | 2010-07-02T02:43:45 | 2010-07-02T02:43:45 | 38,671,921 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,538 | cpp | #include"textboxsample.h"
using namespace Maid;
TextBoxSample::TextBoxSample()
{
}
void TextBoxSample::Initialize( Maid::Graphics2DRender* r )
{
m_pRender = r;
m_hFont.Create( SIZE2DI(8,16), true );
}
void TextBoxSample::OnInitialize( ID id, const IGUIParts& Parent )
{
}
void TextBoxSample::OnFinalize()
{
}
const int BARSIZE_W = 200;
const int BARSIZE_H = 10;
bool TextBoxSample::LocalIsCollision( const POINT2DI& pos ) const
{
const RECT2DI rc( POINT2DI(0,0), SIZE2DI(BARSIZE_W,BARSIZE_H) );
return Collision<float>::IsPointToRect( pos, rc );
}
void TextBoxSample::OnUpdateFrame()
{
}
void TextBoxSample::OnUpdateDraw( const Maid::RenderTargetBase& Target, const Maid::IDepthStencil& Depth, const Maid::POINT2DI& pos )
{
String str = MAIDTEXT("text:");
const bool in = IsMouseIn();
const String Text = GetText();
const int TextCursor = GetTextCursor();
const String IMText = GetIMText();
const int IMCursor = GetIMCursor();
{
char buf[256];
sprintf( buf, "c:%02d: ", TextCursor );
str += String::ConvertSJIStoMAID(buf) + Text;
}
if( IsIMOpen() )
{
char buf[256];
sprintf( buf, "c:%02d: ", IMCursor );
str += String::ConvertSJIStoMAID(buf) + IMText;
}
{
const SIZE2DI size(BARSIZE_W,BARSIZE_H);
const POINT2DI off(0,0);
m_pRender->Fill( pos, COLOR_R32G32B32A32F(0,1,0,1), size, off );
}
m_pRender->BltText( pos, m_hFont, str, COLOR_R32G32B32A32F(1,1,1,1) );
}
| [
"[email protected]"
]
| [
[
[
1,
76
]
]
]
|
e9eb26f30403b725d47b6ef7735275e0bd69ca6c | 2d4221efb0beb3d28118d065261791d431f4518a | /OIDE源代码/OLIDE/Controls/scintilla/ScintillaDocView.h | 48265683fb9710390805c5d050479b976a129964 | []
| no_license | ophyos/olanguage | 3ea9304da44f54110297a5abe31b051a13330db3 | 38d89352e48c2e687fd9410ffc59636f2431f006 | refs/heads/master | 2021-01-10T05:54:10.604301 | 2010-03-23T11:38:51 | 2010-03-23T11:38:51 | 48,682,489 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,633 | h | /*
Module : ScintillaDocView.H
Purpose: Defines the interface for MFC CView and CDocument derived wrapper classes for the Scintilla
edit control (www.scintilla.org)
Created: PJN / 19-03-2004
Copyright (c) 2004 - 2008 by PJ Naughter (Web: www.naughter.com, Email: [email protected])
All rights reserved.
Copyright / Usage Details:
You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise)
when your product is released in binary form. You are allowed to modify the source code in any way you want
except you cannot modify the copyright details at the top of each module. If you want to distribute source
code with your application, then you are only allowed to distribute versions released by the author. This is
to maintain a single distribution point for the source code.
*/
//////////////////// Macros / Defines /////////////////////////////////////////
#pragma once
#ifndef __SCINTILLADOCVIEW_H__
#define __SCINTILLADOCVIEW_H__
//#include "ScintillaCtrl.h"
#include "SyntaxCtrl.h"
#ifndef __AFXTEMPL_H__
#pragma message("To avoid this message please put afxtempl.h into your pre compiled header (normally stdafx.h)")
#include <afxtempl.h>
#endif //__AFXTEMPL_H__
#ifndef SCINTILLADOCVIEW_EXT_CLASS
#define SCINTILLADOCVIEW_EXT_CLASS
#endif
//////////////////// Classes //////////////////////////////////////////////////
class SCINTILLADOCVIEW_EXT_CLASS CScintillaFindReplaceDlg : public CFindReplaceDialog
{
public:
//Constructors / Destructors
CScintillaFindReplaceDlg();
//Methods
BOOL Create(BOOL bFindDialogOnly, LPCTSTR lpszFindWhat, LPCTSTR lpszReplaceWith = NULL, DWORD dwFlags = FR_DOWN, CWnd* pParentWnd = NULL);
BOOL GetRegularExpression() const { return m_bRegularExpression; };
void SetRegularExpression(BOOL bRegularExpression) { m_bRegularExpression = bRegularExpression; };
protected:
virtual BOOL OnInitDialog();
afx_msg void OnRegularExpression();
//Member variables
BOOL m_bRegularExpression;
DECLARE_MESSAGE_MAP()
};
class SCINTILLADOCVIEW_EXT_CLASS CScintillaView : public CView
{
friend class CScintillaDoc;
public:
//Constructors / Destructors
CScintillaView();
//Methods
void AddText(char* pchText,long length);
void AddText(wchar_t* pchText,long length);
CSyntaxCtrl& GetCtrl();
void SetMargins(const CRect& rMargin) { m_rMargin = rMargin; };
CRect GetMargins() const { return m_rMargin; };
BOOL GetUseROFileAttributeDuringLoading() const { return m_bUseROFileAttributeDuringLoading; };
void SetUseROFileAttributeDuringLoading(BOOL bUseROFileAttributeDuringLoading) { m_bUseROFileAttributeDuringLoading = bUseROFileAttributeDuringLoading; };
CScintillaDoc* GetDocument() const;
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
//Printing support
virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo);
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo = NULL);
virtual BOOL PaginateTo(CDC* pDC, CPrintInfo* pInfo);
virtual long PrintPage(CDC* pDC, CPrintInfo* pInfo, long nIndexStart, long nIndexStop);
virtual void PrintHeader(CDC* pDC, CPrintInfo* pInfo, RangeToFormat& frPrint);
virtual void PrintFooter(CDC* pDC, CPrintInfo* pInfo, RangeToFormat& frPrint);
//Search and Replace support
virtual void OnFindNext(LPCTSTR lpszFind, BOOL bNext, BOOL bCase, BOOL bWord, BOOL bRegularExpression);
virtual void TextNotFound(LPCTSTR lpszFind, BOOL bNext, BOOL bCase, BOOL bWord, BOOL bRegularExpression, BOOL bReplaced);
virtual BOOL FindText(LPCTSTR lpszFind, BOOL bNext, BOOL bCase, BOOL bWord, BOOL bRegularExpression);
virtual void OnEditFindReplace(BOOL bFindOnly);
virtual BOOL FindTextSimple(LPCTSTR lpszFind, BOOL bNext, BOOL bCase, BOOL bWord, BOOL bRegularExpression);
virtual void OnReplaceSel(LPCTSTR lpszFind, BOOL bNext, BOOL bCase, BOOL bWord, BOOL bRegularExpression, LPCTSTR lpszReplace);
virtual void OnReplaceAll(LPCTSTR lpszFind, LPCTSTR lpszReplace, BOOL bCase, BOOL bWord, BOOL bRegularExpression);
virtual BOOL SameAsSelected(LPCTSTR lpszCompare, BOOL bCase, BOOL bWord, BOOL bRegularExpression);
virtual long FindAndSelect(DWORD dwFlags, TextToFind& ft);
virtual void AdjustFindDialogPosition();
virtual CScintillaFindReplaceDlg* CreateFindReplaceDialog();
//Misc methods
virtual void OnDraw(CDC*);
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
virtual void DeleteContents();
virtual void Serialize(CArchive& ar);
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
static BOOL UserWantsMetric();
virtual void LoadMarginSettings(const CString& sSection = _T("PageSetup"));
virtual void SaveMarginSettings(const CString& sSection = _T("PageSetup"));
//Notifications
virtual void OnStyleNeeded(SCNotification* pSCNotification);
virtual void OnCharAdded(SCNotification* pSCNotification);
virtual void OnSavePointReached(SCNotification* pSCNotification);
virtual void OnSavePointLeft(SCNotification* pSCNotification);
virtual void OnModifyAttemptRO(SCNotification* pSCNotification);
virtual void OnDoubleClick(SCNotification* pSCNotification);
virtual void OnUpdateUI(SCNotification* pSCNotification);
virtual void OnModified(SCNotification* pSCNotification);
virtual void OnMacroRecord(SCNotification* pSCNotification);
virtual void OnMarginClick(SCNotification* pSCNotification);
virtual void OnNeedShown(SCNotification* pSCNotification);
virtual void OnPainted(SCNotification* pSCNotification);
virtual void OnUserListSelection(SCNotification* pSCNotification);
virtual void OnDwellStart(SCNotification* pSCNotification);
virtual void OnDwellEnd(SCNotification* pSCNotification);
virtual void OnZoom(SCNotification* pSCNotification);
virtual void OnHotSpotClick(SCNotification* pSCNotification);
virtual void OnHotSpotDoubleClick(SCNotification* pSCNotification);
virtual void OnCallTipClick(SCNotification* pSCNotification);
virtual void OnAutoCSelection(SCNotification* pSCNotification);
virtual void OnChange();
virtual void OnSetFocus();
virtual void OnKillFocus();
//Member variables
CSyntaxCtrl m_Edit; //The scintilla control
CArray<int, int> m_aPageStart; //array of starting pages
CRect m_rMargin; //Margin for printing
BOOL m_bFirstSearch; //Is this the first search
BOOL m_bUseROFileAttributeDuringLoading; //Should we check the RO file attribute to see if the file should be opened in read only mode by scintilla
BOOL m_bPrintHeader; //Should Headers be printed?
BOOL m_bPrintFooter; //Should Footers be printed?
BOOL m_bUsingMetric; //TRUE if the margin is specified in Metric units, else FALSE implies imperial
BOOL m_bPersistMarginSettings; //Should we persist the margin settings for the Page Setup dialog
afx_msg void OnPaint();
afx_msg void OnUpdateNeedSel(CCmdUI* pCmdUI);
afx_msg void OnUpdateNeedPaste(CCmdUI* pCmdUI);
afx_msg void OnUpdateNeedText(CCmdUI* pCmdUI);
afx_msg void OnUpdateNeedFind(CCmdUI* pCmdUI);
afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);
afx_msg void OnUpdateNeedTextAndFollowingText(CCmdUI* pCmdUI);
afx_msg void OnEditCut();
afx_msg void OnEditCopy();
afx_msg void OnEditPaste();
afx_msg void OnEditClear();
afx_msg void OnEditUndo();
afx_msg void OnEditRedo();
afx_msg void OnEditSelectAll();
afx_msg void OnEditFind();
afx_msg void OnEditReplace();
afx_msg void OnEditRepeat();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnFilePageSetup();
afx_msg void OnDestroy();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg LRESULT OnFindReplaceCmd(WPARAM, LPARAM lParam);
DECLARE_MESSAGE_MAP()
DECLARE_DYNCREATE(CScintillaView)
};
enum DOCUMENT_TYPE
{
DT_NULL,
DT_ANSI,
DT_UTF8,
DT_UTF16,
DT_UNICODE,
};
class SCINTILLADOCVIEW_EXT_CLASS CScintillaDoc : public CDocument
{
protected: //create from serialization only
CScintillaDoc();
DECLARE_DYNAMIC(CScintillaDoc)
int m_nDocumentType;
//Attributes
public:
virtual CScintillaView* GetView() const;
int GetDocumentType(){return m_nDocumentType;}
void SetDocumentType(int nDocumentType){m_nDocumentType = nDocumentType;}
//Implementation
public:
virtual void DeleteContents();
virtual BOOL IsModified();
virtual void SetModifiedFlag(BOOL bModified = TRUE);
virtual void Serialize(CArchive& ar);
virtual BOOL DoSave(LPCTSTR pszPathName, BOOL bReplace);
virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
};
#ifndef _DEBUG
inline CScintillaDoc* CScintillaView::GetDocument() const
{ return reinterpret_cast<CScintillaDoc*>(m_pDocument); }
#endif
#endif //__SCINTILLADOCVIEW_H__
| [
"[email protected]"
]
| [
[
[
1,
239
]
]
]
|
8bc9ef4383e1452042314fdae39b4f221b666979 | 54cacc105d6bacdcfc37b10d57016bdd67067383 | /trunk/source/io/files/GeometryFile.tpp | d49c871e5921004fe096d3a883f616bdef13ee35 | []
| 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,200 | tpp | /***
* hesperus: GeometryFile.tpp
* Copyright Stuart Golodetz, 2009. All rights reserved.
***/
#include <fstream>
#include <source/io/util/IOUtil.h>
namespace hesp {
//#################### LOADING METHODS ####################
/**
Loads an array of polygons from the specified file.
@param filename The name of the file
@param polygons Used to return the polygons to the caller
*/
template <typename Poly>
void GeometryFile::load(const std::string& filename, std::vector<shared_ptr<Poly> >& polygons)
{
std::ifstream is(filename.c_str());
if(is.fail()) throw Exception("Could not open " + filename + " for reading");
IOUtil::read_uncounted_polygons(is, polygons);
}
//#################### SAVING METHODS ####################
/**
Saves an array of polygons to the specified file.
@param filename The name of the file
@param polygons The polygons
*/
template <typename Poly>
void GeometryFile::save(const std::string& filename, const std::vector<shared_ptr<Poly> >& polygons)
{
std::ofstream os(filename.c_str());
if(os.fail()) throw Exception("Could not open" + filename + " for writing");
IOUtil::write_polygons(os, polygons, false);
}
}
| [
"[email protected]"
]
| [
[
[
1,
42
]
]
]
|
b1eea3be974baba054410381365793d8dd75571e | fcf03ead74f6dc103ec3b07ffe3bce81c820660d | /Graphics/WS/Ordinal/Ordinal.h | 2e39aebabcc110573cfc1ce967cda1c658da6523 | []
| no_license | huellif/symbian-example | 72097c9aec6d45d555a79a30d576dddc04a65a16 | 56f6c5e67a3d37961408fc51188d46d49bddcfdc | refs/heads/master | 2016-09-06T12:49:32.021854 | 2010-10-14T06:31:20 | 2010-10-14T06:31:20 | 38,062,421 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,826 | h | // Ordinal.H
//
// Copyright (c) 2005 Symbian Softwares Ltd. All rights reserved.
//
#if !defined(__WSWNORD1_H__)
#define __WSWNORD1_H__
#include "Base.h"
//////////////////////////////////////////////////////////////////////////
// Derived window classes
//////////////////////////////////////////////////////////////////////////
// CNumberedWindow displays a number in its center and supports drag and drop
class CNumberedWindow : public CWindow
{
public:
CNumberedWindow(CWsClient* aClient, TInt aNum);
~CNumberedWindow();
void Draw(const TRect& aRect);
void HandlePointerEvent(TPointerEvent& aPointerEvent);
private:
TInt iNumber; // Number displayed in window
TPoint iOldPos; // Position is required for drag and drop
};
// CMainWindow is a plain window that just acts as a container for the
// other windows
class CMainWindow : public CWindow
{
public:
CMainWindow(CWsClient* aClient);
~CMainWindow();
void Draw(const TRect& aRect);
void HandlePointerEvent(TPointerEvent& aPointerEvent);
};
//////////////////////////////////////////////////////////////////////////
// Derived client class
//////////////////////////////////////////////////////////////////////////
class CExampleWsClient : public CWsClient
{
public:
static CExampleWsClient* NewL(const TRect& aRect);
private:
CExampleWsClient(const TRect& aRect);
void ConstructMainWindowL();
~CExampleWsClient();
void RunL();
void HandleKeyEventL(TKeyEvent& aKeyEvent);
private:
CMainWindow* iMainWindow;
CNumberedWindow* iWindow1;
CNumberedWindow* iWindow2;
CNumberedWindow* iWindow3;
CNumberedWindow* iWindow4;
CNumberedWindow* iWindow5;
const TRect& iRect;
};
#endif
| [
"liuxk99@bdc341c6-17c0-11de-ac9f-1d9250355bca"
]
| [
[
[
1,
63
]
]
]
|
1c2c7dbf180f5aa5c8cc347bb6b80d00403c56a2 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Scada/scOPCsrv/OPCSrvr/SrvCallback.h | c275b5c9a5c639b87bf42f9592ef2a6aca7f5f48 | []
| 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 | 8,028 | h | //**************************************************************************
//**************************************************************************
//
// Copyright (c) FactorySoft, INC. 1997, All Rights Reserved
//
//**************************************************************************
//
// Filename : Callback.h
// $Author : Jim Hansen
//
// Subsystem : Callback object for OPC Server DLL
//
// Description: This class interfaces to the application's data
//
//**************************************************************************
#if !defined(_SHELLCALLBACK_H_INCLUDED_)
#define _SHELLCALLBACK_H_INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef __SCDVER_H
#include "scdver.h"
#endif
#if WITHOPC
#include "OPCDa.h"
#include "scdopcsrv.h"
#include "afxpriv.h"
#ifndef __COMMSSRVRBASE_H
#include "CommsSrvrBase.h"
#endif
#ifndef __EXECUTIV_H
#include "executiv.h"
#endif
#include "tagbrowse.h"
//--------------------------------------------------------------------------
//#define FlatBranchStructure 1
#define FlatBranchStructure 0
class CScdOPCCallBack;
class Branch;
//*******************************************************************
// Override CTag to add a name
class CScdOPCTag : public CTag
{
public:
CScdOPCTag(CScdOPCCallBack * pCB, LPCTSTR name, Branch* branch);
virtual ~CScdOPCTag();
CScdOPCCallBack * m_pCallBack;
bool m_bChecked;
bool m_bIsValid;
CString m_name;
CString m_fullname;
Strng m_sTagOnly;
byte m_cType;
CCnvIndex m_CnvInx;
Strng m_sCnvTxt;
Strng_List m_StrLst;
COleVariant m_LclValue;
bool CheckTag();
void LoadLocal(CPkDataItem* pItem , FILETIME & FT);
};
typedef CTypedPtrList<CPtrList, CScdOPCTag*> TagList;
typedef CTypedPtrList<CPtrList, Branch*> BranchList;
//*******************************************************************
// Branch class to hold branches and leaves
class Branch
{
public:
Branch(LPCTSTR name);
virtual ~Branch();
void AddTag(CScdOPCTag* pTag);
void AddBranch( Branch* pBranch)
{ m_branches.AddTail(pBranch); pBranch->m_parent = this; };
CScdOPCTag* FindTag(const CString& target);
CString FindTagName(const CString& target);
CString GetPath();
CString m_name;
TagList m_tags;
BranchList m_branches;
Branch* m_parent;
};
//*******************************************************************
class CScdOPCTagArray : public CArray <CScdOPCTag*, CScdOPCTag*> {};
class CScdOPCCallBack : public COPCCallback, public CExecObj
{
friend class ShellBrowser;
friend class CScdOPCTag;
friend class CScdOPCManager;
friend class COPCSrvrStatsDlg;
public:
CScdOPCCallBack(/*CScd * Plc*/);
virtual ~CScdOPCCallBack();
// New 2.0 Item Properties
virtual HRESULT QueryNumProperties(
LPCTSTR name,
DWORD * pdwNumItems,
LPVOID * ppVoid);
virtual HRESULT QueryAvailableProperties(
LPCTSTR name,
DWORD dwNumItems,
LPVOID pVoid,
DWORD * pPropertyIDs,
LPWSTR * pDescriptions,
VARTYPE * pDataTypes);
virtual HRESULT GetItemProperties(
LPCTSTR name,
DWORD dwNumItems,
DWORD * pPropertyIDs,
VARIANT * pData,
HRESULT * pErrors);
virtual HRESULT LookupItemIDs(
LPCTSTR name,
DWORD dwNumItems,
DWORD * pPropertyIDs,
LPWSTR * pszNewItemIDs,
HRESULT * pErrors);
virtual OPCSERVERSTATE GetServerState();
virtual DWORD SetUpdateRate( DWORD newUpdateRate );
virtual COPCBrowser* CreateBrowser();
virtual CTag* AddTag( LPCTSTR name,
LPCTSTR accessPath,
VARTYPE requestedType);
virtual HRESULT ValidateTag(
CTag* pTag,
LPCTSTR name,
LPCTSTR accessPath,
VARTYPE requestedType);
virtual HRESULT Remove(
DWORD dwNumItems,
CTag ** ppTags);
virtual LPCTSTR GetTagName( CTag * pTag );
virtual BOOL GetTagLimits( CTag * pTag, double *pHigh, double *pLow );
virtual HRESULT Scan(
DWORD dwNumItems,
CTag ** ppTags,
HRESULT * pErrors);
/*
virtual HRESULT Read(
DWORD dwNumItems,
CTag ** ppTags,
HRESULT * pErrors);
*/
virtual HRESULT ReadTag(CTag * pTag);
/*
virtual HRESULT Write(
DWORD dwNumItems,
CTag ** ppTags,
VARIANT * pItemValues,
HRESULT * pErrors);
*/
virtual HRESULT WriteTag(
CTag * pTag,
VARIANT & value);
virtual LPCTSTR GetErrorString(
HRESULT dwError,
LCID dwLocale);
virtual LPCTSTR GetVendorString();
virtual void ConnectNotify(bool Connecting);
void BuildBrowserBranchRecursive( char* pBranchName , class Branch* pParentBranch , CTagTreeItem *pRoot);
void PopulateBrowserBranch( Branch* pBranch , CTagTreeItem *pRoot );
protected:
CString error;
//Branch m_root;
Branch m_SubscribedTagsRoot; // Top of subscribed tags branch structure (will be FLAT)
Branch m_BrowseTagsRoot; // Top of browse tags structure (will be hierachical)
bool bForceReadRqd;
long iTagCnt;
long iScanCnt;
long iScdWriteOKCnt;
long iClientWriteOKCnt;
long iWriteFailCnt;
long iScdReadOKCnt;
long iClientReadOKCnt;
long iReadFailCnt;
long iExecuteCnt;
DWORD dwLastScan;
DWORD dwMeasScanRate;
void StatsCntReset() { iScanCnt=0; iScdWriteOKCnt=0; iClientWriteOKCnt=0; iWriteFailCnt=0; iScdReadOKCnt=0; iClientReadOKCnt=0; iReadFailCnt=0; };
void BuildSubsList(CListBox* pList);
flag ForceWriteSubsDataAll();
CScdOPCTag * TryMakeTag(LPCTSTR Name, Branch * pBrnch);
CScdOPCTag * MakeTag(LPCTSTR Name, Branch * pBrnch);
void DumpBranchs();
void SetEnable(bool On);
CScdOPCTagArray m_TagA; // Not the owner of tags
protected:
// CExecObj Overrides
virtual flag EO_QueryTime(CXM_TimeControl &CB, CTimeValue &TimeRqd, CTimeValue &dTimeRqd);
virtual flag EO_Start(CXM_TimeControl &CB);
virtual void EO_QuerySubsReqd(CXMsgLst &XM);
virtual void EO_QuerySubsAvail(CXMsgLst &XM, CXMsgLst &XMRet);
virtual flag EO_ReadSubsData(CXMsgLst &XM);
virtual flag EO_WriteSubsData(CXMsgLst &XM, flag FirstBlock, flag LastBlock);
virtual flag EO_Execute(CXM_TimeControl &CB, CEOExecReturn &EORet);
virtual flag EO_Stop(CXM_TimeControl &CB);
virtual int EO_CanClose(Strng_List & Problems);
};
//*******************************************************************
class ShellBrowser : public COPCBrowser
{
public:
ShellBrowser(CScdOPCCallBack* parent);
//virtual ~ShellBrowser();
virtual OPCNAMESPACETYPE QueryOrganization();
virtual BOOL MoveUp();
virtual BOOL MoveDown(LPCTSTR branch);
virtual HRESULT GetNames( OPCBROWSETYPE type,
LPCTSTR stringFilter,
VARTYPE dataTypeFilter,
DWORD accessFilter );
virtual LPCTSTR GetItemID( LPCTSTR name );
virtual LPCTSTR Next();
virtual void Reset();
virtual HRESULT GetAccessPaths( LPCTSTR name );
virtual LPCTSTR NextAccessPath();
Branch* m_pBranch;
private:
CScdOPCCallBack* m_parent;
POSITION m_pos;
// For browsing flat
CStringList m_paths;
void AddTags( Branch* pBranch );
OPCBROWSETYPE m_type;
CString m_stringFilter;
VARTYPE m_dataTypeFilter;
DWORD m_accessFilter;
TCHAR m_name[256];
BOOL m_bDoStringFilter;
int m_iFilterLen;
};
#endif
#endif | [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
217
],
[
220,
223
],
[
226,
271
]
],
[
[
218,
219
],
[
224,
225
]
]
]
|
500ac2d4e5b94ee8999e594dcb19f273dafe8b05 | cfcd2a448c91b249ea61d0d0d747129900e9e97f | /thirdparty/OpenCOLLADA/COLLADAFramework/include/COLLADAFWMeshPrimitiveWithFaceVertexCount.h | be40c69c7535869df966ac78bd10f3dd6a65d9f3 | []
| no_license | fire-archive/OgreCollada | b1686b1b84b512ffee65baddb290503fb1ebac9c | 49114208f176eb695b525dca4f79fc0cfd40e9de | refs/heads/master | 2020-04-10T10:04:15.187350 | 2009-05-31T15:33:15 | 2009-05-31T15:33:15 | 268,046 | 0 | 0 | null | null | null | null | WINDOWS-1258 | C++ | false | false | 3,633 | h | /*
Copyright (c) 2008 NetAllied Systems GmbH
This file is part of COLLADAFramework.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/
#ifndef __COLLADAFW_MESHPRIMITIVEWITHFACEVERTEXCOUNT_H__
#define __COLLADAFW_MESHPRIMITIVEWITHFACEVERTEXCOUNT_H__
#include "COLLADAFWPrerequisites.h"
#include "COLLADAFWMeshPrimitive.h"
namespace COLLADAFW
{
/**
Geometric primitives, which assemble values from the inputs into vertex attribute data.
Can be any combination of any primitive types in any order.
To describe geometric primitives that are formed from the vertex data, the <mesh> element may
contain zero or more of the primitive elements <lines>, <linestrips>, <polygons>, <polylist>,
<triangles>, <trifans>, and <tristrips>.
The <vertices> element under <mesh> is used to describe mesh-vertices. Polygons, triangles, and
so forth index mesh-vertices, not positions directly. Mesh-vertices must have at least one
<input> (unshared) element with a semantic attribute whose value is POSITION.
For texture coordinates, COLLADA’s right-handed coordinate system applies; therefore, an ST
texture coordinate of [0,0] maps to the lower-left texel of a texture image, when loaded in a
professional 2-D texture viewer/editor.
*/
template<class VertexCountType>
class MeshPrimitiveWithFaceVertexCount : public MeshPrimitive
{
public:
typedef COLLADAFW::ArrayPrimitiveType<VertexCountType> VertexCountArray;
private:
/**
* Contains a list of integers, each specifying the number of vertices for one
* - polygon face
* - hole
* - tristrip or trifan
* element.
*/
VertexCountArray mGroupedVerticesVertexCountArray;
protected:
/**
* Constructor.
*/
MeshPrimitiveWithFaceVertexCount ( PrimitiveType primitiveType ) :
MeshPrimitive(primitiveType)
, mGroupedVerticesVertexCountArray(VertexCountArray::OWNER) {}
public:
/**
* Destructor.
*/
virtual ~MeshPrimitiveWithFaceVertexCount() {}
/**
* Contains a list of integers, each specifying the number of vertices for one polygon face.
*/
VertexCountArray& getGroupedVerticesVertexCountArray () { return mGroupedVerticesVertexCountArray; }
/**
* Contains a list of integers, each specifying the number of vertices for one polygon face.
*/
const VertexCountArray& getGroupedVerticesVertexCountArray () const { return mGroupedVerticesVertexCountArray; }
/**
* Contains a list of integers, each specifying the number of vertices for one polygon face.
*/
void setGroupedVerticesVertexCountArray ( const VertexCountArray& FaceVertexCountArray ) { mGroupedVerticesVertexCountArray = FaceVertexCountArray; }
/*
* Returns the vertex count of the face on the specified index position.
*/
const int getGroupedVerticesVertexCount ( const size_t faceIndex ) const
{
if ( faceIndex >= mGroupedVerticesVertexCountArray.getCount () )
{
std::cerr << "Face index out of range: " << faceIndex << std::endl;
assert ( "Face index out of range: " + faceIndex );
}
return mGroupedVerticesVertexCountArray [ faceIndex ];
}
};
}
#endif // __COLLADAFW_MESHPRIMITIVEWITHFACEVERTEXCOUNT_H__
| [
"[email protected]"
]
| [
[
[
1,
99
]
]
]
|
eff9331f408be22e157954c6ec3f87b4715f7613 | b7c505dcef43c0675fd89d428e45f3c2850b124f | /Src/SimulatorQt/Util/qt/Win32/include/Qt/qpair.h | f1e61c24041b4b2a9f2f991181f46152b18f83ff | [
"BSD-2-Clause"
]
| permissive | pranet/bhuman2009fork | 14e473bd6e5d30af9f1745311d689723bfc5cfdb | 82c1bd4485ae24043aa720a3aa7cb3e605b1a329 | refs/heads/master | 2021-01-15T17:55:37.058289 | 2010-02-28T13:52:56 | 2010-02-28T13:52:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,018 | h | /****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information ([email protected])
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at [email protected].
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QPAIR_H
#define QPAIR_H
#include <QtCore/qdatastream.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Core)
template <class T1, class T2>
struct QPair
{
typedef T1 first_type;
typedef T2 second_type;
QPair() : first(T1()), second(T2()) {}
QPair(const T1 &t1, const T2 &t2) : first(t1), second(t2) {}
QPair<T1, T2> &operator=(const QPair<T1, T2> &other)
{ first = other.first; second = other.second; return *this; }
T1 first;
T2 second;
};
template <class T1, class T2>
Q_INLINE_TEMPLATE bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
{ return p1.first == p2.first && p1.second == p2.second; }
template <class T1, class T2>
Q_INLINE_TEMPLATE bool operator!=(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
{ return !(p1 == p2); }
template <class T1, class T2>
Q_INLINE_TEMPLATE bool operator<(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
{
return p1.first < p2.first || (!(p2.first < p1.first) && p1.second < p2.second);
}
template <class T1, class T2>
Q_INLINE_TEMPLATE bool operator>(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
{
return p2 < p1;
}
template <class T1, class T2>
Q_INLINE_TEMPLATE bool operator<=(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
{
return !(p2 < p1);
}
template <class T1, class T2>
Q_INLINE_TEMPLATE bool operator>=(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
{
return !(p1 < p2);
}
template <class T1, class T2>
Q_OUTOFLINE_TEMPLATE QPair<T1, T2> qMakePair(const T1 &x, const T2 &y)
{
return QPair<T1, T2>(x, y);
}
#ifndef QT_NO_DATASTREAM
template <class T1, class T2>
inline QDataStream& operator>>(QDataStream& s, QPair<T1, T2>& p)
{
s >> p.first >> p.second;
return s;
}
template <class T1, class T2>
inline QDataStream& operator<<(QDataStream& s, const QPair<T1, T2>& p)
{
s << p.first << p.second;
return s;
}
#endif
QT_END_NAMESPACE
QT_END_HEADER
#endif // QPAIR_H
| [
"alon@rogue.(none)"
]
| [
[
[
1,
127
]
]
]
|
547194a47a18b1a30b61337969ea23dadd368928 | 073dfce42b384c9438734daa8ee2b575ff100cc9 | /RCF/include/RCF/RcfBoostThreads/RcfBoostThreads.hpp | 16c9880071ffca1aa6bfa5157256e3e756d97f47 | []
| no_license | r0ssar00/iTunesSpeechBridge | a489426bbe30ac9bf9c7ca09a0b1acd624c1d9bf | 71a27a52e66f90ade339b2b8a7572b53577e2aaf | refs/heads/master | 2020-12-24T17:45:17.838301 | 2009-08-24T22:04:48 | 2009-08-24T22:04:48 | 285,393 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,451 | hpp |
//******************************************************************************
// RCF - Remote Call Framework
// Copyright (c) 2005 - 2009, Jarl Lindrud. All rights reserved.
// Consult your license for conditions of use.
// Version: 1.1
// Contact: jarl.lindrud <at> gmail.com
//******************************************************************************
// RcfBoostThreads is a spin-off of version 1.33.1 of the Boost.Thread library,
// whose copyright notice follows.
// Copyright (C) 2001-2003
// William E. Kempf
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appear in all copies and
// that both that copyright notice and this permission notice appear
// in supporting documentation. William E. Kempf makes no representations
// about the suitability of this software for any purpose.
// It is provided "as is" without express or implied warranty.
#ifndef INCLUDE_RCF_RCFBOOSTTHREADS_RCFBOOSTTHREADS_HPP
#define INCLUDE_RCF_RCFBOOSTTHREADS_RCFBOOSTTHREADS_HPP
#define __STDC_CONSTANT_MACROS
#include <list>
#include <memory>
#include <string>
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/utility.hpp>
#include <boost/function.hpp>
#ifndef RCF_SINGLE_THREADED
#include <boost/config/requires_threads.hpp>
#endif
#include <RCF/Export.hpp>
#define RCF_BOOST_THREAD_DECL RCF_EXPORT
#if defined(BOOST_HAS_PTHREADS)
# include <pthread.h>
//# include <RCF/RcfBoostThreads/boost_1_33_1/boost/thread/condition.hpp>
#elif defined(BOOST_HAS_MPTASKS)
# include <Multiprocessing.h>
#endif
#if defined(BOOST_HAS_MPTASKS)
# include "scoped_critical_region.hpp"
#endif
namespace RCF {
namespace RcfBoostThreads {
#include <RCF/RcfBoostThreads/boost_1_33_1/boost/thread/thread.hpp>
#include <RCF/RcfBoostThreads/boost_1_33_1/boost/thread/tss.hpp>
#include <RCF/RcfBoostThreads/boost_1_33_1/boost/thread/mutex.hpp>
#include <RCF/RcfBoostThreads/boost_1_33_1/boost/thread/condition.hpp>
#include <RCF/RcfBoostThreads/boost_1_33_1/boost/thread/xtime.hpp>
#include <RCF/RcfBoostThreads/boost_1_33_1/boost/thread/once.hpp>
} // namespace RcfBoostThreads
} // namespace RCF
#undef RCF_BOOST_THREAD_DECL
#endif // ! INCLUDE_RCF_RCFBOOSTTHREADS_RCFBOOSTTHREADS_HPP
| [
"[email protected]"
]
| [
[
[
1,
73
]
]
]
|
78937439fd0ad0aa98f9da93776b497a3feffe77 | 2d4221efb0beb3d28118d065261791d431f4518a | /OIDE源代码/OLIDE/Controls/scintilla/scintilla/src/LexCPP.cxx | f90f5f488f194fa5700ed2caff464080e1ebb21c | [
"LicenseRef-scancode-scintilla"
]
| permissive | ophyos/olanguage | 3ea9304da44f54110297a5abe31b051a13330db3 | 38d89352e48c2e687fd9410ffc59636f2431f006 | refs/heads/master | 2021-01-10T05:54:10.604301 | 2010-03-23T11:38:51 | 2010-03-23T11:38:51 | 48,682,489 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,191 | cxx | // Scintilla source code edit control
/** @file LexCPP.cxx
** Lexer for C++, C, Java, and JavaScript.
**/
// Copyright 1998-2005 by Neil Hodgson <[email protected]>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "CharacterSet.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
static bool IsSpaceEquiv(int state) {
return (state <= SCE_C_COMMENTDOC) ||
// including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE
(state == SCE_C_COMMENTLINEDOC) || (state == SCE_C_COMMENTDOCKEYWORD) ||
(state == SCE_C_COMMENTDOCKEYWORDERROR);
}
// Preconditions: sc.currentPos points to a character after '+' or '-'.
// The test for pos reaching 0 should be redundant,
// and is in only for safety measures.
// Limitation: this code will give the incorrect answer for code like
// a = b+++/ptn/...
// Putting a space between the '++' post-inc operator and the '+' binary op
// fixes this, and is highly recommended for readability anyway.
static bool FollowsPostfixOperator(StyleContext &sc, Accessor &styler) {
int pos = (int) sc.currentPos;
while (--pos > 0) {
char ch = styler[pos];
if (ch == '+' || ch == '-') {
return styler[pos - 1] == ch;
}
}
return false;
}
static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler, bool caseSensitive) {
WordList &keywords = *keywordlists[0];
WordList &keywords2 = *keywordlists[1];
WordList &keywords3 = *keywordlists[2];
WordList &keywords4 = *keywordlists[3];
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-");
CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-");
CharacterSet setDoxygen(CharacterSet::setLower, "$@\\&<>#{}[]");
CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) {
setWordStart.Add('$');
setWord.Add('$');
}
int chPrevNonWhite = ' ';
int visibleChars = 0;
bool lastWordWasUUID = false;
int styleBeforeDCKeyword = SCE_C_DEFAULT;
bool continuationLine = false;
if (initStyle == SCE_C_PREPROCESSOR) {
// Set continuationLine if last character of previous line is '\'
int lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0) {
int chBack = styler.SafeGetCharAt(startPos-1, 0);
int chBack2 = styler.SafeGetCharAt(startPos-2, 0);
int lineEndChar = '!';
if (chBack2 == '\r' && chBack == '\n') {
lineEndChar = styler.SafeGetCharAt(startPos-3, 0);
} else if (chBack == '\n' || chBack == '\r') {
lineEndChar = chBack2;
}
continuationLine = lineEndChar == '\\';
}
}
// look back to set chPrevNonWhite properly for better regex colouring
if (startPos > 0) {
int back = startPos;
while (--back && IsSpaceEquiv(styler.StyleAt(back)))
;
if (styler.StyleAt(back) == SCE_C_OPERATOR) {
chPrevNonWhite = styler.SafeGetCharAt(back);
}
}
StyleContext sc(startPos, length, initStyle, styler);
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
if (sc.state == SCE_C_STRING) {
// Prevent SCE_C_STRINGEOL from leaking back to previous line which
// ends with a line continuation by locking in the state upto this position.
sc.SetState(SCE_C_STRING);
}
// Reset states to begining of colourise so no surprises
// if different sets of lines lexed.
visibleChars = 0;
lastWordWasUUID = false;
}
// Handle line continuation generically.
if (sc.ch == '\\') {
if (sc.chNext == '\n' || sc.chNext == '\r') {
sc.Forward();
if (sc.ch == '\r' && sc.chNext == '\n') {
sc.Forward();
}
continuationLine = true;
continue;
}
}
// Determine if the current state should terminate.
switch (sc.state) {
case SCE_C_OPERATOR:
sc.SetState(SCE_C_DEFAULT);
break;
case SCE_C_NUMBER:
// We accept almost anything because of hex. and number suffixes
if (!setWord.Contains(sc.ch)) {
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_IDENTIFIER:
if (!setWord.Contains(sc.ch) || (sc.ch == '.')) {
char s[1000];
if (caseSensitive) {
sc.GetCurrent(s, sizeof(s));
} else {
sc.GetCurrentLowered(s, sizeof(s));
}
if (keywords.InList(s)) {
lastWordWasUUID = strcmp(s, "uuid") == 0;
sc.ChangeState(SCE_C_WORD);
} else if (keywords2.InList(s)) {
sc.ChangeState(SCE_C_WORD2);
} else if (keywords4.InList(s)) {
sc.ChangeState(SCE_C_GLOBALCLASS);
}
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_PREPROCESSOR:
if (sc.atLineStart && !continuationLine) {
sc.SetState(SCE_C_DEFAULT);
} else if (stylingWithinPreprocessor) {
if (IsASpace(sc.ch)) {
sc.SetState(SCE_C_DEFAULT);
}
} else {
if (sc.Match('/', '*') || sc.Match('/', '/')) {
sc.SetState(SCE_C_DEFAULT);
}
}
break;
case SCE_C_COMMENT:
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
}
break;
case SCE_C_COMMENTDOC:
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
// Verify that we have the conditions to mark a comment-doc-keyword
if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) {
styleBeforeDCKeyword = SCE_C_COMMENTDOC;
sc.SetState(SCE_C_COMMENTDOCKEYWORD);
}
}
break;
case SCE_C_COMMENTLINE:
if (sc.atLineStart) {
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_COMMENTLINEDOC:
if (sc.atLineStart) {
sc.SetState(SCE_C_DEFAULT);
} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
// Verify that we have the conditions to mark a comment-doc-keyword
if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) {
styleBeforeDCKeyword = SCE_C_COMMENTLINEDOC;
sc.SetState(SCE_C_COMMENTDOCKEYWORD);
}
}
break;
case SCE_C_COMMENTDOCKEYWORD:
if ((styleBeforeDCKeyword == SCE_C_COMMENTDOC) && sc.Match('*', '/')) {
sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
} else if (!setDoxygen.Contains(sc.ch)) {
char s[100];
if (caseSensitive) {
sc.GetCurrent(s, sizeof(s));
} else {
sc.GetCurrentLowered(s, sizeof(s));
}
if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) {
sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
}
sc.SetState(styleBeforeDCKeyword);
}
break;
case SCE_C_STRING:
if (sc.atLineEnd) {
sc.ChangeState(SCE_C_STRINGEOL);
} else if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}
} else if (sc.ch == '\"') {
sc.ForwardSetState(SCE_C_DEFAULT);
}
break;
case SCE_C_CHARACTER:
if (sc.atLineEnd) {
sc.ChangeState(SCE_C_STRINGEOL);
} else if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}
} else if (sc.ch == '\'') {
sc.ForwardSetState(SCE_C_DEFAULT);
}
break;
case SCE_C_REGEX:
if (sc.atLineStart) {
sc.SetState(SCE_C_DEFAULT);
} else if (sc.ch == '/') {
sc.Forward();
while ((sc.ch < 0x80) && islower(sc.ch))
sc.Forward(); // gobble regex flags
sc.SetState(SCE_C_DEFAULT);
} else if (sc.ch == '\\') {
// Gobble up the quoted character
if (sc.chNext == '\\' || sc.chNext == '/') {
sc.Forward();
}
}
break;
case SCE_C_STRINGEOL:
if (sc.atLineStart) {
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_VERBATIM:
if (sc.ch == '\"') {
if (sc.chNext == '\"') {
sc.Forward();
} else {
sc.ForwardSetState(SCE_C_DEFAULT);
}
}
break;
case SCE_C_UUID:
if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') {
sc.SetState(SCE_C_DEFAULT);
}
}
// Determine if a new state should be entered.
if (sc.state == SCE_C_DEFAULT) {
if (sc.Match('@', '\"')) {
sc.SetState(SCE_C_VERBATIM);
sc.Forward();
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
if (lastWordWasUUID) {
sc.SetState(SCE_C_UUID);
lastWordWasUUID = false;
} else {
sc.SetState(SCE_C_NUMBER);
}
} else if (setWordStart.Contains(sc.ch) || (sc.ch == '@')) {
if (lastWordWasUUID) {
sc.SetState(SCE_C_UUID);
lastWordWasUUID = false;
} else {
sc.SetState(SCE_C_IDENTIFIER);
}
} else if (sc.Match('/', '*')) {
if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style
sc.SetState(SCE_C_COMMENTDOC);
} else {
sc.SetState(SCE_C_COMMENT);
}
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.Match('/', '/')) {
if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!"))
// Support of Qt/Doxygen doc. style
sc.SetState(SCE_C_COMMENTLINEDOC);
else
sc.SetState(SCE_C_COMMENTLINE);
} else if (sc.ch == '/' && setOKBeforeRE.Contains(chPrevNonWhite) &&
(!setCouldBePostOp.Contains(chPrevNonWhite) || !FollowsPostfixOperator(sc, styler))) {
sc.SetState(SCE_C_REGEX); // JavaScript's RegEx
} else if (sc.ch == '\"') {
sc.SetState(SCE_C_STRING);
} else if (sc.ch == '\'') {
sc.SetState(SCE_C_CHARACTER);
} else if (sc.ch == '#' && visibleChars == 0) {
// Preprocessor commands are alone on their line
sc.SetState(SCE_C_PREPROCESSOR);
// Skip whitespace between # and preprocessor word
do {
sc.Forward();
} while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
if (sc.atLineEnd) {
sc.SetState(SCE_C_DEFAULT);
}
} else if (isoperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_C_OPERATOR);
}
}
if (!IsASpace(sc.ch) && !IsSpaceEquiv(sc.state)) {
chPrevNonWhite = sc.ch;
visibleChars++;
}
continuationLine = false;
}
sc.Complete();
}
static bool IsStreamCommentStyle(int style) {
return style == SCE_C_COMMENT ||
style == SCE_C_COMMENTDOC ||
style == SCE_C_COMMENTDOCKEYWORD ||
style == SCE_C_COMMENTDOCKEYWORDERROR;
}
// Store both the current line's fold level and the next lines in the
// level store to make it easy to pick up with each increment
// and to make it possible to fiddle the current level for "} else {".
static void FoldCppDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
unsigned int endPos = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
int levelMinCurrent = levelCurrent;
int levelNext = levelCurrent;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
for (unsigned int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && IsStreamCommentStyle(style)) {
if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_C_COMMENTLINEDOC)) {
levelNext++;
} else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_C_COMMENTLINEDOC) && !atEOL) {
// Comments don't end at end of line and the next character may be unstyled.
levelNext--;
}
}
if (foldComment && (style == SCE_C_COMMENTLINE)) {
if ((ch == '/') && (chNext == '/')) {
char chNext2 = styler.SafeGetCharAt(i + 2);
if (chNext2 == '{') {
levelNext++;
} else if (chNext2 == '}') {
levelNext--;
}
}
}
if (foldPreprocessor && (style == SCE_C_PREPROCESSOR)) {
if (ch == '#') {
unsigned int j = i + 1;
while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
j++;
}
if (styler.Match(j, "region") || styler.Match(j, "if")) {
levelNext++;
} else if (styler.Match(j, "end")) {
levelNext--;
}
}
}
if (style == SCE_C_OPERATOR) {
if (ch == '{') {
// Measure the minimum before a '{' to allow
// folding on "} else {"
if (levelMinCurrent > levelNext) {
levelMinCurrent = levelNext;
}
levelNext++;
} else if (ch == '}') {
levelNext--;
}
}
if (!IsASpace(ch))
visibleChars++;
if (atEOL || (i == endPos-1)) {
int levelUse = levelCurrent;
if (foldAtElse) {
levelUse = levelMinCurrent;
}
int lev = levelUse | levelNext << 16;
if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
if (levelUse < levelNext)
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
levelCurrent = levelNext;
levelMinCurrent = levelCurrent;
visibleChars = 0;
}
}
}
static const char * const cppWordLists[] = {
"Primary keywords and identifiers",
"Secondary keywords and identifiers",
"Documentation comment keywords",
"Unused",
"Global classes and typedefs",
0,
};
static void ColouriseCppDocSensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
ColouriseCppDoc(startPos, length, initStyle, keywordlists, styler, true);
}
static void ColouriseCppDocInsensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
ColouriseCppDoc(startPos, length, initStyle, keywordlists, styler, false);
}
LexerModule lmCPP(SCLEX_CPP, ColouriseCppDocSensitive, "cpp", FoldCppDoc, cppWordLists);
LexerModule lmCPPNoCase(SCLEX_CPPNOCASE, ColouriseCppDocInsensitive, "cppnocase", FoldCppDoc, cppWordLists);
| [
"[email protected]"
]
| [
[
[
1,
470
]
]
]
|
5405e3b547974b0bbc65a3d6aebfb17473b527a8 | 38926bfe477f933a307f51376dd3c356e7893ffc | /Source/GameDLL/PlayerMovement.cpp | fddd2cb5431b0272617beeca3bab63d1d9cedbfb | []
| no_license | richmondx/dead6 | b0e9dd94a0ebb297c0c6e9c4f24c6482ef4d5161 | 955f76f35d94ed5f991871407f3d3ad83f06a530 | refs/heads/master | 2021-12-05T14:32:01.782047 | 2008-01-01T13:13:39 | 2008-01-01T13:13:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 60,710 | cpp | #include "StdAfx.h"
#include "PlayerMovement.h"
#include "GameUtils.h"
#include "Game.h"
#include "GameCVars.h"
#include "PlayerInput.h"
#include "GameActions.h"
#include "NetInputChainDebug.h"
#undef CALL_PLAYER_EVENT_LISTENERS
#define CALL_PLAYER_EVENT_LISTENERS(func) \
{ \
if (m_player.m_playerEventListeners.empty() == false) \
{ \
CPlayer::TPlayerEventListeners::const_iterator iter = m_player.m_playerEventListeners.begin(); \
CPlayer::TPlayerEventListeners::const_iterator cur; \
while (iter != m_player.m_playerEventListeners.end()) \
{ \
cur = iter; \
++iter; \
(*cur)->func; \
} \
} \
}
#define LADDER_TOP_DISTANCE 2.41f
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
CPlayerMovement::CPlayerMovement(CPlayer& player, const SActorFrameMovementParams& movement, float m_frameTime ) :
m_frameTime(m_frameTime),
m_params(player.m_params),
m_stats(player.m_stats),
m_viewQuat(player.m_viewQuat),
m_baseQuat(player.m_baseQuat),
m_movement(movement),
m_player(player),
m_velocity(player.m_velocity),
m_upVector(player.m_upVector),
m_detachLadder(false),
m_onGroundWBoots(player.m_stats.onGroundWBoots),
m_jumped(player.m_stats.jumped),
m_actions(player.m_actions),
m_turnTarget(player.m_turnTarget),
m_thrusters(player.m_stats.thrusters),
m_zgDashTimer(player.m_stats.zgDashTimer),
m_zgDashWorldDir(player.m_stats.zgDashWorldDir),
m_hasJumped(false),
m_swimJumping(player.m_stats.swimJumping),
m_waveRandomMult(1.0f),
m_stickySurfaceTimer(player.m_stickySurfaceTimer)
{
// derive some values that will be useful later
m_worldPos = player.GetEntity()->GetWorldPos();
m_waveTimer = Random()*gf_PI;
}
void CPlayerMovement::Process(CPlayer& player)
{
//FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);
if (m_stats.spectatorMode || m_stats.flyMode)
ProcessFlyMode();
else if (m_stats.isOnLadder)
ProcessMovementOnLadder(player);
else if (/*m_stats.inAir &&*/ m_stats.inZeroG)
ProcessFlyingZeroG();
else if (m_stats.inFreefall.Value()==1)
{
m_request.type = eCMT_Normal;
m_request.velocity.zero();
}
else if (m_stats.inFreefall.Value()==2)
ProcessParachute();
else if (player.ShouldSwim())
ProcessSwimming();
else
ProcessOnGroundOrJumping(player);
// if (!m_player.GetLinkedEntity() && !m_player.GetEntity()->GetParent()) // Leipzig hotfix, these can get out of sync
if (player.m_linkStats.CanRotate())
ProcessTurning();
}
void CPlayerMovement::Commit( CPlayer& player )
{
if (player.m_pAnimatedCharacter)
{
m_request.allowStrafe = m_movement.allowStrafe;
m_request.prediction = m_movement.prediction;
NETINPUT_TRACE(m_player.GetEntityId(), m_request.rotation * FORWARD_DIRECTION);
NETINPUT_TRACE(m_player.GetEntityId(), m_request.velocity);
m_request.jumping = m_stats.jumped;
m_player.DebugGraph_AddValue("ReqVelo", m_request.velocity.GetLength());
m_player.DebugGraph_AddValue("ReqVeloX", m_request.velocity.x);
m_player.DebugGraph_AddValue("ReqVeloY", m_request.velocity.y);
m_player.DebugGraph_AddValue("ReqVeloZ", m_request.velocity.z);
m_player.DebugGraph_AddValue("ReqRotZ", RAD2DEG(m_request.rotation.GetRotZ()));
player.m_pAnimatedCharacter->AddMovement( m_request );
}
if (m_detachLadder)
player.CreateScriptEvent("detachLadder",0);
/*
if (m_thrusters > .1f && m_stats.onGroundWBoots>-0.01f)
player.CreateScriptEvent("thrusters",(m_actions & ACTION_SPRINT)?1:0);
/**/
if (m_hasJumped)
player.CreateScriptEvent("jumped",0);
NETINPUT_TRACE(m_player.GetEntityId(), m_velocity);
NETINPUT_TRACE(m_player.GetEntityId(), m_jumped);
// Reset ground timer to prevent ground time before the jump to be inherited
// and incorrectly/prematurely used to identify landing in mid air in MP.
if (m_jumped && !player.m_stats.jumped)
player.m_stats.onGround = 0.0f;
player.m_velocity = m_velocity;
player.m_stats.jumped = m_jumped;
player.m_stats.onGroundWBoots = m_onGroundWBoots;
player.m_turnTarget = m_turnTarget;
player.m_lastRequestedVelocity = m_request.velocity;
player.m_stats.thrusters = m_thrusters;
player.m_stats.zgDashTimer = m_zgDashTimer;
player.m_stats.zgDashWorldDir = m_zgDashWorldDir;
player.m_stats.swimJumping = m_swimJumping;
player.m_stickySurfaceTimer = m_stickySurfaceTimer;
if(!player.m_stats.bIgnoreSprinting)
player.m_stats.bSprinting = ((m_stats.onGround>0.1f || (m_stats.inWaterTimer > 0.0f)) && m_stats.inMovement>0.1f && m_actions & ACTION_SPRINT);
if(player.m_stats.isOnLadder)
player.m_stats.bSprinting = ((m_actions&ACTION_SPRINT) && (m_movement.desiredVelocity.len2()>0.0f));
}
//-----------------------------------------------------------------------------------------------
// utility functions
//-----------------------------------------------------------------------------------------------
static Vec3 ProjectPointToLine(const Vec3 &point,const Vec3 &lineStart,const Vec3 &lineEnd)
{
Lineseg seg(lineStart, lineEnd);
float t;
Distance::Point_Lineseg( point, seg, t );
return seg.GetPoint(t);
}
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
void CPlayerMovement::ProcessFlyMode()
{
Vec3 move = m_viewQuat * m_movement.desiredVelocity;
float zMove(0.0f);
if (m_actions & ACTION_JUMP)
zMove += 1.0f;
if (m_actions & ACTION_CROUCH)
zMove -= 1.0f;
move += m_viewQuat.GetColumn2() * zMove;
//cap the movement vector to max 1
float moveModule(move.len());
if (moveModule > 1.0f)
move /= moveModule;
move *= m_params.speedMultiplier*m_player.GetZoomSpeedMultiplier(); // respect speed multiplier as well
move *= 30.0f;
if (m_actions & ACTION_SPRINT)
move *= 10.0f;
m_request.type = eCMT_Fly;
m_request.velocity = move;
}
//-----------------------------------------------------------------------------------------------
void CPlayerMovement::ProcessFlyingZeroG()
{
bool debug = false;
Vec3 entityPos = m_player.GetEntity()->GetWorldPos();
Vec3 vRight(m_baseQuat.GetColumn0());
Vec3 vFwd(m_baseQuat.GetColumn1());
bool trail = (g_pGameCVars->pl_zeroGParticleTrail != 0);
if (trail)
m_player.SpawnParticleEffect("alien_special.human_thruster_zerog.human", entityPos, vFwd);
IPhysicalEntity* pPhysEnt = m_player.GetEntity()->GetPhysics();
if (pPhysEnt != NULL)
{
pe_status_dynamics sd;
if (pPhysEnt->GetStatus(&sd) != 0)
m_velocity = sd.v;
pe_player_dynamics pd;
pd.kAirControl = 1.0f;
pd.kAirResistance = 0.0f;
pd.gravity.zero();
pPhysEnt->SetParams(&pd);
}
//--------------------
float dashSpeedBoost = 40.0f;
float dashDuration = 0.4f;
float dashRechargeDuration = 0.5f;
float dashEnergyConsumption = g_pGameCVars->pl_zeroGDashEnergyConsumption * NANOSUIT_ENERGY;
Vec3 acceleration(ZERO);
// Apply desired movement
Vec3 desiredLocalNormalizedVelocity(ZERO);
Vec3 desiredLocalVelocity(ZERO);
Vec3 desiredWorldVelocity(ZERO);
// Calculate desired acceleration (user input)
{
CNanoSuit* pSuit = m_player.GetNanoSuit();
desiredLocalNormalizedVelocity.x = m_movement.desiredVelocity.x;
desiredLocalNormalizedVelocity.y = m_movement.desiredVelocity.y;
if ((m_actions & ACTION_JUMP))
desiredLocalNormalizedVelocity.z += 1.0f;
else if (m_actions & ACTION_CROUCH)
desiredLocalNormalizedVelocity.z -= 1.0f;
desiredLocalNormalizedVelocity.NormalizeSafe(ZERO);
float backwardMultiplier = (m_movement.desiredVelocity.y < 0.0f) ? m_params.backwardMultiplier : 1.0f;
desiredLocalNormalizedVelocity.x *= m_params.strafeMultiplier;
desiredLocalNormalizedVelocity.y *= backwardMultiplier;
desiredLocalNormalizedVelocity.z *= g_pGameCVars->pl_zeroGUpDown;
float maxSpeed = g_pGameCVars->pl_zeroGBaseSpeed;
if ((pSuit != NULL) && (pSuit->GetMode() == NANOMODE_SPEED))
{
if ((m_actions & ACTION_SPRINT) && (m_actions & ACTION_MOVE) &&
(pSuit->GetSuitEnergy() > NANOSUIT_ENERGY * 0.01f))
{
maxSpeed *= g_pGameCVars->pl_zeroGSpeedMultSpeedSprint;
float energy = pSuit->GetSuitEnergy();
energy -= g_pGameCVars->pl_zeroGSpeedModeEnergyConsumption * NANOSUIT_ENERGY * m_frameTime;
pSuit->SetSuitEnergy(energy);
}
else
{
maxSpeed *= g_pGameCVars->pl_zeroGSpeedMultSpeed;
}
}
else
{
if (m_actions & ACTION_SPRINT)
{
maxSpeed *= g_pGameCVars->pl_zeroGSpeedMultNormalSprint;
}
else
{
maxSpeed *= g_pGameCVars->pl_zeroGSpeedMultNormal;
}
}
if (debug)
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.4f), 1.5f, "MoveN[%1.3f, %1.3f, %1.3f]", desiredLocalNormalizedVelocity.x, desiredLocalNormalizedVelocity.y, desiredLocalNormalizedVelocity.z);
/*
if (debug)
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.8f), 1.5f, "SprintMul %1.2f", sprintMultiplier);
*/
/*
float stanceMaxSpeed = m_player.GetStanceMaxSpeed(STANCE_ZEROG);
if (debug)
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.6f), 1.5f, "StanceMax %1.3f", stanceMaxSpeed);
*/
if (debug)
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.6f), 1.5f, "StanceMax %1.3f", maxSpeed);
desiredLocalVelocity.x = desiredLocalNormalizedVelocity.x * maxSpeed;
desiredLocalVelocity.y = desiredLocalNormalizedVelocity.y * maxSpeed;
desiredLocalVelocity.z = desiredLocalNormalizedVelocity.z * maxSpeed;
// The desired movement is applied in viewspace, not in entityspace, since entity does not nessecarily pitch while swimming.
desiredWorldVelocity += m_viewQuat.GetColumn0() * desiredLocalVelocity.x;
desiredWorldVelocity += m_viewQuat.GetColumn1() * desiredLocalVelocity.y;
desiredWorldVelocity += m_viewQuat.GetColumn2() * desiredLocalVelocity.z;
if (debug)
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.2f), 1.5f, "Move[%1.3f, %1.3f, %1.3f]", desiredWorldVelocity.x, desiredWorldVelocity.y, desiredWorldVelocity.z);
float desiredAlignment = m_velocity.GetNormalizedSafe(ZERO) * desiredWorldVelocity.GetNormalizedSafe(ZERO);
int sound = 0;
float thrusters = desiredWorldVelocity.GetLength();
if ((thrusters > 0.0f) && (m_thrusters == 0.0f))
sound = 1;
if ((m_thrusters > 0.0f) && (thrusters == 0.0f))
sound = -1;
m_thrusters = thrusters;
{
float energy = (pSuit != NULL) ? pSuit->GetSuitEnergy() : 0.0f;
if ((m_zgDashTimer <= 0.0f) && m_zgDashWorldDir.IsZero() &&
(m_actions & ACTION_SPRINT) && /*!desiredWorldVelocity.IsZero() && */
(fabs(desiredLocalNormalizedVelocity.x) > 0.9f))
{
if (energy >= dashEnergyConsumption)
{
m_zgDashTimer = 0.0f;
m_zgDashWorldDir = desiredWorldVelocity.GetNormalized();
m_player.PlaySound(CPlayer::ESound_ThrustersDash, true);
//m_player.PlaySound(CPlayer::ESound_ThrustersDash02, true);
if (pSuit != NULL)
{
energy -= dashEnergyConsumption;
pSuit->SetSuitEnergy(energy, true);
}
}
else
{
if (m_zgDashTimer == 0.0f)
{
m_zgDashTimer -= 0.3f;
m_player.PlaySound(CPlayer::ESound_ThrustersDashFail, true);
}
else
{
m_zgDashTimer += m_frameTime;
if (m_zgDashTimer > 0.0f)
m_zgDashTimer = 0.0f;
}
}
}
if (m_zgDashTimer >= dashDuration)
{
if (!m_zgDashWorldDir.IsZero())
{
m_zgDashWorldDir.zero();
//m_player.PlaySound(CPlayer::ESound_ThrustersDash, false);
m_player.PlaySound(CPlayer::ESound_ThrustersDashRecharged, true);
//m_player.PlaySound(CPlayer::ESound_ThrustersDashRecharged02, true);
}
if ((m_zgDashTimer >= (dashDuration + dashRechargeDuration)) &&
(!(m_actions & ACTION_SPRINT) || /*desiredWorldVelocity.IsZero()*/
(fabs(desiredLocalNormalizedVelocity.x) < 0.7f)))
{
m_zgDashTimer = 0.0f;
}
}
if (!m_zgDashWorldDir.IsZero() || (m_zgDashTimer > dashDuration))
{
float dashTimeFraction = sqr(1.0f - CLAMP(m_zgDashTimer / dashDuration, 0.0f, 1.0f));
acceleration += dashSpeedBoost * dashTimeFraction * m_zgDashWorldDir;
m_zgDashTimer += m_frameTime;
}
if (!m_zgDashWorldDir.IsZero())
desiredWorldVelocity *= 0.5f;
}
acceleration += desiredWorldVelocity;
if ((pSuit != NULL) && (sound != 0))
{
if (sound > 0)
m_player.PlaySound(CPlayer::ESound_Thrusters, true);
else
m_player.PlaySound(CPlayer::ESound_Thrusters, false);
}
}
Vec3 gravityStream;
pe_params_buoyancy buoyancy;
if (gEnv->pPhysicalWorld->CheckAreas(entityPos, gravityStream, &buoyancy))
acceleration += gravityStream;
//--------------------
// Apply velocity dampening (framerate independent)
Vec3 damping(ZERO);
{
damping.x = abs(m_velocity.x);
damping.y = abs(m_velocity.y);
damping.z = abs(m_velocity.z);
//*
if (!m_zgDashWorldDir.IsZero())
{
float dashFraction = CLAMP(m_zgDashTimer / dashDuration, 0.0f, 1.0f);
damping *= 1.0f + 1.0f * CLAMP((dashFraction - 0.5f) / 0.5f, 0.0f, 1.0f);
}
/**/
float stopDelay = g_pGameCVars->pl_zeroGFloatDuration;
if (!desiredWorldVelocity.IsZero())
stopDelay = g_pGameCVars->pl_zeroGThrusterResponsiveness;
else if (!m_zgDashWorldDir.IsZero())
stopDelay = g_pGameCVars->pl_zeroGFloatDuration * 0.5f;
damping *= (m_frameTime / stopDelay);
m_velocity.x = (abs(m_velocity.x) > damping.x) ? (m_velocity.x - sgn(m_velocity.x) * damping.x) : 0.0f;
m_velocity.y = (abs(m_velocity.y) > damping.y) ? (m_velocity.y - sgn(m_velocity.y) * damping.y) : 0.0f;
m_velocity.z = (abs(m_velocity.z) > damping.z) ? (m_velocity.z - sgn(m_velocity.z) * damping.z) : 0.0f;
}
// Apply acceleration (framerate independent)
float accelerateDelay = g_pGameCVars->pl_zeroGThrusterResponsiveness;
m_velocity += acceleration * (m_frameTime / accelerateDelay);
//--------------------
// Set request type and velocity
m_request.type = eCMT_Fly;
m_request.velocity = m_velocity;
// DEBUG VELOCITY
if (debug)
{
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f - Vec3(0,0,0.0f), 1.5f, "Velo[%1.3f, %1.3f, %1.3f] (%1.3f)", m_velocity.x, m_velocity.y, m_velocity.z, m_velocity.len());
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f - Vec3(0,0,0.2f), 1.5f, " Axx[%1.3f, %1.3f, %1.3f]", acceleration.x, acceleration.y, acceleration.z);
//gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f - Vec3(0,0,0.4f), 1.5f, "Damp[%1.3f, %1.3f, %1.3f]", damping.x, damping.y, damping.z);
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f - Vec3(0,0,0.6f), 1.5f, "FrameTime %1.4f", m_frameTime);
}
/*
m_player.DebugGraph_AddValue("Velo", m_velocity.len());
m_player.DebugGraph_AddValue("VeloX", m_velocity.x);
m_player.DebugGraph_AddValue("VeloY", m_velocity.y);
m_player.DebugGraph_AddValue("VeloZ", m_velocity.z);
/**/
/*
m_player.DebugGraph_AddValue("Axx", acceleration.len());
m_player.DebugGraph_AddValue("AxxX", acceleration.x);
m_player.DebugGraph_AddValue("AxxY", acceleration.y);
m_player.DebugGraph_AddValue("AxxZ", acceleration.z);
/**/
//m_player.DebugGraph_AddValue("ZGDashTimer", m_zgDashTimer);
// CryLogAlways("speed: %.2f", m_velocity.len());
}
//-----------------------------------------------------------------------------------------------
/*
void CPlayerMovement::ProcessFlyingZeroGOLD()
{
CNanoSuit* pSuit = m_player.GetNanoSuit();
assert(pSuit);
//movement
Vec3 move(0,0,0);//usually 0, except AIs
Vec3 desiredVelocity(m_movement.desiredVelocity);
if((m_actions & ACTION_MOVE) && (desiredVelocity.len() > 1.0f))
desiredVelocity.Normalize();
if((m_actions & ACTION_SPRINT) && (m_player.GetNanoSuit()->GetMode() == NANOMODE_SPEED))
{
move = m_viewQuat.GetColumn1() * desiredVelocity.len();
if(m_actions & ACTION_ZEROGBACK)
move *= -1.0f;
}
else
{
if (m_actions & ACTION_JUMP)
desiredVelocity.z += g_pGameCVars->v_zeroGUpDown;
if (m_actions & ACTION_CROUCH)
desiredVelocity.z -= g_pGameCVars->v_zeroGUpDown;
move += m_baseQuat.GetColumn0() * desiredVelocity.x;
move += m_baseQuat.GetColumn1() * desiredVelocity.y;
move += m_baseQuat.GetColumn2() * desiredVelocity.z;
}
//cap the movement vector to max 1
float moveModule(move.len());
if (moveModule > 1.0f)
{
move /= moveModule;
}
//afterburner
if (m_actions & ACTION_SPRINT)
{
float mult(1.0f);
if (m_thrusterSprint>0.001f)
mult += (m_params.afterburnerMultiplier) * m_thrusterSprint;
if (move.len2()>0.01f)
m_thrusterSprint = max(0.0f,m_thrusterSprint - m_frameTime * 5.0f);
if(pSuit->GetMode() == NANOMODE_SPEED && m_actions & ACTION_MOVE)
{
if(pSuit->GetSuitEnergy() >= NANOSUIT_ENERGY * 0.2f)
{
mult *= 3.0f;
pSuit->SetSuitEnergy(pSuit->GetSuitEnergy()-100.0f*g_pGameCVars->v_zeroGSpeedModeEnergyConsumption*m_frameTime);
}
else if(pSuit->GetSuitEnergy() < NANOSUIT_ENERGY * 0.2f)
{
mult *= 0.8f;
pSuit->SetSuitEnergy(pSuit->GetSuitEnergy()-25.0f*g_pGameCVars->v_zeroGSpeedModeEnergyConsumption*m_frameTime);
}
}
move *= mult;
}
AdjustMovementForEnvironment( move, (m_actions&ACTION_SPRINT)!=0 );
m_thrusters = moveModule;
float inertiaMul(1.0f);
if (move.len2()>0.1)
{
inertiaMul = min(1.0f,max(0.0f,1.0f - move * m_stats.velocityUnconstrained));
inertiaMul = 1.0f + inertiaMul * 2.0f;
//if(CNanoSuit *pSuit = m_player.GetNanoSuit())
// inertiaMul *= 1.0f+pSuit->GetSlotValue(NANOSLOT_SPEED)*0.01f;
}
move *= m_params.thrusterImpulse * m_frameTime;
float stabilize = m_params.thrusterStabilizeImpulse;
bool autoStabilize = false;
if(m_player.GetStabilize())
{
stabilize = 2.0f;
if(pSuit->GetMode() == NANOMODE_SPEED)
stabilize = 3.0f;
else if(pSuit->GetMode() == NANOMODE_STRENGTH)
stabilize = 5.0f;
}
else if(float len = m_stats.gravity.len()) //we are probably in some gravity stream
{
stabilize = len * 0.2f;
autoStabilize = true;
}
//this is important for the player's gravity stream movement
move += (m_stats.gravity*0.81f - m_stats.velocityUnconstrained) * min(1.0f,m_frameTime*stabilize*inertiaMul);
if (stabilize > 1.0f && !autoStabilize)
{
float velLen = m_velocity.len();
if(velLen > 0.5f) //play sound when the stabilize is actually used
{
pSuit->SetSuitEnergy(pSuit->GetSuitEnergy()-stabilize*10.0f*m_frameTime);
pSuit->PlaySound(ESound_ZeroGThruster, std::min(1.0f, 1.0f-(velLen * stabilize * 0.02f)));
}
else
{
pSuit->PlaySound(ESound_ZeroGThruster, 1.0f, true);
}
}
if (m_player.GravityBootsOn() && desiredVelocity.z<0.1f)
{
IPhysicalEntity *pSkip = m_player.GetEntity()->GetPhysics();
ray_hit hit;
Vec3 ppos(m_player.GetEntity()->GetWorldPos());
int rayFlags = (COLLISION_RAY_PIERCABILITY & rwi_pierceability_mask);
float rayLen(10.0f);
if (gEnv->pPhysicalWorld->RayWorldIntersection(ppos, m_baseQuat.GetColumn2() * -rayLen, ent_terrain|ent_static|ent_rigid, rayFlags, &hit, 1, &pSkip, 1) && m_player.IsMaterialBootable(hit.surface_idx))
{
Vec3 delta(hit.pt - ppos);
float len = delta.len();
float lenMult(min(1.0f,len/rayLen));
lenMult = 1.0f - lenMult*lenMult;
delta /= max(0.001f,len);
move += delta * (10.0f * lenMult * m_frameTime);
m_gBootsSpotNormal = hit.n;
}
else
m_gBootsSpotNormal.Set(0,0,0);
}
//
//FIXME:pretty hacky, needed when passing from zeroG to normalG
m_velocity = m_stats.velocityUnconstrained;
m_velocity = m_velocity * m_baseQuat.GetInverted();
m_velocity.z = 0;
m_velocity = m_velocity * m_baseQuat;
// Design tweak values for movement speed
if((m_actions & ACTION_MOVE) || (m_actions & ACTION_JUMP) || (m_actions & ACTION_CROUCH))
{
if(m_actions & ACTION_SPRINT && pSuit->GetSuitEnergy() > NANOSUIT_ENERGY * 0.01f)
{
if(m_player.GetNanoSuit()->GetMode() == NANOMODE_SPEED)
move *= g_pGameCVars->v_zeroGSpeedMultSpeedSprint;
else
move *= g_pGameCVars->v_zeroGSpeedMultNormalSprint;
}
else
{
if(m_player.GetNanoSuit()->GetMode() == NANOMODE_SPEED)
move *= g_pGameCVars->v_zeroGSpeedMultSpeed;
else
move *= g_pGameCVars->v_zeroGSpeedMultNormal;
}
}
m_request.type = eCMT_Impulse;
m_request.velocity = move * m_stats.mass;
if (pSuit && pSuit->GetMode() == NANOMODE_SPEED)
{
if(m_request.velocity.len() > g_pGameCVars->v_zeroGSpeedMaxSpeed)
if((m_actions & ACTION_MOVE) || (m_actions & ACTION_JUMP) || (m_actions & ACTION_CROUCH))
m_request.velocity.SetLength(g_pGameCVars->v_zeroGSpeedMaxSpeed);
}
else
{
if(m_request.velocity.len() > g_pGameCVars->v_zeroGMaxSpeed)
if((m_actions & ACTION_MOVE) || (m_actions & ACTION_JUMP) || (m_actions & ACTION_CROUCH))
m_request.velocity.SetLength(g_pGameCVars->v_zeroGMaxSpeed);
}
}
*/
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
void CPlayerMovement::ProcessSwimming()
{
bool debug = (g_pGameCVars->cl_debugSwimming != 0);
Vec3 entityPos = m_player.GetEntity()->GetWorldPos();
Vec3 vRight(m_baseQuat.GetColumn0());
// Don't enable sticky surface directly when entering water.
if (m_stats.inWaterTimer < 0.5f)
{
m_stickySurfaceTimer = 0.0f;
}
CNanoSuit* pSuit = m_player.GetNanoSuit();
IPhysicalEntity* pPhysEnt = m_player.GetEntity()->GetPhysics();
if (pPhysEnt != NULL) // entity might have been shattered on be unphysicalized
{
pe_status_dynamics sd;
if (pPhysEnt->GetStatus(&sd) != 0)
m_velocity = sd.v;
pe_player_dynamics pd;
pd.kAirControl = 1.0f;
pd.kAirResistance = 0.0f;
pPhysEnt->SetParams(&pd);
}
{
// Apply water flow velocity to the player
Vec3 gravity;
pe_params_buoyancy buoyancy;
if (gEnv->pPhysicalWorld->CheckAreas(entityPos, gravity, &buoyancy))
m_velocity += buoyancy.waterFlow*m_frameTime;
}
Vec3 acceleration(ZERO);
//--------------------
// Apply gravity when above the surface.
if (m_swimJumping || (m_stats.relativeWaterLevel > 0.2f))
{
float gravityScaling = 0.5f;
if (!m_stats.gravity.IsZero())
acceleration += m_stats.gravity * gravityScaling;
else
acceleration.z += -9.8f * gravityScaling;
}
//--------------------
if ((m_velocity.z < -0.5f) && (m_stats.relativeWaterLevel < -0.2f))
{
m_swimJumping = false;
}
// Apply jump impulse when below but close to the surface (if in water for long enough).
if (!m_swimJumping && (m_actions & ACTION_JUMP) && (m_velocity.z >= -0.2f) && (m_stats.relativeWaterLevel > -0.1f) && (m_stats.relativeWaterLevel < 0.1f))
{
float jumpMul = 1.0f;
if (pSuit != NULL)
{
float jumpEnergyCost = 0.0f;
float jumpBaseMul = 1.0f;
float jumpSprintMul = 1.0f;
if (pSuit->GetMode() == NANOMODE_STRENGTH)
{
jumpEnergyCost = 50.0f; // g_pGameCVars->pl_swimJumpStrengthCost
jumpSprintMul = 2.5; // g_pGameCVars->pl_swimJumpStrengthSprintMul
jumpBaseMul = 1.0; // g_pGameCVars->pl_swimJumpStrengthBaseMul
}
else if (pSuit->GetMode() == NANOMODE_SPEED)
{
jumpEnergyCost = 50.0f; // g_pGameCVars->pl_swimJumpStrengthCost
jumpSprintMul = 2.5; // g_pGameCVars->pl_swimJumpStrengthSprintMul
jumpBaseMul = 1.0; // g_pGameCVars->pl_swimJumpStrengthBaseMul
}
if ((m_actions & ACTION_SPRINT) && (pSuit->GetSuitEnergy() >= jumpEnergyCost))
{
pSuit->SetSuitEnergy(pSuit->GetSuitEnergy() - jumpEnergyCost);
jumpMul = jumpSprintMul;
}
else
{
jumpMul = jumpBaseMul;
}
}
m_velocity.z = max(m_velocity.z, 6.0f + 2.0f * jumpMul);
m_swimJumping = true;
}
if ((m_velocity.z > 5.0f) && (m_stats.relativeWaterLevel > 0.2f))
{
m_swimJumping = true;
}
//--------------------
/*
// Apply automatic float up towards surface when not in conflict with desired movement (if in water for long enough).
if ((m_velocity.z > -0.1f) && (m_velocity.z < 0.2f) && (m_stats.relativeWaterLevel < -0.1f) && (m_stats.inWaterTimer > 0.5f))
acceleration.z += (1.0f - sqr(1.0f - CLAMP(-m_stats.relativeWaterLevel, 0.0f, 1.0f))) * 0.08f;
*/
//--------------------
// Apply desired movement
Vec3 desiredLocalNormalizedVelocity(ZERO);
Vec3 desiredLocalVelocity(ZERO);
Vec3 desiredWorldVelocity(ZERO);
// Less control when jumping or otherwise above surface
// (where bottom ray miss geometry that still keeps the collider up).
float userControlFraction = m_swimJumping ? 0.1f : 1.0f;
// Calculate desired acceleration (user input)
{
// Apply up/down control when well below surface (if in water for long enough).
if ((m_stats.inWaterTimer > 0.5f) && !m_swimJumping)
{
if (m_actions & ACTION_JUMP)
desiredLocalNormalizedVelocity.z += 1.0f;
else if (m_actions & ACTION_CROUCH)
desiredLocalNormalizedVelocity.z -= 1.0f;
}
float backwardMultiplier = (m_movement.desiredVelocity.y < 0.0f) ? g_pGameCVars->pl_swimBackSpeedMul : 1.0f;
desiredLocalNormalizedVelocity.x = m_movement.desiredVelocity.x * g_pGameCVars->pl_swimSideSpeedMul;
desiredLocalNormalizedVelocity.y = m_movement.desiredVelocity.y * backwardMultiplier;
// AI can set a custom sprint value, so don't cap the movement vector
float sprintMultiplier = 1.0f;
if ((m_actions & ACTION_SPRINT) && (m_stats.relativeWaterLevel < 0.2f))
{
sprintMultiplier = g_pGameCVars->pl_swimNormalSprintSpeedMul;
if ((pSuit != NULL) && (pSuit->GetMode() == NANOMODE_SPEED) && (pSuit->GetSprintMultiplier(false) > 1.0f))
sprintMultiplier = g_pGameCVars->pl_swimSpeedSprintSpeedMul;
// Higher speed multiplier when sprinting while looking up, to get higher dolphin jumps.
float upFraction = CLAMP(m_viewQuat.GetFwdZ(), 0.0f, 1.0f);
sprintMultiplier *= LERP(1.0f, g_pGameCVars->pl_swimUpSprintSpeedMul, upFraction);
}
if (debug)
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,1.0f), 1.5f, "SprintMul %1.2f", sprintMultiplier);
//float baseSpeed = m_player.GetStanceMaxSpeed(STANCE_SWIM);
float baseSpeed = g_pGameCVars->pl_swimBaseSpeed;
if (debug)
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.8f), 1.5f, "BaseSpeed %1.3f", baseSpeed);
desiredLocalVelocity.x = desiredLocalNormalizedVelocity.x * sprintMultiplier * baseSpeed;
desiredLocalVelocity.y = desiredLocalNormalizedVelocity.y * sprintMultiplier * baseSpeed;
desiredLocalVelocity.z = desiredLocalNormalizedVelocity.z * g_pGameCVars->pl_swimVertSpeedMul * baseSpeed;
// The desired movement is applied in viewspace, not in entityspace, since entity does not necessarily pitch while swimming.
desiredWorldVelocity += m_viewQuat.GetColumn0() * desiredLocalVelocity.x;
desiredWorldVelocity += m_viewQuat.GetColumn1() * desiredLocalVelocity.y;
// though, apply up/down in world space.
desiredWorldVelocity.z += desiredLocalVelocity.z;
if (debug)
{
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.6f), 1.5f, "MoveN[%1.3f, %1.3f, %1.3f]", desiredLocalNormalizedVelocity.x, desiredLocalNormalizedVelocity.y, desiredLocalNormalizedVelocity.z);
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.5f), 1.5f, "VeloL[%1.3f, %1.3f, %1.3f]", desiredLocalVelocity.x, desiredLocalVelocity.y, desiredLocalVelocity.z);
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.4f), 1.5f, "VeloW[%1.3f, %1.3f, %1.3f]", desiredWorldVelocity.x, desiredWorldVelocity.y, desiredWorldVelocity.z);
}
/*
//if ((m_stats.waterLevel > 0.2f) && (desiredWorldVelocity.z > 0.0f)) // WIP: related to jumping out of water
if ((m_stats.relativeWaterLevel > -0.1f) && (desiredWorldVelocity.z > 0.0f))
desiredWorldVelocity.z = 0.0f;
*/
if (debug)
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f + Vec3(0,0,0.2f), 1.5f, "Move[%1.3f, %1.3f, %1.3f]", desiredWorldVelocity.x, desiredWorldVelocity.y, desiredWorldVelocity.z);
acceleration += desiredWorldVelocity * userControlFraction;
}
//--------------------
float stickySurfaceRadius = 1.0f;
float surfaceDistanceFraction = CLAMP(abs(m_stats.relativeWaterLevel) / stickySurfaceRadius, 0.0f, 1.0f);
float surfaceProximityInfluence = 1.0f - surfaceDistanceFraction;
float verticalVelocityFraction = CLAMP((abs(desiredWorldVelocity.z) - 0.3f) / 0.4f, 0.0f, 1.0f);
surfaceProximityInfluence *= 1.0f - verticalVelocityFraction;
if (m_swimJumping)
surfaceProximityInfluence = 0.0f;
//--------------------
// Apply acceleration (framerate independent)
float accelerateDelay = 0.3f;
m_velocity += acceleration * (m_frameTime / accelerateDelay);
// Apply velocity dampening (framerate independent)
Vec3 damping(ZERO);
{
if (!m_swimJumping)
{
damping.x = abs(m_velocity.x);
damping.y = abs(m_velocity.y);
}
// Vertical damping is special, to allow jumping out of water with higher speed,
// and also not sink too deep when falling down ito the water after jump or such.
float zDamp = 1.0f;
zDamp += 6.0f * CLAMP((-m_velocity.z - 1.0f) / 3.0f, 0.0f, 1.0f);
zDamp *= 1.0f - surfaceProximityInfluence;
if (m_swimJumping)
zDamp = 0.0f;
damping.z = abs(m_velocity.z) * zDamp;
float stopDelay = 0.3f;
damping *= (m_frameTime / stopDelay);
m_velocity.x = (abs(m_velocity.x) > damping.x) ? (m_velocity.x - sgn(m_velocity.x) * damping.x) : 0.0f;
m_velocity.y = (abs(m_velocity.y) > damping.y) ? (m_velocity.y - sgn(m_velocity.y) * damping.y) : 0.0f;
m_velocity.z = (abs(m_velocity.z) > damping.z) ? (m_velocity.z - sgn(m_velocity.z) * damping.z) : 0.0f;
}
//--------------------
if (surfaceProximityInfluence > 0.0f)
{
m_stickySurfaceTimer += m_frameTime * surfaceProximityInfluence;
float stickyFraction = CLAMP(m_stickySurfaceTimer / 1.0f, 0.0f, 1.0f);
float desiredVeloZ = m_frameTime > 0.0f ? (m_stats.worldWaterLevelDelta / m_frameTime * surfaceProximityInfluence) : 0.0f;
m_velocity.z = LERP(m_velocity.z, desiredVeloZ, stickyFraction);
m_velocity.z += stickyFraction * 1.0f * -sgn(m_stats.relativeWaterLevel) * pow(surfaceDistanceFraction, 1.0f);
}
else
{
m_stickySurfaceTimer = 0.0f;
}
//--------------------
// Set request type and velocity
m_request.type = eCMT_Fly;
m_request.velocity = m_velocity;
// DEBUG VELOCITY
if (debug)
{
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f - Vec3(0,0,0.0f), 1.5f, "Velo[%1.3f, %1.3f, %1.3f]", m_velocity.x, m_velocity.y, m_velocity.z);
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f - Vec3(0,0,0.2f), 1.5f, " Axx[%1.3f, %1.3f, %1.3f]", acceleration.x, acceleration.y, acceleration.z);
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f - Vec3(0,0,0.4f), 1.5f, "Damp[%1.3f, %1.3f, %1.3f]", damping.x, damping.y, damping.z);
gEnv->pRenderer->DrawLabel(entityPos - vRight * 1.5f - Vec3(0,0,0.6f), 1.5f, "FrameTime %1.4f", m_frameTime);
if (m_swimJumping)
gEnv->pRenderer->DrawLabel(entityPos - vRight * 0.15f + Vec3(0,0,0.6f), 2.0f, "JUMP");
}
if (m_player.m_pAnimatedCharacter != NULL)
{
IAnimationGraphState* pAnimGraphState = m_player.m_pAnimatedCharacter->GetAnimationGraphState();
if (pAnimGraphState != NULL)
{
IAnimationGraph::InputID inputSwimControlX = pAnimGraphState->GetInputId("SwimControlX");
IAnimationGraph::InputID inputSwimControlY = pAnimGraphState->GetInputId("SwimControlY");
IAnimationGraph::InputID inputSwimControlZ = pAnimGraphState->GetInputId("SwimControlZ");
pAnimGraphState->SetInput(inputSwimControlX, desiredLocalVelocity.x);
pAnimGraphState->SetInput(inputSwimControlY, desiredLocalVelocity.y);
pAnimGraphState->SetInput(inputSwimControlZ, desiredWorldVelocity.z);
}
}
return;
}
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
void CPlayerMovement::ProcessParachute()
{
//Vec3 desiredVelocity(m_stats.velocity);
float desiredZ(-1.5f + ((m_actions & ACTION_JUMP)?3.0f:0.0f));
//desiredVelocity.z += (desiredZ - desiredVelocity.z)*min(1.0f,m_frameTime*1.5f);
m_request.type = eCMT_Impulse;//eCMT_Fly;
m_request.velocity = (Vec3(0,0,desiredZ)-m_stats.velocity) * m_stats.mass/* * m_frameTime*/;//desiredVelocity;
Vec3 forwardComp(m_baseQuat.GetColumn1() * 10.0f);
forwardComp.z = 0.0f;
m_request.velocity += forwardComp * m_stats.mass;// * m_frameTime;//desiredVelocity;
}
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
void CPlayerMovement::ProcessOnGroundOrJumping(CPlayer& player)
{
//process movement
Vec3 move(0,0,0);
CNanoSuit *pSuit = m_player.GetNanoSuit();
/*
m_player.DebugGraph_AddValue("InputMoveX", m_movement.desiredVelocity.x);
m_player.DebugGraph_AddValue("InputMoveY", m_movement.desiredVelocity.y);
/**/
IPhysicalEntity* pPhysEnt = m_player.GetEntity()->GetPhysics();
if (pPhysEnt != NULL)
{
pe_player_dynamics pd;
pd.kAirControl = m_player.GetAirControl();
pd.kAirResistance = m_player.GetAirResistance();
pPhysEnt->SetParams(&pd);
}
if (m_movement.desiredVelocity.x || m_movement.desiredVelocity.y)
{
Vec3 desiredVelocityClamped = m_movement.desiredVelocity;
float desiredVelocityMag = desiredVelocityClamped.GetLength();
if (desiredVelocityMag > 1.0f)
desiredVelocityClamped /= desiredVelocityMag;
float strafeMul = m_params.strafeMultiplier;
float backwardMul = 1.0f;
//going back?
if (m_player.IsPlayer()) //[Mikko] Do not limit backwards movement when controlling AI.
{
if (desiredVelocityClamped.y < 0.0f)
backwardMul = LERP(backwardMul, m_params.backwardMultiplier, -desiredVelocityClamped.y);
}
NETINPUT_TRACE(m_player.GetEntityId(), backwardMul);
NETINPUT_TRACE(m_player.GetEntityId(), strafeMul);
move += m_baseQuat.GetColumn0() * desiredVelocityClamped.x * strafeMul * backwardMul;
move += m_baseQuat.GetColumn1() * desiredVelocityClamped.y * backwardMul;
}
float sprintMult = 1.0f;
//ai can set a custom sprint value, so dont cap the movement vector
if (m_movement.sprint<=0.0f)
{
//cap the movement vector to max 1
float moveModule(move.len());
//[Mikko] Do not limit backwards movement when controlling AI, otherwise it will disable sprinting.
if (m_player.IsPlayer())
{ //^^[Stas] Added this hack, other clients are not AIs
if ( moveModule > 1.0f)
move /= moveModule;
}
NETINPUT_TRACE(m_player.GetEntityId(), moveModule);
//move *= m_animParams.runSpeed/GetStanceMaxSpeed(m_stance);
bool speedMode = false;
if(pSuit)
{
sprintMult = pSuit->GetSprintMultiplier(cry_fabsf(m_movement.desiredVelocity.x)>0.01f);
speedMode = (pSuit->GetMode() == NANOMODE_SPEED)?true:false;
}
NETINPUT_TRACE(m_player.GetEntityId(), sprintMult);
if (gEnv->bMultiplayer)
{
if ((m_actions & ACTION_SPRINT) && !m_player.m_stats.bIgnoreSprinting)
move *= m_params.sprintMultiplier * sprintMult ;
}
else
{
if (m_actions & ACTION_SPRINT && (!speedMode || sprintMult > 1.0f) && !m_player.m_stats.bIgnoreSprinting)// && m_player.GetStance() == STANCE_STAND)
move *= m_params.sprintMultiplier * sprintMult ;
}
}
//player movement dont need the m_frameTime, its handled already in the physics
float scale = m_player.GetStanceMaxSpeed(m_player.GetStance());
if (m_player.IsClient() && !gEnv->bMultiplayer)
move *= scale*0.75f;
else
move *= scale;
NETINPUT_TRACE(m_player.GetEntityId(), scale);
//when using gravity boots speed can be slowed down
if (m_player.GravityBootsOn())
move *= m_params.gravityBootsMultipler;
// Danny todo: This is a temporary workaround (but generally better than nothing I think)
// to stop the AI movement from getting changed beyond recognition under normal circumstances.
// If the movement request gets modified then it invalidates the prediciton made by AI, and thus
// the choice of animation/parameters.
//-> please adjust the prediction
if (m_player.IsPlayer())
AdjustMovementForEnvironment( move, (m_actions&ACTION_SPRINT)!=0 );
//adjust prone movement for slopes
if (m_player.GetStance()==STANCE_PRONE && move.len2()>0.01f)
{
float slopeRatio(1.0f - m_stats.groundNormal.z*m_stats.groundNormal.z);
slopeRatio *= slopeRatio;
Vec3 terrainTangent((Vec3(0,0,1)%m_stats.groundNormal)%m_stats.groundNormal);
if(slopeRatio > 0.5f && move.z > 0.0f) //emergence stop when going up extreme walls
{
if(slopeRatio > 0.7f)
move *= 0.0f;
else
move *= ((0.7f - slopeRatio) * 5.0f);
}
else
{
move *= 1.0f - min(1.0f,m_params.slopeSlowdown * slopeRatio * max(0.0f,-(terrainTangent * move.GetNormalizedSafe(ZERO))));
//
move += terrainTangent * slopeRatio * m_player.GetStanceMaxSpeed(m_player.GetStance());
}
}
//only the Z component of the basematrix, handy with flat speeds,jump and gravity
Matrix33 baseMtxZ(Matrix33(m_baseQuat) * Matrix33::CreateScale(Vec3(0,0,1)));
m_request.type = eCMT_Normal;
Vec3 jumpVec(0,0,0);
//jump?
//FIXME: I think in zeroG should be possible to jump to detach from the ground, for now its like this since its the easiest fix
bool allowJump = !m_jumped || m_movement.strengthJump;
bool dt_jumpCondition = m_movement.strengthJump;
if (g_pGameCVars->dt_enable)
{
if (pSuit && pSuit->GetMode() == NANOMODE_STRENGTH && pSuit->PendingAction() == eNA_Jump && m_stats.inAir < 0.25)
{
dt_jumpCondition = true;
allowJump = true;
pSuit->ConsumeAction();
}
}
bool isRemoteClient=!gEnv->bServer && !m_player.IsClient();
/*
// TODO: Graph has broken, appearantly, so we can't use this atm.
// Also, there's already a delay between jumps.
const char* AGAllowJump = player.GetAnimationGraphState()->QueryOutput("AllowJump");
if (strcmp(AGAllowJump, "1") != 0)
allowJump = false;
*/
bool debugJumping = (g_pGameCVars->pl_debug_jumping != 0);
if (m_movement.jump && allowJump)
{
if ((m_stats.onGround > 0.2f || dt_jumpCondition) && m_player.GetStance() != STANCE_PRONE)
{
//float verticalMult(max(0.75f,1.0f-min(1.0f,m_stats.flatSpeed / GetStanceMaxSpeed(STANCE_STAND) * m_params.sprintMultiplier)));
//mul * gravity * jump height
float mult = 1.0f;
//this is used to easily find steep ground
float slopeDelta = (m_stats.inZeroG)? 0.0f : (m_stats.upVector - m_stats.groundNormal).len();
if (pSuit && (pSuit->GetSuitEnergy()>=70.0f || isRemoteClient))
{
ENanoMode mode = pSuit->GetMode();
if(m_stats.inZeroG)
{
if(mode == NANOMODE_SPEED)
jumpVec += m_viewQuat.GetColumn1() * 15.0f * m_stats.mass;
else if(mode == NANOMODE_STRENGTH)
jumpVec += m_viewQuat.GetColumn1() * 25.0f * m_stats.mass;
else
jumpVec += m_viewQuat.GetColumn1() * 10.0f * m_stats.mass;
}
else if(mode == NANOMODE_STRENGTH)
{
// marcok: always perform strength jump
mult = 4.7f;
}
}
/*
if(m_stats.inZeroG)
m_request.type = eCMT_Impulse;//eCMT_JumpAccumulate;
else
*/
{
m_request.type = eCMT_JumpAccumulate;//eCMT_Fly;
float g = m_stats.gravity.len();
float t = 0.0f;
if (g > 0.0f)
{
t = cry_sqrtf( 2.0f * g * m_params.jumpHeight * mult)/g - m_stats.inAir*0.5f;
}
jumpVec += m_baseQuat.GetColumn2() * g * t;// * verticalMult;
if (m_stats.groundNormal.len2() > 0.0f)
{
float vertical = CLAMP((m_stats.groundNormal.z - 0.25f) / 0.5f, 0.0f, 1.0f);
Vec3 modifiedJumpDirection = LERP(m_stats.groundNormal, Vec3(0,0,1), vertical);
jumpVec = modifiedJumpDirection * jumpVec.len();
}
}
// Don't speed up...
//move = m_stats.velocityUnconstrained * 1.0f;
move -= move * baseMtxZ;
//with gravity boots on, jumping will disable them for a bit.
if (m_onGroundWBoots && m_player.GravityBootsOn())
{
m_onGroundWBoots = -0.5f;
jumpVec += m_baseQuat.GetColumn2() * cry_sqrtf( 2.0f * 9.81f * m_params.jumpHeight );
}
else
m_jumped = true;
// Set ag action 'jumpMP' cleared in CPlayer::UpdateStats()
player.GetAnimationGraphState()->SetInput(player.GetAnimationGraphState()->GetInputId("Action"),
((pSuit->GetMode() == NANOMODE_STRENGTH) && !m_player.m_stats.bIgnoreSprinting && (mult > 1.0f)) ?
"jumpMPStrength" : "jumpMP");
bool bNormalJump = true;
CPlayer* pPlayer = const_cast<CPlayer*>(&m_player);
CNanoSuit *pSuit = m_player.GetNanoSuit();
if(pSuit && pSuit->GetMode() == NANOMODE_STRENGTH)
{
if (pSuit->GetSuitEnergy() >= 70.0f)
{
if(m_stats.inZeroG)
pSuit->SetSuitEnergy(pSuit->GetSuitEnergy()-10.0f);
else
{
if (g_pGameCVars->dt_enable)
{
// cancel a potential double jump
pSuit->Tap(eNA_None);
}
pSuit->SetSuitEnergy(pSuit->GetSuitEnergy()-70.0f);
pSuit->PlaySound(STRENGTH_JUMP_SOUND, (pSuit->GetSlotValue(NANOSLOT_STRENGTH))*0.01f);
// Report super jump to AI system.
if (m_player.GetEntity() && m_player.GetEntity()->GetAI())
m_player.GetEntity()->GetAI()->Event(AIEVENT_PLAYER_STUNT_JUMP, 0);
CALL_PLAYER_EVENT_LISTENERS(OnSpecialMove(pPlayer, IPlayerEventListener::eSM_StrengthJump));
// mark as 'un-normal' jump, so normal sound is NOT played and listeners are NOT called below
bNormalJump = false;
}
}
}
if(pSuit && pSuit->GetMode() == NANOMODE_SPEED)
{
if((m_actions & ACTION_SPRINT) && !m_player.m_stats.bIgnoreSprinting /*&& m_stats.speedFlat > 0.5f*//* && slopeDelta < 0.7f*/)
{
pSuit->SetSuitEnergy(pSuit->GetSuitEnergy()-10.0f);
}
}
if (bNormalJump)
{
pPlayer->PlaySound(CPlayer::ESound_Jump);
CALL_PLAYER_EVENT_LISTENERS(OnSpecialMove(pPlayer, IPlayerEventListener::eSM_Jump));
}
if (m_jumped)
m_hasJumped = true;
if (m_player.IsClient())
m_player.GetGameObject()->InvokeRMI(CPlayer::SvRequestJump(), CPlayer::JumpParams(!bNormalJump), eRMI_ToServer);
}
}
if(m_player.IsClient() && !gEnv->bMultiplayer)
move *= g_pGameCVars->g_walkMultiplier; //global speed adjuster used by level design
//CryLogAlways("%s speed: %.1f stanceMaxSpeed: %.1f sprintMult: %.1f suitSprintMult: %.1f", m_player.GetEntity()->GetName(), move.len(), scale, m_params.sprintMultiplier, sprintMult);
//apply movement
Vec3 desiredVel(0,0,0);
Vec3 entityPos = m_player.GetEntity()->GetWorldPos();
Vec3 entityRight(m_baseQuat.GetColumn0());
if (m_stats.onGround || dt_jumpCondition)
{
desiredVel = move;
/*
// This was causing the vertical jumping speed to be much slower.
if (m_stats.jumpLock>0.001f)
desiredVel *= 0.3f;
/**/
{ // Shallow water speed slowdown
float shallowWaterMultiplier = 1.0f;
if (player.IsPlayer())
shallowWaterMultiplier = g_pGameCVars->cl_shallowWaterSpeedMulPlayer;
else
shallowWaterMultiplier = g_pGameCVars->cl_shallowWaterSpeedMulAI;
shallowWaterMultiplier = CLAMP(shallowWaterMultiplier, 0.1f, 1.0f);
if ((shallowWaterMultiplier < 1.0f) && (m_stats.relativeBottomDepth > 0.0f))
{
float shallowWaterDepthSpan = (g_pGameCVars->cl_shallowWaterDepthHi - g_pGameCVars->cl_shallowWaterDepthLo);
shallowWaterDepthSpan = max(0.1f, shallowWaterDepthSpan);
float slowdownFraction = (m_stats.relativeBottomDepth - g_pGameCVars->cl_shallowWaterDepthLo) / shallowWaterDepthSpan;
slowdownFraction = CLAMP(slowdownFraction, 0.0f, 1.0f);
shallowWaterMultiplier = LERP(1.0f, shallowWaterMultiplier, slowdownFraction);
desiredVel *= shallowWaterMultiplier;
}
}
}
else if (move.len2()>0.01f)//"passive" air control, the player can air control as long as it is to decelerate
{
Vec3 currVelFlat(m_stats.velocity - m_stats.velocity * baseMtxZ);
Vec3 moveFlat(move - move * baseMtxZ);
float dot(currVelFlat.GetNormalizedSafe(ZERO) * moveFlat.GetNormalizedSafe(ZERO));
if (dot<-0.001f)
{
desiredVel = (moveFlat-currVelFlat)*max(abs(dot)*0.3f,0.1f);
}
else
{
desiredVel = moveFlat*max(0.5f,1.0f-dot);
}
float currVelModSq(currVelFlat.len2());
float desiredVelModSq(desiredVel.len2());
if (desiredVelModSq>currVelModSq)
{
desiredVel.Normalize();
desiredVel *= max(1.5f,sqrtf(currVelModSq));
}
}
//be sure desired velocity is flat to the ground
desiredVel -= desiredVel * baseMtxZ;
Vec3 modifiedSlopeNormal = m_stats.groundNormal;
if (m_player.IsPlayer())
{
float h = Vec2(modifiedSlopeNormal.x, modifiedSlopeNormal.y).GetLength(); // TODO: OPT: sqrt(x*x+y*y)
float v = modifiedSlopeNormal.z;
float slopeAngleCur = RAD2DEG(cry_atan2f(h, v));
float slopeAngleHor = 10.0f;
float slopeAngleVer = 50.0f;
float slopeAngleFraction = CLAMP((slopeAngleCur - slopeAngleHor) / (slopeAngleVer - slopeAngleHor), 0.0f, 1.0f);
slopeAngleFraction = cry_powf(slopeAngleFraction, 3.0f); // TODO: OPT: x*x*x
float slopeAngleMod = LERP(0.0f, 90.0f, slopeAngleFraction);
float c = cry_cosf(DEG2RAD(slopeAngleMod)); // TODO: OPT: sincos?
float s = cry_sinf(DEG2RAD(slopeAngleMod));
if (h > 0.0f)
{
modifiedSlopeNormal.x *= s / h;
modifiedSlopeNormal.y *= s / h;
}
if (v > 0.0f)
{
modifiedSlopeNormal.z *= c / v;
}
modifiedSlopeNormal.Normalize();
float alignment = modifiedSlopeNormal * desiredVel;
alignment = min(0.0f, alignment);
// Also affect air control (but not as much), to prevent jumping up against steep slopes.
if (m_stats.onGround == 0.0f)
{
float noControlBlend = 1.0f - CLAMP(modifiedSlopeNormal.z / 0.01f, 0.0f, 1.0f);
alignment *= LERP(0.7f, 1.0f, noControlBlend);
}
desiredVel -= modifiedSlopeNormal * alignment;
/*
float unconstrainedFallBlend = 1.0f - CLAMP(modifiedSlopeNormal.z / 0.05f, 0.0f, 1.0f);
desiredVel = LERP(desiredVel, m_stats.velocityUnconstrained, unconstrainedFallBlend);
/**/
if (debugJumping)
{
m_player.DebugGraph_AddValue("GroundSlope", slopeAngleCur);
m_player.DebugGraph_AddValue("GroundSlopeMod", slopeAngleMod);
}
}
/*
{
Vec3 slideDirection = m_stats.groundNormal;
slideDirection.z = 0.0f;
ISurfaceType* pSurface = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeManager()->GetSurfaceType(m_stats.groundMaterialIdx);
const ISurfaceType::SPhysicalParams& params = pSurface->GetPhyscalParams();
float slideScale = 4.0f * (1.0f - CLAMP((params.friction - 0.1f) / 0.3f, 0.0f, 1.0f));
desiredVel += slideScale * slideDirection;
}
*/
NETINPUT_TRACE(m_player.GetEntityId(), jumpVec);
m_request.velocity = desiredVel + jumpVec;
if(!m_stats.inZeroG && (m_movement.jump && (g_pGameCVars->dt_enable && m_stats.inAir > 0.3f)) && m_request.velocity.len() > 22.0f) //cap maximum velocity when jumping (limits speed jump length)
m_request.velocity = m_request.velocity.normalized() * 22.0f;
if (debugJumping)
{
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(entityPos, ColorB(255,255,255,255), entityPos + modifiedSlopeNormal, ColorB(255,255,0,255), 2.0f);
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(entityPos+Vec3(0,0,2), ColorB(255,255,255,255), entityPos+Vec3(0,0,2) + desiredVel, ColorB(0,255,0,255), 2.0f);
}
if (debugJumping)
{
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(entityPos, ColorB(255,255,255,255), entityPos + jumpVec, ColorB(0,255,255,255), 2.0f);
}
if (debugJumping)
{
gEnv->pRenderer->DrawLabel(entityPos - entityRight * 1.0f + Vec3(0,0,3.0f), 1.5f, "Velo[%2.3f = %2.3f, %2.3f, %2.3f]", m_request.velocity.len(), m_request.velocity.x, m_request.velocity.y, m_request.velocity.z);
}
m_velocity.Set(0,0,0);
}
void CPlayerMovement::AdjustMovementForEnvironment( Vec3& move, bool sprinting )
{
//nanoSuit
if(CNanoSuit *pSuit = m_player.GetNanoSuit())
{
if (gEnv->bMultiplayer)
{
if(pSuit->GetMode() == NANOMODE_SPEED)
{
if (sprinting)
{
float nanoSpeed = pSuit->GetSlotValue(NANOSLOT_SPEED);
float nanoSpeedMul = 1.0f+nanoSpeed*0.01f*0.5f;
move *= nanoSpeedMul;
NETINPUT_TRACE(m_player.GetEntityId(), nanoSpeedMul);
}
else //confirmed with CJ : also in MP the suit is a bit faster in speed mode walking
move *= 1.3f;
}
}
else
{
float nanoSpeed = pSuit->GetSlotValue(NANOSLOT_SPEED);
float nanoSpeedMul = 1.0f+nanoSpeed*0.01f;
move *= nanoSpeedMul;
NETINPUT_TRACE(m_player.GetEntityId(), nanoSpeedMul);
}
}
//player is slowed down by carrying heavy objects (max. 33%)
float massFactor = m_player.GetMassFactor();
NETINPUT_TRACE(m_player.GetEntityId(), massFactor);
move *= massFactor;
}
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
void CPlayerMovement::ProcessTurning()
{
if (m_stats.isRagDoll || (m_player.m_stats.isFrozen.Value() || m_stats.isOnLadder/*&& !m_player.IsPlayer()*/))
return;
static const bool ROTATION_AFFECTS_THIRD_PERSON_MODEL = true;
static const float ROTATION_SPEED = 23.3f;
Quat entityRot = m_player.GetEntity()->GetWorldRotation().GetNormalized();
Quat inverseEntityRot = entityRot.GetInverted();
// TODO: figure out a way to unify this
if (m_player.IsClient())
{
Vec3 right = m_turnTarget.GetColumn0();
Vec3 up = m_upVector.GetNormalized();
Vec3 forward = (up % right).GetNormalized();
m_turnTarget = GetQuatFromMat33( Matrix33::CreateFromVectors(forward%up, forward, up) );
if (ROTATION_AFFECTS_THIRD_PERSON_MODEL)
{
if (m_stats.inAir && m_stats.inZeroG)
{
m_turnTarget = m_baseQuat;
m_request.rotation = inverseEntityRot * m_turnTarget;
}
else
{
/*float turn = m_movement.deltaAngles.z;
m_turnTarget = Quat::CreateRotationZ(turn) * m_turnTarget;
Quat turnQuat = inverseEntityRot * m_turnTarget;
Vec3 epos(m_player.GetEntity()->GetWorldPos()+Vec3(1,0,1));
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(epos, ColorB(255,255,0,100), epos + m_turnTarget.GetColumn1()*2.0f, ColorB(255,0,255,100));*/
/*
float turnAngle = cry_acosf( CLAMP( FORWARD_DIRECTION.Dot(turn * FORWARD_DIRECTION), -1.0f, 1.0f ) );
float turnRatio = turnAngle / (ROTATION_SPEED * m_frameTime);
if (turnRatio > 1)
turnQuat = Quat::CreateSlerp( Quat::CreateIdentity(), turnQuat, 1.0f/turnRatio );
*/
//float white[4] = {1,1,1,1};
//gEnv->pRenderer->Draw2dLabel( 100, 50, 4, white, false, "%f %f %f %f", turnQuat.w, turnQuat.v.x, turnQuat.v.y, turnQuat.v.z );
//m_request.turn = turnQuat;
m_request.rotation = inverseEntityRot * m_baseQuat;
m_request.rotation.Normalize();
}
}
}
else
{
/*Vec3 right = entityRot.GetColumn0();
Vec3 up = m_upVector.GetNormalized();
Vec3 forward = (up % right).GetNormalized();
m_turnTarget = GetQuatFromMat33( Matrix33::CreateFromVectors(forward%up, forward, up) );
float turn = m_movement.deltaAngles.z;
if (fabsf(turn) > ROTATION_SPEED * m_frameTime)
turn = ROTATION_SPEED * m_frameTime * (turn > 0.0f? 1.0f : -1.0f);*/
if (1)//m_stats.speedFlat>0.5f)
{
m_request.rotation = inverseEntityRot * m_baseQuat;//(m_turnTarget * Quat::CreateRotationZ(turn));
m_request.rotation.Normalize();
}
else
m_request.rotation = inverseEntityRot * Quat::CreateRotationZ(gf_PI);
}
if (m_player.IsPlayer() && (g_pGameCVars->ca_GameControlledStrafingPtr->GetIVal() != 0) && (g_pGameCVars->ac_enableProceduralLeaning == 0.0f))
{
float turningSpeed = m_frameTime > 0.0f ? (fabs(RAD2DEG(m_request.rotation.GetRotZ())) / m_frameTime) : 0.0f;
float turningSpeedMin = 30.0f;
float turningSpeedMax = 180.0f;
float turningSpeedFraction = CLAMP((turningSpeed - turningSpeedMin) / (turningSpeedMax - turningSpeedMin), 0.0f, 1.0f);
float travelSpeedScale = LERP(1.0f, CLAMP(g_pGameCVars->pl_curvingSlowdownSpeedScale, 0.0f, 1.0f), turningSpeedFraction);
m_request.velocity *= travelSpeedScale;
}
m_request.proceduralLeaning = (g_pGameCVars->ac_enableProceduralLeaning > 0.0f);
/*
Vec3 pos = m_player.GetEntity()->GetWorldPos();
Vec3 curDir = entityRot.GetColumn1();
Vec3 wantDir = m_baseQuat.GetColumn1();
Vec3 lftDir = entityRot.GetColumn0();
float rot = m_request.rotation.GetRotZ();
gEnv->pRenderer->GetIRenderAuxGeom()->SetRenderFlags( e_Def3DPublicRenderflags );
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(pos, ColorB(255,255,0,255), pos+curDir, ColorB(255,255,0,255), 2.0f);
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(pos, ColorB(255,0,255,255), pos+wantDir, ColorB(255,0,255,255), 2.0f);
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(pos+curDir, ColorB(0,255,255,255), pos+curDir+lftDir*rot, ColorB(0,255,255,255), 2.0f);
*/
}
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
void CPlayerMovement::ProcessMovementOnLadder(CPlayer &player)
{
if(m_stats.isExitingLadder)
{
if(gEnv->bClient)
{
IAnimatedCharacter* pAC = m_player.GetAnimatedCharacter();
IAnimationGraphState* pAGState = pAC ? pAC->GetAnimationGraphState() : NULL;
const char* agOutputOnLadder = pAGState ? pAGState->QueryOutput("OnLadder") : NULL;
bool onLadder = agOutputOnLadder && agOutputOnLadder[0] == '1';
if(!onLadder)
player.RequestLeaveLadder(CPlayer::eLAT_ReachedEnd);
}
return;
}
Vec3 mypos = m_worldPos;
Vec3 move(m_stats.ladderTop - m_stats.ladderBottom);
move.NormalizeSafe();
float topDist = (m_stats.ladderTop-player.GetEntity()->GetWorldPos()).len();
float bottomDist = (m_stats.ladderBottom-player.GetEntity()->GetWorldPos()).len();
//Animation and movement synch
{
AdjustPlayerPositionOnLadder(player);
bottomDist +=0.012f; //Offset to make the anim match better... (depends on animation and ladder, they should be all exactly the same)
float animTime = bottomDist - cry_floorf(bottomDist);
CPlayer::ELadderDirection eLDir = (m_movement.desiredVelocity.y >= 0.0f ? CPlayer::eLDIR_Up : CPlayer::eLDIR_Down);
if(!player.UpdateLadderAnimation(CPlayer::eLS_Climb,eLDir,animTime))
{
return;
}
}
//Just another check
if(player.IsClient() && m_movement.desiredVelocity.y<-0.01f)
{
// check collision with terrain/static objects when moving down, some ladders are very badly placed ;(
// player will need to detach
ray_hit hit;
static const int obj_types = ent_static|ent_terrain;
static const unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
Vec3 currentPos = player.GetEntity()->GetWorldPos();
currentPos.z +=0.15f;
int rayHits = gEnv->pPhysicalWorld->RayWorldIntersection( currentPos, m_stats.ladderUpDir*-0.3f, obj_types, flags, &hit, 1, player.GetEntity()->GetPhysics() );
if(rayHits!=0)
{
player.RequestLeaveLadder(CPlayer::eLAT_None);
return;
}
}
if (player.IsClient() && ((topDist < LADDER_TOP_DISTANCE && m_movement.desiredVelocity.y > 0.01f) || (bottomDist < 0.1f && m_movement.desiredVelocity.y < -0.01f)))
{
if(m_movement.desiredVelocity.y>0.01f)
{
// check if player can move forward from top of ladder before getting off. If they can't,
// they'll need to strafe / jump off.
ray_hit hit;
static const int obj_types = ent_static|ent_terrain|ent_rigid|ent_sleeping_rigid;
static const unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
static float backDist = 0.15f;
Vec3 currentPos = player.m_stats.ladderTop + backDist * player.m_stats.ladderOrientation;
Vec3 newPos = player.m_stats.ladderTop-player.m_stats.ladderOrientation;
currentPos.z += 0.35f;
newPos.z +=0.35f;
if(g_pGameCVars->pl_debug_ladders !=0)
{
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(currentPos, ColorF(1,1,1,1), newPos, ColorF(1,1,1,1));
}
bool rayHitAny = 0 != gEnv->pPhysicalWorld->RayWorldIntersection( currentPos, newPos-currentPos, obj_types, flags, &hit, 1, player.GetEntity()->GetPhysics() );
if (!rayHitAny /*|| abs(hit.n.z) > 0.1f*/)
{
player.RequestLeaveLadder(CPlayer::eLAT_ExitTop);
return;
}
else
{
m_movement.desiredVelocity.y = 0.0f;
if(g_pGameCVars->pl_debug_ladders !=0)
{
float white[] = {1,1,1,1};
gEnv->pRenderer->Draw2dLabel(50,125,2.0f,white,false,"CLAMPING");
}
}
}
else
{
player.RequestLeaveLadder(CPlayer::eLAT_None);
return;
}
}
//Strafe
if(m_stats.ladderAction == CPlayer::eLAT_StrafeRight || m_stats.ladderAction == CPlayer::eLAT_StrafeLeft)
{
player.RequestLeaveLadder(static_cast<CPlayer::ELadderActionType>(m_stats.ladderAction));
return;
}
if(g_pGameCVars->pl_debug_ladders !=0)
{
gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(m_stats.ladderBottom,0.12f,ColorB(0,255,0,100) );
gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(m_stats.ladderTop,0.12f,ColorB(0,255,0,100) );
gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(player.GetEntity()->GetWorldPos(),0.12f,ColorB(255,0,0,100) );
float white[4]={1,1,1,1};
gEnv->pRenderer->Draw2dLabel(50,50,2.0f,white,false,"Top Dist: %f - Bottom Dist: %f - Desired Vel: %f",topDist,bottomDist,m_movement.desiredVelocity.y);
gEnv->pRenderer->Draw2dLabel(50,75,2.0f,white,false,"Ladder Orientation (%f, %f, %f) - Ladder Up Direction (%f, %f, %f)", m_stats.ladderOrientation.x,m_stats.ladderOrientation.y,m_stats.ladderOrientation.z,m_stats.ladderUpDir.x,m_stats.ladderUpDir.y,m_stats.ladderUpDir.z);
}
move *= m_movement.desiredVelocity.y*0.5f;// * (dirDot>0.0f?1.0f:-1.0f) * min(1.0f,fabs(dirDot)*5);
//cap the movement vector to max 1
float moveModule(move.len());
if (moveModule > 1.0f)
move /= moveModule;
move *= m_player.GetStanceMaxSpeed(STANCE_STAND)*0.5f;
//player.m_stats.bSprinting = false; //Manual update here (if not suit doensn't decrease energy and so on...)
if (m_actions & ACTION_SPRINT)
{
if((move.len2()>0.1f))
{
move *= 1.2f;
if(player.GetNanoSuit() && (player.GetNanoSuit()->GetMode()==NANOMODE_SPEED))
move *= (max(1.2f,player.GetNanoSuit()->GetSprintMultiplier(cry_fabsf(m_movement.desiredVelocity.x)>0.01f)*0.5f));
//player.m_stats.bSprinting = true;
}
}
if(m_actions & ACTION_JUMP)
{
player.RequestLeaveLadder(CPlayer::eLAT_Jump);
move += Vec3(0.0f,0.0f,3.0f);
}
if(g_pGameCVars->pl_debug_ladders !=0)
{
float white[] = {1,1,1,1};
gEnv->pRenderer->Draw2dLabel(50,100,2.0f,white,false, "Move (%.2f, %.2f, %.2f)", move.x, move.y, move.z);
}
m_request.type = eCMT_Fly;
m_request.velocity = move;
m_velocity.Set(0,0,0);
}
//---------------------------------------------------------
void CPlayerMovement::AdjustPlayerPositionOnLadder(CPlayer &player)
{
IEntity *pEntity = player.GetEntity();
if(pEntity)
{
//In some cases the rotation is not correct, force it if neccessary
if(!pEntity->GetRotation().IsEquivalent(m_stats.playerRotation))
pEntity->SetRotation(Quat(Matrix33::CreateOrientation(-m_stats.ladderOrientation,m_stats.ladderUpDir,g_PI)));
Vec3 projected = ProjectPointToLine(pEntity->GetWorldPos(),m_stats.ladderBottom,m_stats.ladderTop);
//Same problem with the position
if(!pEntity->GetWorldPos().IsEquivalent(projected))
{
Matrix34 finalPos = pEntity->GetWorldTM();
finalPos.SetTranslation(projected);
pEntity->SetWorldTM(finalPos);
}
}
}
| [
"[email protected]",
"kkirst@c5e09591-5635-0410-80e3-0b71df3ecc31"
]
| [
[
[
1,
9
],
[
11,
25
],
[
27,
28
],
[
30,
43
],
[
47,
47
],
[
51,
65
],
[
67,
88
],
[
91,
94
],
[
103,
107
],
[
110,
111
],
[
114,
119
],
[
125,
129
],
[
136,
136
],
[
141,
173
],
[
175,
185
],
[
460,
472
],
[
476,
509
],
[
511,
514
],
[
516,
522
],
[
524,
640
],
[
642,
646
],
[
648,
650
],
[
656,
656
],
[
658,
658
],
[
679,
684
],
[
686,
686
],
[
688,
688
],
[
690,
690
],
[
692,
695
],
[
697,
697
],
[
699,
700
],
[
703,
703
],
[
722,
722
],
[
733,
733
],
[
737,
737
],
[
741,
744
],
[
746,
746
],
[
750,
759
],
[
761,
764
],
[
766,
766
],
[
768,
768
],
[
770,
772
],
[
775,
778
],
[
780,
780
],
[
782,
782
],
[
785,
785
],
[
789,
791
],
[
793,
793
],
[
796,
796
],
[
798,
798
],
[
802,
802
],
[
809,
811
],
[
815,
816
],
[
818,
818
],
[
820,
820
],
[
822,
830
],
[
841,
841
],
[
843,
847
],
[
849,
853
],
[
861,
862
],
[
864,
871
],
[
886,
899
],
[
901,
929
],
[
931,
934
],
[
936,
946
],
[
961,
962
],
[
968,
973
],
[
976,
980
],
[
983,
984
],
[
987,
1006
],
[
1008,
1012
],
[
1023,
1025
],
[
1031,
1041
],
[
1044,
1076
],
[
1099,
1101
],
[
1103,
1109
],
[
1111,
1116
],
[
1118,
1121
],
[
1127,
1128
],
[
1130,
1132
],
[
1134,
1134
],
[
1143,
1143
],
[
1150,
1151
],
[
1154,
1165
],
[
1169,
1174
],
[
1176,
1178
],
[
1180,
1180
],
[
1188,
1197
],
[
1206,
1216
],
[
1220,
1222
],
[
1228,
1230
],
[
1235,
1237
],
[
1240,
1241
],
[
1262,
1266
],
[
1268,
1268
],
[
1270,
1290
],
[
1354,
1357
],
[
1359,
1359
],
[
1377,
1379
],
[
1381,
1384
],
[
1408,
1409
],
[
1411,
1485
],
[
1510,
1516
],
[
1532,
1544
],
[
1565,
1565
],
[
1567,
1570
],
[
1572,
1577
],
[
1579,
1579
],
[
1582,
1582
],
[
1586,
1589
],
[
1591,
1591
],
[
1593,
1597
],
[
1599,
1617
],
[
1619,
1637
],
[
1639,
1640
],
[
1642,
1642
],
[
1647,
1654
],
[
1656,
1687
]
],
[
[
10,
10
],
[
26,
26
],
[
29,
29
],
[
44,
46
],
[
48,
50
],
[
66,
66
],
[
89,
90
],
[
95,
102
],
[
108,
109
],
[
112,
113
],
[
120,
124
],
[
130,
135
],
[
137,
140
],
[
174,
174
],
[
186,
459
],
[
473,
475
],
[
510,
510
],
[
515,
515
],
[
523,
523
],
[
641,
641
],
[
647,
647
],
[
651,
655
],
[
657,
657
],
[
659,
678
],
[
685,
685
],
[
687,
687
],
[
689,
689
],
[
691,
691
],
[
696,
696
],
[
698,
698
],
[
701,
702
],
[
704,
721
],
[
723,
732
],
[
734,
736
],
[
738,
740
],
[
745,
745
],
[
747,
749
],
[
760,
760
],
[
765,
765
],
[
767,
767
],
[
769,
769
],
[
773,
774
],
[
779,
779
],
[
781,
781
],
[
783,
784
],
[
786,
788
],
[
792,
792
],
[
794,
795
],
[
797,
797
],
[
799,
801
],
[
803,
808
],
[
812,
814
],
[
817,
817
],
[
819,
819
],
[
821,
821
],
[
831,
840
],
[
842,
842
],
[
848,
848
],
[
854,
860
],
[
863,
863
],
[
872,
885
],
[
900,
900
],
[
930,
930
],
[
935,
935
],
[
947,
960
],
[
963,
967
],
[
974,
975
],
[
981,
982
],
[
985,
986
],
[
1007,
1007
],
[
1013,
1022
],
[
1026,
1030
],
[
1042,
1043
],
[
1077,
1098
],
[
1102,
1102
],
[
1110,
1110
],
[
1117,
1117
],
[
1122,
1126
],
[
1129,
1129
],
[
1133,
1133
],
[
1135,
1142
],
[
1144,
1149
],
[
1152,
1153
],
[
1166,
1168
],
[
1175,
1175
],
[
1179,
1179
],
[
1181,
1187
],
[
1198,
1205
],
[
1217,
1219
],
[
1223,
1227
],
[
1231,
1234
],
[
1238,
1239
],
[
1242,
1261
],
[
1267,
1267
],
[
1269,
1269
],
[
1291,
1353
],
[
1358,
1358
],
[
1360,
1376
],
[
1380,
1380
],
[
1385,
1407
],
[
1410,
1410
],
[
1486,
1509
],
[
1517,
1531
],
[
1545,
1564
],
[
1566,
1566
],
[
1571,
1571
],
[
1578,
1578
],
[
1580,
1581
],
[
1583,
1585
],
[
1590,
1590
],
[
1592,
1592
],
[
1598,
1598
],
[
1618,
1618
],
[
1638,
1638
],
[
1641,
1641
],
[
1643,
1646
],
[
1655,
1655
]
]
]
|
15c00d8cca966f43b5200901c712126ef522aa38 | 3c22e8879c8060942ad1ba4a28835d7963e10bce | /trunk/scintilla/include/Scintilla.h | b56368c4cbe9ffb65faf6a6a37ca07310f2e9626 | [
"LicenseRef-scancode-scintilla"
]
| permissive | svn2github/NotepadPlusPlus | b17f159f9fe6d8d650969b0555824d259d775d45 | 35b5304f02aaacfc156269c4b894159de53222ef | refs/heads/master | 2021-01-22T09:05:19.267064 | 2011-01-31T01:46:36 | 2011-01-31T01:46:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 31,533 | h | /* Scintilla source code edit control */
/** @file Scintilla.h
** Interface to the edit control.
**/
/* Copyright 1998-2003 by Neil Hodgson <[email protected]>
* The License.txt file describes the conditions under which this software may be distributed. */
/* Most of this file is automatically generated from the Scintilla.iface interface definition
* file which contains any comments about the definitions. HFacer.py does the generation. */
#ifndef SCINTILLA_H
#define SCINTILLA_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32)
/* Return false on failure: */
int Scintilla_RegisterClasses(void *hInstance);
int Scintilla_ReleaseResources();
#endif
int Scintilla_LinkLexers();
#ifdef __cplusplus
}
#endif
/* Here should be placed typedefs for uptr_t, an unsigned integer type large enough to
* hold a pointer and sptr_t, a signed integer large enough to hold a pointer.
* May need to be changed for 64 bit platforms. */
#if defined(_WIN32)
#include <basetsd.h>
#endif
#ifdef MAXULONG_PTR
typedef ULONG_PTR uptr_t;
typedef LONG_PTR sptr_t;
#else
typedef unsigned long uptr_t;
typedef long sptr_t;
#endif
typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam);
/* ++Autogenerated -- start of section automatically generated from Scintilla.iface */
#define INVALID_POSITION -1
#define SCI_START 2000
#define SCI_OPTIONAL_START 3000
#define SCI_LEXER_START 4000
#define SCI_ADDTEXT 2001
#define SCI_ADDSTYLEDTEXT 2002
#define SCI_INSERTTEXT 2003
#define SCI_CLEARALL 2004
#define SCI_CLEARDOCUMENTSTYLE 2005
#define SCI_GETLENGTH 2006
#define SCI_GETCHARAT 2007
#define SCI_GETCURRENTPOS 2008
#define SCI_GETANCHOR 2009
#define SCI_GETSTYLEAT 2010
#define SCI_REDO 2011
#define SCI_SETUNDOCOLLECTION 2012
#define SCI_SELECTALL 2013
#define SCI_SETSAVEPOINT 2014
#define SCI_GETSTYLEDTEXT 2015
#define SCI_CANREDO 2016
#define SCI_MARKERLINEFROMHANDLE 2017
#define SCI_MARKERDELETEHANDLE 2018
#define SCI_GETUNDOCOLLECTION 2019
#define SCWS_INVISIBLE 0
#define SCWS_VISIBLEALWAYS 1
#define SCWS_VISIBLEAFTERINDENT 2
#define SCI_GETVIEWWS 2020
#define SCI_SETVIEWWS 2021
#define SCI_POSITIONFROMPOINT 2022
#define SCI_POSITIONFROMPOINTCLOSE 2023
#define SCI_GOTOLINE 2024
#define SCI_GOTOPOS 2025
#define SCI_SETANCHOR 2026
#define SCI_GETCURLINE 2027
#define SCI_GETENDSTYLED 2028
#define SC_EOL_CRLF 0
#define SC_EOL_CR 1
#define SC_EOL_LF 2
#define SCI_CONVERTEOLS 2029
#define SCI_GETEOLMODE 2030
#define SCI_SETEOLMODE 2031
#define SCI_STARTSTYLING 2032
#define SCI_SETSTYLING 2033
#define SCI_GETBUFFEREDDRAW 2034
#define SCI_SETBUFFEREDDRAW 2035
#define SCI_SETTABWIDTH 2036
#define SCI_GETTABWIDTH 2121
#define SC_CP_UTF8 65001
#define SCI_SETCODEPAGE 2037
#define SCI_SETUSEPALETTE 2039
#define MARKER_MAX 31
#define SC_MARK_CIRCLE 0
#define SC_MARK_ROUNDRECT 1
#define SC_MARK_ARROW 2
#define SC_MARK_SMALLRECT 3
#define SC_MARK_SHORTARROW 4
#define SC_MARK_EMPTY 5
#define SC_MARK_ARROWDOWN 6
#define SC_MARK_MINUS 7
#define SC_MARK_PLUS 8
#define SC_MARK_VLINE 9
#define SC_MARK_LCORNER 10
#define SC_MARK_TCORNER 11
#define SC_MARK_BOXPLUS 12
#define SC_MARK_BOXPLUSCONNECTED 13
#define SC_MARK_BOXMINUS 14
#define SC_MARK_BOXMINUSCONNECTED 15
#define SC_MARK_LCORNERCURVE 16
#define SC_MARK_TCORNERCURVE 17
#define SC_MARK_CIRCLEPLUS 18
#define SC_MARK_CIRCLEPLUSCONNECTED 19
#define SC_MARK_CIRCLEMINUS 20
#define SC_MARK_CIRCLEMINUSCONNECTED 21
#define SC_MARK_BACKGROUND 22
#define SC_MARK_DOTDOTDOT 23
#define SC_MARK_ARROWS 24
#define SC_MARK_PIXMAP 25
#define SC_MARK_FULLRECT 26
#define SC_MARK_LEFTRECT 27
#define SC_MARK_AVAILABLE 28
#define SC_MARK_UNDERLINE 29
#define SC_MARK_CHARACTER 10000
#define SC_MARKNUM_FOLDEREND 25
#define SC_MARKNUM_FOLDEROPENMID 26
#define SC_MARKNUM_FOLDERMIDTAIL 27
#define SC_MARKNUM_FOLDERTAIL 28
#define SC_MARKNUM_FOLDERSUB 29
#define SC_MARKNUM_FOLDER 30
#define SC_MARKNUM_FOLDEROPEN 31
#define SC_MASK_FOLDERS 0xFE000000
#define SCI_MARKERDEFINE 2040
#define SCI_MARKERSETFORE 2041
#define SCI_MARKERSETBACK 2042
#define SCI_MARKERADD 2043
#define SCI_MARKERDELETE 2044
#define SCI_MARKERDELETEALL 2045
#define SCI_MARKERGET 2046
#define SCI_MARKERNEXT 2047
#define SCI_MARKERPREVIOUS 2048
#define SCI_MARKERDEFINEPIXMAP 2049
#define SCI_MARKERADDSET 2466
#define SCI_MARKERSETALPHA 2476
#define SC_MARGIN_SYMBOL 0
#define SC_MARGIN_NUMBER 1
#define SC_MARGIN_BACK 2
#define SC_MARGIN_FORE 3
#define SC_MARGIN_TEXT 4
#define SC_MARGIN_RTEXT 5
#define SCI_SETMARGINTYPEN 2240
#define SCI_GETMARGINTYPEN 2241
#define SCI_SETMARGINWIDTHN 2242
#define SCI_GETMARGINWIDTHN 2243
#define SCI_SETMARGINMASKN 2244
#define SCI_GETMARGINMASKN 2245
#define SCI_SETMARGINSENSITIVEN 2246
#define SCI_GETMARGINSENSITIVEN 2247
#define STYLE_DEFAULT 32
#define STYLE_LINENUMBER 33
#define STYLE_BRACELIGHT 34
#define STYLE_BRACEBAD 35
#define STYLE_CONTROLCHAR 36
#define STYLE_INDENTGUIDE 37
#define STYLE_CALLTIP 38
#define STYLE_LASTPREDEFINED 39
#define STYLE_MAX 255
#define SC_CHARSET_ANSI 0
#define SC_CHARSET_DEFAULT 1
#define SC_CHARSET_BALTIC 186
#define SC_CHARSET_CHINESEBIG5 136
#define SC_CHARSET_EASTEUROPE 238
#define SC_CHARSET_GB2312 134
#define SC_CHARSET_GREEK 161
#define SC_CHARSET_HANGUL 129
#define SC_CHARSET_MAC 77
#define SC_CHARSET_OEM 255
#define SC_CHARSET_RUSSIAN 204
#define SC_CHARSET_CYRILLIC 1251
#define SC_CHARSET_SHIFTJIS 128
#define SC_CHARSET_SYMBOL 2
#define SC_CHARSET_TURKISH 162
#define SC_CHARSET_JOHAB 130
#define SC_CHARSET_HEBREW 177
#define SC_CHARSET_ARABIC 178
#define SC_CHARSET_VIETNAMESE 163
#define SC_CHARSET_THAI 222
#define SC_CHARSET_8859_15 1000
#define SCI_STYLECLEARALL 2050
#define SCI_STYLESETFORE 2051
#define SCI_STYLESETBACK 2052
#define SCI_STYLESETBOLD 2053
#define SCI_STYLESETITALIC 2054
#define SCI_STYLESETSIZE 2055
#define SCI_STYLESETFONT 2056
#define SCI_STYLESETEOLFILLED 2057
#define SCI_STYLERESETDEFAULT 2058
#define SCI_STYLESETUNDERLINE 2059
#define SC_CASE_MIXED 0
#define SC_CASE_UPPER 1
#define SC_CASE_LOWER 2
#define SCI_STYLEGETFORE 2481
#define SCI_STYLEGETBACK 2482
#define SCI_STYLEGETBOLD 2483
#define SCI_STYLEGETITALIC 2484
#define SCI_STYLEGETSIZE 2485
#define SCI_STYLEGETFONT 2486
#define SCI_STYLEGETEOLFILLED 2487
#define SCI_STYLEGETUNDERLINE 2488
#define SCI_STYLEGETCASE 2489
#define SCI_STYLEGETCHARACTERSET 2490
#define SCI_STYLEGETVISIBLE 2491
#define SCI_STYLEGETCHANGEABLE 2492
#define SCI_STYLEGETHOTSPOT 2493
#define SCI_STYLESETCASE 2060
#define SCI_STYLESETCHARACTERSET 2066
#define SCI_STYLESETHOTSPOT 2409
#define SCI_SETSELFORE 2067
#define SCI_SETSELBACK 2068
#define SCI_GETSELALPHA 2477
#define SCI_SETSELALPHA 2478
#define SCI_GETSELEOLFILLED 2479
#define SCI_SETSELEOLFILLED 2480
#define SCI_SETCARETFORE 2069
#define SCI_ASSIGNCMDKEY 2070
#define SCI_CLEARCMDKEY 2071
#define SCI_CLEARALLCMDKEYS 2072
#define SCI_SETSTYLINGEX 2073
#define SCI_STYLESETVISIBLE 2074
#define SCI_GETCARETPERIOD 2075
#define SCI_SETCARETPERIOD 2076
#define SCI_SETWORDCHARS 2077
#define SCI_BEGINUNDOACTION 2078
#define SCI_ENDUNDOACTION 2079
#define INDIC_PLAIN 0
#define INDIC_SQUIGGLE 1
#define INDIC_TT 2
#define INDIC_DIAGONAL 3
#define INDIC_STRIKE 4
#define INDIC_HIDDEN 5
#define INDIC_BOX 6
#define INDIC_ROUNDBOX 7
#define INDIC_MAX 31
#define INDIC_CONTAINER 8
#define INDIC0_MASK 0x20
#define INDIC1_MASK 0x40
#define INDIC2_MASK 0x80
#define INDICS_MASK 0xE0
#define SCI_INDICSETSTYLE 2080
#define SCI_INDICGETSTYLE 2081
#define SCI_INDICSETFORE 2082
#define SCI_INDICGETFORE 2083
#define SCI_INDICSETUNDER 2510
#define SCI_INDICGETUNDER 2511
#define SCI_GETCARETLINEVISIBLEALWAYS 3095
#define SCI_SETCARETLINEVISIBLEALWAYS 3096
#define SCI_SETWHITESPACEFORE 2084
#define SCI_SETWHITESPACEBACK 2085
#define SCI_SETWHITESPACESIZE 2086
#define SCI_GETWHITESPACESIZE 2087
#define SCI_SETSTYLEBITS 2090
#define SCI_GETSTYLEBITS 2091
#define SCI_SETLINESTATE 2092
#define SCI_GETLINESTATE 2093
#define SCI_GETMAXLINESTATE 2094
#define SCI_GETCARETLINEVISIBLE 2095
#define SCI_SETCARETLINEVISIBLE 2096
#define SCI_GETCARETLINEBACK 2097
#define SCI_SETCARETLINEBACK 2098
#define SCI_STYLESETCHANGEABLE 2099
#define SCI_AUTOCSHOW 2100
#define SCI_AUTOCCANCEL 2101
#define SCI_AUTOCACTIVE 2102
#define SCI_AUTOCPOSSTART 2103
#define SCI_AUTOCCOMPLETE 2104
#define SCI_AUTOCSTOPS 2105
#define SCI_AUTOCSETSEPARATOR 2106
#define SCI_AUTOCGETSEPARATOR 2107
#define SCI_AUTOCSELECT 2108
#define SCI_AUTOCSETCANCELATSTART 2110
#define SCI_AUTOCGETCANCELATSTART 2111
#define SCI_AUTOCSETFILLUPS 2112
#define SCI_AUTOCSETCHOOSESINGLE 2113
#define SCI_AUTOCGETCHOOSESINGLE 2114
#define SCI_AUTOCSETIGNORECASE 2115
#define SCI_AUTOCGETIGNORECASE 2116
#define SCI_USERLISTSHOW 2117
#define SCI_AUTOCSETAUTOHIDE 2118
#define SCI_AUTOCGETAUTOHIDE 2119
#define SCI_AUTOCSETDROPRESTOFWORD 2270
#define SCI_AUTOCGETDROPRESTOFWORD 2271
#define SCI_REGISTERIMAGE 2405
#define SCI_CLEARREGISTEREDIMAGES 2408
#define SCI_AUTOCGETTYPESEPARATOR 2285
#define SCI_AUTOCSETTYPESEPARATOR 2286
#define SCI_AUTOCSETMAXWIDTH 2208
#define SCI_AUTOCGETMAXWIDTH 2209
#define SCI_AUTOCSETMAXHEIGHT 2210
#define SCI_AUTOCGETMAXHEIGHT 2211
#define SCI_SETINDENT 2122
#define SCI_GETINDENT 2123
#define SCI_SETUSETABS 2124
#define SCI_GETUSETABS 2125
#define SCI_SETLINEINDENTATION 2126
#define SCI_GETLINEINDENTATION 2127
#define SCI_GETLINEINDENTPOSITION 2128
#define SCI_GETCOLUMN 2129
#define SCI_SETHSCROLLBAR 2130
#define SCI_GETHSCROLLBAR 2131
#define SC_IV_NONE 0
#define SC_IV_REAL 1
#define SC_IV_LOOKFORWARD 2
#define SC_IV_LOOKBOTH 3
#define SCI_SETINDENTATIONGUIDES 2132
#define SCI_GETINDENTATIONGUIDES 2133
#define SCI_SETHIGHLIGHTGUIDE 2134
#define SCI_GETHIGHLIGHTGUIDE 2135
#define SCI_GETLINEENDPOSITION 2136
#define SCI_GETCODEPAGE 2137
#define SCI_GETCARETFORE 2138
#define SCI_GETUSEPALETTE 2139
#define SCI_GETREADONLY 2140
#define SCI_SETCURRENTPOS 2141
#define SCI_SETSELECTIONSTART 2142
#define SCI_GETSELECTIONSTART 2143
#define SCI_SETSELECTIONEND 2144
#define SCI_GETSELECTIONEND 2145
#define SCI_SETPRINTMAGNIFICATION 2146
#define SCI_GETPRINTMAGNIFICATION 2147
#define SC_PRINT_NORMAL 0
#define SC_PRINT_INVERTLIGHT 1
#define SC_PRINT_BLACKONWHITE 2
#define SC_PRINT_COLOURONWHITE 3
#define SC_PRINT_COLOURONWHITEDEFAULTBG 4
#define SCI_SETPRINTCOLOURMODE 2148
#define SCI_GETPRINTCOLOURMODE 2149
#define SCFIND_WHOLEWORD 2
#define SCFIND_MATCHCASE 4
#define SCFIND_WORDSTART 0x00100000
#define SCFIND_REGEXP 0x00200000
#define SCFIND_POSIX 0x00400000
#define SCI_FINDTEXT 2150
#define SCI_FORMATRANGE 2151
#define SCI_GETFIRSTVISIBLELINE 2152
#define SCI_GETLINE 2153
#define SCI_GETLINECOUNT 2154
#define SCI_SETMARGINLEFT 2155
#define SCI_GETMARGINLEFT 2156
#define SCI_SETMARGINRIGHT 2157
#define SCI_GETMARGINRIGHT 2158
#define SCI_GETMODIFY 2159
#define SCI_SETSEL 2160
#define SCI_GETSELTEXT 2161
#define SCI_GETTEXTRANGE 2162
#define SCI_HIDESELECTION 2163
#define SCI_POINTXFROMPOSITION 2164
#define SCI_POINTYFROMPOSITION 2165
#define SCI_LINEFROMPOSITION 2166
#define SCI_POSITIONFROMLINE 2167
#define SCI_LINESCROLL 2168
#define SCI_SCROLLCARET 2169
#define SCI_REPLACESEL 2170
#define SCI_SETREADONLY 2171
#define SCI_NULL 2172
#define SCI_CANPASTE 2173
#define SCI_CANUNDO 2174
#define SCI_EMPTYUNDOBUFFER 2175
#define SCI_UNDO 2176
#define SCI_CUT 2177
#define SCI_COPY 2178
#define SCI_PASTE 2179
#define SCI_CLEAR 2180
#define SCI_SETTEXT 2181
#define SCI_GETTEXT 2182
#define SCI_GETTEXTLENGTH 2183
#define SCI_GETDIRECTFUNCTION 2184
#define SCI_GETDIRECTPOINTER 2185
#define SCI_SETOVERTYPE 2186
#define SCI_GETOVERTYPE 2187
#define SCI_SETCARETWIDTH 2188
#define SCI_GETCARETWIDTH 2189
#define SCI_SETTARGETSTART 2190
#define SCI_GETTARGETSTART 2191
#define SCI_SETTARGETEND 2192
#define SCI_GETTARGETEND 2193
#define SCI_REPLACETARGET 2194
#define SCI_REPLACETARGETRE 2195
#define SCI_SEARCHINTARGET 2197
#define SCI_SETSEARCHFLAGS 2198
#define SCI_GETSEARCHFLAGS 2199
#define SCI_CALLTIPSHOW 2200
#define SCI_CALLTIPCANCEL 2201
#define SCI_CALLTIPACTIVE 2202
#define SCI_CALLTIPPOSSTART 2203
#define SCI_CALLTIPSETHLT 2204
#define SCI_CALLTIPSETBACK 2205
#define SCI_CALLTIPSETFORE 2206
#define SCI_CALLTIPSETFOREHLT 2207
#define SCI_CALLTIPUSESTYLE 2212
#define SCI_VISIBLEFROMDOCLINE 2220
#define SCI_DOCLINEFROMVISIBLE 2221
#define SCI_WRAPCOUNT 2235
#define SC_FOLDLEVELBASE 0x400
#define SC_FOLDLEVELWHITEFLAG 0x1000
#define SC_FOLDLEVELHEADERFLAG 0x2000
#define SC_FOLDLEVELNUMBERMASK 0x0FFF
#define SCI_SETFOLDLEVEL 2222
#define SCI_GETFOLDLEVEL 2223
#define SCI_GETLASTCHILD 2224
#define SCI_GETFOLDPARENT 2225
#define SCI_SHOWLINES 2226
#define SCI_HIDELINES 2227
#define SCI_GETLINEVISIBLE 2228
#define SCI_SETFOLDEXPANDED 2229
#define SCI_GETFOLDEXPANDED 2230
#define SCI_TOGGLEFOLD 2231
#define SCI_ENSUREVISIBLE 2232
#define SC_FOLDFLAG_LINEBEFORE_EXPANDED 0x0002
#define SC_FOLDFLAG_LINEBEFORE_CONTRACTED 0x0004
#define SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008
#define SC_FOLDFLAG_LINEAFTER_CONTRACTED 0x0010
#define SC_FOLDFLAG_LEVELNUMBERS 0x0040
#define SCI_SETFOLDFLAGS 2233
#define SCI_ENSUREVISIBLEENFORCEPOLICY 2234
#define SCI_SETTABINDENTS 2260
#define SCI_GETTABINDENTS 2261
#define SCI_SETBACKSPACEUNINDENTS 2262
#define SCI_GETBACKSPACEUNINDENTS 2263
#define SC_TIME_FOREVER 10000000
#define SCI_SETMOUSEDWELLTIME 2264
#define SCI_GETMOUSEDWELLTIME 2265
#define SCI_WORDSTARTPOSITION 2266
#define SCI_WORDENDPOSITION 2267
#define SC_WRAP_NONE 0
#define SC_WRAP_WORD 1
#define SC_WRAP_CHAR 2
#define SCI_SETWRAPMODE 2268
#define SCI_GETWRAPMODE 2269
#define SC_WRAPVISUALFLAG_NONE 0x0000
#define SC_WRAPVISUALFLAG_END 0x0001
#define SC_WRAPVISUALFLAG_START 0x0002
#define SCI_SETWRAPVISUALFLAGS 2460
#define SCI_GETWRAPVISUALFLAGS 2461
#define SC_WRAPVISUALFLAGLOC_DEFAULT 0x0000
#define SC_WRAPVISUALFLAGLOC_END_BY_TEXT 0x0001
#define SC_WRAPVISUALFLAGLOC_START_BY_TEXT 0x0002
#define SCI_SETWRAPVISUALFLAGSLOCATION 2462
#define SCI_GETWRAPVISUALFLAGSLOCATION 2463
#define SCI_SETWRAPSTARTINDENT 2464
#define SCI_GETWRAPSTARTINDENT 2465
#define SC_WRAPINDENT_FIXED 0
#define SC_WRAPINDENT_SAME 1
#define SC_WRAPINDENT_INDENT 2
#define SCI_SETWRAPINDENTMODE 2472
#define SCI_GETWRAPINDENTMODE 2473
#define SC_CACHE_NONE 0
#define SC_CACHE_CARET 1
#define SC_CACHE_PAGE 2
#define SC_CACHE_DOCUMENT 3
#define SCI_SETLAYOUTCACHE 2272
#define SCI_GETLAYOUTCACHE 2273
#define SCI_SETSCROLLWIDTH 2274
#define SCI_GETSCROLLWIDTH 2275
#define SCI_SETSCROLLWIDTHTRACKING 2516
#define SCI_GETSCROLLWIDTHTRACKING 2517
#define SCI_TEXTWIDTH 2276
#define SCI_SETENDATLASTLINE 2277
#define SCI_GETENDATLASTLINE 2278
#define SCI_TEXTHEIGHT 2279
#define SCI_SETVSCROLLBAR 2280
#define SCI_GETVSCROLLBAR 2281
#define SCI_APPENDTEXT 2282
#define SCI_GETTWOPHASEDRAW 2283
#define SCI_SETTWOPHASEDRAW 2284
#define SC_EFF_QUALITY_MASK 0xF
#define SC_EFF_QUALITY_DEFAULT 0
#define SC_EFF_QUALITY_NON_ANTIALIASED 1
#define SC_EFF_QUALITY_ANTIALIASED 2
#define SC_EFF_QUALITY_LCD_OPTIMIZED 3
#define SCI_SETFONTQUALITY 2611
#define SCI_GETFONTQUALITY 2612
#define SCI_SETFIRSTVISIBLELINE 2613
#define SC_MULTIPASTE_ONCE 0
#define SC_MULTIPASTE_EACH 1
#define SCI_SETMULTIPASTE 2614
#define SCI_GETMULTIPASTE 2615
#define SCI_GETTAG 2616
#define SCI_TARGETFROMSELECTION 2287
#define SCI_LINESJOIN 2288
#define SCI_LINESSPLIT 2289
#define SCI_SETFOLDMARGINCOLOUR 2290
#define SCI_SETFOLDMARGINHICOLOUR 2291
#define SCI_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302
#define SCI_LINEUPEXTEND 2303
#define SCI_CHARLEFT 2304
#define SCI_CHARLEFTEXTEND 2305
#define SCI_CHARRIGHT 2306
#define SCI_CHARRIGHTEXTEND 2307
#define SCI_WORDLEFT 2308
#define SCI_WORDLEFTEXTEND 2309
#define SCI_WORDRIGHT 2310
#define SCI_WORDRIGHTEXTEND 2311
#define SCI_HOME 2312
#define SCI_HOMEEXTEND 2313
#define SCI_LINEEND 2314
#define SCI_LINEENDEXTEND 2315
#define SCI_DOCUMENTSTART 2316
#define SCI_DOCUMENTSTARTEXTEND 2317
#define SCI_DOCUMENTEND 2318
#define SCI_DOCUMENTENDEXTEND 2319
#define SCI_PAGEUP 2320
#define SCI_PAGEUPEXTEND 2321
#define SCI_PAGEDOWN 2322
#define SCI_PAGEDOWNEXTEND 2323
#define SCI_EDITTOGGLEOVERTYPE 2324
#define SCI_CANCEL 2325
#define SCI_DELETEBACK 2326
#define SCI_TAB 2327
#define SCI_BACKTAB 2328
#define SCI_NEWLINE 2329
#define SCI_FORMFEED 2330
#define SCI_VCHOME 2331
#define SCI_VCHOMEEXTEND 2332
#define SCI_ZOOMIN 2333
#define SCI_ZOOMOUT 2334
#define SCI_DELWORDLEFT 2335
#define SCI_DELWORDRIGHT 2336
#define SCI_DELWORDRIGHTEND 2518
#define SCI_LINECUT 2337
#define SCI_LINEDELETE 2338
#define SCI_LINETRANSPOSE 2339
#define SCI_LINEDUPLICATE 2404
#define SCI_LOWERCASE 2340
#define SCI_UPPERCASE 2341
#define SCI_LINESCROLLDOWN 2342
#define SCI_LINESCROLLUP 2343
#define SCI_DELETEBACKNOTLINE 2344
#define SCI_HOMEDISPLAY 2345
#define SCI_HOMEDISPLAYEXTEND 2346
#define SCI_LINEENDDISPLAY 2347
#define SCI_LINEENDDISPLAYEXTEND 2348
#define SCI_HOMEWRAP 2349
#define SCI_HOMEWRAPEXTEND 2450
#define SCI_LINEENDWRAP 2451
#define SCI_LINEENDWRAPEXTEND 2452
#define SCI_VCHOMEWRAP 2453
#define SCI_VCHOMEWRAPEXTEND 2454
#define SCI_LINECOPY 2455
#define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351
#define SCI_BRACEBADLIGHT 2352
#define SCI_BRACEMATCH 2353
#define SCI_GETVIEWEOL 2355
#define SCI_SETVIEWEOL 2356
#define SCI_GETDOCPOINTER 2357
#define SCI_SETDOCPOINTER 2358
#define SCI_SETMODEVENTMASK 2359
#define EDGE_NONE 0
#define EDGE_LINE 1
#define EDGE_BACKGROUND 2
#define SCI_GETEDGECOLUMN 2360
#define SCI_SETEDGECOLUMN 2361
#define SCI_GETEDGEMODE 2362
#define SCI_SETEDGEMODE 2363
#define SCI_GETEDGECOLOUR 2364
#define SCI_SETEDGECOLOUR 2365
#define SCI_SEARCHANCHOR 2366
#define SCI_SEARCHNEXT 2367
#define SCI_SEARCHPREV 2368
#define SCI_LINESONSCREEN 2370
#define SCI_USEPOPUP 2371
#define SCI_SELECTIONISRECTANGLE 2372
#define SCI_SETZOOM 2373
#define SCI_GETZOOM 2374
#define SCI_CREATEDOCUMENT 2375
#define SCI_ADDREFDOCUMENT 2376
#define SCI_RELEASEDOCUMENT 2377
#define SCI_GETMODEVENTMASK 2378
#define SCI_SETFOCUS 2380
#define SCI_GETFOCUS 2381
#define SC_STATUS_OK 0
#define SC_STATUS_FAILURE 1
#define SC_STATUS_BADALLOC 2
#define SCI_SETSTATUS 2382
#define SCI_GETSTATUS 2383
#define SCI_SETMOUSEDOWNCAPTURES 2384
#define SCI_GETMOUSEDOWNCAPTURES 2385
#define SC_CURSORNORMAL -1
#define SC_CURSORWAIT 4
#define SCI_SETCURSOR 2386
#define SCI_GETCURSOR 2387
#define SCI_SETCONTROLCHARSYMBOL 2388
#define SCI_GETCONTROLCHARSYMBOL 2389
#define SCI_WORDPARTLEFT 2390
#define SCI_WORDPARTLEFTEXTEND 2391
#define SCI_WORDPARTRIGHT 2392
#define SCI_WORDPARTRIGHTEXTEND 2393
#define VISIBLE_SLOP 0x01
#define VISIBLE_STRICT 0x04
#define SCI_SETVISIBLEPOLICY 2394
#define SCI_DELLINELEFT 2395
#define SCI_DELLINERIGHT 2396
#define SCI_SETXOFFSET 2397
#define SCI_GETXOFFSET 2398
#define SCI_CHOOSECARETX 2399
#define SCI_GRABFOCUS 2400
#define CARET_SLOP 0x01
#define CARET_STRICT 0x04
#define CARET_JUMPS 0x10
#define CARET_EVEN 0x08
#define SCI_SETXCARETPOLICY 2402
#define SCI_SETYCARETPOLICY 2403
#define SCI_SETPRINTWRAPMODE 2406
#define SCI_GETPRINTWRAPMODE 2407
#define SCI_SETHOTSPOTACTIVEFORE 2410
#define SCI_GETHOTSPOTACTIVEFORE 2494
#define SCI_SETHOTSPOTACTIVEBACK 2411
#define SCI_GETHOTSPOTACTIVEBACK 2495
#define SCI_SETHOTSPOTACTIVEUNDERLINE 2412
#define SCI_GETHOTSPOTACTIVEUNDERLINE 2496
#define SCI_SETHOTSPOTSINGLELINE 2421
#define SCI_GETHOTSPOTSINGLELINE 2497
#define SCI_PARADOWN 2413
#define SCI_PARADOWNEXTEND 2414
#define SCI_PARAUP 2415
#define SCI_PARAUPEXTEND 2416
#define SCI_POSITIONBEFORE 2417
#define SCI_POSITIONAFTER 2418
#define SCI_COPYRANGE 2419
#define SCI_COPYTEXT 2420
#define SC_SEL_STREAM 0
#define SC_SEL_RECTANGLE 1
#define SC_SEL_LINES 2
#define SC_SEL_THIN 3
#define SCI_SETSELECTIONMODE 2422
#define SCI_GETSELECTIONMODE 2423
#define SCI_GETLINESELSTARTPOSITION 2424
#define SCI_GETLINESELENDPOSITION 2425
#define SCI_LINEDOWNRECTEXTEND 2426
#define SCI_LINEUPRECTEXTEND 2427
#define SCI_CHARLEFTRECTEXTEND 2428
#define SCI_CHARRIGHTRECTEXTEND 2429
#define SCI_HOMERECTEXTEND 2430
#define SCI_VCHOMERECTEXTEND 2431
#define SCI_LINEENDRECTEXTEND 2432
#define SCI_PAGEUPRECTEXTEND 2433
#define SCI_PAGEDOWNRECTEXTEND 2434
#define SCI_STUTTEREDPAGEUP 2435
#define SCI_STUTTEREDPAGEUPEXTEND 2436
#define SCI_STUTTEREDPAGEDOWN 2437
#define SCI_STUTTEREDPAGEDOWNEXTEND 2438
#define SCI_WORDLEFTEND 2439
#define SCI_WORDLEFTENDEXTEND 2440
#define SCI_WORDRIGHTEND 2441
#define SCI_WORDRIGHTENDEXTEND 2442
#define SCI_SETWHITESPACECHARS 2443
#define SCI_SETCHARSDEFAULT 2444
#define SCI_AUTOCGETCURRENT 2445
#define SCI_AUTOCGETCURRENTTEXT 2610
#define SCI_ALLOCATE 2446
#define SCI_TARGETASUTF8 2447
#define SCI_SETLENGTHFORENCODE 2448
#define SCI_ENCODEDFROMUTF8 2449
#define SCI_FINDCOLUMN 2456
#define SCI_GETCARETSTICKY 2457
#define SCI_SETCARETSTICKY 2458
#define SC_CARETSTICKY_OFF 0
#define SC_CARETSTICKY_ON 1
#define SC_CARETSTICKY_WHITESPACE 2
#define SCI_TOGGLECARETSTICKY 2459
#define SCI_SETPASTECONVERTENDINGS 2467
#define SCI_GETPASTECONVERTENDINGS 2468
#define SCI_SELECTIONDUPLICATE 2469
#define SC_ALPHA_TRANSPARENT 0
#define SC_ALPHA_OPAQUE 255
#define SC_ALPHA_NOALPHA 256
#define SCI_SETCARETLINEBACKALPHA 2470
#define SCI_GETCARETLINEBACKALPHA 2471
#define CARETSTYLE_INVISIBLE 0
#define CARETSTYLE_LINE 1
#define CARETSTYLE_BLOCK 2
#define SCI_SETCARETSTYLE 2512
#define SCI_GETCARETSTYLE 2513
#define SCI_SETINDICATORCURRENT 2500
#define SCI_GETINDICATORCURRENT 2501
#define SCI_SETINDICATORVALUE 2502
#define SCI_GETINDICATORVALUE 2503
#define SCI_INDICATORFILLRANGE 2504
#define SCI_INDICATORCLEARRANGE 2505
#define SCI_INDICATORALLONFOR 2506
#define SCI_INDICATORVALUEAT 2507
#define SCI_INDICATORSTART 2508
#define SCI_INDICATOREND 2509
#define SCI_SETPOSITIONCACHE 2514
#define SCI_GETPOSITIONCACHE 2515
#define SCI_COPYALLOWLINE 2519
#define SCI_GETCHARACTERPOINTER 2520
#define SCI_SETKEYSUNICODE 2521
#define SCI_GETKEYSUNICODE 2522
#define SCI_INDICSETALPHA 2523
#define SCI_INDICGETALPHA 2524
#define SCI_SETEXTRAASCENT 2525
#define SCI_GETEXTRAASCENT 2526
#define SCI_SETEXTRADESCENT 2527
#define SCI_GETEXTRADESCENT 2528
#define SCI_MARKERSYMBOLDEFINED 2529
#define SCI_MARGINSETTEXT 2530
#define SCI_MARGINGETTEXT 2531
#define SCI_MARGINSETSTYLE 2532
#define SCI_MARGINGETSTYLE 2533
#define SCI_MARGINSETSTYLES 2534
#define SCI_MARGINGETSTYLES 2535
#define SCI_MARGINTEXTCLEARALL 2536
#define SCI_MARGINSETSTYLEOFFSET 2537
#define SCI_MARGINGETSTYLEOFFSET 2538
#define SCI_ANNOTATIONSETTEXT 2540
#define SCI_ANNOTATIONGETTEXT 2541
#define SCI_ANNOTATIONSETSTYLE 2542
#define SCI_ANNOTATIONGETSTYLE 2543
#define SCI_ANNOTATIONSETSTYLES 2544
#define SCI_ANNOTATIONGETSTYLES 2545
#define SCI_ANNOTATIONGETLINES 2546
#define SCI_ANNOTATIONCLEARALL 2547
#define ANNOTATION_HIDDEN 0
#define ANNOTATION_STANDARD 1
#define ANNOTATION_BOXED 2
#define SCI_ANNOTATIONSETVISIBLE 2548
#define SCI_ANNOTATIONGETVISIBLE 2549
#define SCI_ANNOTATIONSETSTYLEOFFSET 2550
#define SCI_ANNOTATIONGETSTYLEOFFSET 2551
#define UNDO_MAY_COALESCE 1
#define SCI_ADDUNDOACTION 2560
#define SCI_CHARPOSITIONFROMPOINT 2561
#define SCI_CHARPOSITIONFROMPOINTCLOSE 2562
#define SCI_SETMULTIPLESELECTION 2563
#define SCI_GETMULTIPLESELECTION 2564
#define SCI_SETADDITIONALSELECTIONTYPING 2565
#define SCI_GETADDITIONALSELECTIONTYPING 2566
#define SCI_SETADDITIONALCARETSBLINK 2567
#define SCI_GETADDITIONALCARETSBLINK 2568
#define SCI_SETADDITIONALCARETSVISIBLE 2608
#define SCI_GETADDITIONALCARETSVISIBLE 2609
#define SCI_GETSELECTIONS 2570
#define SCI_CLEARSELECTIONS 2571
#define SCI_SETSELECTION 2572
#define SCI_ADDSELECTION 2573
#define SCI_SETMAINSELECTION 2574
#define SCI_GETMAINSELECTION 2575
#define SCI_SETSELECTIONNCARET 2576
#define SCI_GETSELECTIONNCARET 2577
#define SCI_SETSELECTIONNANCHOR 2578
#define SCI_GETSELECTIONNANCHOR 2579
#define SCI_SETSELECTIONNCARETVIRTUALSPACE 2580
#define SCI_GETSELECTIONNCARETVIRTUALSPACE 2581
#define SCI_SETSELECTIONNANCHORVIRTUALSPACE 2582
#define SCI_GETSELECTIONNANCHORVIRTUALSPACE 2583
#define SCI_SETSELECTIONNSTART 2584
#define SCI_GETSELECTIONNSTART 2585
#define SCI_SETSELECTIONNEND 2586
#define SCI_GETSELECTIONNEND 2587
#define SCI_SETRECTANGULARSELECTIONCARET 2588
#define SCI_GETRECTANGULARSELECTIONCARET 2589
#define SCI_SETRECTANGULARSELECTIONANCHOR 2590
#define SCI_GETRECTANGULARSELECTIONANCHOR 2591
#define SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE 2592
#define SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE 2593
#define SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE 2594
#define SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE 2595
#define SCVS_NONE 0
#define SCVS_RECTANGULARSELECTION 1
#define SCVS_USERACCESSIBLE 2
#define SCI_SETVIRTUALSPACEOPTIONS 2596
#define SCI_GETVIRTUALSPACEOPTIONS 2597
#define SCI_SETRECTANGULARSELECTIONMODIFIER 2598
#define SCI_GETRECTANGULARSELECTIONMODIFIER 2599
#define SCI_SETADDITIONALSELFORE 2600
#define SCI_SETADDITIONALSELBACK 2601
#define SCI_SETADDITIONALSELALPHA 2602
#define SCI_GETADDITIONALSELALPHA 2603
#define SCI_SETADDITIONALCARETFORE 2604
#define SCI_GETADDITIONALCARETFORE 2605
#define SCI_ROTATESELECTION 2606
#define SCI_SWAPMAINANCHORCARET 2607
#define SCI_CHANGELEXERSTATE 2617
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCI_SETLEXER 4001
#define SCI_GETLEXER 4002
#define SCI_COLOURISE 4003
#define SCI_SETPROPERTY 4004
#define KEYWORDSET_MAX 8
#define SCI_SETKEYWORDS 4005
#define SCI_SETLEXERLANGUAGE 4006
#define SCI_LOADLEXERLIBRARY 4007
#define SCI_GETPROPERTY 4008
#define SCI_GETPROPERTYEXPANDED 4009
#define SCI_GETPROPERTYINT 4010
#define SCI_GETSTYLEBITSNEEDED 4011
#define SCI_GETLEXERLANGUAGE 4012
#define SCI_PRIVATELEXERCALL 4013
#define SCI_PROPERTYNAMES 4014
#define SC_TYPE_BOOLEAN 0
#define SC_TYPE_INTEGER 1
#define SC_TYPE_STRING 2
#define SCI_PROPERTYTYPE 4015
#define SCI_DESCRIBEPROPERTY 4016
#define SCI_DESCRIBEKEYWORDSETS 4017
#define SC_MOD_INSERTTEXT 0x1
#define SC_MOD_DELETETEXT 0x2
#define SC_MOD_CHANGESTYLE 0x4
#define SC_MOD_CHANGEFOLD 0x8
#define SC_PERFORMED_USER 0x10
#define SC_PERFORMED_UNDO 0x20
#define SC_PERFORMED_REDO 0x40
#define SC_MULTISTEPUNDOREDO 0x80
#define SC_LASTSTEPINUNDOREDO 0x100
#define SC_MOD_CHANGEMARKER 0x200
#define SC_MOD_BEFOREINSERT 0x400
#define SC_MOD_BEFOREDELETE 0x800
#define SC_MULTILINEUNDOREDO 0x1000
#define SC_STARTACTION 0x2000
#define SC_MOD_CHANGEINDICATOR 0x4000
#define SC_MOD_CHANGELINESTATE 0x8000
#define SC_MOD_CHANGEMARGIN 0x10000
#define SC_MOD_CHANGEANNOTATION 0x20000
#define SC_MOD_CONTAINER 0x40000
#define SC_MOD_LEXERSTATE 0x80000
#define SC_MODEVENTMASKALL 0xFFFFF
#define SC_SEARCHRESULT_LINEBUFFERMAXLENGTH 1024
#define SCEN_CHANGE 768
#define SCEN_SETFOCUS 512
#define SCEN_KILLFOCUS 256
#define SCK_DOWN 300
#define SCK_UP 301
#define SCK_LEFT 302
#define SCK_RIGHT 303
#define SCK_HOME 304
#define SCK_END 305
#define SCK_PRIOR 306
#define SCK_NEXT 307
#define SCK_DELETE 308
#define SCK_INSERT 309
#define SCK_ESCAPE 7
#define SCK_BACK 8
#define SCK_TAB 9
#define SCK_RETURN 13
#define SCK_ADD 310
#define SCK_SUBTRACT 311
#define SCK_DIVIDE 312
#define SCK_WIN 313
#define SCK_RWIN 314
#define SCK_MENU 315
#define SCMOD_NORM 0
#define SCMOD_SHIFT 1
#define SCMOD_CTRL 2
#define SCMOD_ALT 4
#define SCMOD_SUPER 8
#define SCN_STYLENEEDED 2000
#define SCN_CHARADDED 2001
#define SCN_SAVEPOINTREACHED 2002
#define SCN_SAVEPOINTLEFT 2003
#define SCN_MODIFYATTEMPTRO 2004
#define SCN_KEY 2005
#define SCN_DOUBLECLICK 2006
#define SCN_UPDATEUI 2007
#define SCN_MODIFIED 2008
#define SCN_MACRORECORD 2009
#define SCN_MARGINCLICK 2010
#define SCN_NEEDSHOWN 2011
#define SCN_PAINTED 2013
#define SCN_USERLISTSELECTION 2014
#define SCN_URIDROPPED 2015
#define SCN_DWELLSTART 2016
#define SCN_DWELLEND 2017
#define SCN_ZOOM 2018
#define SCN_HOTSPOTCLICK 2019
#define SCN_HOTSPOTDOUBLECLICK 2020
#define SCN_CALLTIPCLICK 2021
#define SCN_AUTOCSELECTION 2022
#define SCN_INDICATORCLICK 2023
#define SCN_INDICATORRELEASE 2024
#define SCN_AUTOCCANCELLED 2025
#define SCN_AUTOCCHARDELETED 2026
#define SCN_SCROLLED 2080
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
/* These structures are defined to be exactly the same shape as the Win32
* CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs.
* So older code that treats Scintilla as a RichEdit will work. */
#ifdef SCI_NAMESPACE
namespace Scintilla {
#endif
struct Sci_CharacterRange {
long cpMin;
long cpMax;
};
struct Sci_TextRange {
struct Sci_CharacterRange chrg;
char *lpstrText;
};
struct Sci_TextToFind {
struct Sci_CharacterRange chrg;
char *lpstrText;
struct Sci_CharacterRange chrgText;
};
#define CharacterRange Sci_CharacterRange
#define TextRange Sci_TextRange
#define TextToFind Sci_TextToFind
typedef void *Sci_SurfaceID;
struct Sci_Rectangle {
int left;
int top;
int right;
int bottom;
};
/* This structure is used in printing and requires some of the graphics types
* from Platform.h. Not needed by most client code. */
struct Sci_RangeToFormat {
Sci_SurfaceID hdc;
Sci_SurfaceID hdcTarget;
struct Sci_Rectangle rc;
struct Sci_Rectangle rcPage;
struct Sci_CharacterRange chrg;
};
#define RangeToFormat Sci_RangeToFormat
struct Sci_NotifyHeader {
/* Compatible with Windows NMHDR.
* hwndFrom is really an environment specific window handle or pointer
* but most clients of Scintilla.h do not have this type visible. */
void *hwndFrom;
uptr_t idFrom;
unsigned int code;
};
#define NotifyHeader Sci_NotifyHeader
struct SCNotification {
struct Sci_NotifyHeader nmhdr;
int position; /* SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND */
int ch; /* SCN_CHARADDED, SCN_KEY */
int modifiers; /* SCN_KEY */
int modificationType; /* SCN_MODIFIED */
const char *text; /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */
int length; /* SCN_MODIFIED */
int linesAdded; /* SCN_MODIFIED */
int message; /* SCN_MACRORECORD */
uptr_t wParam; /* SCN_MACRORECORD */
sptr_t lParam; /* SCN_MACRORECORD */
int line; /* SCN_MODIFIED */
int foldLevelNow; /* SCN_MODIFIED */
int foldLevelPrev; /* SCN_MODIFIED */
int margin; /* SCN_MARGINCLICK */
int listType; /* SCN_USERLISTSELECTION */
int x; /* SCN_DWELLSTART, SCN_DWELLEND */
int y; /* SCN_DWELLSTART, SCN_DWELLEND */
int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */
int annotationLinesAdded; /* SC_MOD_CHANGEANNOTATION */
};
struct SearchResultMarking {
long _start;
long _end;
};
struct SearchResultMarkings {
long _length;
SearchResultMarking *_markings;
};
#ifdef SCI_NAMESPACE
}
#endif
#ifdef INCLUDE_DEPRECATED_FEATURES
#define SC_CP_DBCS 1
#endif
#endif
| [
"donho@9e717b3d-e3cd-45c4-bdc4-af0eb0386351",
"harrybharry@9e717b3d-e3cd-45c4-bdc4-af0eb0386351"
]
| [
[
[
1,
889
],
[
891,
997
]
],
[
[
890,
890
]
]
]
|
5828e61e89636a7515dd137713f0ec5003c5dbea | 9a6a9d17dde3e8888d8183618a02863e46f072f1 | /SettingsDialog2.h | 4035cd634979835d8ef349c2b7f4dadd26c5159d | []
| no_license | pritykovskaya/max-visualization | 34266c449fb2c03bed6fd695e0b54f144d78e123 | a3c0879a8030970bb1fee95d2bfc6ccf689972ea | refs/heads/master | 2021-01-21T12:23:01.436525 | 2011-07-06T18:23:38 | 2011-07-06T18:23:38 | 2,006,225 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 400 | h | #pragma once
// SettingsDialog2 dialog
class SettingsDialog2 : public CDialog
{
DECLARE_DYNAMIC(SettingsDialog2)
public:
SettingsDialog2(CWnd* pParent = NULL); // standard constructor
virtual ~SettingsDialog2();
// Dialog Data
enum { IDD = IDD_DIALOG1 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
};
| [
"[email protected]"
]
| [
[
[
1,
22
]
]
]
|
7822f11b5f286b9aaa5caeccc602b062833b5e11 | 79cbdf99590cb47e7b8020da2db7fd400b028c4c | /include/mt/QtMessageQueue.h | 87a1f7e5733266532d030ba8a5123b655478f692 | []
| no_license | jmckaskill/mt | af1b471478d03d554fb84b4f0bd0887575c78507 | 485a786c49ea7d2995eada4f1ccb230ed155a18a | refs/heads/master | 2020-06-09T01:03:41.579618 | 2011-02-26T05:26:14 | 2011-02-26T05:26:14 | 1,413,794 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,678 | h | /* vim: ts=4 sw=4 sts=4 et
*
* Copyright (c) 2009 James R. McKaskill
*
* This software is licensed under the stock MIT license:
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* ----------------------------------------------------------------------------
*/
#pragma once
#include <mt/message.h>
#include <QtCore/QEvent>
#include <QtCore/QObject>
#include <QtCore/QCoreApplication>
namespace MT
{
// Use a global of a dummy template to get a weakly linked global variable
namespace detail {
template <class Tag = void>
struct EventType {
static QEvent::Type type;
};
EventType<Tag>::type = (QEvent::Type) QEvent::registerEventType();
}
class QtMessageQueue : public QObject
{
public:
QtMessageQueue() {
m_EventType = detail::EventType<>::type;
m_Queue = MT_NewMessageQueue();
MT_SetMessageQueueWakeup(m_Queue, BindVoid(&PostWakeup, this));
}
~QtMessageQueue() {
MT_FreeMessageQueue(m_Queue);
}
virtual bool event(QEvent* e) {
if (e->type == m_EventType) {
MT_ProcessMessageQueue(m_Queue);
return true;
} else {
return QObject::event(e);
}
}
void setCurrent() {
MT_SetCurrentMessageQueue(m_Queue);
}
MT_MessageQueue* queue() {
return m_Queue;
}
private:
static void PostWakeup(QtMessageQueue* s) {
QCoreApplication::postEvent(s, new QEvent(m_EventType));
}
QEvent::Type m_EventType;
MT_MessageQueue* m_Queue;
};
}
| [
"[email protected]"
]
| [
[
[
1,
89
]
]
]
|
941512dd4123aa656fae886a312e5386c0def20d | ef8e875dbd9e81d84edb53b502b495e25163725c | /litewiz/src/user_interface/file_cluster_list_view.cpp | 6aa144bbd4870bd4db42178d96d31e138e7f7aeb | []
| no_license | panone/litewiz | 22b9d549097727754c9a1e6286c50c5ad8e94f2d | e80ed9f9d845b08c55b687117acb1ed9b6e9a444 | refs/heads/master | 2021-01-10T19:54:31.146153 | 2010-10-01T13:29:38 | 2010-10-01T13:29:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,543 | cpp | /*******************************************************************************
*******************************************************************************/
#include <QAction>
#include <QContextMenuEvent>
#include <QListView>
#include <QMenu>
#include "utility.h"
#include "context_menu_info.h"
#include "file_cluster_list_model.h"
#include "file_cluster_list_view.h"
/*******************************************************************************
*******************************************************************************/
FileClusterListView::FileClusterListView
(
QWidget * const parent
) :
QListView( parent )
{
createActions();
connectSignals();
}
/*******************************************************************************
*******************************************************************************/
void FileClusterListView::setModel
(
FileClusterListModel * model
)
{
QListView::setModel( model );
connect( this, SIGNAL( contextMenuRequest( ContextMenuInfo * const ) ), model, SLOT( initContextMenu( ContextMenuInfo * const ) ) );
connect( this, SIGNAL( excludeRequest( QIntList, bool ) ), model, SLOT( exclude( QIntList, bool ) ) );
connect( model, SIGNAL( selectionMoved( QItemSelection ) ), this, SLOT( setSelection( QItemSelection ) ) );
}
/*******************************************************************************
*******************************************************************************/
void FileClusterListView::createActions
(
void
)
{
excludeAction = new QAction( tr( "&Exclude" ), this );
includeAction = new QAction( tr( "&Include" ), this );
renameAction = new QAction( tr( "&Rename" ), this );
}
/*******************************************************************************
*******************************************************************************/
void FileClusterListView::connectSignals
(
void
)
{
connect( excludeAction, SIGNAL( triggered() ), this, SLOT( exclude() ) );
connect( includeAction, SIGNAL( triggered() ), this, SLOT( include() ) );
connect( renameAction, SIGNAL( triggered() ), this, SLOT( rename() ) );
}
/*******************************************************************************
*******************************************************************************/
QIntList FileClusterListView::getSelection
(
void
)
{
QIntList result;
foreach ( QModelIndex const & index, selectedIndexes() )
{
result.append( index.row() );
}
return result;
}
/*******************************************************************************
*******************************************************************************/
void FileClusterListView::exclude
(
void
)
{
emit excludeRequest( getSelection(), true );
}
/*******************************************************************************
*******************************************************************************/
void FileClusterListView::include
(
void
)
{
emit excludeRequest( getSelection(), false );
}
/*******************************************************************************
*******************************************************************************/
void FileClusterListView::rename
(
void
)
{
edit( selectedIndexes().first() );
}
/*******************************************************************************
*******************************************************************************/
void FileClusterListView::setSelection
(
QItemSelection const & selection
)
{
selectionModel()->select( selection, QItemSelectionModel::ClearAndSelect );
selectionModel()->setCurrentIndex( selection.indexes().first(), QItemSelectionModel::Select );
}
/*******************************************************************************
*******************************************************************************/
void FileClusterListView::contextMenuEvent
(
QContextMenuEvent * event
)
{
ContextMenuInfo menuInfo = getDefaultContextMenu();
emit contextMenuRequest( &menuInfo );
QMenu menu( this );
populateContextMenu( menuInfo, &menu );
menu.exec( event->globalPos() );
}
/*******************************************************************************
*******************************************************************************/
ContextMenuInfo FileClusterListView::getDefaultContextMenu
(
void
)
{
ContextMenuInfo result( getSelection() );
result.addMenuEntry( ContextMenuInfo::Exclude );
result.addMenuEntry( ContextMenuInfo::Include );
return result;
}
/*******************************************************************************
*******************************************************************************/
void FileClusterListView::populateContextMenu
(
ContextMenuInfo const & menuInfo,
QMenu * const menu
)
{
if ( menuInfo.hasMenuEntry( ContextMenuInfo::Exclude ) )
{
menu->addAction( excludeAction );
}
if ( menuInfo.hasMenuEntry( ContextMenuInfo::Include ) )
{
menu->addAction( includeAction );
}
if ( menuInfo.hasMenuEntry( ContextMenuInfo::Rename ) )
{
menu->addSeparator();
menu->addAction( renameAction );
}
}
/******************************************************************************/
| [
"[email protected]"
]
| [
[
[
1,
180
]
]
]
|
1431bcdb42a64b00e91d17be0934f7b9fa54b5a4 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Common/Scd/ScdLib/GDIBLK.CPP | 50d072afe8d7f5a737d76ecbc349b3b0f3da6831 | []
| 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 | 21,673 | cpp | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#include "stdafx.h"
#define __GDIBLK_CPP
#include "sc_defs.h"
#include "gpfuncs.h"
#include "gdiblk.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#define BoxOverlap 1
#define NewFont 01
//===========================================================================
pGDIBlkCfg GDIBlkCfg::List=NULL;
GDIBlkCfg::GDIBlkCfg(pchar pName_)
{
strncpy(Name, pName_, sizeof(Name));
crText[0] = RGB(0x00, 0x00, 0x00);
crText[1] = RGB(0xff, 0xff, 0xff);
crTextChg[0] = RGB(0x00, 0x00, 0xff);
crTextChg[1] = RGB(0xff, 0xff, 0xff);
crTextDef[0] = RGB( 0, 140, 140);
crTextDef[1] = RGB(0xff, 0xff, 0xff);
// crTextChg[1] = RGB(0x00, 0x00, 0xff);
// crTextInvalid = RGB(0x80, 0x80, 0x80);
crTextInvalid[0] = RGB(0x60, 0x60, 0x60);
crTextInvalid[1] = RGB(0xc0, 0xc0, 0xc0);
// crTextInvalid[1] = RGB(0xff, 0xff, 0xff);
crTextError[0] = RGB(0xff, 0x00, 0x00);
crTextError[1] = RGB(0xff, 0x00, 0x00);
crTxtBackError = RGB(0xc0, 0xc0, 0xc0);
crTxtBackSelect = RGB(0x00, 0x00, 0x80);
crTxtBackRmtData = RGB(0x00, 0xc0, 0x00);
crTxtBackRmtChgd = RGB(0xc0, 0xc0, 0x00);
crTxtFore = RGB(0xff, 0xff, 0xff);
crTxtBack = RGB(0xc0, 0xc0, 0xc0);
crTxtEdgeLight = RGB(0xe0, 0xe0, 0xe0);
crTxtEdgeDark = RGB(0x60, 0x60, 0x60);
crTxtBord = RGB(0x00, 0x00, 0x00);
crGrfGrid = RGB(0x80, 0x80, 0x80);
crGrfBack = RGB(0x00, 0x00, 0x00);
crGrfAxes = RGB(0xc0, 0xc0, 0xc0);
crTrndGrid = RGB(0x80, 0x80, 0x80);
crTrndBack = RGB(0x00, 0x00, 0x00);
crTrndAxes = RGB(0xc0, 0xc0, 0xc0);
for (int i=0; i<MaxGDILines; i++)
{
LineLogBrush[i].lbStyle = PS_SOLID;
LineLogBrush[i].lbColor = RGB(0xff, 0xff, 0xff); // All The Same For Now
LineLogBrush[i].lbHatch = 0;
LineLogBrushDim[i].lbStyle = PS_SOLID; // All The Same For Now
LineLogBrushDim[i].lbColor = RGB(0x40, 0x40, 0x40);
LineLogBrushDim[i].lbHatch = 0;
}
LineLogBrushDim[1].lbColor = RGB(0x80, 0x80, 0x80);
LineLogBrushDim[2].lbColor = RGB(0xc0, 0xc0, 0xc0);
LineLogBrushDim[3].lbColor = RGB(0xc0, 0x00, 0x00);
LineLogBrushDim[4].lbColor = RGB(0x00, 0xc0, 0x00);
LineLogBrushDim[5].lbColor = RGB(0x00, 0x00, 0xc0);
LineLogBrush[3].lbColor = RGB(0xff, 0x00, 0x00);
LineLogBrush[4].lbColor = RGB(0x00, 0xff, 0x00);
LineLogBrush[5].lbColor = RGB(0x00, 0x00, 0xff);
#if NewFont
FontHgt[0]= 9;
SmlFontHgt[0]= 8;
#else
FontHgt[0]= 7;
SmlFontHgt[0]= 7;
#endif
FontHgt[1]= 9;
SmlFontHgt[1]= 9;
FontHgt[2]= 11;
SmlFontHgt[2]= 11;
//#if NewFont
// FontHgt[3]= 9;
// SmlFontHgt[3]= 9;
//#else
// FontHgt[3]= 7;
// SmlFontHgt[3]= 7;
//#endif
// FontHgt[4]= 9;
// SmlFontHgt[4]= 9;
// FontHgt[5]= 11;
// SmlFontHgt[5]= 11;
for (i=0; i<MaxGDIFonts ; i++)
{
LogFont[i].lfHeight =0;
LogFont[i].lfWidth =0;
LogFont[i].lfEscapement =0;
LogFont[i].lfOrientation =0;
LogFont[i].lfWeight =FW_REGULAR;
LogFont[i].lfItalic =0;// (i>=MaxGDIFonts/2) ? TRUE : FALSE;
LogFont[i].lfUnderline =0;
LogFont[i].lfStrikeOut =0;
LogFont[i].lfCharSet =1;
LogFont[i].lfOutPrecision = OUT_DEFAULT_PRECIS;
LogFont[i].lfClipPrecision = CLIP_DEFAULT_PRECIS;
LogFont[i].lfQuality = DEFAULT_QUALITY;
LogFont[i].lfPitchAndFamily = FIXED_PITCH|FF_MODERN;
// strcpy(LogFont[i].lfFaceName, "Courier");
#if NewFont
strcpy(LogFont[i].lfFaceName, "Lucida Console");
// strcpy(LogFont[i].lfFaceName, "MS Sans Serif");
#else
strcpy(LogFont[i].lfFaceName, "Courier");
#endif
}
ScrollBarSize = 15;
fGrfRevGrayScaleOnPrint = 1;
Next=List;
List=this;
TRACE("Cons:%8x\n", this);
};
//---------------------------------------------------------------------------
GDIBlkCfg::~GDIBlkCfg()
{
TRACE("Delete GDIBLKCfg:%8x\n", this);
if (List==this)
List=Next;
else
{
pGDIBlkCfg p=List;
while (p->Next!=this)
p=p->Next;
if (p->Next!=NULL)
p->Next=p->Next->Next;
}
//Save();
};
//---------------------------------------------------------------------------
GDIBlkCfg::GDIBlkCfg(const GDIBlkCfg &S)
{
*this=S;
Next=List;
List=this;
}
//---------------------------------------------------------------------------
GDIBlkCfg& GDIBlkCfg::operator=(const GDIBlkCfg &S)
{
strncpy(Name,S.Name,sizeof(Name));
crText[0] = S.crText[0];
crText[1] = S.crText[1];
crTextChg[0] = S.crTextChg[0];
crTextChg[1] = S.crTextChg[1];
crTextDef[0] = S.crTextDef[0];
crTextDef[1] = S.crTextDef[1];
crTextInvalid[0] = S.crTextInvalid[0];
crTextInvalid[1] = S.crTextInvalid[1];
crTextError[0] = S.crTextError[0];
crTextError[1] = S.crTextError[1];
crTxtBackError = S.crTxtBackError;
crTxtBackSelect = S.crTxtBackSelect;
crTxtBackRmtData = S.crTxtBackRmtData;
crTxtBackRmtChgd = S.crTxtBackRmtChgd;
crTxtFore = S.crTxtFore;
crTxtBack = S.crTxtBack;
crTxtEdgeLight = S.crTxtEdgeLight;
crTxtEdgeDark = S.crTxtEdgeDark;
crTxtBord = S.crTxtBord;
crGrfGrid = S.crGrfGrid;
crGrfBack = S.crGrfBack;
crGrfAxes = S.crGrfAxes;
crTrndGrid = S.crTrndGrid;
crTrndBack = S.crTrndBack;
crTrndAxes = S.crTrndAxes;
for (int i=0; i<MaxGDILines; i++)
{
LineLogBrush[i]=S.LineLogBrush[i];
LineLogBrushDim[i]=S.LineLogBrushDim[i];
}
for (i=0; i<MaxGDIFonts ; i++)
{
FontHgt[i] = S.FontHgt[i];
SmlFontHgt[i] = S.SmlFontHgt[i];
LogFont[i] = S.LogFont[i];
}
ScrollBarSize = S.ScrollBarSize;
fGrfRevGrayScaleOnPrint = S.fGrfRevGrayScaleOnPrint;
return *this;
}
//---------------------------------------------------------------------------
void GDIBlkCfg::Save()
{
};
//---------------------------------------------------------------------------
void GDIBlkCfg::Restore()
{
};
//---------------------------------------------------------------------------
void GDIBlkCfg::DoConfigDialog()
{
AfxMessageBox("Configuration Dialog to come here !");
};
//---------------------------------------------------------------------------
void GDIBlkCfg::SaveAll()
{
pGDIBlkCfg p=List;
while (p)
{
p->Save();
p=p->Next;
}
};
//---------------------------------------------------------------------------
void GDIBlkCfg::RestoreAll()
{
pGDIBlkCfg p=List;
while (p)
{
p->Restore();
p=p->Next;
}
};
//===========================================================================
CRITICAL_SECTION GDIBlk::cbDrawSect;
int GDIBlk::iDrawSectBlkCnt=0;
flag GDIBlk::bIsLowRes=1;
//---------------------------------------------------------------------------
GDIBlk::GDIBlk()
{
pGBC=NULL;
pWnd=NULL;
iAttachNo=-1;
//pDC=NULL;
//pPInfo=NULL;
bValid=0;
iAttachCount=0;
if (iDrawSectBlkCnt==0)
{
InitializeCriticalSection(&cbDrawSect);
dbgpln("InitializeCriticalSection(&cbDrawSect);");
}
iDrawSectBlkCnt++;
};
//---------------------------------------------------------------------------
GDIBlk::~GDIBlk()
{
iDrawSectBlkCnt--;
Clear();
if (iDrawSectBlkCnt==0)
{
DeleteCriticalSection(&cbDrawSect);
dbgpln("DeleteCriticalSection(&cbDrawSect);");
}
}
//---------------------------------------------------------------------------
void GDIBlk::Clear()
{
if (bValid)
{
// delete pPenTxt;
delete pBrushTxtFore;
delete pBrushTxtBack;
delete pBrushTxtBackError;
delete pBrushTxtBackSelect;
delete pBrushTxtBackRmtData;
delete pBrushTxtBackRmtChgd;
delete pBrushTxtEdgeLight;
delete pBrushTxtEdgeDark;
delete pPenTxtBord;
delete pPenTxtBack;
delete pPenGrfGrid;
delete pPenGrfAxes;
delete pBrushGrfBack;
delete pPenTrndGrid;
delete pPenTrndAxes;
delete pBrushTrndBack;
for (int i=0; i<MaxGDILines; i++)
{
DeleteObject(hLinePen[i]);
DeleteObject(hLinePenDim[i]);
}
for (i=0; i<MaxGDIFonts ; i++)
{
delete pFont[i];
delete pSmlFont[i];
delete pItlFont[i];
}
}
bValid=0;
};
//---------------------------------------------------------------------------
flag GDIBlk::Create(pGDIBlkCfg pGBC_, /*pFxdEdtView pView_,*/ CWnd* pWnd_, CDC* pDC_, flag fForPrinter)
{
EnterCriticalSection(&cbDrawSect);
Clear();
pGBC=pGBC_;
pWnd=pWnd_;
// pDC=pDC_;
iAttachNo++;
Attached[iAttachNo].pDC=pDC_;
Attached[iAttachNo].pPInfo=NULL;//pPInfo_;
Attached[iAttachNo].ToPrint=false;//(pPInfo!=NULL);
Attached[iAttachNo].pOldFont=NULL;//pDC_->SelectObject(pFont[0]);
CFont * pOldFont=pDC_->GetCurrentFont();
for (int i=0; i<MaxGDIFonts; i++)
{
TEXTMETRIC tm;
pFont[i]=new CFont();
pSmlFont[i]=new CFont();
pItlFont[i]=new CFont();
pGBC->LogFont[i].lfHeight = (pGBC->FontHgt[i] * pDC_->GetDeviceCaps(LOGPIXELSY)) / 72;
pFont[i]->CreateFontIndirect(&pGBC->LogFont[i]);
pGBC->LogFont[i].lfItalic = True;
pItlFont[i]->CreateFontIndirect(&pGBC->LogFont[i]);
pGBC->LogFont[i].lfItalic = False;
pGBC->LogFont[i].lfHeight = (pGBC->SmlFontHgt[i] * pDC_->GetDeviceCaps(LOGPIXELSY)) / 72;
pSmlFont[i]->CreateFontIndirect(&pGBC->LogFont[i]);
pDC_->SelectObject(pFont[i]);
pDC_->GetTextMetrics(&tm);
#if NewFont
CharSize[i].cx=tm.tmAveCharWidth;
#else
CharSize[i].cx=tm.tmMaxCharWidth;
#endif
CharSize[i].cy=tm.tmHeight;
CharSpc[i].cx=0;//Max(1, CharSize[i].cx/20);
CharSpc[i].cy=Max(1L, long(CharSize[i].cy/6));
LineSize[i].cx=CharSize[i].cx+CharSpc[i].cx;
LineSize[i].cy=CharSize[i].cy+CharSpc[i].cy;
}
bIsLowRes = (LineSize[0].cy<17); //Crude method to test if high res graphics supported
pDC_->SelectObject(pOldFont);
if (LineSize[0].cx==0 || LineSize[0].cy==0)
{
AfxMessageBox("Aborting: Bad Font Size");
exit(-1);
}
EdgeW=Max(0,1);//CharSpc[0].cx, CharSpc[0].cy);
crText[0] = /*MakeColor(*/pGBC->crText[0]/*, fForPrinter)*/;
crText[1] = /*MakeColor(*/pGBC->crText[1]/*, fForPrinter)*/;
crTextChg[0] = /*MakeColor(*/pGBC->crTextChg[0]/*, fForPrinter)*/;
crTextChg[1] = /*MakeColor(*/pGBC->crTextChg[1]/*, fForPrinter)*/;
crTextDef[0] = /*MakeColor(*/pGBC->crTextDef[0]/*, fForPrinter)*/;
crTextDef[1] = /*MakeColor(*/pGBC->crTextDef[1]/*, fForPrinter)*/;
crTextInvalid[0] = /*MakeColor(*/pGBC->crTextInvalid[0]/*, fForPrinter)*/;
crTextInvalid[1] = /*MakeColor(*/pGBC->crTextInvalid[1]/*, fForPrinter)*/;
crTextError[0] = /*MakeColor(*/pGBC->crTextError[0];
crTextError[1] = /*MakeColor(*/pGBC->crTextError[1];
crTxtBackError = /*MakeColor(*/pGBC->crTxtBackError;
crTxtBackSelect = /*MakeColor(*/pGBC->crTxtBackSelect;
crTxtBackRmtData = /*MakeColor(*/pGBC->crTxtBackRmtData;
crTxtBackRmtChgd = /*MakeColor(*/pGBC->crTxtBackRmtChgd;
crTxtBack = /*MakeColor(*/pGBC->crTxtBack/*, fForPrinter)*/;
crTxtFore = /*MakeColor(*/pGBC->crTxtFore/*, fForPrinter)*/;
crTxtEdgeLight = /*MakeColor(*/pGBC->crTxtEdgeLight/*, fForPrinter)*/;
crTxtEdgeDark = /*MakeColor(*/pGBC->crTxtEdgeDark/*, fForPrinter)*/;
crTxtBord = /*MakeColor(*/pGBC->crTxtBord/*, fForPrinter)*/;
crGrfGrid = MakeColor(pGBC->crGrfGrid, fForPrinter);
crGrfBack = MakeColor(pGBC->crGrfBack, fForPrinter);
crGrfAxes = MakeColor(pGBC->crGrfAxes, fForPrinter);
crTrndGrid = MakeColor(pGBC->crTrndGrid, fForPrinter);
crTrndBack = MakeColor(pGBC->crTrndBack, fForPrinter);
crTrndAxes = MakeColor(pGBC->crTrndAxes, fForPrinter);
// pPenTxt = new CPen(PS_SOLID, EdgeW, crText[0]);
pBrushTxtFore = new CBrush(crTxtFore); //on Windows 98 this changes the CurrentBrush!!!
pBrushTxtBack = new CBrush(crTxtBack);
pBrushTxtBackError = new CBrush(/*pDC_->GetNearestColor*/(crTxtBackError));
pBrushTxtBackSelect = new CBrush(/*pDC_->GetNearestColor*/(crTxtBackSelect));
pBrushTxtBackRmtData= new CBrush(/*pDC_->GetNearestColor*/(crTxtBackRmtData));
pBrushTxtBackRmtChgd= new CBrush(/*pDC_->GetNearestColor*/(crTxtBackRmtChgd));
pBrushTxtEdgeLight = new CBrush(pDC_->GetNearestColor(crTxtEdgeLight));
pBrushTxtEdgeDark = new CBrush(pDC_->GetNearestColor(crTxtEdgeDark));
pPenTxtBord = new CPen(PS_SOLID, EdgeW, crTxtBord);
pPenTxtBack = new CPen(PS_SOLID, EdgeW, crTxtBack);
pPenGrfGrid = new CPen(PS_SOLID, 0, crGrfGrid);
pPenGrfAxes = new CPen(PS_SOLID, 0, crGrfAxes);
pBrushGrfBack = new CBrush(pDC_->GetNearestColor(crGrfBack));
pPenTrndGrid = new CPen(PS_SOLID, 0, crTrndGrid);
pPenTrndAxes = new CPen(PS_SOLID, 0, crTrndAxes);
pBrushTrndBack = new CBrush(pDC_->GetNearestColor(crTrndBack));
for (i=0; i<MaxGDILines; i++)
{
LineLogBrush[i] = pGBC->LineLogBrush[i];
LineLogBrush[i].lbColor = MakeColor(LineLogBrush[i].lbColor, fForPrinter);
hLinePen[i] = ::ExtCreatePen(PS_GEOMETRIC|PS_SOLID, 1, &LineLogBrush[i], 0, NULL);
LineLogBrushDim[i] = pGBC->LineLogBrushDim[i];
LineLogBrushDim[i].lbColor = MakeColor(LineLogBrushDim[i].lbColor, fForPrinter);
hLinePenDim[i] = ::ExtCreatePen(PS_GEOMETRIC|PS_SOLID, 1, &LineLogBrushDim[i], 0, NULL);;
}
LuMargin.cx=0;
LuMargin.cy=0;
LuBorder.cx=0;
LuBorder.cy=0;
ChScroll.cx=0;
ChScroll.cy=0;
ChScrollBy.cx=0;
ChScrollBy.cy=0;
bValid=1;
LeaveCriticalSection(&cbDrawSect); // Must be balanced
return True;
};
//---------------------------------------------------------------------------
COLORREF GDIBlk::MakeColor(COLORREF CR, flag fForPrinter)
{
if (pGBC->fGrfRevGrayScaleOnPrint && fForPrinter)
{
BYTE r=GetRValue(CR);
BYTE g=GetGValue(CR);
BYTE b=GetBValue(CR);
if (r==g && g==b)
return RGB(255-r, 255-g, 255-b);
}
return CR;
};
//---------------------------------------------------------------------------
flag GDIBlk::Attach(CDC* pDC_,CPrintInfo* pPInfo_)
{
EnterCriticalSection(&cbDrawSect);
iAttachNo++;
if (iAttachNo>=MaxGDIAttach)
DoBreak();
Attached[iAttachNo].pDC=pDC_;
Attached[iAttachNo].pPInfo=pPInfo_;
Attached[iAttachNo].ToPrint=(pPInfo_!=NULL);
Attached[iAttachNo].pOldFont=pDC_->SelectObject(pFont[0]);
return True;
};
//---------------------------------------------------------------------------
flag GDIBlk::Detach()
{
Attached[iAttachNo].pDC->SelectObject(Attached[iAttachNo].pOldFont);
Attached[iAttachNo].pDC=NULL;
Attached[iAttachNo].pPInfo=NULL;
iAttachNo--;
LeaveCriticalSection(&cbDrawSect); // Must be balanced
return True;
};
//---------------------------------------------------------------------------
CPoint GDIBlk::LuPt(const CPoint &Pt)
{
CPoint pt(LuMargin.cx+LuBorder.cx+(Pt.x-ChScroll.cx)*ColWdt(),
LuMargin.cy+LuBorder.cy+(Pt.y-ChScroll.cy)*RowHgt());
return pt;
}
//---------------------------------------------------------------------------
CRect GDIBlk::GetClientRect()
{
if (IsPrinting())
return Attached[iAttachNo].pPInfo->m_rectDraw;
else
{
CRect cr;
pWnd->GetClientRect(&cr);
return cr;
}
}
//---------------------------------------------------------------------------
CRect GDIBlk::ChVisibleRect(flag fVScrlBar, flag fHScrlBar)
{
CRect cr=GetClientRect();
CRect rd =LuDataRect();
int cw=ColWdt();
int rh=RowHgt();
int rsbw=fVScrlBar ? VScrlWidth() : 0 ;
int bsbh=fHScrlBar ? HScrlHeight() : 0 ;
CRect rv(Max(0L, long((cr.left-rd.left+cw-1)/cw)),
Max(0L, long((cr.top-rd.top+rh-1)/rh)),
/*Min((int)ChDataSize.cx,*/ (int)((cr.right-rd.left+1-rsbw)/cw-1),
/*Min((int)ChDataSize.cy,*/ (int)((cr.bottom-rd.top+1-bsbh)/rh-1));
return rv;
}
//---------------------------------------------------------------------------
CRect GDIBlk::LuPageRect()
{
CRect r(LuMargin.cx-ChScroll.cx*ColWdt(),
LuMargin.cy-ChScroll.cy*RowHgt(),
LuMargin.cx+2*LuBorder.cx+(ChDataSize.cx-ChScroll.cx)*ColWdt(),
LuMargin.cy+2*LuBorder.cy+(ChDataSize.cy-ChScroll.cy)*RowHgt());
return r;
}
//---------------------------------------------------------------------------
CRect GDIBlk::LuDataRect()
{
CRect r(LuMargin.cx+LuBorder.cx-ChScroll.cx*ColWdt(),
LuMargin.cy+LuBorder.cy-ChScroll.cy*RowHgt(),
LuMargin.cx+LuBorder.cx+(ChDataSize.cx-ChScroll.cx)*ColWdt(),
LuMargin.cy+LuBorder.cy+(ChDataSize.cy-ChScroll.cy)*RowHgt());
return r;
}
//---------------------------------------------------------------------------
CRect GDIBlk::LuWorkRect(flag fVScrlBar, flag fHScrlBar)
{
CRect cr=GetClientRect();
CRect rd =LuDataRect();
int cw=ColWdt();
int rh=RowHgt();
long rsbw=fVScrlBar ? VScrlWidth() : 0 ;
long bsbh=fHScrlBar ? HScrlHeight() : 0 ;
CRect rv(Max(cr.left+LuMargin.cx+LuBorder.cx, rd.left),
Max(cr.top+LuMargin.cy+LuBorder.cy,rd.top),
Min(cr.right-(LuMargin.cx+LuBorder.cx)-rsbw, rd.right),
Min(cr.bottom-(LuMargin.cy+LuBorder.cy)-bsbh, rd.bottom));
return rv;
}
//---------------------------------------------------------------------------
CRect GDIBlk::ChWorkRect(flag fVScrlBar, flag fHScrlBar)
{
// CRect cr=GetClientRect();
// CRect rd =LuDataRect();
int cw=ColWdt();
int rh=RowHgt();
// int rsbw=fVScrlBar ? VScrlWidth() : 0 ;
// int bsbh=fHScrlBar ? HScrlHeight() : 0 ;
// CRect rv(0,//(cr.left-rd.left+cw-1)/cw,
// 0,//(cr.top-rd.top+rh-1)/rh,
// (cr.right-Max(0L, rd.left-cr.left)-Max(0L, cr.right-rd.right)+1-rsbw)/cw-1,
// (cr.bottom-Max(0L, rd.top-cr.top)-Max(0L, cr.bottom-rd.bottom)+1-bsbh)/rh-1);
// //(cr.bottom-rd.top+1-bsbh)/rh-1);
CRect wr=LuWorkRect(fVScrlBar, fHScrlBar);
wr.left=wr.left/cw;
wr.right=(wr.right)/cw;
wr.top=wr.top/rh;
wr.bottom=(wr.bottom)/rh;
return wr;
}
//---------------------------------------------------------------------------
int GDIBlk::ChWorkWidth(flag fVScrlBar)
{
CRect r=ChWorkRect(fVScrlBar, False);
return r.right-r.left+1;
}
//---------------------------------------------------------------------------
int GDIBlk::ChWorkHeight(flag fHScrlBar)
{
CRect r=ChWorkRect(False, fHScrlBar);
return r.bottom-r.top+1;
}
//---------------------------------------------------------------------------
CRect GDIBlk::LuClipRect(flag fVScrlBar, flag fHScrlBar)
{
CRect cr=GetClientRect();
int rsbw=fVScrlBar ? VScrlWidth() : 0 ;
int bsbh=fHScrlBar ? HScrlHeight() : 0 ;
CRect rv(LuMargin.cx,
LuMargin.cy,
cr.right-rsbw,
cr.bottom-bsbh);
return rv;
}
//---------------------------------------------------------------------------
int GDIBlk::VScrlWidth()
{
int sbs=GBC().ScrollBarSize;
return sbs>0 ? ColWdt()*sbs/10 : GetSystemMetrics(SM_CXVSCROLL);
}
//---------------------------------------------------------------------------
int GDIBlk::HScrlHeight()
{
int sbs=GBC().ScrollBarSize;
return sbs>0 ? ColWdt()*sbs/10 : GetSystemMetrics(SM_CXHSCROLL);
}
//===========================================================================
CDCResChk::CDCResChk(CDC & DC):
dc(DC)
{
#ifdef _DEBUG
pMemBitmap =dc.GetCurrentBitmap( );
pMemBrush =dc.GetCurrentBrush( );
pMemFont =dc.GetCurrentFont( );
pMemPen =dc.GetCurrentPen( );
#endif
}
CDCResChk::CDCResChk(CDC * pDC):
dc(*pDC)
{
#ifdef _DEBUG
pMemBitmap =dc.GetCurrentBitmap( );
pMemBrush =dc.GetCurrentBrush( );
pMemFont =dc.GetCurrentFont( );
pMemPen =dc.GetCurrentPen( );
#endif
}
CDCResChk::~CDCResChk()
{
#ifdef _DEBUG
ASSERT_ALWAYS(pMemBitmap==dc.GetCurrentBitmap( ), "Bitmap not restored", __FILE__, __LINE__);
ASSERT_ALWAYS(pMemBrush ==dc.GetCurrentBrush( ), "Brush not restored", __FILE__, __LINE__);
// ASSERT_ALWAYS(pMemFont ==dc.GetCurrentFont( ), "Font not restored", __FILE__, __LINE__);
ASSERT_ALWAYS(pMemPen ==dc.GetCurrentPen( ), "Pen not restored", __FILE__, __LINE__);
#endif
}
//=========================================================================== | [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
29
],
[
32,
40
],
[
43,
166
],
[
169,
174
],
[
177,
300
],
[
303,
394
],
[
397,
402
],
[
405,
423
],
[
426,
686
],
[
691,
694
]
],
[
[
30,
31
],
[
41,
42
],
[
167,
168
],
[
175,
176
],
[
301,
302
],
[
395,
396
],
[
403,
404
],
[
424,
425
],
[
687,
690
]
]
]
|
770a22ec876a8ab16254bdb9bb6613db87aa2f84 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Dependencies/Xerces/include/xercesc/dom/impl/DOMErrorImpl.cpp | 7e4d2f4c403d87fa059cd9725307010209617dd1 | []
| 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 | 2,443 | cpp | /*
* Copyright 2002,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: DOMErrorImpl.cpp 191054 2005-06-17 02:56:35Z jberry $
*/
#include "DOMErrorImpl.hpp"
#include <xercesc/dom/DOMException.hpp>
#include <xercesc/dom/DOMLocator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// DOMErrorImpl: Constructors and Destructor
// ---------------------------------------------------------------------------
DOMErrorImpl::DOMErrorImpl(const short severity) :
fAdoptLocation(false)
, fSeverity(severity)
, fMessage(0)
, fLocation(0)
, fType(0)
, fRelatedData(0)
{
}
DOMErrorImpl::DOMErrorImpl(const short severity,
const XMLCh* const message,
DOMLocator* const location) :
fAdoptLocation(false)
, fSeverity(severity)
, fMessage(message)
, fLocation(location)
, fType(0)
, fRelatedData(0)
{
}
DOMErrorImpl::DOMErrorImpl(const short severity,
const XMLCh* type,
const XMLCh* message,
void* relatedData) :
fAdoptLocation(false)
, fSeverity(severity)
, fMessage(message)
, fLocation(0)
, fType(type)
, fRelatedData(relatedData)
{
}
DOMErrorImpl::~DOMErrorImpl()
{
if (fAdoptLocation)
delete fLocation;
}
// ---------------------------------------------------------------------------
// DOMErrorImpl: Setter methods
// ---------------------------------------------------------------------------
void DOMErrorImpl::setLocation(DOMLocator* const location)
{
if (fAdoptLocation)
delete fLocation;
fLocation = location;
}
void DOMErrorImpl::setRelatedException(void*) const
{
throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
}
XERCES_CPP_NAMESPACE_END
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
90
]
]
]
|
7b1d3f94db1432df435a900e314fade497ae1bcc | 9152cb31fbe4e82c22092bb3071b2ec8c6ae86ab | /tests/siptestwin/testwinDlg.h | 1de24a372bdad99204a347b0fcd5d64c7f25e302 | []
| no_license | zzjs2001702/sfsipua-svn | ca3051b53549066494f6264e8f3bf300b8090d17 | e8768338340254aa287bf37cf620e2c68e4ff844 | refs/heads/master | 2022-01-09T20:02:20.777586 | 2006-03-29T13:24:02 | 2006-03-29T13:24:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,445 | h | // testwinDlg.h : header file
//
#if !defined(AFX_TESTWINDLG_H__289D82D7_2A0E_4541_8C11_3B557DDA73C2__INCLUDED_)
#define AFX_TESTWINDLG_H__289D82D7_2A0E_4541_8C11_3B557DDA73C2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CTestwinDlg dialog
class CTestwinDlg : public CDialog
{
// Construction
public:
CTestwinDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CTestwinDlg)
enum { IDD = IDD_TESTWIN_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTestwinDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CTestwinDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnButton1();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnCall();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TESTWINDLG_H__289D82D7_2A0E_4541_8C11_3B557DDA73C2__INCLUDED_)
| [
"yippeesoft@5dda88da-d10c-0410-ac74-cc18da35fedd"
]
| [
[
[
1,
52
]
]
]
|
20096f2d5350f9c0d40eea6e88c509c6ddfb8370 | 2bcfdc7adc9d794391e0f79e4dab5c481ca5a09b | /applications/hac01/src/gui/mainwindow.cpp | c9a85e6e67743aaad68acc9aecb0bf45a9d85cda | []
| no_license | etop-wesley/hac | 592912a7c4023ba8bd2c25ae5de9c18d90c79b0b | ab82cb047ed15346c25ce01faff00815256b00b7 | refs/heads/master | 2021-01-02T22:45:32.603368 | 2010-09-01T08:38:01 | 2010-09-01T08:38:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,912 | cpp | //#define QT_NO_DEBUG_OUTPUT
#include <QDebug>
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f), ui(new Ui::MainWindow)
{
qDebug() << "MainWindow::MainWindow";
/* init UI */
ui->setupUi(this);
while (ui->stackedWidget->count() > 0)
ui->stackedWidget->removeWidget(ui->stackedWidget->widget(0));
#ifdef HAC_PERFORMANCE_FIXUP
ui->stackedWidget->setAttribute(Qt::WA_PaintOnScreen, true);
//ui->stackedWidget->setAttribute(Qt::WA_OpaquePaintEvent, true);
ui->stackedWidget->setAttribute(Qt::WA_NoSystemBackground, true);
ui->stackedWidget->setAutoFillBackground(false);
#endif // HAC_PERFORMANCE_FIXUP
/* setup from settings */
readSettings();
/* connect signals, we are ready to go! */
connect(ui->homeButton, SIGNAL(clicked()), this, SLOT(OnHomeButtonClicked()));
connect(ui->backButton, SIGNAL(clicked()), this, SLOT(OnBackButtonClicked()));
connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(OnStackWidgetCurrentChanged(int)));
connect(ui->stackedWidget, SIGNAL(widgetRemoved(int)), this, SLOT(OnStackWidgetWidgetRemoved(int)));
}
MainWindow::~MainWindow()
{
qDebug() << "MainWindow::~MainWindow";
writeSettings();
delete ui;
}
void MainWindow::readSettings()
{
qDebug() << "MainWindow::readSettings";
// setup background
QImage image(":/hac01/images/desktop-wallpaper.png");
if (!image.isNull()) {
QPalette palette;
palette = this->palette();
palette.setBrush(this->backgroundRole(), image);
this->setPalette(palette);
this->setAutoFillBackground(true);
} else {
qDebug() << "can not find desktop background image";
}
}
void MainWindow::writeSettings()
{
qDebug() << "MainWindow::writeSettings";
}
void MainWindow::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void MainWindow::OnHomeButtonClicked()
{
qDebug() << "MainWindow::OnHomeButtonClicked";
while (ui->stackedWidget->count() > 1) {
QWidget *widget = ui->stackedWidget->currentWidget();
ui->stackedWidget->removeWidget(widget);
delete widget;
widget = NULL;
}
}
void MainWindow::OnBackButtonClicked()
{
qDebug() << "MainWindow::OnBackButtonClicked";
if (ui->stackedWidget->count() > 1) {
QWidget *widget = ui->stackedWidget->currentWidget();
ui->stackedWidget->removeWidget(widget);
delete widget;
widget = NULL;
}
}
void MainWindow::OnStackWidgetCurrentChanged(int index)
{
qDebug() << "MainWindow::OnStackWidgetCurrentChanged" << index;
ui->homeButton->setVisible(index != 0);
ui->backButton->setVisible(index != 0);
}
void MainWindow::OnStackWidgetWidgetRemoved(int index)
{
qDebug() << "MainWindow::OnStackWidgetWidgetRemoved" << index;
}
| [
"wesley@debian.(none)"
]
| [
[
[
1,
108
]
]
]
|
d8725306c37fa34ec4f4aa1483b7714f1c74c9b7 | b3283c88e4ddb5f228f16448be6e9dee3d8cb272 | /ngy313/texture.hpp | 2f72e8dca5b9898fd14d2a37bd5e69b24fac1671 | [
"BSD-3-Clause",
"BSL-1.0"
]
| permissive | nagoya313/ngy313 | ae386c84a4d3b5b68d5e172b32de9cd0fe90cf5c | 7c93a3edf69080559049d5e759a4db1be5e1e2fd | refs/heads/master | 2021-01-10T19:09:18.562953 | 2011-07-27T17:12:19 | 2011-07-27T17:12:19 | 1,025,796 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,255 | hpp | #ifndef NGY313_TEXTURE_HPP_
#define NGY313_TEXTURE_HPP_
#include <boost/noncopyable.hpp>
#include <ngy313/detail/ngy313.hpp>
#if defined(_WIN32)
#include <ngy313/detail/direct3d9_texture.hpp>
#elif defined(__linux__)
#include <ngy313/detail/opengl_texture.hpp>
#endif
namespace ngy313 {
template <typename Texture>
class basic_texture {
public:
typedef typename Texture::handle_type handle_type;
typedef typename Texture::texture_tuple texture_tuple;
explicit basic_texture(int width, int height)
: texture_(detail::main_singleton::instance().graphic(),
width,
height) {}
template <typename Image>
explicit basic_texture(const Image &image)
: texture_(detail::main_singleton::instance().graphic(),
image) {}
int width() const {
return texture_.width();
}
int height() const {
return texture_.height();
}
handle_type handle() const {
return texture_.handle();
}
private:
Texture texture_;
};
#if defined(_WIN32)
typedef basic_texture<detail::direct3d9_texture> texture;
#elif defined(__linux__)
typedef basic_texture<detail::opengl_texture<detail::graphic_system>> texture;
#endif
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
53
]
]
]
|
d75b4aa4b4f644ffdc86e680f9b544dca1cef17c | e2e49023f5a82922cb9b134e93ae926ed69675a1 | /tools/aosdesigner/core/ForwardCore.hpp | 2a0a5a8a61b2e276e6bc2be49904e599c289dc86 | []
| no_license | invy/mjklaim-freewindows | c93c867e93f0e2fe1d33f207306c0b9538ac61d6 | 30de8e3dfcde4e81a57e9059dfaf54c98cc1135b | refs/heads/master | 2021-01-10T10:21:51.579762 | 2011-12-12T18:56:43 | 2011-12-12T18:56:43 | 54,794,395 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 280 | hpp | #ifndef HGUARD_AOSD_FORWARDCORE_HPP__
#define HGUARD_AOSD_FORWARDCORE_HPP__
#pragma once
namespace aosd
{
namespace core
{
/* Forward declaration of core classes.
*/
class Context;
class Project;
class Sequence;
class EditionSession;
}
}
#endif | [
"klaim@localhost"
]
| [
[
[
1,
22
]
]
]
|
4ae0bec4172696c591a11352011431e671bc9e50 | 9a36ea9f4f189264cc506371af14444edf2c342e | /Naadh.h | d0d2f4f5ed7c4c9317bee5179f83ea60c3c41271 | []
| no_license | 15831944/naad1 | f3ca7db73cc16b4ffe0e5397ca0d78b0a532a8fb | b8a97fbfdcc81d310368efaafd2fe69eee4d4dd3 | refs/heads/master | 2021-12-04T10:55:19.583409 | 2010-11-06T18:09:45 | 2010-11-06T18:09:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 918 | h | // Naadh.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#define VERSION 3
#define VERMONTH "Oct 2010"
#define MAXRESRV 16
#define MAXGHUNGRU 5
#define MAXTANPURA 1
#define MAXBPM 800
#define DEFAULT_BPM 180
#define FILETYPE_COMP 1
#define FILETYPE_LOOP 2
#define FILETYPE_SETT 3
//#define BOLFILE {"Dha0^.wav", "Dhin0^.wav", "Dhit0^.wav", "Dhun0^.wav", "Ga0^.wav", "Ge0^.wav", "Ke0^.wav", "Na0^.wav", "Tat0^.wav", "Ti0^.wav", "Tin0^.wav", "Tun0^.wav"}
// CNaadhApp:
// See Naadh.cpp for the implementation of this class
//
class CNaadhApp : public CWinApp
{
public:
CNaadhApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CNaadhApp theApp;
| [
"sanjeev.567@localhost"
]
| [
[
[
1,
47
]
]
]
|
cb7f9976b61c053b33e3dba528f933696c74fefa | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Samples/AIAD/LevelUpWindow.h | a85304448f50ca813d8ed612bdea9c720ecb86e2 | []
| 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 | 668 | h | /*
---------------------------------------------------------------------------
This source file is part of nGENE Tech.
Copyright (c) 2006- Wojciech Toman
This program is free software.
File: LevelUpWindow.h
Version: 0.01
---------------------------------------------------------------------------
*/
#pragma once
#include "GUIImage.h"
#include "GUIStatic.h"
#include "GUIWindow.h"
using nGENE::GUIImage;
using nGENE::GUIStatic;
using nGENE::GUIWindow;
using nGENE::GUIButton;
using nGENE::uint;
class LevelUpWindow: public GUIWindow
{
private:
void onWindowPaint();
public:
LevelUpWindow();
void addControls();
}; | [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
39
]
]
]
|
a7df7403d6e7ef138913b24996211e23d403bedc | cbb40e1d71bc4585ad3a58d32024090901487b76 | /trunk/tokamaksrc/src/stack.cpp | 7369c03d9014b4e613a559f0b28cfe167fe5b392 | []
| no_license | huangleon/tokamak | c0dee7b8182ced6b514b37cf9c526934839c6c2e | 0218e4d17dcf93b7ab476e3e8bd4026f390f82ca | refs/heads/master | 2021-01-10T10:11:42.617076 | 2011-08-22T02:32:16 | 2011-08-22T02:32:16 | 50,816,154 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,046 | cpp | /*************************************************************************
* *
* Tokamak Physics Engine, Copyright (C) 2002-2007 David Lam. *
* All rights reserved. Email: [email protected] *
* Web: www.tokamakphysics.com *
* *
* 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 files *
* LICENSE.TXT for more details. *
* *
*************************************************************************/
#include "math/ne_type.h"
#include "math/ne_debug.h"
#include "tokamak.h"
#include "containers.h"
#include "scenery.h"
#include "collision.h"
#include "constraint.h"
#include "rigidbody.h"
/*
#ifdef _WIN32
#include <windows.h>
#endif
*/
#include "stack.h"
#include "simulator.h"
#include "scenery.h"
/*
#include <algorithm>
#include <assert.h>
*/
namespace Tokamak {
s32 neStackHeader::golbalTime = 0;
void neRestRecord::Update()
{
worldThisBody = body->State().b2w * bodyPoint;
neRigidBody_ * rb = otherBody->AsRigidBody();
neCollisionBody_ * cb = otherBody->AsCollisionBody();
if (cb)
{
normalWorld = cb->b2w.rot * normalBody;
worldOtherBody = cb->b2w * otherBodyPoint;
}
else
{
normalWorld = rb->State().b2w.rot * normalBody;
worldOtherBody = rb->State().b2w * otherBodyPoint;
}
worldDiff = worldThisBody - worldOtherBody;
normalDiff = worldDiff.Dot(normalWorld); // < 0.0f means penetration
neV3 v = worldDiff;
v.RemoveComponent(normalWorld);
tangentialDiffSq = v.Dot(v);
}
void neStackInfo::Resolve()
{
isResolved = true;
if (isTerminator)
return;
ASSERT(body);
for (s32 i = 0; i < NE_RB_MAX_RESTON_RECORDS; i++)
{
if (body->GetRestRecord(i).IsValid())
{
neRigidBody_ * rb = body->GetRestRecord(i).GetOtherRigidBody();
if (rb && rb->stackInfo)
{
if (!rb->stackInfo->isResolved)
rb->stackInfo->Resolve();
}
}
}
//body->ResolveRestingPenetration();
}
void neStackInfo::CheckHeader(neStackHeader * sh)
{
ASSERT(stackHeader == sh);
neRigidBody_ * b = body->AsRigidBody();
if (!b)
return;
for (s32 i = 0; i < NE_RB_MAX_RESTON_RECORDS; i++)
{
if (b->GetRestRecord(i).GetOtherRigidBody())
{
neRigidBody_ * otherBody = b->GetRestRecord(i).GetOtherRigidBody();
if (otherBody)
{
ASSERT(otherBody->stackInfo);
ASSERT(otherBody->stackInfo->stackHeader == sh);
if (!otherBody->stackInfo->isTerminator)
{
otherBody->stackInfo->CheckHeader(sh);
}
}
}
}
}
#if 0
void neStackInfo::Break()
{
/* char ss [256];
sprintf(ss, "break %d\n", body->id);
OutputDebugString(ss);
*/
if (stackHeader->isHeaderX)
{
stackHeader->Remove(this);
body->FreeStackInfo();
return;
}
stackHeader->CheckHeader();
neStackHeader * newHeader = body->sim->NewStackHeader(NULL);
for (s32 i = 0; i < NE_RB_MAX_RESTON_RECORDS; i++)
{
if (body->GetRestRecord(i).otherBody)
{
neRigidBody_* b = (neRigidBody_*)body->GetRestRecord(i).otherBody;
if (b)
{
if (!b->stackInfo) //remove from previous iteration
continue;
if (b->stackInfo->stackHeader == newHeader) //migrate from previous iteration
continue;
if (b->stackInfo->isTerminator)
{
stackHeader->Remove(b->stackInfo);
b->FreeStackInfo();
b->ResetRestOnRecords();
}
else
{
ASSERT(b->stackInfo->stackHeader == stackHeader);
b->MigrateNewHeader(newHeader, stackHeader);
body->GetRestRecord(i).Init();
}
}
}
}
if (newHeader->infoCount == 0)
{
body->sim->stackHeaderHeap.Dealloc(newHeader);
}
else
{
newHeader->CheckHeader();
}
if (stackHeader->infoCount == 1)
{
ASSERT(stackHeader->head == this);
stackHeader->infoCount = 0;
neStackHeader * h = stackHeader;
h->Remove(this);
body->sim->stackHeaderHeap.Dealloc(h);
body->FreeStackInfo();
}
else
{
body->stackInfo->isTerminator = true;
stackHeader->CheckHeader();
}
}
#endif
void neStackHeader::Resolve()
{
// resolve all penetration under this header
// ASSERT(head);
// if (head == NULL)
// return;
s32 c = 0;
neStackInfoItem * item = (neStackInfoItem *) head;
while (item)
{
neStackInfo * sinfo = (neStackInfo *) item;
ASSERT(sinfo->stackHeader == this);
sinfo->isResolved = false;
item = item->next;
c++;
}
item = (neStackInfoItem *) head;
while (item)
{
neStackInfo * sinfo = (neStackInfo *) item;
item = item->next;
if (!sinfo->isResolved)
sinfo->Resolve();
}
}
/*
void neStackHeader::Purge()
{
if (!head)
return;
neStackInfoItem * item = (neStackInfoItem *) head;
while (item)
{
neStackInfo * sinfo = (neStackInfo *) item;
item = item->next;
sim->stackInfoHeap.Dealloc(sinfo, 1);
}
Null();
}
*/
void neStackHeader::ChangeHeader(neStackHeader * newHeader)
{
if (!head)
{
ASSERT(0);
}
neStackInfoItem * item = (neStackInfoItem *) head;
s32 c = 0;
while (item)
{
neStackInfo * sinfo = (neStackInfo *) item;
item = item->next;
sinfo->stackHeader = newHeader;
c++;
}
ASSERT(c == infoCount);
ASSERT(newHeader->tail);
neStackInfoItem * newTailItem = (neStackInfoItem *) newHeader->tail;
newTailItem->Concat((neStackInfoItem *)head);
newHeader->tail = tail;
newHeader->infoCount += c;
}
/*
s32 pop = 0;
neStackHeader * hell[256];
*/
neBool neStackHeader::CheckStackDisconnected()
{
// OutputDebugString("start\n");
//neSimpleArray<neStackInfo*, 1000> stackInfoBuffer;
neSimpleArray<neByte *> & stackInfoBuffer = sim->pointerBuffer2;
stackInfoBuffer.Clear();
neStackInfoItem * item = (neStackInfoItem *) head;
while (item)
{
neStackInfo * sinfo = (neStackInfo *) item;
sinfo->startTime = 0;
sinfo->endTime = 0;
item = item->next;
ASSERT(sinfo->stackHeader == this);
Remove(sinfo, 1);
*stackInfoBuffer.Alloc() = (neByte *)sinfo;
}
s32 i;
for (i = 0; i < stackInfoBuffer.GetUsedCount(); i++)
{
neStackInfo * sinfo = (neStackInfo *)stackInfoBuffer[i];
if (sinfo->isBroken)
continue;
neRigidBody_ * rb = sinfo->body;
for (s32 j = 0; j < NE_RB_MAX_RESTON_RECORDS; j++)
{
if (rb->GetRestRecord(j).IsValid())
{
neRigidBody_ * otherbody = rb->GetRestRecord(j).GetOtherRigidBody();
if (otherbody)
{
if (otherbody->stackInfo->stackHeader)
{
if (sinfo->stackHeader)
{
if (sinfo->stackHeader != otherbody->stackInfo->stackHeader)
{
// merge
neStackHeader * otherHeader = otherbody->stackInfo->stackHeader;
otherHeader->ChangeHeader(sinfo->stackHeader);
sim->stackHeaderHeap.Dealloc(otherHeader);
}
}
else
{
otherbody->stackInfo->stackHeader->Add(sinfo);
}
}
else
{
if (sinfo->stackHeader)
{
sinfo->stackHeader->Add(otherbody->stackInfo);
}
else
{
neStackHeader * newStackHeader = sim->NewStackHeader(NULL);
newStackHeader->dynamicSolved = dynamicSolved;
newStackHeader->Add(sinfo);
newStackHeader->Add(otherbody->stackInfo);
}
}
}
}
}
}
for (i = 0; i < stackInfoBuffer.GetUsedCount(); i++)
{
neStackInfo * sinfo = (neStackInfo *)stackInfoBuffer[i];
if (!sinfo->stackHeader)
{
neRigidBody_ * rb = sinfo->body;
sim->stackInfoHeap.Dealloc(sinfo, 1);
for (s32 i = 0; i < NE_MAX_REST_ON; i++)
{
rb->GetRestRecord(i).SetInvalid();
}
rb->stackInfo = NULL;
}
}
/*
item = (neStackInfoItem *) head;
//pop = 0;
for (s32 i = 0; i < stackInfoBuffer.GetUsedCount(); i++)
{
// char ss[256];
neStackInfo * sinfo = (neStackInfo *)stackInfoBuffer[i];
// sprintf(ss, "starting at %d\n", sinfo->body->id);
// OutputDebugString(ss);
neStackHeader * newStackHeader = sim->NewStackHeader(NULL);
// hell[pop] = newStackHeader;
// pop++;
neStackHeader * anotherHeader = sinfo->CheckAcceptNewHeader(newStackHeader);
if (anotherHeader && (anotherHeader != newStackHeader))
{
for (s32 j = 0; j < i ; j++)
{
((neStackInfo *)stackInfoBuffer[j])->ForceAcceptNewHeader(anotherHeader);
}
}
// sprintf(ss, "newStackheader %d count = %d\n",pop, newStackHeader->infoCount);
// OutputDebugString(ss);
if (newStackHeader->infoCount == 0)
{
sim->stackHeaderHeap.Dealloc(newStackHeader);
// sprintf(ss, "dealloc %d\n",pop);
// OutputDebugString(ss);
}
}
ASSERT(infoCount == 0);
// sim->stackHeaderHeap.Dealloc(this);
// sim->CheckStackHeader();
*/
return true; // always dealloc this header
}
#if 0
void neStackHeader::AddToSolver()
{
neStackInfoItem * sitem = (neStackInfoItem *)head;
while (sitem)
{
neStackInfo * sinfo = (neStackInfo*) sitem;
sitem = sitem->next;
if (!sinfo->isTerminator)
sinfo->body->AddContactImpulseRecord(true);
sinfo->body->needRecalc = true;
if (!sinfo->body->GetConstraintHeader())
{
sinfo->body->SetConstraintHeader(&sinfo->body->sim->contactConstraintHeader);
sinfo->body->sim->contactConstraintHeader.bodies.Add(&sinfo->body->constraintHeaderItem);
}
}
}
#else
void neStackHeader::AddToSolver()
{
neStackInfoItem * item = (neStackInfoItem *) head;
while (item)
{
neStackInfo * sinfo = (neStackInfo *) item;
ASSERT(sinfo->stackHeader == this);
sinfo->isResolved = false;
item = item->next;
}
item = (neStackInfoItem *) head;
while (item)
{
neStackInfo * sinfo = (neStackInfo *) item;
item = item->next;
if (!sinfo->isResolved)
{
if (!sinfo->body->GetConstraintHeader())
{
sinfo->body->SetConstraintHeader(&sinfo->body->sim->contactConstraintHeader);
sinfo->body->sim->contactConstraintHeader.bodies.Add(&sinfo->body->constraintHeaderItem);
}
if (!sinfo->isTerminator)
sinfo->AddToSolver(true);
}
}
}
void neStackHeader::AddToSolverNoConstraintHeader()
{
neStackInfoItem * item = (neStackInfoItem *) head;
while (item)
{
neStackInfo * sinfo = (neStackInfo *) item;
ASSERT(sinfo->stackHeader == this);
sinfo->isResolved = false;
item = item->next;
}
item = (neStackInfoItem *) head;
while (item)
{
neStackInfo * sinfo = (neStackInfo *) item;
item = item->next;
if (!sinfo->isResolved)
{
if (!sinfo->isTerminator)
sinfo->AddToSolver(false);
}
}
/*
neStackInfoItem * sitem = (neStackInfoItem *)head;
while (sitem)
{
neStackInfo * sinfo = (neStackInfo*) sitem;
sitem = sitem->next;
if (!sinfo->isTerminator)
sinfo->body->AddContactImpulseRecord(false);
sinfo->body->needRecalc = true;
}
*/
}
#endif
void neStackInfo::AddToSolver(neBool addCHeader)
{
isResolved = true;
ASSERT (!isTerminator);
ASSERT(body);
// body->AddContactImpulseRecord(addCHeader);
for (s32 i = 0; i < NE_RB_MAX_RESTON_RECORDS; i++)
{
if (!body->GetRestRecord(i).IsValid())
{
continue;
}
neRigidBody_ * rb = body->GetRestRecord(i).GetOtherRigidBody();
if (!rb || !rb->stackInfo)
{
continue;
}
if (rb->stackInfo->isResolved)
{
continue;
}
if (!rb->GetConstraintHeader() && addCHeader)
{
rb->SetConstraintHeader(&rb->sim->contactConstraintHeader);
rb->sim->contactConstraintHeader.bodies.Add(&rb->constraintHeaderItem);
}
if (!rb->stackInfo->isTerminator)
rb->stackInfo->AddToSolver(addCHeader);
}
body->AddContactImpulseRecord(addCHeader);
}
void neStackHeader::ResetRigidBodyFlag()
{
neStackInfoItem * sitem = (neStackInfoItem *)head;
while (sitem)
{
neStackInfo * sinfo = (neStackInfo*) sitem;
sitem = sitem->next;
sinfo->body->needRecalc = false;
}
}
neStackHeader * neStackInfo::CheckAcceptNewHeader(neStackHeader * newHeader)
{
// this function is for diagnostic only
if (startTime > 0) // already visited
{
return NULL;
}
startTime = ++neStackHeader::golbalTime;
if (stackHeader) //already visited
{
if (stackHeader != newHeader)
{
return stackHeader;
}
else
{
return NULL;
}
}
if (isTerminator)
{
newHeader->Add(this);
return NULL;
}
if (isBroken)
{
newHeader->Add(this);
isTerminator = true;
return NULL;
}
neBool anotherHeaderFound = false;
neStackHeader * anotherHeader = NULL;
neRigidBody_ * foundBody;
s32 i;
for (i = 0; i < NE_RB_MAX_RESTON_RECORDS; i++)
{
neRigidBody_* otherBody = (neRigidBody_*)body->GetRestRecord(i).GetOtherRigidBody();
if (!otherBody)
continue;
/*
if (otherBody->AsCollisionBody())
{
continue;
}
*/ ASSERT(otherBody->stackInfo);
anotherHeader = otherBody->stackInfo->CheckAcceptNewHeader(newHeader);
ASSERT(anotherHeader != newHeader);
if (anotherHeader != NULL)
{
anotherHeaderFound = true;
foundBody = otherBody;
break;
}
}
if (anotherHeaderFound)
{
anotherHeader->Add(this);
for (i = 0; i < NE_RB_MAX_RESTON_RECORDS; i++)
{
neRigidBody_* otherBody = (neRigidBody_*)body->GetRestRecord(i).GetOtherRigidBody();
if (!otherBody)
continue;
/*
if (otherBody->AsCollisionBody())
continue;
*/
if (otherBody != foundBody)
{
if (otherBody->stackInfo->stackHeader != anotherHeader)
otherBody->stackInfo->ForceAcceptNewHeader(anotherHeader);
}
}
return stackHeader;
}
else
{
newHeader->Add(this);
return NULL;
}
}
void neStackInfo::ForceAcceptNewHeader(neStackHeader * newHeader)
{
if (isTerminator)
{
if (stackHeader)
stackHeader->Remove(this);
newHeader->Add(this);
return;
}
if (isBroken)
{
if (stackHeader)
stackHeader->Remove(this);
newHeader->Add(this);
return;
}
if (stackHeader)
{
if (stackHeader == newHeader)
{
return;
}
stackHeader->Remove(this);
}
newHeader->Add(this);
for (s32 i = 0; i < NE_RB_MAX_RESTON_RECORDS; i++)
{
neRigidBody_* otherBody = (neRigidBody_*)body->GetRestRecord(i).GetOtherRigidBody();
if (!otherBody)
continue;
/*
if (otherBody->AsCollisionBody())
{
continue;
}
*/ ASSERT(otherBody->stackInfo);
otherBody->stackInfo->ForceAcceptNewHeader(newHeader);
}
}
}
| [
"[email protected]"
]
| [
[
[
1,
764
]
]
]
|
882ce7408050d0a776e184a50b2fb275d975baf9 | 7acbb1c1941bd6edae0a4217eb5d3513929324c0 | /GLibrary-CPP/sources/GIPC.h | 7d4b424273cb9efb9363559aa2768742ee329dca | []
| no_license | hungconcon/geofreylibrary | a5bfc96e0602298b5a7b53d4afe7395a993498f1 | 3abf3e1c31a245a79fa26b4bcf2e6e86fa258e4d | refs/heads/master | 2021-01-10T10:11:51.535513 | 2009-11-30T15:29:34 | 2009-11-30T15:29:34 | 46,771,895 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,310 | h |
#ifndef __GIPC_H__
# define __GIPC_H__
#include "GExport.h"
#include "GString.h"
#include "GMap.hpp"
#include "GMutex.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#if defined (GWIN)
#include <windows.h>
#else
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/types.h>
#endif
namespace GIPC
{
class GEXPORTED GPipe
{
public:
GPipe(const GString &);
void SetName(const GString &);
const GString &GetName(void);
void SetMode(bool);
bool Start(void);
bool Read(void *, unsigned int);
bool Write(void *, unsigned int);
bool Write(const GString &);
bool IsReadable(void);
private:
bool _read;
GString _name;
#if defined (GWIN)
static GMap<GString, GVector<HANDLE> > _map;
#else
static GMap<GString, GVector<int> > _map;
#endif
static GMutex _mutex;
};
class GEXPORTED GSemaphore
{
public:
GSemaphore(unsigned int, const GString & = "");
bool Lock(void);
bool Unlock(void);
private:
GString _name;
unsigned int _nb;
#if defined (GWIN)
CRITICAL_SECTION _critical;
HANDLE _semid;
#else
key_t _key;
int _semid;
unsigned int _num;
static unsigned int _sum;
#endif
};
}
#endif
| [
"mvoirgard@34e8d5ee-a372-11de-889f-a79cef5dd62c",
"[email protected]"
]
| [
[
[
1,
19
],
[
21,
25
],
[
27,
72
]
],
[
[
20,
20
],
[
26,
26
]
]
]
|
fd8829201f7f00629b8e80766c7971a6fdd52c3d | 95e051bc96bd3f765ce1cec4868535b667be81b6 | /ExplodedView/src/Cell.h | 9ff9796c357ea503cda6a70e3e700f96c9ea33e1 | []
| no_license | fabio-miranda/exploded | 6aacdb5ca1250b676990572ef028fcbc0af93b1a | 12ca185b161b78d0b903c86fb5a08cee3ed87362 | refs/heads/master | 2021-05-29T09:06:03.007813 | 2010-02-26T04:40:32 | 2010-02-26T04:40:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 425 | h | #ifndef Cell_H
#define Cell_H
#include <osg/Vec3>
#include <vector>
class Cell{
public:
Cell(bool pActive, osg::Vec3* pIndex, int* pVerticesIndex, int* pNeighboursIndex, float pProp);
bool isActive();
bool isOnAPart();
bool isOnEdge();
private:
bool mActive;
bool mIsOnAPart;
bool mIsOnEdge;
osg::Vec3* mIndex;
int* mVerticesIndex;
int* mNeighboursIndex;
float mProp;
};
#endif | [
"fabiom@2fa1dc7e-98ce-11de-bff5-93fd3790126f"
]
| [
[
[
1,
29
]
]
]
|
ebdbb150dc1c24bd655c61309cd57a6afeff64c4 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ClientShellDLL/ClientShellShared/ScreenSpriteMgr.h | 8842835fa32fa0a531022c8bc8751f9fa63ea726 | []
| 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 | 4,607 | h | // ----------------------------------------------------------------------- //
//
// MODULE : ScreenSpriteMgr.h
//
// PURPOSE : Manage all game-side handling of 2d (screenspace) sprites
//
// CREATED : 12/7/01
//
// (c) 2001-2002 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef __SCREEN_SPRITE_MGR_H__
#define __SCREEN_SPRITE_MGR_H__
#include "iltdrawprim.h"
class CScreenSpriteMgr;
extern CScreenSpriteMgr *g_pScreenSpriteMgr;
typedef enum
{
// default layer, the very back
SPRITELAYER_DEFAULT = 0,
// the layers to a subroutine: subroutine bitmap, build state, and condition
SPRITELAYER_SUBROUTINE_SHAPE,
SPRITELAYER_SUBROUTINE_BUILD,
SPRITELAYER_SUBROUTINE_CONDITION,
// the layers to a subroutine
SPRITELAYER_ADDITIVE_SHAPE,
SPRITELAYER_ADDITIVE_GLOW,
SPRITELAYER_ADDITIVE_HIGHLIGHT,
// procedurals
SPRITELAYER_PROCEDURAL_SHAPE,
SPRITELAYER_PROCEDURAL_PROGRESS,
SPRITELAYER_PROCEDURAL_HIGHLIGHT,
// at the very front, the three layers to a mouse cursor
SPRITELAYER_CURSOR_ADDITIVE,
SPRITELAYER_CURSOR_BACKGROUND,
SPRITELAYER_CURSOR_FOREGROUND,
} ScreenSpriteLayer;
// Wrapper struct for HTEXTUREs that expose a bit more information on our end
// Managed by the CScreenSpriteMgr class. One frame refers to a single texture
// that can be used by multiple sprites
struct ScreenSpriteFrame
{
int iFrameID; // unique ID number (it's an array index)
char *pName;
HTEXTURE hTex;
unsigned int iWidth;
unsigned int iHeight;
};
typedef std::vector<ScreenSpriteFrame *> FrameArray;
class CScreenSprite
{
friend class CScreenSpriteMgr;
public:
CScreenSprite();
~CScreenSprite();
// LTBOOL Init(char *pName, LTBOOL bExpires = LTTRUE);
void Show(LTBOOL bShow, LTBOOL bRestartAnimation = LTTRUE);
void SetAdditive(LTBOOL bAdditive) {m_bAdditive = bAdditive;}
void SetCenter(int x, int y);
void SetCenter(LTIntPt pos);
void SetPosition(int x, int y);
void SetPosition(LTIntPt pos);
LTIntPt GetPosition();
LTIntPt GetDims();
char * GetName() {return m_pName;}
void SetLifeTime(int iLoops);
void SetLifeTime(float fSeconds);
LTBOOL KillMe() {return (m_bExpires && (m_fLifeTime < 0.0f));}
private:
// Private functions used by ScreenSpriteMgr
void Init();
void SetExpiration(bool bExpires);
void Term();
void AdvanceTime(float fDelta); // Tell the sprite how much time has elapsed
void Render(); // Render the sprite,called from the Mgr
ScreenSpriteLayer m_eLayer; // sprite layer to determine draw-order
LTIntPt m_Position;
LTIntPt m_Center; // Offset from top-left corner of bitmap to center of sprite (0,0)
char *m_pName; // filename (spr or dtx)
int m_nFrames; // Number of frames in the sprite
int m_nFrameRate; // frame rate (in frames per second) for animation
float m_fOneFrameTime; // Time in seconds for a single frame to be visible
LTBOOL m_bExpires; // flag to set if the sprite will die (default = true)
float m_fLifeTime; // Life expectancy of sprite
LTBOOL m_bShow; // flag. Is this sprite supposed to be drawn?
LTBOOL m_bAdditive; // new bonus flag. Is this an additive texture?
LTPoly_GT4 m_DrawPrim; // Drawprim used for rendering
FrameArray m_FrameArray; // array of pointers to the textures used
// Variables used to animate
int m_iCurrentFrame;
float m_fCurrentTime;
};
typedef std::vector<CScreenSprite *> ScreenSpriteArray;
// The management class. Simply takes charge of updating timers and drawing the respective
// frames of all active sprites. Manages the list of all sprites.
class CScreenSpriteMgr
{
friend class CScreenSprite;
public:
CScreenSpriteMgr();
~CScreenSpriteMgr();
LTBOOL Init();
void Term();
void Update(); // Draw all visible sprites
CScreenSprite * CreateScreenSprite(char * pFile, bool bExpires = true, ScreenSpriteLayer eLayer = SPRITELAYER_DEFAULT);
void DestroyScreenSprite(CScreenSprite * pSprite); // public fn for destructor
private:
bool GiveSpriteResources(CScreenSprite * pSprite, char * pFile); // can only be called by CScreenSprites
int CacheTexture(char * pFile);
LTBOOL CacheSprite(CScreenSprite * pSprite, char * pFile);
LTBOOL m_bInitialized;
FrameArray m_FrameArray;
ScreenSpriteArray m_SpriteArray;
float m_fLastTime;
// TODO if a sprite has expired, go ahead and term() it and delete it!
};
#endif // __SCREEN_SPRITE_MGR_H__ | [
"[email protected]"
]
| [
[
[
1,
156
]
]
]
|
535a9da25db445fb12745a3a8ee680853983bf8e | 16d8b25d0d1c0f957c92f8b0d967f71abff1896d | /OblivionOnline/cegui/RendererModules/OpenGLGUIRenderer/openglrenderer.h | d65b0508ec275b24e5fc18b7553bfd9b03d63405 | []
| no_license | wlasser/oonline | 51973b5ffec0b60407b63b010d0e4e1622cf69b6 | fd37ee6985f1de082cbc9f8625d1d9307e8801a6 | refs/heads/master | 2021-05-28T23:39:16.792763 | 2010-05-12T22:35:20 | 2010-05-12T22:35:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,400 | h | /***********************************************************************
filename: openglrenderer.h
created: 9/4/2004
author: Mark Strom
[email protected]
purpose: Interface to Renderer implemented via Opengl
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _openglrenderer_h_
#define _openglrenderer_h_
#include "CEGUIBase.h"
#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
# ifdef OPENGL_GUIRENDERER_EXPORTS
# define OPENGL_GUIRENDERER_API __declspec(dllexport)
# else
# define OPENGL_GUIRENDERER_API __declspec(dllimport)
# endif
#else
# define OPENGL_GUIRENDERER_API
#endif
#if defined(_WIN32)// All this taken from glut.h
# ifndef APIENTRY
# define GLUT_APIENTRY_DEFINED
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__) || defined(__GNUC__)
# define APIENTRY __stdcall
# else
# define APIENTRY
# endif
# endif
/* XXX This is from Win32's <winnt.h> */
# ifndef CALLBACK
# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) || defined(__LCC__) || defined(__GNUC__)
# define CALLBACK __stdcall
# else
# define CALLBACK
# endif
# endif
/* XXX Hack for lcc compiler. It doesn't support __declspec(dllimport), just __stdcall. */
# if defined( __LCC__ )
# undef WINGDIAPI
# define WINGDIAPI __stdcall
# else
/* XXX This is from Win32's <wingdi.h> and <winnt.h> */
# ifndef WINGDIAPI
# define GLUT_WINGDIAPI_DEFINED
# define WINGDIAPI __declspec(dllimport)
# endif
# endif
/* XXX This is from Win32's <ctype.h> */
# ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
# define _WCHAR_T_DEFINED
# endif
# endif //win32 end glut.h stuff
/* XXX Hack for finding headers in Apple's OpenGL framework. */
#if defined( __APPLE__ )
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else /* __APPLE__ */
#include <GL/gl.h>
#include <GL/glu.h>
#endif /* __APPLE__ */
#include <list>
#include <set>
#include "CEGUIRenderer.h"
#include "CEGUITexture.h"
// #if defined(_WIN32)
// # if defined(_DEBUG)
// # pragma comment(lib, "CEGUIBase_d.lib")
// # else
// # pragma comment(lib, "CEGUIBase.lib")
// # endif
// #endif
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4251)
#endif
#define OGLRENDERER_VBUFF_CAPACITY 4096
// Start of CEGUI namespace section
namespace CEGUI
{
/*************************************************************************
Forward refs
*************************************************************************/
class OpenGLTexture;
class ImageCodec;
class DynamicModule;
/*!
\brief
Renderer class to interface with OpenGL
*/
class OPENGL_GUIRENDERER_API OpenGLRenderer : public Renderer
{
public:
/*!
\brief
Constructor for OpenGL Renderer object
\param max_quads
obsolete. Set to 0.
\param codec
A pointer to a user provided image codec. The renderer
does not take ownership of the codec object.
*/
OpenGLRenderer(uint max_quads, ImageCodec* codec = 0);
/*!
\brief
Constructor for OpenGL Renderer object
\param max_quads
obsolete. Set to 0.
\param width
width of the CEGUI viewport.
\param height
height of the CEGUI viewport.
\param codec
A pointer to a user provided image codec. The renderer
does not take ownership of the codec object.
*/
OpenGLRenderer(uint max_quads,int width, int height, ImageCodec* codec = 0);
/*!
\brief
Destructor for OpenGLRenderer objects
*/
virtual ~OpenGLRenderer(void);
// add's a quad to the list to be rendered
virtual void addQuad(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode);
// perform final rendering for all queued renderable quads.
virtual void doRender(void);
// clear the queue
virtual void clearRenderList(void);
/*!
\brief
Enable or disable the queuing of quads from this point on.
This only affects queuing. If queuing is turned off, any calls to addQuad will cause the quad to be rendered directly. Note that
disabling queuing will not cause currently queued quads to be rendered, nor is the queue cleared - at any time the queue can still
be drawn by calling doRender, and the list can be cleared by calling clearRenderList. Re-enabling the queue causes subsequent quads
to be added as if queuing had never been disabled.
\param setting
true to enable queuing, or false to disable queuing (see notes above).
\return
Nothing
*/
virtual void setQueueingEnabled(bool setting) {d_queueing = setting;}
// create an empty texture
virtual Texture* createTexture(void);
// create a texture and load it with the specified file.
virtual Texture* createTexture(const String& filename, const String& resourceGroup);
// create a texture and set it to the specified size
virtual Texture* createTexture(float size);
// destroy the given texture
virtual void destroyTexture(Texture* texture);
// destroy all textures still active
virtual void destroyAllTextures(void);
/*!
\brief
Return whether queuing is enabled.
\return
true if queuing is enabled, false if queuing is disabled.
*/
virtual bool isQueueingEnabled(void) const {return d_queueing;}
/*!
\brief
Return the current width of the display in pixels
\return
float value equal to the current width of the display in pixels.
*/
virtual float getWidth(void) const {return d_display_area.getWidth();}
/*!
\brief
Return the current height of the display in pixels
\return
float value equal to the current height of the display in pixels.
*/
virtual float getHeight(void) const {return d_display_area.getHeight();}
/*!
\brief
Return the size of the display in pixels
\return
Size object describing the dimensions of the current display.
*/
virtual Size getSize(void) const {return d_display_area.getSize();}
/*!
\brief
Return a Rect describing the screen
\return
A Rect object that describes the screen area. Typically, the top-left values are always 0, and the size of the area described is
equal to the screen resolution.
*/
virtual Rect getRect(void) const {return d_display_area;}
/*!
\brief
Return the maximum texture size available
\return
Size of the maximum supported texture in pixels (textures are always assumed to be square)
*/
virtual uint getMaxTextureSize(void) const {return d_maxTextureSize;}
/*!
\brief
Return the horizontal display resolution dpi
\return
horizontal resolution of the display in dpi.
*/
virtual uint getHorzScreenDPI(void) const {return 96;}
/*!
\brief
Return the vertical display resolution dpi
\return
vertical resolution of the display in dpi.
*/
virtual uint getVertScreenDPI(void) const {return 96;}
/*!
\brief
Set the size of the display in pixels.
If your viewport size changes, you can call this function with the new size
in pixels to update the rendering area.
\note
This method will cause the EventDisplaySizeChanged event to fire if the
display size has changed.
\param sz
Size object describing the size of the display.
\return
Nothing.
*/
void setDisplaySize(const Size& sz);
/*!
\brief
Grabs all the loaded textures from Texture RAM and stores them in a local data buffer.
This function invalidates all textures, and restoreTextures must be called before any
CEGUI rendering is done for predictable results
*/
void grabTextures(void);
/*!
\brief
Restores all the loaded textures from the local data buffers previously created by 'grabTextures'
*/
void restoreTextures(void);
/*!
\brief
Retrieve the image codec used internaly
*/
ImageCodec& getImageCodec(void);
/*!
\brief
Set the image codec to use for loading textures
*/
void setImageCodec(const String& codecName);
/*!
\brief
Set the image codec to use from an existing image codec.
In this case the renderer does not take the ownership of the
image codec object.
\param codec a pointer to an image codec object
*/
void setImageCodec(ImageCodec* codec);
/*!
\brief
Set the name of the default image codec to be used
*/
static void setDefaultImageCodecName(const String& codecName);
/*!
\brief
Get the name of the default image codec
*/
static const String& getDefaultImageCodecName();
private:
/************************************************************************
Implementation Constants
************************************************************************/
static const int VERTEX_PER_QUAD; //!< number of vertices per quad
static const int VERTEX_PER_TRIANGLE; //!< number of vertices for a triangle
static const int VERTEXBUFFER_CAPACITY; //!< capacity of the allocated vertex buffer
/*************************************************************************
Implementation Structs & classes
*************************************************************************/
struct MyQuad
{
float tex[2];
uint32 color;
float vertex[3];
};
/*!
\brief
structure holding details about a quad to be drawn
*/
struct QuadInfo
{
GLuint texid;
Rect position;
float z;
Rect texPosition;
uint32 topLeftCol;
uint32 topRightCol;
uint32 bottomLeftCol;
uint32 bottomRightCol;
QuadSplitMode splitMode;
bool operator<(const QuadInfo& other) const
{
// this is intentionally reversed.
return z > other.z;
}
};
/*************************************************************************
Implementation Methods
*************************************************************************/
// setup states etc
void initPerFrameStates(void);
// restore states
void exitPerFrameStates(void);
// render whatever is in the vertex buffer
void renderVBuffer(void);
// sort quads list according to texture
void sortQuads(void);
// render a quad directly to the display
void renderQuadDirect(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode);
// convert colour value to whatever the OpenGL system is expecting.
uint32 colourToOGL(const colour& col) const;
// set the module ID string
void setModuleIdentifierString();
// setup image codec
void setupImageCodec(const String& codecName);
// cleanup image codec
void cleanupImageCodec();
/*************************************************************************
Implementation Data
*************************************************************************/
typedef std::multiset<QuadInfo> QuadList;
QuadList d_quadlist;
Rect d_display_area;
MyQuad myBuff[OGLRENDERER_VBUFF_CAPACITY];
bool d_queueing; //!< setting for queuing control.
uint d_currTexture; //!< Currently bound texture.
int d_bufferPos; //!< index into buffer where next vertex should be put.
bool d_sorted; //!< true when data in quad list is sorted.
std::list<OpenGLTexture*> d_texturelist; //!< List used to track textures.
GLint d_maxTextureSize; //!< Holds maximum supported texture size (in pixels).
ImageCodec* d_imageCodec; //!< Holds a pointer to the image codec to use.
DynamicModule* d_imageCodecModule; //!< Holds a pointer to the image codec module. If d_imageCodecModule is 0 we are not owner of the image codec object
static String d_defaultImageCodecName; //!< Holds the name of the default codec to use
};
} // End of CEGUI namespace section
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // end of guard _openglrenderer_h_
| [
"masterfreek64@2644d07b-d655-0410-af38-4bee65694944"
]
| [
[
[
1,
471
]
]
]
|
804072798e945faadcdf3937f8c248b9b28ca109 | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SEFoundation/SEObjectSystem/SEObject.h | a38f18c51d0b9334921004b6ee01ae933995cadc | []
| no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,132 | h | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// 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. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#ifndef Swing_Object_H
#define Swing_Object_H
#include "SEFoundationLIB.h"
#include "SEPlatforms.h"
#include "SEMain.h"
#include "SERTTI.h"
#include "SENameIdMCR.h"
#include "SESmartPointer.h"
#include "SEStream.h"
#include "SEStringTree.h"
#include "SEStringHashTable.h"
namespace Swing
{
//----------------------------------------------------------------------------
// Description:
// Author:Sun Che
// Date:20080329
//----------------------------------------------------------------------------
class SE_FOUNDATION_API SEObject
{
public:
virtual ~SEObject(void);
protected:
// Abstract base class.
SEObject(void);
// RTTI system.
public:
static const SERTTI TYPE;
virtual const SERTTI& GetType(void) const;
inline bool IsExactly(const SERTTI& rType) const;
inline bool IsDerived(const SERTTI& rType) const;
inline bool IsExactlyTypeOf(const SEObject* pObject) const;
inline bool IsDerivedTypeOf(const SEObject* pObject) const;
// Copying system.
public:
SESmartPointer<SEObject> Copy(bool bUniqueNames = true) const;
static char NameAppend;
// Name-ID system.
public:
inline void SetName(const std::string& rName);
inline const std::string& GetName(void) const;
inline unsigned int GetID(void) const;
inline static unsigned int GetNextID(void);
virtual SEObject* GetObjectByName(const std::string& rName);
virtual void GetAllObjectsByName(const std::string& rName,
std::vector<SEObject*>& rObjects);
virtual SEObject* GetObjectByID(unsigned int uiID);
private:
std::string m_Name;
unsigned int m_uiID;
static unsigned int ms_uiNextID;
// Smart pointer system.
public:
inline void IncrementReferences(void);
void DecrementReferences(void);
inline int GetReferences(void) const;
// SEObject级的内存泄漏跟踪使用此hash表
static SEHashTable<unsigned int, SEObject*>* InUse;
static void PrintInUse(const char* pFileName, const char* pMessage);
private:
int m_iReferences;
// Streaming system.
// 内部使用
public:
enum { FACTORY_MAP_SIZE = 256 };
static SEStringHashTable<FactoryFunction>* ms_pFactory;
static bool RegisterFactory(void);
static void InitializeFactory(void);
static void TerminateFactory(void);
static SEObject* Factory(SEStream& rStream);
virtual void Load(SEStream& rStream, SEStream::SELink* pLink);
virtual void Link(SEStream& rStream, SEStream::SELink* pLink);
virtual bool Register(SEStream& rStream) const;
virtual void Save(SEStream& rStream) const;
virtual int GetDiskUsed(const SEStreamVersion& rVersion) const;
virtual SEStringTree* SaveStrings(const char* pTitle = 0);
private:
static bool ms_bStreamRegistered;
};
// 静态,动态类型转换
template <class T> T* StaticCast(SEObject* pObject);
template <class T> const T* StaticCast(const SEObject* pObject);
template <class T> T* DynamicCast(SEObject* pObject);
template <class T> const T* DynamicCast(const SEObject* pObject);
typedef SESmartPointer<SEObject> SEObjectPtr;
#include "SEObject.inl"
}
#endif
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
125
]
]
]
|
910d2e3eaa0fbfa6cec19cc1e7e6c6257c1db33d | af671ed33a21541dab54d427da4adf7bbca3f2c1 | /embedded/arduino/StorqueUAV/libraries/APM_ADC/.svn/text-base/APM_ADC.h.svn-base | a37d3a97a5d9667096aff982bca44bd7d3bc7ba1 | []
| no_license | ianohara/StorqueUAV | 703902d17b7a9c41e46ed3925dec071f123e97b1 | ecec3d06e4b1a772b09d289a37903593ef0484cf | refs/heads/master | 2018-12-31T14:35:37.188778 | 2011-04-03T16:27:42 | 2011-04-03T16:27:42 | 1,090,295 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 536 | #ifndef APM_ADC_h
#define APM_ADC_h
#define bit_set(p,m) ((p) |= ( 1<<m))
#define bit_clear(p,m) ((p) &= ~(1<<m))
// We use Serial Port 2 in SPI Mode
#define ADC_DATAOUT 51 // MOSI
#define ADC_DATAIN 50 // MISO
#define ADC_SPICLOCK 52 // SCK
#define ADC_CHIP_SELECT 33 // PC4 9 // PH6 Puerto:0x08 Bit mask : 0x40
class APM_ADC_Class
{
private:
public:
APM_ADC_Class(); // Constructor
void Init();
int Ch(unsigned char ch_num);
};
extern APM_ADC_Class APM_ADC;
#endif | [
"[email protected]"
]
| [
[
[
1,
24
]
]
]
|
|
dc428c4bd8a3bde742a4793d2cb8afcc0e470b10 | aab4c401149d8cdee10094d4fb4de98f490be3b6 | /include/modules/renderer.h | dbf3a66854e1b89e006a6295cd264b6f1e2a76f5 | []
| no_license | soulik/quads | a7a49e32dcd137fd32fd45b60fa26b5c0747bd03 | ce440c5d35448908fd936797bff0cb7a9ff78b6e | refs/heads/master | 2016-09-08T00:18:28.704939 | 2008-09-01T14:18:42 | 2008-09-01T14:18:42 | 32,122,815 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,175 | h | #ifndef RENDERER_H_
#define RENDERER_H_
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include "module.h"
#include "gui/qFont.h"
#include "objects/qVector.h"
#include "utils/qRGBA.h"
#include "gui/gui.h"
#include "gui/cGL.h"
class cRenderer : public cGui{
private:
int scr_width;
int scr_height;
int red_size;
int green_size;
int blue_size;
int depth_size;
int doublebuffer;
void initLayers();
void drawLayers();
void quitLayers();
cGL ssGL;
unsigned int frames;
unsigned int time;
float fps;
public:
qFont * font;
SDL_mutex * rend_mutex;
unsigned int main_counter;
cRenderer(cBase * parent);
virtual ~cRenderer();
void init(int width,int height,int red_size=8, int green_size=8, int blue_size=8, int depth_size=16, int doublebuffer=1);
void drawPlayerView(int i=0);
void drawScene();
void prepareScene();
void prepareTexture();
void prepareMultitexture();
void prepareOrthogonal();
void countFPS();
inline SDL_Surface * getSurface(){
return ssGL.surface;
}
inline float getFPS(){
return fps;
};
void init();
void stop();
void run();
};
#endif /*RENDERER_H_*/
| [
"soulik42@89f801e3-d555-0410-a9c1-35b9be595399"
]
| [
[
[
1,
60
]
]
]
|
d4f0b7f57781df8648fa7f6e223b8e25654f4da0 | c1e296853ec2e63cdc0ac04d28c14a0270453cd3 | /clients/CUDA/jaerCuda/spikeConv_gold.cpp | f8d3ec9f6b99f1bb3535b9f4916617ff150c9296 | []
| no_license | capocaccia2011/jAER | fc9298c5a1236eb25d7fd4781eb320d4058661e0 | e043f687630f4aa26ec32e3fe3c0bbbc9be2aa59 | refs/heads/master | 2021-01-18T03:48:36.813191 | 2011-05-12T13:36:22 | 2011-05-12T13:36:22 | 1,722,290 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 53,815 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <string.h>
#include "config.h"
////////////////////////////////////////////////////////////////////////////////
// export C interface
extern "C" {
int extractJaerRawData( unsigned int* addr, unsigned long* timeStamp, char* Data, const unsigned int len);
void computeGold(int numInSpike);
int templateConvInit(int selectType=TEMP_METHOD1, int templateType=TEMPLATE_DoG);
void setInitLastTimeStamp(unsigned long timeStamp);
}
//===========================================================
// Functions related to dumping trace info and other matlab scripts
//===========================================================
extern "C"{
void dumpTemplate(FILE* fp, char* fstr);
}
//=========================================================
// Functions for jAER communication
//=========================================================
extern "C"{
void jaerSendEvent(unsigned int addrx, unsigned int addry, unsigned long timeStamp, unsigned char type);
}
extern unsigned int delta_time;
extern int num_object;
extern globalNeuronParams_t hostNeuronParams;
extern unsigned int filteredSpike_addr[RECV_SOCK_BUFLEN/EVENT_LEN]; // array of filterred spike's address
extern unsigned long filteredSpike_timeStamp[RECV_SOCK_BUFLEN/EVENT_LEN]; // array of filtered spikes's timestamp
extern int radius_loc_inh;
////////////////////////////////////////////////////////////////////////////////
int cpu_totFiring=0; // used to calculate the average firing rate from CPU model
int cpu_totFiringMO[MAX_NUM_TEMPLATE]; // store the firing count for each object that is tracked.
float conv_template[MAX_NUM_TEMPLATE][MAX_TEMPLATE_SIZE][MAX_TEMPLATE_SIZE]; // template of all objects
unsigned long lastInputStamp[MAX_X][MAX_Y]; // stores the time of last firing of the input addr. This is used
// to filter spikes that happens at a high rate.
float membranePotential[MAX_NUM_TEMPLATE][MAX_X][MAX_Y]; // corresponds to membrane potential of each neuron.
int curNumFiring[MAX_NUM_TEMPLATE][MAX_Y][MAX_X]; // the number of generated spikes during current cycle
unsigned long lastTimeStamp[MAX_X][MAX_Y]; // store the firing time of each neuron. This is used
// calcuate the membrane potential decay.
const float objSizeArray[] = {14,11,8,5,2}; // 15.0,7.0,22.0,21.0,20.0,19.0,18.0,12.0,11.0,10.0}; // ball size in pixels
float iNeuronPotential[MAX_NUM_TEMPLATE]; // membrane potential of inhibitory neuron. one inhibitory neuron
// for each object plane or object to be recognized
int iNeuronFiringCnt = 0; // used to calculate the firing rate of inhibitory neurons
int iNeuronCallingCnt = 0; // keeps track of number of times an inhibitory neuron is called.
int lastSequenceNumber=0; // to check dropped packets from jaer
// paramters for gabor template
float f_gabor_bandwidth = GABOR_BAND_WIDTH; //bandwidth of the gabor function
float f_gabor_theta[] = {0,45,90,135}; // orientation of the gabor function
float f_gabor_lambda = GABOR_WAVELENGTH; //wavelength of the gabor function
float f_gabor_psi = GABOR_PHASE_OFFSET; //phase offset of the gabor function
float f_gabor_gamma = GABOR_ASPECT_RATIO; // aspect ratio of the gabor function
float f_gabor_xymax = GABOR_XY_MAX; // the maximum value of x and y value
float f_gabor_maxamp = GABOR_MAX_AMP; // the maximum amplitude of the gabor function
/** convert 4-byte char to an integer
* @param: data data stream reveived from jaer
* return: the converted integer, could be timestamp or address of a spike
**/
unsigned long getInt( char* data)
{
// java is little endian, so LSB comes first to us. we put it at the MSB here and vice versa.
unsigned long temp = (((data[0]&0xffUL) << 24)
+ ((data[1]&0xffUL) << 16)
+ ((data[2]&0xffUL) << 8)
+ (data[3]&0xffUL));
return temp;
}
/** initiate the matrix "lastTimeStamp" using the time stamp of the first received spike
* @param: timeStamp the reference time stamp, which is the timestamp of the first reveived spike
* @param: objId the id of the object
* return
**/
void setInitLastTimeStamp(unsigned long timeStamp){
for(int i = 0; i < MAX_X; i++){
for(int j = 0; j < MAX_Y; j++){
lastTimeStamp[i][j] = timeStamp;
}
}
}
/** filter input spikes based on the refractory period
* @param: addrx & addry the x and y address of the input spike within retina coordinates
* @param: timeStamp current time stamp
* return true if the spike is not filtered out
false otherwise
**/
bool spikeFilter(unsigned int addrx, unsigned int addry, unsigned long timeStamp){
if((timeStamp - lastInputStamp[addrx][addry]) > hostNeuronParams.minFiringTimeDiff){
lastInputStamp[addrx][addry] = timeStamp;
return true;
}else{
return false;
}
}
/** Reads spikes information from a file 'filtered_packet.txt' and returns the info in addr,timeStamp array.
* @param: addr parsed address array
* @param: timeStamp parsed time stamp array
* return the total number of parsed events
**/
int readSpikeFromFile(unsigned int* addr, unsigned long* timeStamp)
{
static FILE* fp = NULL;
static int cntPacket = 1;
if(fp==NULL) {
fp=fopen("filtered_packet.txt", "r");
if (!fp) {
fprintf(stderr, "\n\n\nWARNING !!! filtered_packet.txt file not present in current directory\n");
fprintf(stderr, "Generate one before continuing\n");
exit(1);
}
}
if(!feof(fp)) {
int i=0;
while(!feof(fp)&& (i<(RECV_SOCK_BUFLEN/EVENT_LEN))) {
fscanf(fp, "%d %u\n", &addr[i], &timeStamp[i]);
i=i+1;
}
cntPacket++;
return i;
}
else {
return -1;
}
}
unsigned long prevTimeStamp = 0; // stores the time when last event happened
unsigned int lenData = 0; // stores the length of data generated from input
long long num_packets = 0; //
/** store the filtered spikes in a file for quickly testing without jAER TCP/UDP interface.
* @param: addr the address array
* @param: timeStamp the time stamp array
* return the total number of parsed events
**/
void storeFilteredSpikes(unsigned int* addr, unsigned long* timeStamp)
{
static FILE* fp = NULL;
static unsigned int tot_filtered_spikes = 0;
static int numRecorded = 0;
if(fp==NULL) {
fp=fopen("filtered_packet.txt", "w");
if (!fp) {
fprintf(stderr, "\n\n\nError !!! Cannot create filtered_packet.txt in current directory\n");
exit(1);
}
}
numRecorded += lenData;
for(unsigned int i = 0; i < lenData; i++) {
fprintf(fp, "%d %u\n", addr[i], timeStamp[i]);
}
tot_filtered_spikes++;
if(tot_filtered_spikes == (unsigned)RECORD_MODE_SAMPLES_CNT) {
fprintf(stdout, "RECORD MODE ===> %d filtered spikes recorded\n", numRecorded);
fprintf(stdout, "RECORDING MODE FINISHED....\n");
fclose(fp);
fflush(stdout);
exit(0);
}
}
/////////////////////////////////////////////////////////
// extractJaerRawData:
// This function filters incoming spikes and puts a list of filtered addresses and timeStamp
// for processing by remaining stage. This function can either take an incoming
// array of characters from TCP/UDP (stored in Data). Or it can also read the
// input spikes from a local file called filtered_packet.txt.
//
// Input
// -----
// Data: The incoming spikes are stored as array of chars.
// len: Length of the packet in events. Length of 1 corresponds to 1 AER event.
//
// Output
// ------
// addr: List of addresses (events) after filtering
// timeStamp: List of timeStamp for each address after filtering
////////////////////////////////////////////////////////
int
extractJaerRawData( unsigned int* addr, unsigned long* timeStamp, char* Data, const unsigned int len)
{
num_packets++;
#ifdef REPLAY_MODE
lenData= readSpikeFromFile(addr, timeStamp);
return lenData;
#endif
#if DUMP_RECV_DATA
char fname[100];
sprintf(fname, "recv_packet%d.m", num_packets);
FILE* fpDumpSpike;
fpDumpSpike = fopen(fname, "w");
fprintf( fpDumpSpike, " spikes = [ " );
#endif
lenData = 0; // reset lenData for each received packet
unsigned int* addrCur = addr;
unsigned long* timeStampCur = timeStamp;
unsigned int i;
#ifdef USE_PACKET_SEQUENCE_NUMBER
int sequenceNumber=getInt(Data);
if(sequenceNumber!=lastSequenceNumber+1 && lastSequenceNumber>0){
//TODO doesn't ever seem to print out
if(debugLevel>-1) fprintf(stderr,"extractJaerRawData: dropped packet %d packets? (sequenceNumber=%d, lastSequenceNumber=%d)\n",(sequenceNumber-lastSequenceNumber), sequenceNumber, lastSequenceNumber);
//fflush(stderr);
}
lastSequenceNumber=sequenceNumber;
Data+=4; // skip over 4 byte sequence number
#endif
// This code reads each packet, reconstructs addr and timeStamp
// checks for errors, timeReversal and also filters the spikes
// according to the frequency of occurence.
bool filterFlag = false;
for( i = 0; i < len; i++) {
unsigned int addrxCur = MAX_X - 1 - (Data[i*EVENT_LEN+3] >> 1)& 0x7f;
unsigned int addryCur = (Data[i*EVENT_LEN+2]& 0x7f);
*timeStampCur = getInt( &Data[i*EVENT_LEN+4]); //*((unsigned int *)&Data[i*6+2]);
#if DUMP_RECV_DATA
fprintf(fpDumpSpike, "%u %u %u\n", addrxCur, addryCur, *timeStampCur);
#endif
if ( *timeStampCur < prevTimeStamp ) {
printf("AE timestamp time reversal occured\n");
printf("packet number = %d", num_packets);
printf("i (%d)====>\n, Data[EVENT_LEN*i] = %d\n, Data[EVENT_LEN*i+1] = %d\n, Data[EVENT_LEN*i+2] = %d\n, Data[EVENT_LEN*i+3] = %d\n, \
Data[EVENT_LEN*i+4] = %d\n, Data[EVENT_LEN*i+5] = %d\n, Data[EVENT_LEN*i+6] = %d\n, Data[EVENT_LEN*i+7] = %d\n\n", \
i, Data[EVENT_LEN*i] , Data[EVENT_LEN*i+1] , Data[EVENT_LEN*i+2] , Data[EVENT_LEN*i+3] , Data[EVENT_LEN*i+4] , Data[EVENT_LEN*i+5] , \
Data[EVENT_LEN*i+6] , Data[EVENT_LEN*i+7]);
}
prevTimeStamp = *timeStampCur;
//filterFlag = spikeFilter(addrxCur, addryCur, *timeStampCur);
//if(filterFlag) {
*addrCur = addrxCur + (addryCur << 8);
timeStampCur++;
addrCur++;
lenData++;
//}
}
#if DUMP_RECV_DATA
fprintf(fpDumpSpike, " ]; " );
fclose(fpDumpSpike);
if(num_packets == (unsigned)RECORD_MODE_SAMPLES_CNT){
exit(0);
}
#endif
#ifdef DUMP_FILTERED_DATA
storeFilteredSpikes(addr,timeStamp);
#endif
return lenData;
}
/******************************************************************************************************************************/
/********************************** MEMBRANE POTENTIAL CALCULATION ************************************************************/
/******************************************************************************************************************************/
/** This function implements the integration of the global inhibitory neuron.
* The change of inhibitory membrane potential is dependent upon the number of exc neurons fired ('numFired').
* TODO: Add leaky term into the equation. Currently the neuron does not have leaky behaviour.
* It just accumulates and then fires if the membrane potential of inhibitory crosses the threshold.
* @param: fp pointer to a log file which records inhibitory neuron firing time.
* @param: timeStamp current time stamp
* @param: objId the id of the object
* @param: numFired the number of excitatory spikes generated at this timestamp and this object
* return 1 if the inhibitory neuron fires
0 otherwise
**/
int update_inh_neuron(FILE *fp, unsigned long timeStamp, int objId=0,int numFired=1)
{
iNeuronPotential[objId] += (float)(hostNeuronParams.eISynWeight*numFired);
iNeuronCallingCnt++;
if(iNeuronPotential[objId] > hostNeuronParams.threshold ) {
iNeuronFiringCnt++;
for(int i=0; i < MAX_Y; i++) {
for(int j=0; j < MAX_X; j++) {
membranePotential[objId][i][j] -= hostNeuronParams.iESynWeight;
if (membranePotential[objId][i][j]< hostNeuronParams.membranePotentialMin)
membranePotential[objId][i][j] = hostNeuronParams.membranePotentialMin;
}
}
#if RECORD_FIRING_INFO
if ( fp != NULL)
fprintf( fp, "%u -1 -1\n", timeStamp);
#endif
iNeuronPotential[objId] = 0.0;
return 1;
}
return 0;
}
/** update neuron membrane potentials when input spike is received (single spike mode)
* @param: numInSpikes the number of input spikes received from jaer
**/
void update_neurons(int numInSpikes)
{
static FILE* fpFiring = NULL;
unsigned long spikeTimeStampV;
#if RECORD_FIRING_INFO
if(fpFiring == NULL){
if ((fpFiring = fopen("firing.m", "w")) == NULL){
printf("failed to open file firing.m");
return;
}
}
#endif
int i,j,objId,spk_i;
// this loop iterates over spikes in the packet
for (spk_i = 0; spk_i < numInSpikes; spk_i++ ) {
// update time stamp and address of the input spike
spikeTimeStampV = filteredSpike_timeStamp[spk_i];
int addrx = filteredSpike_addr[spk_i]&0xff;
int addry = (filteredSpike_addr[spk_i]>>8)&0xff;
// calculate the coverage of the template which centers around the address of the current spike
int min_x = addrx - (MAX_TEMPLATE_SIZE/2) + 1;
int temp_min_x = (min_x < 0 ) ? min_x - 1 : min_x;
min_x = (min_x < 0 ) ? 0 : min_x;
int min_y = addry - (MAX_TEMPLATE_SIZE/2) + 1;
int temp_min_y = (min_y < 0 ) ? min_y - 1 : min_y;
min_y = (min_y < 0 ) ? 0 : min_y;
int max_x = addrx + (MAX_TEMPLATE_SIZE/2);
max_x = (max_x > MAX_X) ? MAX_X : max_x;
int max_y = addry + (MAX_TEMPLATE_SIZE/2);
max_y = (max_y > MAX_Y ) ? MAX_Y : max_y;
// calculate the membrane potential of each neuron
for(i = min_x; i < max_x; i++) {
for(j = min_y; j < max_y; j++) {
assert(i-temp_min_x>=0);
assert(i-temp_min_x<MAX_TEMPLATE_SIZE);
assert(j-temp_min_y>=0);
assert(j-temp_min_y<MAX_TEMPLATE_SIZE);
for(objId = 0; objId < num_object; objId++) {
// calculate membrane potential for each neuron
unsigned long timeDiff = spikeTimeStampV-lastTimeStamp[j][i];
float decayFactor = (float)exp(timeDiff/hostNeuronParams.membraneTau*(-1.0f));
membranePotential[objId][j][i] = membranePotential[objId][j][i]*decayFactor +
conv_template[objId][j-temp_min_y][i-temp_min_x];
if((membranePotential[objId][j][i]) > hostNeuronParams.threshold) { // hit the threshold
cpu_totFiring++; // total number of spikes from all populations
cpu_totFiringMO[objId]++; // total number of generated spikes within one population
membranePotential[objId][j][i] = 0;
// send the output events back to cuda
#if !REPLAY_MODE
// accumulate fired neuron and send to jaer
jaerSendEvent(i,j,spikeTimeStampV,objId);
// update inhibitory neuron
int ineuron_fired = update_inh_neuron(fpFiring, spikeTimeStampV, objId);
if (ineuron_fired)
jaerSendEvent(1,1,spikeTimeStampV,0);
#endif
}
else if ( membranePotential[objId][j][i] < hostNeuronParams.membranePotentialMin ) { // hit the lower bound of membrane potential
membranePotential[objId][j][i] = hostNeuronParams.membranePotentialMin;
}
}
lastTimeStamp[j][i] = spikeTimeStampV; // update lastTimeStamp
}
}
}
}
/** update neuron membrane potentials when input spike is received (multi spike mode)
* @param: numInSpikes the number of input spikes received from jaer
**/
void update_neurons_grouping(int numInSpikes)
{
static FILE* fpFiring = NULL;
int ineuron_fired = 0;
int numFired[MAX_NUM_TEMPLATE];
// initiate variables with the first spike
int spikeLen = 0;
unsigned long spikeTimeStampV = filteredSpike_timeStamp[0]; // set the global timestamp for packet
#if RECORD_FIRING_INFO
if(fpFiring == NULL){
if ((fpFiring = fopen("firing.m", "w")) == NULL){
printf("failed to open file firing.m");
return;
}
}
#endif
int i,j,objId,spk_i,spk_cnt,index_start = 0;
// this loop iterates over spikes in the packet, calling the "kernel" periodically when it has collected enough
// spikes.
for (spk_i = 0; spk_i < numInSpikes; spk_i++ ) {
/*********************************************************/
/****Generate input event packet *************************/
/*********************************************************/
if (spk_i==(numInSpikes-1)){
// this is the last spike then just go and process the bufferred spikes in the GPU.
spikeLen++; // just increment number of spikes to be processed
}
else if (spikeLen == (GPU_MAX_SPIKE_PACKETS)) {
// our buffer is full. so go and process existing spike buffer the current spike will be part of next group..
}
else if ((filteredSpike_timeStamp[index_start] - spikeTimeStampV) < delta_time) {
// if we're not the first or last spike or at the limit, and
// If the current time stamp of a spike is within the delta_time then
// we buffer the spike and start reading the next spike...
spikeLen++;
continue;
}
// initiate the spike counter for one cycle to 0
for(i = 0; i < num_object; i++){
numFired[i] = 0;
}
/*********************************************************/
/*******Call multi-spike "kernel"*************************/
/*********************************************************/
for(spk_cnt = 0; spk_cnt < spikeLen; spk_cnt++){
// update time stamp and address of the input spike
spikeTimeStampV = filteredSpike_timeStamp[spk_cnt+index_start];
int addrx = filteredSpike_addr[spk_cnt+index_start]&0xff;
int addry = (filteredSpike_addr[spk_cnt+index_start]>>8)&0xff;
// calculate the coverage of the template which centers around the address of the current spike
int min_x = addrx - (MAX_TEMPLATE_SIZE/2) + 1;
int temp_min_x = (min_x < 0 ) ? min_x - 1 : min_x;
min_x = (min_x < 0 ) ? 0 : min_x;
int min_y = addry - (MAX_TEMPLATE_SIZE/2) + 1;
int temp_min_y = (min_y < 0 ) ? min_y - 1 : min_y;
min_y = (min_y < 0 ) ? 0 : min_y;
int max_x = addrx + (MAX_TEMPLATE_SIZE/2);
max_x = (max_x > MAX_X) ? MAX_X : max_x;
int max_y = addry + (MAX_TEMPLATE_SIZE/2);
max_y = (max_y > MAX_Y) ? MAX_Y : max_y;
// iterate through all the template covered addresses and calculate the membrane potentials
for(i = min_x; i < max_x; i++) {
for(j = min_y; j < max_y; j++) {
assert(i-temp_min_x>=0);
assert(i-temp_min_x<MAX_TEMPLATE_SIZE);
assert(j-temp_min_y>=0);
assert(j-temp_min_y<MAX_TEMPLATE_SIZE);
for(objId = 0; objId < num_object; objId++) {
// calculate membrane potential for each neuron
unsigned long timeDiff = spikeTimeStampV-lastTimeStamp[j][i];
float decayFactor = (float)exp(timeDiff/hostNeuronParams.membraneTau*(-1.0f));
membranePotential[objId][j][i] = membranePotential[objId][j][i]*decayFactor +
conv_template[objId][j-temp_min_y][i-temp_min_x];
if((membranePotential[objId][j][i]) > hostNeuronParams.threshold) { // hit the threshold
cpu_totFiring++; // total number of spikes from all populations
numFired[objId]++; // number of generated spikes within one population in current cycle
cpu_totFiringMO[objId]++; // total number of generated spikes within one population
membranePotential[objId][j][i] = 0;
#if RECORD_FIRING_INFO
fprintf(fpFiring, "%u %d %d\n", timeStamp, i, j);
#endif
// send the excitatory output events back to jaer
#if !REPLAY_MODE
jaerSendEvent(i,j,spikeTimeStampV,objId);
#endif
}
else if ( membranePotential[objId][j][i] < hostNeuronParams.membranePotentialMin ) { // hit the lower bound of membrane potential
membranePotential[objId][j][i] = hostNeuronParams.membranePotentialMin;
}
}
lastTimeStamp[j][i] = spikeTimeStampV;
}
}
// Delta crossed for grouping, and calculate the inhibitory membrane potential
for(i = 0; i < num_object; i++){
if(numFired[i])
ineuron_fired = update_inh_neuron(fpFiring, spikeTimeStampV, i, numFired[i]);
#if !REPLAY_MODE
if(ineuron_fired)
jaerSendEvent(1,1,spikeTimeStampV,0);
}
#endif
if(debugLevel>1){
printf("# spikes fired by object layers: ");
for(int i=0;i<num_object;i++){
printf("%d, ",numFired[i]);
}
printf("\n");
}
}
spikeLen = 0;
index_start = spk_i;
}
}
/** This kernel is to update neurons (from different populations) at the same position together, and add in lateral inhibition between these neurons for each input spike
* @param: numInSpikes the number of input spikes received from jaer
**/
void update_neurons_grouping_inh(int numInSpikes)
{
// initiate variables with the first spike
int spikeLen = 0;
unsigned long spikeTimeStampV = filteredSpike_timeStamp[0]; // set the global timestamp for packet
static FILE* fpFiring = NULL;
int numFired[MAX_NUM_TEMPLATE];
char b_NeuronFired; // It takes as many bits as num_object. Each bit reflects if there is a spike generated by a neuron at the same location but from different population
#if RECORD_FIRING_INFO
if(fpFiring == NULL){
if ((fpFiring = fopen("firing.m", "w")) == NULL){
printf("failed to open file firing.m");
return;
}
}
#endif
int i,j,spk_cnt,spk_i,index_start = 0,objId,m;
// this loop iterates over spikes in the packet, calling the "kernel" periodically when it has collected enough
// spikes.
for (spk_i = 0; spk_i < numInSpikes; spk_i++ ) {
/*********************************************************/
/****Generate input event packet ************************/
/*********************************************************/
if (spk_i==(numInSpikes-1)){
// this is the last spike then just go and process the bufferred spikes in the GPU.
spikeLen++; // just increment number of spikes to be processed
}
else if (spikeLen == (GPU_MAX_SPIKE_PACKETS)) {
// our buffer is full. so go and process existing spike buffer the current spike will be part of next group..
}
else if ((filteredSpike_timeStamp[index_start] - spikeTimeStampV) < delta_time) {
// if we're not the first or last spike or at the limit, and
// If the current time stamp of a spike is within the delta_time then
// we buffer the spike and start reading the next spike...
spikeLen++;
continue;
}
// initiate the spike counter for one cycle to 0
for(i = 0; i < num_object; i++){
numFired[i] = 0;
}
/*********************************************************/
/*******Call multi-spike "kernel"*************************/
/*********************************************************/
for(spk_cnt = 0; spk_cnt < spikeLen; spk_cnt++){
// update time stamp and address of the input spike
spikeTimeStampV = filteredSpike_timeStamp[spk_cnt+index_start];
int addrx = filteredSpike_addr[spk_cnt+index_start]&0xff;
int addry = (filteredSpike_addr[spk_cnt+index_start]>>8)&0xff;
b_NeuronFired = 0; // reset the spike flags
// calculate the coverage of the template which centers around the address of the current spike
int min_x = addrx - (MAX_TEMPLATE_SIZE/2) + 1;
int temp_min_x = (min_x < 0 ) ? min_x - 1 : min_x;
min_x = (min_x < 0 ) ? 0 : min_x;
int min_y = addry - (MAX_TEMPLATE_SIZE/2) + 1;
int temp_min_y = (min_y < 0 ) ? min_y - 1 : min_y;
min_y = (min_y < 0 ) ? 0 : min_y;
int max_x = addrx + (MAX_TEMPLATE_SIZE/2);
max_x = (max_x > MAX_X) ? MAX_X : max_x;
int max_y = addry + (MAX_TEMPLATE_SIZE/2);
max_y = (max_y > MAX_Y ) ? MAX_Y : max_y;
// iterate through all the template covered addresses and calculate the membrane potentials
for(i = min_x; i < max_x; i++) {
for(j = min_y; j < max_y; j++) {
assert(i-temp_min_x>=0);
assert(i-temp_min_x<MAX_TEMPLATE_SIZE);
assert(j-temp_min_y>=0);
assert(j-temp_min_y<MAX_TEMPLATE_SIZE);
for(objId = 0; objId < num_object; objId++) {
// calculate membrane potential for each neuron
unsigned long timeDiff = spikeTimeStampV-lastTimeStamp[j][i];
float decayFactor = (float)exp(timeDiff/hostNeuronParams.membraneTau*(-1.0f));
membranePotential[objId][j][i] = membranePotential[objId][j][i]*decayFactor +
conv_template[objId][j-temp_min_y][i-temp_min_x];
if((membranePotential[objId][j][i]) > hostNeuronParams.threshold) { // hit the threshold
cpu_totFiring++; // total number of spikes from all populations
numFired[objId]++; // number of generated spikes within one population in current cycle
cpu_totFiringMO[objId]++; // total number of generated spikes within one population
membranePotential[objId][j][i] = 0;
b_NeuronFired = (char)(b_NeuronFired | (0x01 << objId)); // set corresponding bit if one neuron in one population generates a spike
#if RECORD_FIRING_INFO
fprintf(fpFiring, "%u %d %d\n", spikeTimeStampV, i, j);
#endif
// send the excitatory output events back to jaer
#if !REPLAY_MODE
jaerSendEvent(i,j,spikeTimeStampV,objId);
#endif
}
else if ( membranePotential[objId][j][i] < hostNeuronParams.membranePotentialMin ) { // hit the lower bound of membrane potential
membranePotential[objId][j][i] = hostNeuronParams.membranePotentialMin;
}
}
// update lastTimeStamp
lastTimeStamp[j][i] = spikeTimeStampV;
// if a spike is generated, inhibit all the neurons at the same location but in other populations
if(b_NeuronFired != 0){
for(objId = 0; objId < num_object; objId++){
char neuronFired = (b_NeuronFired >> objId) & (0x01); // check if there is a spike from the neuron
for(m = 0; m < num_object; m++){ // inhibit all the other neurons from other populations at the same location
if(objId != m){
membranePotential[m][j][i] = membranePotential[m][j][i] - neuronFired * hostNeuronParams.iESynWeight;
if (membranePotential[m][j][i] < hostNeuronParams.membranePotentialMin)
membranePotential[m][j][i] = hostNeuronParams.membranePotentialMin;
}
}
}
}
}
}
}
if(debugLevel>1){
printf("# spikes fired by object layers: ");
for(int i=0;i<num_object;i++){
printf("%d, ",numFired[i]);
}
printf("\n");
}
spikeLen = 0; // reset length
index_start = spk_i;
}
}
/** This kernel is to update neurons (from different populations) at the same position together, and add in lateral inhibition between these neurons for each input spike
* local inhibition between populations for each kernel call
* @param: numInSpikes the number of input spikes received from jaer
**/
void update_neurons_grouping_inh1(int numInSpikes)
{
// initiate variables with the first spike
int spikeLen = 0;
unsigned long spikeTimeStampV = filteredSpike_timeStamp[0]; // set the global timestamp for packet
static FILE* fpFiring = NULL;
char b_NeuronFired; // It takes as many bits as num_object. Each bit reflects if there is a spike generated by a neuron at the same location but from different population
int numFired[MAX_NUM_TEMPLATE]; // number of generated spikes within one population in current cycle
float decayFactor = 1.0;
unsigned long timeDiff;
#if RECORD_FIRING_INFO
if(fpFiring == NULL){
if ((fpFiring = fopen("firing.m", "w")) == NULL){
printf("failed to open file firing.m");
return;
}
}
#endif
int i,j,spk_cnt,spk_i, index_start = 0,objId,m,n;
// this loop iterates over spikes in the packet, calling the "kernel" periodically when it has collected enough
// spikes.
for (spk_i = 0; spk_i < numInSpikes; spk_i++ ) {
/*********************************************************/
/****Generate input event packet *************************/
/*********************************************************/
if (spk_i==(numInSpikes-1)){
// this is the last spike then just go and process the bufferred spikes in the GPU.
spikeLen++; // just increment number of spikes to be processed
}
else if (spikeLen == (GPU_MAX_SPIKE_PACKETS)) {
// our buffer is full. so go and process existing spike buffer the current spike will be part of next group..
}
else if ((filteredSpike_timeStamp[index_start] - spikeTimeStampV) < delta_time) {
// if we're not the first or last spike or at the limit, and
// If the current time stamp of a spike is within the delta_time then
// we buffer the spike and start reading the next spike...
spikeLen++;
continue;
}
int curNumFiringTmp[MAX_NUM_TEMPLATE]; // number of inhibitory spikes received from other neurons during last cycle
// iterate through all the neurons in the network, calculate the total amount of inhibitory spikes received from local areas of other populations and update the membrane potential
for(i = 0; i < MAX_X; i++){
for(j = 0; j < MAX_Y; j++){
timeDiff = filteredSpike_timeStamp[index_start]-lastTimeStamp[j][i];
decayFactor = (float)exp(timeDiff/hostNeuronParams.membraneTau*(-1.0f));
// count the number of inhibitory input spikes from last cycle
for(objId = 0; objId < num_object; objId++){
curNumFiringTmp[objId] = 0;
for(m = -radius_loc_inh; m <= radius_loc_inh; m++){ // check the local area centered by the neuron's location
int tmp_addrx = i + m;
int tmp_addry = j + m;
if((tmp_addrx >= 0) & (tmp_addry >= 0) & (tmp_addrx < MAX_X) & (tmp_addry < MAX_Y)){ // boundary check
for(n = 0; n < num_object; n++){ // accumulate all the spikes generated from other populations
if(n != objId){
curNumFiringTmp[objId] += curNumFiring[n][tmp_addry][tmp_addrx];
}
}
}
}
membranePotential[objId][j][i] = (membranePotential[objId][j][i] - curNumFiringTmp[objId] * hostNeuronParams.iESynWeight) * decayFactor;
curNumFiring[objId][j][i] = 0; // reset the spike counter for current cycle
}
lastTimeStamp[j][i] = filteredSpike_timeStamp[index_start]; //update lastTimeStamp
}
}
// initiate the spike counter for one cycle to 0
for(i = 0; i < num_object; i++){
numFired[i] = 0;
}
/*********************************************************/
/*******Call multi-spike "kernel"*************************/
/*********************************************************/
for(spk_cnt = 0; spk_cnt < spikeLen; spk_cnt++){
// update time stamp and address of the input spike
spikeTimeStampV = filteredSpike_timeStamp[spk_cnt+index_start];
int addrx = filteredSpike_addr[spk_cnt+index_start]&0xff;
int addry = (filteredSpike_addr[spk_cnt+index_start]>>8)&0xff;
b_NeuronFired = 0; // reset the spike counter
// calculate the coverage of the template which centers around the address of the current spike
int min_x = addrx - (MAX_TEMPLATE_SIZE/2) + 1;
int temp_min_x = (min_x < 0 ) ? min_x - 1 : min_x;
min_x = (min_x < 0 ) ? 0 : min_x;
int min_y = addry - (MAX_TEMPLATE_SIZE/2) + 1;
int temp_min_y = (min_y < 0 ) ? min_y - 1 : min_y;
min_y = (min_y < 0 ) ? 0 : min_y;
int max_x = addrx + (MAX_TEMPLATE_SIZE/2);
max_x = (max_x > MAX_X) ? MAX_X : max_x;
int max_y = addry + (MAX_TEMPLATE_SIZE/2);
max_y = (max_y > MAX_Y ) ? MAX_Y : max_y;
// iterate through all the template covered addresses and calculate the membrane potentials
for(i = min_x; i < max_x; i++) {
for(j = min_y; j < max_y; j++) {
assert(i-temp_min_x>=0);
assert(i-temp_min_x<MAX_TEMPLATE_SIZE);
assert(j-temp_min_y>=0);
assert(j-temp_min_y<MAX_TEMPLATE_SIZE);
for(objId = 0; objId < num_object; objId++) {
// calculate membrane potential for each neuron
timeDiff = spikeTimeStampV-lastTimeStamp[j][i];
decayFactor = (float)exp(timeDiff/hostNeuronParams.membraneTau*(-1.0f));
membranePotential[objId][j][i] = membranePotential[objId][j][i]*decayFactor +
conv_template[objId][j-temp_min_y][i-temp_min_x];
if((membranePotential[objId][j][i]) > hostNeuronParams.threshold) { // hit the threshold
cpu_totFiring++; // total number of spikes from all populations
cpu_totFiringMO[objId]++; // total number of generated spikes within one population
numFired[objId]++; // number of generated spikes within one population in current cycle
curNumFiring[objId][j][i]++; // number of generated spikes for each neuron in current cycle
membranePotential[objId][j][i] = 0;
b_NeuronFired = (char)(b_NeuronFired | (0x01 << objId)); // set corresponding bit if one neuron in one population generates a spike
#if RECORD_FIRING_INFO
fprintf(fpFiring, "%u %d %d\n", spikeTimeStampV, i, j);
#endif
// send the excitatory output events back to jaer
#if !REPLAY_MODE
jaerSendEvent(i,j,spikeTimeStampV,objId);
#endif
}
else if ( membranePotential[objId][j][i] < hostNeuronParams.membranePotentialMin ) { // hit the lower bound of membrane potential
membranePotential[objId][j][i] = hostNeuronParams.membranePotentialMin;
}
}
lastTimeStamp[j][i] = spikeTimeStampV;
// if a spike is generated, inhibit all the neurons at the same location but in other populations
if(b_NeuronFired != 0){
for(objId = 0; objId < num_object; objId++){
char neuronFired = (b_NeuronFired >> objId) & (0x01); // check if there is a spike from the neuron
for(m = 0; m < num_object; m++){ // inhibit all the other neurons from other populations at the same location
if(objId != m){
membranePotential[m][j][i] = membranePotential[m][j][i] - neuronFired * hostNeuronParams.iESynWeight;
if (membranePotential[m][j][i] < hostNeuronParams.membranePotentialMin)
membranePotential[m][j][i] = hostNeuronParams.membranePotentialMin;
}
}
}
}
}
}
}
if(debugLevel>1){
printf("# spikes fired by object layers: ");
for(int i=0;i<num_object;i++){
printf("%d, ",numFired[i]);
}
printf("\n");
}
spikeLen = 0; // reset length
index_start = spk_i;
}
}
/** cpu mode computation
* @param: numInSpikes the number of input spikes received from jaer
**/
void computeGold(int numInSpike)
{
#if CPU_ENABLE_SPIKE_GROUPING
update_neurons_grouping_inh1(numInSpike);
#else
update_neurons(numInSpike);
#endif
}
/******************************************************************************************************************************/
/********************************** TEMPLATE GENERATION ***********************************************************************/
/******************************************************************************************************************************/
/** generate a two dimensional Gaussian template with constant negative margin
* @param: templateIndex the index of the template
* @param: sizeObject the size of the ball
**/
void templateConvGau(int templateIndex, float sizeObject)
{
if(debugLevel>0) {
printf("templateConvGau: Generating Template #%d for sizeObject=%f\n",templateIndex,sizeObject);
}
float center = (float)(MAX_TEMPLATE_SIZE/2);
int i, j;
if(sizeObject < MAX_TEMPLATE_SIZE){
//float ampFactor = MAX_TEMPLATE_SIZE/sizeObject/2;
float maxNegAmp = MAX_NEG_AMP;
float maxAmpActivation = MAX_AMP_ACTIVATION;
for(i = 0; i < MAX_TEMPLATE_SIZE; i++){ // scanning through vertical axis
float dist = abs(i - center);
for(j = 0; j < MAX_TEMPLATE_SIZE; j++){ // scanning through horizontal axis, each row contains 0 to 2 Gaussian bumps depending on their vertical location
if(dist > sizeObject) // if the vertical distance is larger than the size of the object, the amplitude is defined as max negative value
conv_template[templateIndex][i][j] = maxNegAmp;
else if(dist == sizeObject){ // if the vertical distance is equal to the size of the object, there is one peak which is located at the center of the row
float meanGauss = center;
conv_template[templateIndex][i][j] = maxAmpActivation*exp(-(pow((j - meanGauss),2))/(GAUSS_VAR*GAUSS_VAR)) + maxNegAmp;
}
else { // if the vertical distance is smaller than the size of the object, there are two Gaussian peaks symmetric around the center
float radiusGauss = sqrt(sizeObject*sizeObject - dist*dist);
float meanGauss1 = center - radiusGauss,
meanGauss2 = center + radiusGauss;
if(j <= center)
conv_template[templateIndex][i][j] = maxAmpActivation*exp(-(pow((j - meanGauss1),2))/(GAUSS_VAR*GAUSS_VAR)) + maxNegAmp;
else
conv_template[templateIndex][i][j] = maxAmpActivation*exp(-(pow((j - meanGauss2),2))/(GAUSS_VAR*GAUSS_VAR)) + maxNegAmp;
}
}
}
//transpose of the template matrix to reverse the horizontal and vertical axis
float temp;
for(i = 0; i < MAX_TEMPLATE_SIZE; i++){
for(j = 0; j < MAX_TEMPLATE_SIZE; j++){
if(i > j){
temp = conv_template[templateIndex][i][j];
conv_template[templateIndex][i][j] = conv_template[templateIndex][j][i];
conv_template[templateIndex][j][i] = temp;
}
}
}
// calculate the amplitude in the transposed orientation again to eliminate the unsymmetry of the resulting template
for(i = 0; i < MAX_TEMPLATE_SIZE; i++){
float dist = abs(i - center);
for(j = 0; j < MAX_TEMPLATE_SIZE; j++){
if(dist > sizeObject)
conv_template[templateIndex][i][j] = conv_template[templateIndex][i][j] + maxNegAmp;
else if(dist == sizeObject){
float meanGauss = center;
conv_template[templateIndex][i][j] = conv_template[templateIndex][i][j] + maxAmpActivation*exp(-(pow((j - meanGauss),2))/(GAUSS_VAR*GAUSS_VAR)) + maxNegAmp;
}
else {
float radiusGauss = sqrt(sizeObject*sizeObject - dist*dist);
float meanGauss1 = center - radiusGauss,
meanGauss2 = center + radiusGauss;
if(j <= center)
conv_template[templateIndex][i][j] = conv_template[templateIndex][i][j] + maxAmpActivation*exp(-(pow((j - meanGauss1),2))/(GAUSS_VAR*GAUSS_VAR)) + maxNegAmp;
else
conv_template[templateIndex][i][j] = conv_template[templateIndex][i][j] + maxAmpActivation*exp(-(pow((j - meanGauss2),2))/(GAUSS_VAR*GAUSS_VAR)) + maxNegAmp;
}
}
}
// transpose back to the original orientation
for(i = 0; i < MAX_TEMPLATE_SIZE; i++){
for(j = 0; j < MAX_TEMPLATE_SIZE; j++){
if(i > j){
temp = conv_template[templateIndex][i][j];
conv_template[templateIndex][i][j] = conv_template[templateIndex][j][i];
conv_template[templateIndex][j][i] = temp;
}
}
}
// make templates have zero integral
// compute sum of all template values to check zero integral
float templateSum=0;
for(i=0;i<MAX_TEMPLATE_SIZE;i++)
for(j=0;j<MAX_TEMPLATE_SIZE;j++)
templateSum+= conv_template[templateIndex][j][i]; // integrate
float f=templateSum/MAX_TEMPLATE_SIZE/MAX_TEMPLATE_SIZE; // compute value to subtract from each element
for(i=0;i<MAX_TEMPLATE_SIZE;i++)
for(j=0;j<MAX_TEMPLATE_SIZE;j++)
conv_template[templateIndex][j][i]-=f; // subtract it
if(debugLevel>1){ // now print integral
float templateSum=0;
for(i=0;i<MAX_TEMPLATE_SIZE;i++)
for(j=0;j<MAX_TEMPLATE_SIZE;j++)
templateSum+= conv_template[templateIndex][j][i];
printf("Integral of template #%d for sizeObject=%f is %f\n",templateIndex,sizeObject,templateSum);
}
}
else{
fprintf(stderr,"object size (%f) should be smaller than template size (%d).\n",sizeObject,MAX_TEMPLATE_SIZE);
}
}
/** generate a two dimensional DOG template
* @param: templateIndex the index of the template
* @param: sizeObject the size of the ball
**/
void templateConvDoG(int templateIndex, float sizeObject)
{
if(debugLevel>0){
printf("Generating DoG Template #%d for sizeObject=%f\n",templateIndex,sizeObject);
}
//float sizeObject = MAX_OBJECT_SIZE;
float center = (float)(MAX_TEMPLATE_SIZE/2);
int i, j;
// difference of gaussian shape template
if(sizeObject < MAX_TEMPLATE_SIZE){
//float ampFactor = MAX_TEMPLATE_SIZE/sizeObject/2;
float maxNegAmp = MAX_NEG_AMP;
float maxAmpActivation = MAX_AMP_ACTIVATION;
for(i = 0; i < MAX_TEMPLATE_SIZE; i++){
float dist = abs(i - center);
for(j = 0; j < MAX_TEMPLATE_SIZE; j++){
if(dist > sizeObject)
conv_template[templateIndex][i][j] = maxNegAmp;
else if(dist == sizeObject){
float meanGauss = center;
conv_template[templateIndex][i][j] = maxAmpActivation*exp(-(pow((j - meanGauss),2))/(GAUSS_VAR*GAUSS_VAR)) - maxNegAmp*exp(-(pow((j - meanGauss),2))/(GAUSS_VAR_NEG*GAUSS_VAR_NEG));
} else {
float radiusGauss = sqrt(sizeObject*sizeObject - dist*dist);
float meanGauss1 = center - radiusGauss,
meanGauss2 = center + radiusGauss;
if(j <= center)
conv_template[templateIndex][i][j] = maxAmpActivation*exp(-(pow((j - meanGauss1),2))/(GAUSS_VAR*GAUSS_VAR)) - maxNegAmp*exp(-(pow((j - meanGauss1),2))/(GAUSS_VAR_NEG*GAUSS_VAR_NEG));
else
conv_template[templateIndex][i][j] = maxAmpActivation*exp(-(pow((j - meanGauss2),2))/(GAUSS_VAR*GAUSS_VAR)) - maxNegAmp*exp(-(pow((j - meanGauss2),2))/(GAUSS_VAR_NEG*GAUSS_VAR_NEG));
}
}
}
//transpose
float temp;
for(i = 0; i < MAX_TEMPLATE_SIZE; i++){
for(j = 0; j < MAX_TEMPLATE_SIZE; j++){
if(i > j){
temp = conv_template[templateIndex][i][j];
conv_template[templateIndex][i][j] = conv_template[templateIndex][j][i];
conv_template[templateIndex][j][i] = temp;
}
}
}
for(i = 0; i < MAX_TEMPLATE_SIZE; i++){
float dist = abs(i - center);
for(j = 0; j < MAX_TEMPLATE_SIZE; j++){
if(dist > sizeObject)
conv_template[templateIndex][i][j] = conv_template[templateIndex][i][j];
else if(dist == sizeObject){
float meanGauss = center;
conv_template[templateIndex][i][j] = conv_template[templateIndex][i][j] + maxAmpActivation*exp(-(pow((j - meanGauss),2))/(GAUSS_VAR*GAUSS_VAR)) - maxNegAmp*exp(-(pow((j - meanGauss),2))/(GAUSS_VAR_NEG*GAUSS_VAR_NEG));
}
else {
float radiusGauss = sqrt(sizeObject*sizeObject - dist*dist);
float meanGauss1 = center - radiusGauss,
meanGauss2 = center + radiusGauss;
if(j <= center)
conv_template[templateIndex][i][j] = conv_template[templateIndex][i][j] + maxAmpActivation*exp(-(pow((j - meanGauss1),2))/(GAUSS_VAR*GAUSS_VAR)) - maxNegAmp*exp(-(pow((j - meanGauss1),2))/(GAUSS_VAR_NEG*GAUSS_VAR_NEG));
else
conv_template[templateIndex][i][j] = conv_template[templateIndex][i][j] + maxAmpActivation*exp(-(pow((j - meanGauss2),2))/(GAUSS_VAR*GAUSS_VAR)) - maxNegAmp*exp(-(pow((j - meanGauss2),2))/(GAUSS_VAR_NEG*GAUSS_VAR_NEG));
}
}
}
for(i = 0; i < MAX_TEMPLATE_SIZE; i++){
for(j = 0; j < MAX_TEMPLATE_SIZE; j++){
if(i > j){
temp = conv_template[templateIndex][i][j];
conv_template[templateIndex][i][j] = conv_template[templateIndex][j][i];
conv_template[templateIndex][j][i] = temp;
}
}
}
} else{
fprintf(stderr, "object size (%f) should be smaller than template size (%d); no template generated\n",sizeObject,MAX_TEMPLATE_SIZE);
fflush(stderr);
}
// make templates have zero integral
// compute sum of all template values to check zero integral
float templateSum=0;
for(i=0;i<MAX_TEMPLATE_SIZE;i++)
for(j=0;j<MAX_TEMPLATE_SIZE;j++)
templateSum+= conv_template[templateIndex][j][i]; // integrate
float f=templateSum/MAX_TEMPLATE_SIZE/MAX_TEMPLATE_SIZE; // compute value to subtract from each element
for(i=0;i<MAX_TEMPLATE_SIZE;i++)
for(j=0;j<MAX_TEMPLATE_SIZE;j++)
conv_template[templateIndex][j][i]-=f; // subtract it
if(debugLevel>1){ // now print integral
float templateSum=0;
for(i=0;i<MAX_TEMPLATE_SIZE;i++)
for(j=0;j<MAX_TEMPLATE_SIZE;j++)
templateSum+= conv_template[templateIndex][j][i];
printf("Integral of template #%d for sizeObject=%f is %f\n",templateIndex,sizeObject,templateSum);
}
}
/** generate a two dimensional DOG template
* @param: templateIndex the index of the template
**/
void templateGabor(int templateIndex)
{
float sigma_x = 1/PI * sqrt( log( 2.0F )/2) * ((pow(2,f_gabor_bandwidth)+1) / (pow(2,f_gabor_bandwidth)-1)) * f_gabor_lambda;
float sigma_y = sigma_x / f_gabor_gamma;
float x, y, theta_radian = f_gabor_theta[templateIndex]/360*2*PI;
float x_theta, y_theta;
for(int i = 0; i < MAX_TEMPLATE_SIZE; i++){
y = -f_gabor_xymax+i*f_gabor_xymax/(float)(MAX_TEMPLATE_SIZE-1)*2;
for(int j = 0; j < MAX_TEMPLATE_SIZE; j++){
x = -f_gabor_xymax+j*f_gabor_xymax/(float)(MAX_TEMPLATE_SIZE-1)*2;
x_theta=x*cos(theta_radian)+y*sin(theta_radian);
y_theta=-x*sin(theta_radian)+y*cos(theta_radian);
conv_template[templateIndex][i][j] = f_gabor_maxamp*exp(-(pow(x_theta,2)/pow(sigma_x,2)+pow(y_theta,2)/pow(sigma_y,2))/2) * cos(2 * PI / f_gabor_lambda*x_theta + f_gabor_psi);
}
}
}
int circleArr[MAX_TEMPLATE_SIZE][MAX_TEMPLATE_SIZE];
int countPixel=0;
int pixelPos[2*MAX_TEMPLATE_SIZE][2];
#define setPixel(a,b) {circleArr[a][b]=1; assert(countPixel < 2*MAX_TEMPLATE_SIZE); pixelPos[countPixel][0]=a; pixelPos[countPixel][1]=b; countPixel++;}
/** generate a circle for given radius and centered at x0,y0.
* @param: x0,y0 the center of the circle
* @pram: radius the radius of the circle
**/
void rasterCircle(int x0, int y0, int radius)
{
memset(circleArr,0,sizeof(circleArr));
int f = 1 - radius;
int ddF_x = 1;
int ddF_y = -2 * radius;
int x = 0;
int y = radius;
setPixel(x0, y0 + radius);
setPixel(x0, y0 - radius);
setPixel(x0 + radius, y0);
setPixel(x0 - radius, y0);
while(x < y)
{
if(f >= 0)
{
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
setPixel(x0 + x, y0 + y);
setPixel(x0 - x, y0 + y);
setPixel(x0 + x, y0 - y);
setPixel(x0 - x, y0 - y);
setPixel(x0 + y, y0 + x);
setPixel(x0 - y, y0 + x);
setPixel(x0 + y, y0 - x);
setPixel(x0 - y, y0 - x);
}
}
float gaussianArr0[MAX_TEMPLATE_SIZE][MAX_TEMPLATE_SIZE];
float gaussianArr1[MAX_TEMPLATE_SIZE][MAX_TEMPLATE_SIZE];
float diffGaussArr[MAX_TEMPLATE_SIZE][MAX_TEMPLATE_SIZE];
float gaussianRing[MAX_TEMPLATE_SIZE][MAX_TEMPLATE_SIZE];
float diffGaussianRing[MAX_TEMPLATE_SIZE][MAX_TEMPLATE_SIZE];
// generate a 2D diff-of-gaussian for given parameters
void initGaussianDoG(int idx, float sigma0, float maxAmp0, float sigma1, float maxAmp1)
{
int i,j;
float center = (MAX_TEMPLATE_SIZE/2);
for(i=0; i < MAX_TEMPLATE_SIZE; i++) {
for(j=0; j < MAX_TEMPLATE_SIZE; j++) {
double distSqr = ((pow((double)(i-center),2))+(pow((double)(j-center),2.0)));
gaussianArr0[i][j] = (float)( (maxAmp0)*exp(-distSqr/(2*sigma0*sigma0)));
gaussianArr1[i][j] = (float)( (maxAmp1)*exp(-distSqr/(2*sigma1*sigma1)));
}
}
float sumDOG = 0.0;
for(i=0; i < MAX_TEMPLATE_SIZE; i++) {
for(j=0; j < MAX_TEMPLATE_SIZE; j++) {
diffGaussArr[i][j] = gaussianArr0[i][j] - gaussianArr1[i][j];
}
}
}
// generate a simple 2D gaussian for given parameters
void initGaussianGau(float sigma0, float maxAmp0, float minAmp0)
{
int i,j;
float center = (MAX_TEMPLATE_SIZE/2);
for(i=0; i < MAX_TEMPLATE_SIZE; i++) {
for(j=0; j < MAX_TEMPLATE_SIZE; j++) {
double distSqr = ((pow((double)(i-center),2))+(pow((double)(j-center),2.0)));
gaussianArr0[i][j] = (float)( (maxAmp0-minAmp0)*exp(-distSqr/(2*sigma0*sigma0)) + minAmp0);
}
}
}
///////////////////////////////////////////////////////////////
// This function dumps the generated gaussian
// using method0, into a file pointed by fp.
// Run the generated file to visualize the
// different kinds of generated templates using method0
// File name is: "template_[DoG|Gau][0|1].m"
////////////////////////////////////////////////////////////////
void dumpGauss(FILE* fp, int idx)
{
int i,j;
if(fp==NULL) {
return;
}
fprintf(fp, "gauss%d=[\n",idx);
for(i=0; i < MAX_TEMPLATE_SIZE; i++) {
for(j=0; j < MAX_TEMPLATE_SIZE; j++) {
fprintf(fp, "%f ", gaussianArr0[i][j] );
}
fprintf(fp, ";\n");
}
fprintf(fp, "];\n");
fprintf(fp, "circleArr%d=[\n",idx);
for(i=0; i < MAX_TEMPLATE_SIZE; i++) {
for(j=0; j < MAX_TEMPLATE_SIZE; j++) {
fprintf(fp, "%d ", circleArr[i][j] );
}
fprintf(fp, ";\n");
}
fprintf(fp, "];\n");
fprintf(fp, "ringTemplate%d=[\n",idx);
for(i=0; i < MAX_TEMPLATE_SIZE; i++) {
for(j=0; j < MAX_TEMPLATE_SIZE; j++) {
fprintf(fp, "%f ", conv_template[idx][i][j]);
}
fprintf(fp, ";\n");
}
fprintf(fp, "];\n");
fprintf(fp, "figure; subplot(1,3,1); surf(gauss%d); subplot(1,3,2); imagesc(circleArr%d); subplot(1,3,3); surf(ringTemplate%d);\n",idx,idx,idx);
fflush(fp);
}
////////////////////////////////////////////////////
// Generate a template for ball using gaussian parameters
// Uses a different method0 for generating template.
// (1) we draw a clear circle using 'rasterCircle' function.
// (2) we create a simple 2D gaussian using 'initGaussian' function
// (3) reproduce this gaussian for every point in the circle to create a gaussian ring
////////////////////////////////////////////////////
void generateObjectTemplate(FILE* fp, int templateIndex, int templateType)
{
int i,j,k;
countPixel=0;
int objectRadius = (int)objSizeArray[templateIndex];
rasterCircle(MAX_TEMPLATE_SIZE/2,MAX_TEMPLATE_SIZE/2, objectRadius);
if (templateType==TEMPLATE_DoG)
initGaussianDoG(templateIndex,SIGMA1, MAX_AMP1, SIGMA2, MAX_AMP2);
else
initGaussianGau(SIGMA0, MAX_AMP0, MIN_AMP0);
float templateSum=0;
for(i=0; i < MAX_TEMPLATE_SIZE; i++) {
for(j=0; j < MAX_TEMPLATE_SIZE; j++) {
float minVal=1000000;
int m,n;
for(k=0; k < countPixel; k++) {
float distXY = sqrt(pow((float)(i-pixelPos[k][0]),2)+pow((float)(j-pixelPos[k][1]),2));
if(distXY <= minVal) {
minVal = distXY;
m = pixelPos[k][0];
n = pixelPos[k][1];
}
}
if (templateType==TEMPLATE_DoG)
conv_template[templateIndex][i][j] = diffGaussArr[(MAX_TEMPLATE_SIZE/2)+i-m][(MAX_TEMPLATE_SIZE/2)+j-n];
else
conv_template[templateIndex][i][j] = gaussianArr0[(MAX_TEMPLATE_SIZE/2)+i-m][(MAX_TEMPLATE_SIZE/2)+j-n];
templateSum+=conv_template[templateIndex][i][j];
}
}
if(debugLevel>1){
printf("generated template %d, sum of values=%f\n",templateIndex,templateSum);
}
dumpGauss(fp, templateIndex);
}
//////////////////////////////////////////////////////////////
// Generate template for different sizes of objects.
// We have two methods, and method 1 seems to work
// well when it comes circular template.
//
// selectType = 0 => Use method0
// selectType = 1 => Use method1 (default)
//
// templateType = TEMP_DoG => Simple Ring Diff-of-Gaussian
// templateType = TEMP_GAU => Simple Ring Gaussian (default)
//
// return 0, if succesful, else return -1;
//
// TIP: After simulation, run the matlab script "template_[DoG|Gau][0|1].m"
// to see the kinds of template generated/used by the program.
// >>> template_[DoG|Gau][0|1]
//////////////////////////////////////////////////////////////////
int templateConvInit(int selectType, int templateType)
{
int i,j,k;
/// .... dump the generated template as a matlab file.
FILE *fp;
char fstr[100];
sprintf(fstr,"template.m");
fp = fopen(fstr,"w");
if(fp==NULL){
fprintf(stderr,"Warning !! ... Couldn't create %s for output, skipping writing templates\n", fstr);
fflush(stderr);
}
switch(selectType) {
case TEMP_METHOD0:
// generate template using method0
if(debugLevel>0) printf("generating template using method0\n");
for(i = 0; i < num_object; i++){
generateObjectTemplate(fp, i, templateType);
}
break;
case TEMP_METHOD1:
// generate template using method1
if(debugLevel>0) printf("generating template using method1\n");
if(templateType==TEMPLATE_DoG){
for(i = 0; i < num_object; i++){
templateConvDoG(i,objSizeArray[i]);
}
}else if(templateType==TEMPLATE_Gau){
for(i = 0; i < num_object; i++){
templateConvGau(i,objSizeArray[i]);
}
}else{
/* // sent from jaer now
for(i = 0; i < num_object; i++){
templateGabor(i);
}
*/
}
}
dumpTemplate(fp,fstr);
////...... reset the variables for simulations on CPU...
for(k=0; k < num_object; k++)
for(i = 0; i < MAX_X; i++)
for(j = 0; j<MAX_Y; j++)
membranePotential[k][i][j] = 0;
for(k=0; k < num_object; k++)
cpu_totFiringMO[k] = 0;
return 0;
}
| [
"tobidelbruck@b7f4320f-462c-0410-a916-d9f35bb82d52",
"yingxue@b7f4320f-462c-0410-a916-d9f35bb82d52"
]
| [
[
[
1,
11
],
[
14,
14
],
[
29,
29
],
[
31,
37
],
[
43,
47
],
[
50,
51
],
[
55,
56
],
[
58,
63
],
[
93,
94
],
[
96,
99
],
[
309,
332
],
[
336,
336
],
[
338,
339
],
[
342,
350
],
[
354,
354
],
[
359,
359
],
[
364,
364
],
[
420,
420
],
[
431,
431
],
[
433,
434
],
[
441,
441
],
[
443,
443
],
[
459,
459
],
[
475,
475
],
[
479,
482
],
[
487,
487
],
[
491,
491
],
[
494,
494
],
[
535,
536
],
[
555,
555
],
[
557,
561
],
[
566,
566
],
[
568,
568
],
[
570,
570
],
[
574,
581
],
[
583,
583
],
[
600,
600
],
[
616,
616
],
[
620,
623
],
[
625,
625
],
[
630,
630
],
[
634,
634
],
[
637,
637
],
[
699,
699
],
[
708,
709
],
[
711,
711
],
[
714,
714
],
[
722,
722
],
[
739,
739
],
[
756,
756
],
[
769,
769
],
[
789,
789
],
[
791,
791
],
[
793,
794
],
[
810,
812
],
[
896,
900
],
[
902,
903
],
[
909,
909
],
[
911,
911
],
[
913,
913
],
[
915,
917
],
[
926,
931
],
[
933,
934
],
[
940,
940
],
[
943,
943
],
[
945,
947
],
[
949,
959
],
[
961,
961
],
[
964,
971
],
[
974,
974
],
[
976,
993
],
[
997,
1003
],
[
1023,
1024
],
[
1026,
1028
],
[
1034,
1039
],
[
1041,
1041
],
[
1043,
1045
],
[
1051,
1051
],
[
1053,
1070
],
[
1073,
1079
],
[
1081,
1081
],
[
1083,
1100
],
[
1103,
1110
],
[
1112,
1113
],
[
1133,
1134
],
[
1158,
1164
],
[
1169,
1335
],
[
1337,
1365
],
[
1367,
1383
],
[
1387,
1387
],
[
1391,
1392
],
[
1394,
1394
],
[
1398,
1414
]
],
[
[
12,
13
],
[
15,
28
],
[
30,
30
],
[
38,
42
],
[
48,
49
],
[
52,
54
],
[
57,
57
],
[
64,
92
],
[
95,
95
],
[
100,
308
],
[
333,
335
],
[
337,
337
],
[
340,
341
],
[
351,
353
],
[
355,
358
],
[
360,
363
],
[
365,
419
],
[
421,
430
],
[
432,
432
],
[
435,
440
],
[
442,
442
],
[
444,
458
],
[
460,
474
],
[
476,
478
],
[
483,
486
],
[
488,
490
],
[
492,
493
],
[
495,
534
],
[
537,
554
],
[
556,
556
],
[
562,
565
],
[
567,
567
],
[
569,
569
],
[
571,
573
],
[
582,
582
],
[
584,
599
],
[
601,
615
],
[
617,
619
],
[
624,
624
],
[
626,
629
],
[
631,
633
],
[
635,
636
],
[
638,
698
],
[
700,
707
],
[
710,
710
],
[
712,
713
],
[
715,
721
],
[
723,
738
],
[
740,
755
],
[
757,
768
],
[
770,
788
],
[
790,
790
],
[
792,
792
],
[
795,
809
],
[
813,
895
],
[
901,
901
],
[
904,
908
],
[
910,
910
],
[
912,
912
],
[
914,
914
],
[
918,
925
],
[
932,
932
],
[
935,
939
],
[
941,
942
],
[
944,
944
],
[
948,
948
],
[
960,
960
],
[
962,
963
],
[
972,
973
],
[
975,
975
],
[
994,
996
],
[
1004,
1022
],
[
1025,
1025
],
[
1029,
1033
],
[
1040,
1040
],
[
1042,
1042
],
[
1046,
1050
],
[
1052,
1052
],
[
1071,
1072
],
[
1080,
1080
],
[
1082,
1082
],
[
1101,
1102
],
[
1111,
1111
],
[
1114,
1132
],
[
1135,
1157
],
[
1165,
1168
],
[
1336,
1336
],
[
1366,
1366
],
[
1384,
1386
],
[
1388,
1390
],
[
1393,
1393
],
[
1395,
1397
]
]
]
|
8bdcc8d1c18465089db3c682d596ccc0829ac537 | ef23e388061a637f82b815d32f7af8cb60c5bb1f | /src/mame/includes/namcona1.h | d619118a2cb6b366bde8f6482f3cb7695cf5a315 | []
| no_license | marcellodash/psmame | 76fd877a210d50d34f23e50d338e65a17deff066 | 09f52313bd3b06311b910ed67a0e7c70c2dd2535 | refs/heads/master | 2021-05-29T23:57:23.333706 | 2011-06-23T20:11:22 | 2011-06-23T20:11:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,516 | h | enum
{
NAMCO_CGANGPZL,
NAMCO_EMERALDA,
NAMCO_KNCKHEAD,
NAMCO_BKRTMAQ,
NAMCO_EXBANIA,
NAMCO_QUIZTOU,
NAMCO_SWCOURT,
NAMCO_TINKLPIT,
NAMCO_NUMANATH,
NAMCO_FA,
NAMCO_XDAY2
};
#define NA1_NVRAM_SIZE (0x800)
#define NAMCONA1_NUM_TILEMAPS 4
class namcona1_state : public driver_device
{
public:
namcona1_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT16 *m_videoram;
UINT16 *m_spriteram;
UINT16 *m_mpBank0;
UINT16 *m_mpBank1;
int m_mEnableInterrupts;
int m_gametype;
UINT8 m_nvmem[NA1_NVRAM_SIZE];
UINT16 m_count;
UINT32 m_keyval;
UINT16 m_mcu_mailbox[8];
UINT8 m_mcu_port4;
UINT8 m_mcu_port5;
UINT8 m_mcu_port6;
UINT8 m_mcu_port8;
UINT16 *m_workram;
UINT16 *m_vreg;
UINT16 *m_scroll;
UINT16 *m_shaperam;
UINT16 *m_cgram;
tilemap_t *m_roz_tilemap;
int m_roz_palette;
tilemap_t *m_bg_tilemap[NAMCONA1_NUM_TILEMAPS];
int m_tilemap_palette_bank[NAMCONA1_NUM_TILEMAPS];
int m_palette_is_dirty;
UINT8 m_mask_data[8];
UINT8 m_conv_data[9];
};
/*----------- defined in video/namcona1.c -----------*/
extern WRITE16_HANDLER( namcona1_videoram_w );
extern READ16_HANDLER( namcona1_videoram_r );
extern READ16_HANDLER( namcona1_gfxram_r );
extern WRITE16_HANDLER( namcona1_gfxram_w );
extern READ16_HANDLER( namcona1_paletteram_r );
extern WRITE16_HANDLER( namcona1_paletteram_w );
extern SCREEN_UPDATE( namcona1 );
extern VIDEO_START( namcona1 );
| [
"Mike@localhost"
]
| [
[
[
1,
67
]
]
]
|
7d422edb8f06fa389199398f445dacb880b61c39 | 5e6ff9e6e8427078135a7b4d3b194bcbf631e9cd | /EngineSource/dpslim/dpslim/Random/ex-stoc.cpp | 37c1e76f0ac559a4aa77d5c7ca4bdd30d9c484ec | []
| no_license | karakots/dpresurrection | 1a6f3fca00edd24455f1c8ae50764142bb4106e7 | 46725077006571cec1511f31d314ccd7f5a5eeef | refs/heads/master | 2016-09-05T09:26:26.091623 | 2010-02-01T11:24:41 | 2010-02-01T11:24:41 | 32,189,181 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 2,766 | cpp | /*************************** EX-STOC.CPP ******************** AgF 2001-11-11 *
* *
* Example showing how to use non-uniform random variate generator library. *
* Necessary files are in stocc.zip. *
* *
* Compile for console mode. * *
* © 2001 Agner Fog. GNU General Public License www.gnu.org/copyleft/gpl.html *
*****************************************************************************/
#include <time.h> // define time()
#include "randomc.h" // define classes for random number generators
#include "stocc.h" // define random library classes
#ifndef MULTIFILE_PROJECT
// If compiled as a single file then include these cpp files,
// If compiled as a project then compile and link in these cpp files.
#include "mersenne.cpp" // code for random number generator
#include "stoc1.cpp" // random library source code
#include "userintf.cpp" // define system specific user interface
#endif
int main() {
int32 seed = (int32)time(0); // random seed
StochasticLib1 sto(seed); // make instance of random library
int i; // loop counter
double r; // random number
int ir; // random integer number
// make random numbers with uniform distribution
printf("Random numbers with uniform distribution:\n");
for (i=0; i<16; i++) {
ir = sto.IRandom(0, 20);
printf("%8i ", ir);
}
// make random numbers with normal distribution
printf("\n\nRandom numbers with normal distribution:\n");
for (i=0; i<16; i++) {
r = sto.Normal(10, 4);
printf("%8.5f ", r);
}
// make random numbers with poisson distribution
printf("\n\nRandom numbers with poisson distribution:\n");
for (i=0; i<16; i++) {
ir = sto.Poisson(10);
printf("%8i ", ir);
}
// make random numbers with binomial distribution
printf("\n\nRandom numbers with binomial distribution:\n");
for (i=0; i<16; i++) {
ir = sto.Binomial(40, 0.25);
printf("%8i ", ir);
}
// make random numbers with hypergeometric distribution
printf("\n\nRandom numbers with hypergeometric distribution:\n");
for (i=0; i<16; i++) {
ir = sto.Hypergeometric(20, 20, 40);
printf("%8i ", ir);
}
EndOfProgram(); // system-specific exit code
return 0;
}
| [
"Isaac.Noble@fd82578e-0ebe-11df-96d9-85c6b80b8d9c"
]
| [
[
[
1,
67
]
]
]
|
e333c0e4d4c7cdd76322cf8693041bfe6660e5d3 | 04fec4cbb69789d44717aace6c8c5490f2cdfa47 | /include/wx/html/winpars.h | 3c5dd032eee6699ac82786a44f1f42c07035231c | []
| no_license | aaryanapps/whiteTiger | 04f39b00946376c273bcbd323414f0a0b675d49d | 65ed8ffd530f20198280b8a9ea79cb22a6a47acd | refs/heads/master | 2021-01-17T12:07:15.264788 | 2010-10-11T20:20:26 | 2010-10-11T20:20:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,282 | h | /////////////////////////////////////////////////////////////////////////////
// Name: winpars.h
// Purpose: wxHtmlWinParser class (parser to be used with wxHtmlWindow)
// Author: Vaclav Slavik
// RCS-ID: $Id: winpars.h 45498 2007-04-16 13:03:05Z VZ $
// Copyright: (c) 1999 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WINPARS_H_
#define _WX_WINPARS_H_
#include "wx/defs.h"
#if wxUSE_HTML
#include "wx/module.h"
#include "wx/font.h"
#include "wx/html/htmlpars.h"
#include "wx/html/htmlcell.h"
#include "wx/encconv.h"
class WXDLLIMPEXP_HTML wxHtmlWindow;
class WXDLLIMPEXP_HTML wxHtmlWindowInterface;
class WXDLLIMPEXP_HTML wxHtmlWinParser;
class WXDLLIMPEXP_HTML wxHtmlWinTagHandler;
class WXDLLIMPEXP_HTML wxHtmlTagsModule;
//--------------------------------------------------------------------------------
// wxHtmlWinParser
// This class is derived from wxHtmlParser and its mail goal
// is to parse HTML input so that it can be displayed in
// wxHtmlWindow. It uses special wxHtmlWinTagHandler.
//--------------------------------------------------------------------------------
class WXDLLIMPEXP_HTML wxHtmlWinParser : public wxHtmlParser
{
DECLARE_ABSTRACT_CLASS(wxHtmlWinParser)
friend class wxHtmlWindow;
public:
wxHtmlWinParser(wxHtmlWindowInterface *wndIface = NULL);
virtual ~wxHtmlWinParser();
virtual void InitParser(const wxString& source);
virtual void DoneParser();
virtual wxObject* GetProduct();
virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const;
// Set's the DC used for parsing. If SetDC() is not called,
// parsing won't proceed
virtual void SetDC(wxDC *dc, double pixel_scale = 1.0)
{ m_DC = dc; m_PixelScale = pixel_scale; }
wxDC *GetDC() {return m_DC;}
double GetPixelScale() {return m_PixelScale;}
int GetCharHeight() const {return m_CharHeight;}
int GetCharWidth() const {return m_CharWidth;}
// NOTE : these functions do _not_ return _actual_
// height/width. They return h/w of default font
// for this DC. If you want actual values, call
// GetDC()->GetChar...()
// returns interface to the rendering window
wxHtmlWindowInterface *GetWindowInterface() {return m_windowInterface;}
#if WXWIN_COMPATIBILITY_2_6
// deprecated, use GetWindowInterface()->GetHTMLWindow() instead
wxDEPRECATED( wxHtmlWindow *GetWindow() );
#endif
// Sets fonts to be used when displaying HTML page. (if size null then default sizes used).
void SetFonts(const wxString& normal_face, const wxString& fixed_face, const int *sizes = NULL);
// Sets font sizes to be relative to the given size or the system
// default size; use either specified or default font
void SetStandardFonts(int size = -1,
const wxString& normal_face = wxEmptyString,
const wxString& fixed_face = wxEmptyString);
// Adds tags module. see wxHtmlTagsModule for details.
static void AddModule(wxHtmlTagsModule *module);
static void RemoveModule(wxHtmlTagsModule *module);
// parsing-related methods. These methods are called by tag handlers:
// Returns pointer to actual container. Common use in tag handler is :
// m_WParser->GetContainer()->InsertCell(new ...);
wxHtmlContainerCell *GetContainer() const {return m_Container;}
// opens new container. This container is sub-container of opened
// container. Sets GetContainer to newly created container
// and returns it.
wxHtmlContainerCell *OpenContainer();
// works like OpenContainer except that new container is not created
// but c is used. You can use this to directly set actual container
wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
// closes the container and sets actual Container to upper-level
// container
wxHtmlContainerCell *CloseContainer();
int GetFontSize() const {return m_FontSize;}
void SetFontSize(int s);
int GetFontBold() const {return m_FontBold;}
void SetFontBold(int x) {m_FontBold = x;}
int GetFontItalic() const {return m_FontItalic;}
void SetFontItalic(int x) {m_FontItalic = x;}
int GetFontUnderlined() const {return m_FontUnderlined;}
void SetFontUnderlined(int x) {m_FontUnderlined = x;}
int GetFontFixed() const {return m_FontFixed;}
void SetFontFixed(int x) {m_FontFixed = x;}
wxString GetFontFace() const {return GetFontFixed() ? m_FontFaceFixed : m_FontFaceNormal;}
void SetFontFace(const wxString& face);
int GetAlign() const {return m_Align;}
void SetAlign(int a) {m_Align = a;}
wxHtmlScriptMode GetScriptMode() const { return m_ScriptMode; }
void SetScriptMode(wxHtmlScriptMode mode) { m_ScriptMode = mode; }
long GetScriptBaseline() const { return m_ScriptBaseline; }
void SetScriptBaseline(long base) { m_ScriptBaseline = base; }
const wxColour& GetLinkColor() const { return m_LinkColor; }
void SetLinkColor(const wxColour& clr) { m_LinkColor = clr; }
const wxColour& GetActualColor() const { return m_ActualColor; }
void SetActualColor(const wxColour& clr) { m_ActualColor = clr ;}
const wxHtmlLinkInfo& GetLink() const { return m_Link; }
void SetLink(const wxHtmlLinkInfo& link);
// applies current parser state (link, sub/supscript, ...) to given cell
void ApplyStateToCell(wxHtmlCell *cell);
#if !wxUSE_UNICODE
void SetInputEncoding(wxFontEncoding enc);
wxFontEncoding GetInputEncoding() const { return m_InputEnc; }
wxFontEncoding GetOutputEncoding() const { return m_OutputEnc; }
wxEncodingConverter *GetEncodingConverter() const { return m_EncConv; }
#endif
// creates font depending on m_Font* members.
virtual wxFont* CreateCurrentFont();
protected:
virtual void AddText(const wxChar* txt);
private:
void DoAddText(wxChar *temp, int& templen, wxChar nbsp);
bool m_tmpLastWasSpace;
wxChar *m_tmpStrBuf;
size_t m_tmpStrBufSize;
// temporary variables used by AddText
wxHtmlWindowInterface *m_windowInterface;
// window we're parsing for
double m_PixelScale;
wxDC *m_DC;
// Device Context we're parsing for
static wxList m_Modules;
// list of tags modules (see wxHtmlTagsModule for details)
// This list is used to initialize m_Handlers member.
wxHtmlContainerCell *m_Container;
// current container. See Open/CloseContainer for details.
int m_FontBold, m_FontItalic, m_FontUnderlined, m_FontFixed; // this is not true,false but 1,0, we need it for indexing
int m_FontSize; /* -2 to +4, 0 is default */
wxColour m_LinkColor;
wxColour m_ActualColor;
// basic font parameters.
wxHtmlLinkInfo m_Link;
// actual hypertext link or empty string
bool m_UseLink;
// true if m_Link is not empty
long m_CharHeight, m_CharWidth;
// average height of normal-sized text
int m_Align;
// actual alignment
wxHtmlScriptMode m_ScriptMode;
// current script mode (sub/sup/normal)
long m_ScriptBaseline;
// current sub/supscript base
wxFont* m_FontsTable[2][2][2][2][7];
wxString m_FontsFacesTable[2][2][2][2][7];
#if !wxUSE_UNICODE
wxFontEncoding m_FontsEncTable[2][2][2][2][7];
#endif
// table of loaded fonts. 1st four indexes are 0 or 1, depending on on/off
// state of these flags (from left to right):
// [bold][italic][underlined][fixed_size]
// last index is font size : from 0 to 6 (remapped from html sizes 1 to 7)
// Note : this table covers all possible combinations of fonts, but not
// all of them are used, so many items in table are usually NULL.
int m_FontsSizes[7];
wxString m_FontFaceFixed, m_FontFaceNormal;
// html font sizes and faces of fixed and proportional fonts
#if !wxUSE_UNICODE
wxFontEncoding m_InputEnc, m_OutputEnc;
// I/O font encodings
wxEncodingConverter *m_EncConv;
#endif
wxHtmlWordCell *m_lastWordCell;
DECLARE_NO_COPY_CLASS(wxHtmlWinParser)
};
//-----------------------------------------------------------------------------
// wxHtmlWinTagHandler
// This is basicly wxHtmlTagHandler except
// it is extended with protected member m_Parser pointing to
// the wxHtmlWinParser object
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_HTML wxHtmlWinTagHandler : public wxHtmlTagHandler
{
DECLARE_ABSTRACT_CLASS(wxHtmlWinTagHandler)
public:
wxHtmlWinTagHandler() : wxHtmlTagHandler() {}
virtual void SetParser(wxHtmlParser *parser) {wxHtmlTagHandler::SetParser(parser); m_WParser = (wxHtmlWinParser*) parser;}
protected:
wxHtmlWinParser *m_WParser; // same as m_Parser, but overcasted
DECLARE_NO_COPY_CLASS(wxHtmlWinTagHandler)
};
//----------------------------------------------------------------------------
// wxHtmlTagsModule
// This is basic of dynamic tag handlers binding.
// The class provides methods for filling parser's handlers
// hash table.
// (See documentation for details)
//----------------------------------------------------------------------------
class WXDLLIMPEXP_HTML wxHtmlTagsModule : public wxModule
{
DECLARE_DYNAMIC_CLASS(wxHtmlTagsModule)
public:
wxHtmlTagsModule() : wxModule() {}
virtual bool OnInit();
virtual void OnExit();
// This is called by wxHtmlWinParser.
// The method must simply call parser->AddTagHandler(new
// <handler_class_name>); for each handler
virtual void FillHandlersTable(wxHtmlWinParser * WXUNUSED(parser)) { }
};
#endif
#endif // _WX_WINPARS_H_
| [
"[email protected]"
]
| [
[
[
1,
273
]
]
]
|
fa7ba706a5f366b69d23fe9c34830a8abf8b0438 | b83c990328347a0a2130716fd99788c49c29621e | /include/boost/signals2/detail/slot_template.hpp | 9f3112af65c61b390de29c492c0541233fe4fb2b | []
| no_license | SpliFF/mingwlibs | c6249fbb13abd74ee9c16e0a049c88b27bd357cf | 12d1369c9c1c2cc342f66c51d045b95c811ff90c | refs/heads/master | 2021-01-18T03:51:51.198506 | 2010-06-13T15:13:20 | 2010-06-13T15:13:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,031 | hpp | // Boost.Signals2 library
// Copyright Frank Mori Hess 2007-2008.
// Copyright Timmo Stange 2007.
// Copyright Douglas Gregor 2001-2004. Use, modification and
// distribution is 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)
// For more information, see http://www.boost.org
// This file is included iteratively, and should not be protected from multiple inclusion
#define BOOST_SIGNALS2_NUM_ARGS BOOST_PP_ITERATION()
namespace boost
{
namespace signals2
{
template<typename Signature, typename SlotFunction> class slot;
// slot class template.
template<BOOST_SIGNALS2_SIGNATURE_TEMPLATE_DECL(BOOST_SIGNALS2_NUM_ARGS),
typename SlotFunction = BOOST_SIGNALS2_FUNCTION_N_DECL(BOOST_SIGNALS2_NUM_ARGS)>
class BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS): public slot_base
{
public:
template<BOOST_SIGNALS2_PREFIXED_SIGNATURE_TEMPLATE_DECL(BOOST_SIGNALS2_NUM_ARGS, Other), typename OtherSlotFunction>
friend class BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS);
typedef SlotFunction slot_function_type;
typedef R result_type;
// typedef Tn argn_type;
#define BOOST_SIGNALS2_MISC_STATEMENT(z, n, data) \
typedef BOOST_PP_CAT(T, BOOST_PP_INC(n)) BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(n)), _type);
BOOST_PP_REPEAT(BOOST_SIGNALS2_NUM_ARGS, BOOST_SIGNALS2_MISC_STATEMENT, ~)
#undef BOOST_SIGNALS2_MISC_STATEMENT
#if BOOST_SIGNALS2_NUM_ARGS == 1
typedef arg1_type argument_type;
#elif BOOST_SIGNALS2_NUM_ARGS == 2
typedef arg1_type first_argument_type;
typedef arg2_type second_argument_type;
#endif
BOOST_STATIC_CONSTANT(int, arity = BOOST_SIGNALS2_NUM_ARGS);
template<typename F>
BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)(const F& f)
{
init_slot_function(f);
}
// copy constructors
template<BOOST_SIGNALS2_PREFIXED_SIGNATURE_TEMPLATE_DECL(BOOST_SIGNALS2_NUM_ARGS, Other), typename OtherSlotFunction>
BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)(const BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
<BOOST_SIGNALS2_PREFIXED_SIGNATURE_TEMPLATE_INSTANTIATION(BOOST_SIGNALS2_NUM_ARGS, Other), OtherSlotFunction> &other_slot):
slot_base(other_slot), _slot_function(other_slot._slot_function)
{
}
template<typename Signature, typename OtherSlotFunction>
BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)(const slot<Signature, OtherSlotFunction> &other_slot):
slot_base(other_slot), _slot_function(other_slot._slot_function)
{
}
// bind syntactic sugar
// const ArgTypeN & argN
#define BOOST_SIGNALS2_SLOT_BINDING_ARG_DECL(z, n, data) \
const BOOST_PP_CAT(ArgType, n) & BOOST_PP_CAT(arg, n)
// template<typename Func, typename ArgType0, typename ArgType1, ..., typename ArgTypen-1> slotN(...
#define BOOST_SIGNALS2_SLOT_BINDING_CONSTRUCTOR(z, n, data) \
template<typename Func, BOOST_PP_ENUM_PARAMS(n, typename ArgType)> \
BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)(const Func &func, BOOST_PP_ENUM(n, BOOST_SIGNALS2_SLOT_BINDING_ARG_DECL, ~)) \
{ \
init_slot_function(bind(func, BOOST_PP_ENUM_PARAMS(n, arg))); \
}
#define BOOST_SIGNALS2_SLOT_MAX_BINDING_ARGS 10
BOOST_PP_REPEAT_FROM_TO(1, BOOST_SIGNALS2_SLOT_MAX_BINDING_ARGS, BOOST_SIGNALS2_SLOT_BINDING_CONSTRUCTOR, ~)
#undef BOOST_SIGNALS2_SLOT_MAX_BINDING_ARGS
#undef BOOST_SIGNALS2_SLOT_BINDING_ARG_DECL
#undef BOOST_SIGNALS2_SLOT_BINDING_CONSTRUCTOR
// invocation
R operator()(BOOST_SIGNALS2_SIGNATURE_FULL_ARGS(BOOST_SIGNALS2_NUM_ARGS))
{
locked_container_type locked_objects = lock();
return _slot_function(BOOST_SIGNALS2_SIGNATURE_ARG_NAMES(BOOST_SIGNALS2_NUM_ARGS));
}
R operator()(BOOST_SIGNALS2_SIGNATURE_FULL_ARGS(BOOST_SIGNALS2_NUM_ARGS)) const
{
locked_container_type locked_objects = lock();
return _slot_function(BOOST_SIGNALS2_SIGNATURE_ARG_NAMES(BOOST_SIGNALS2_NUM_ARGS));
}
// tracking
BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)& track(const weak_ptr<void> &tracked)
{
_tracked_objects.push_back(tracked);
return *this;
}
BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)& track(const signal_base &signal)
{
track_signal(signal);
return *this;
}
BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)& track(const slot_base &slot)
{
tracked_container_type::const_iterator it;
for(it = slot.tracked_objects().begin(); it != slot.tracked_objects().end(); ++it)
{
track(*it);
}
return *this;
}
const slot_function_type& slot_function() const {return _slot_function;}
slot_function_type& slot_function() {return _slot_function;}
private:
template<typename F>
void init_slot_function(const F& f)
{
_slot_function = detail::get_invocable_slot(f, detail::tag_type(f));
signals2::detail::tracked_objects_visitor visitor(this);
boost::visit_each(visitor, f);
}
SlotFunction _slot_function;
};
namespace detail
{
template<unsigned arity, typename Signature, typename SlotFunction>
class slotN;
// partial template specialization
template<typename Signature, typename SlotFunction>
class slotN<BOOST_SIGNALS2_NUM_ARGS, Signature, SlotFunction>
{
public:
typedef BOOST_SIGNALS2_SLOT_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)<
BOOST_SIGNALS2_PORTABLE_SIGNATURE(BOOST_SIGNALS2_NUM_ARGS, Signature),
SlotFunction> type;
};
}
} // end namespace signals2
} // end namespace boost
#undef BOOST_SIGNALS2_NUM_ARGS
| [
"[email protected]"
]
| [
[
[
1,
142
]
]
]
|
af04d1449b88a90c3cd63a4c702fad7cddbb8d05 | 6e563096253fe45a51956dde69e96c73c5ed3c18 | /NBPlayer/MY_IAddRefAble.h | 41e0f5ff291164c44f729e5d1111148910abd2d9 | []
| no_license | 15831944/phoebemail | 0931b76a5c52324669f902176c8477e3bd69f9b1 | e10140c36153aa00d0251f94bde576c16cab61bd | refs/heads/master | 2023-03-16T00:47:40.484758 | 2010-10-11T02:31:02 | 2010-10-11T02:31:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 337 | h | #ifndef __MY_IADDREFABLE_INC__
#define __MY_IADDREFABLE_INC__
#include "ax_iaddrefable.h"
#ifdef _DEBUG
class MY_IAddRefAble : public AX_IAddRefAble
{
public:
MY_IAddRefAble(void);
virtual ~MY_IAddRefAble(void);
};
#else
#define MY_IAddRefAble AX_IAddRefAble
#endif //_DEBUG
#endif //__MY_IADDREFABLE_INC__
| [
"guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd"
]
| [
[
[
1,
21
]
]
]
|
fb85ad210a7e70c5932c986b13f390bba7057b0c | 6e563096253fe45a51956dde69e96c73c5ed3c18 | /dhnetsdk/dvr/Net/TcpSocket.cpp | 7bc31e58b2e5818a87ecac9746d47c659b53a6ec | []
| no_license | 15831944/phoebemail | 0931b76a5c52324669f902176c8477e3bd69f9b1 | e10140c36153aa00d0251f94bde576c16cab61bd | refs/heads/master | 2023-03-16T00:47:40.484758 | 2010-10-11T02:31:02 | 2010-10-11T02:31:02 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 16,590 | cpp | // TcpSocket.cpp: implementation of the CTcpSocket class.
//
//////////////////////////////////////////////////////////////////////
#include "../StdAfx.h"
#include "TcpSocket.h"
#include "../ParseString.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#pragma warning(disable:4355)
CTcpSocket::CTcpSocket() : TPTCPServer(this), TPTCPClient(this)
{
m_pPacketBuf = NULL;
m_nBufSize = 0;
m_nWritePos = 0;
m_nReadPos = 0;
m_pDisConnect = NULL;
m_pReconnect = NULL;
m_pNormalPacket = NULL;
m_pRecvPakcet = NULL;
m_pUserData = NULL;
m_pListenSockFunc = NULL;
m_pListenUserData = NULL;
m_pListenSocket = NULL;
CreateEventEx(m_hRecEvent, TRUE, FALSE);
#ifdef NETSDK_VERSION_BOGUSSSL
CreateEventEx(m_hSpecialEvent, FALSE, FALSE);
m_nSSL = 0;
#endif
}
int CTcpSocket::CreateRecvBuf(unsigned int nRecvSize)
{
if (nRecvSize > 0 && m_pPacketBuf == NULL)
{
m_pPacketBuf = new unsigned char[nRecvSize];
if (m_pPacketBuf != NULL)
{
m_nBufSize = nRecvSize;
return 1;
}
}
return -1;
}
CTcpSocket::~CTcpSocket()
{
CloseEventEx(m_hRecEvent);
#ifdef NETSDK_VERSION_BOGUSSSL
CloseEventEx(m_hSpecialEvent);
#endif
if (m_pPacketBuf != NULL)
{
delete[] m_pPacketBuf;
m_pPacketBuf = NULL;
}
m_nBufSize = 0;
}
int CTcpSocket::InitNetwork()
{
return TPTCPClient::Startup();
}
int CTcpSocket::ClearNetwork()
{
return TPTCPClient::Cleanup();
}
/*
* 摘要:接收数据回调
*/
int CTcpSocket::onData(int nEngineId, int nConnId, unsigned char* data, int nLen)
{
int nRet = 1;
if (m_pPacketBuf == NULL)
{
return nRet;
}
#ifdef NETSDK_VERSION_INVERSE
for (int i = 0; i < nLen; i++)
{
unsigned char *p = (unsigned char*)(data + i);
*p = ~(*p);
}
#endif
CReadWriteMutexLock lock(m_csBuffer);
if (nLen > 0)
{
/***********************缓冲数据***********************/
// 现在当包长大于存储空间时采取丢包的原则
// 情况可能有:调试中断太久和收到错误数据包
int nEndPos = nLen + m_nWritePos;
// 如果缓冲区足够缓冲数据
if (nEndPos <= m_nBufSize)
{
memcpy(m_pPacketBuf + m_nWritePos, data, nLen);
m_nWritePos = m_nWritePos + nLen;
}
// 如果缓冲区不足以缓冲数据,从头再来
else
{
// 整个缓冲区都不足以容纳该数据,一般是因为调试中断太久或错误数据包
if (nLen + (m_nWritePos-m_nReadPos) >= m_nBufSize)
{
nLen = 0;
nRet = -1;
}
else
{
memmove(m_pPacketBuf, m_pPacketBuf + m_nReadPos, m_nWritePos - m_nReadPos);
m_nWritePos = m_nWritePos - m_nReadPos;
m_nReadPos = 0;
if (nLen > 0)
{
memcpy(m_pPacketBuf + m_nWritePos, data, nLen);
m_nWritePos = m_nWritePos + nLen;
}
}
}
}
lock.Unlock();
return nRet;
}
/*
* 摘要:处理数据
* 返回值:0:忙;1:空闲
*/
int CTcpSocket::onDealData(int nEngineId, int nConnId, unsigned char* buffer, int nLen)
{
#ifdef NETSDK_VERSION_BOGUSSSL
if (m_nSSL < 7)
{
//SSL
DealSSL();
return 1;
}
#endif
int nRet = 1;
if (m_pPacketBuf == NULL)
{
return nRet;
}
int nPacketLen = GetData(buffer, nLen);
if (nPacketLen > 0)
{
CReadWriteMutexLock lock(m_csOutCallBack);
if (m_pRecvPakcet)
{
m_pRecvPakcet(buffer, nPacketLen, m_pUserData);
}
DealSpecialPacket((unsigned char*)buffer, nPacketLen);
if (m_pNormalPacket != NULL)
{
m_pNormalPacket(buffer, nPacketLen, m_pUserData);
}
lock.Unlock();
nRet = 0;
}
return nRet;
}
/*
* 摘要:发送数据完成回调,从发送队列中取数据继续发送
*/
int CTcpSocket::onSendDataAck(int nEngineId, int nConnId, int nId)
{
return 1;
}
/*
* 摘要:作服务器用才回调,有新的client连接,返回值为0表示接受此连接,返回值为1表示拒绝接受
*/
int CTcpSocket::onConnect(int nEngineId, int nConnId, char* szIp, int nPort)
{
return 1;
}
/*
* 摘要:作服务器用才回调,client退出回调,删除客户端连接列表
*/
int CTcpSocket::onClose(int nEngineId, int nConnId)
{
return 1;
}
/*
* 摘要:作客户端用才回调,断线回调,内部可能重连,由应用层决定是否close
*/
int CTcpSocket::onDisconnect(int nEngineId, int nConnId)
{
m_nWritePos = m_nReadPos = 0;
ResetEventEx(m_hRecEvent);
CReadWriteMutexLock lock(m_csOutCallBack);
if (m_pDisConnect != NULL)
{
m_pDisConnect(m_pUserData);
}
// 主动注册
if (m_pListenSockFunc != NULL)
{
in_addr ip = {0};
ip.s_addr = TPTCPClient::m_remoteIp;
m_pListenSockFunc(m_pListenSocket, inet_ntoa(ip), ntohs(TPTCPClient::m_remotePort), -1, (void*)this, m_pListenUserData);
}
lock.Unlock();
return 1;
}
/*
* 摘要:作客户端用才回调,断线后重连成功回调,恢复所有的业务(操作)
*/
int CTcpSocket::onReconnect(int nEngineId, int nConnId)
{
ResetEventEx(m_hRecEvent);
CReadWriteMutexLock lock(m_csOutCallBack);
if (m_pReconnect != NULL)
{
m_pReconnect(m_pUserData);
}
lock.Unlock();
return 1;
}
//////////////////////////////////////////////////////////////////////////
void CTcpSocket::SetCallBack(OnDisConnectFunc cbDisConnect, OnReConnectFunc cbReconnect,
OnNormalPacketFunc cbNormalPacket, OnRecPacketFunc cbReceivePacket, void* userdata)
{
CReadWriteMutexLock lock(m_csOutCallBack);
m_pUserData = userdata;
m_pDisConnect = cbDisConnect;
m_pReconnect = cbReconnect;
m_pNormalPacket = cbNormalPacket;
m_pRecvPakcet = cbReceivePacket;
m_pListenSockFunc = NULL;
m_pListenUserData = NULL;
m_pListenSocket = NULL;
lock.Unlock();
}
void CTcpSocket::SetKeepLife(unsigned char *szLifePacket, int nBufLen, unsigned int nKeepLifeTime)
{
TPTCPClient::SetKeepLifePacket(szLifePacket, nBufLen, nKeepLifeTime);
}
int CTcpSocket::ConnectHost(const char *szIp, int nPort, int nTimeOut)
{
return TPTCPClient::Connect(szIp, nPort, nTimeOut);
}
void CTcpSocket::Disconnect()
{
TPTCPClient::Close();
}
int CTcpSocket::WriteData(char *pBuf, int nLen)
{
#ifdef NETSDK_VERSION_INVERSE
for (int i = 0; i < nLen; i++)
{
unsigned char *p = (unsigned char*)(pBuf + i);
*p = ~(*p);
}
#endif
IBufferRef pDataBuf = CAutoBuffer::CreateBuffer(nLen, pBuf, true);
#ifdef NETSDK_VERSION_INVERSE
for (int j = 0; j < nLen; j++)
{
unsigned char *p = (unsigned char*)(pBuf + j);
*p = ~(*p);
}
#endif
if (pDataBuf.IsEmpty())
{
return -1;
}
return TPTCPClient::Send(0, pDataBuf);
}
int CTcpSocket::Heartbeat()
{
return TPTCPClient::Heartbeat();
}
//////////////////////////////////////////////////////////////////////////
int CTcpSocket::StartListen(const char *szIp, int nPort, OnListenSockFunc cbListenSock, void *userdata)
{
m_pListenSockFunc = cbListenSock;
m_pListenUserData = userdata;
return TPTCPServer::Listen((char*)szIp, nPort);
}
int CTcpSocket::StopListen()
{
return TPTCPServer::Close();
}
int CTcpSocket::DealNewSocket(SOCKET newsock, int connId, char* ip, int port)
{
CTcpSocket *pNewSocket = new CTcpSocket();
if (pNewSocket == NULL)
{
closesocket(newsock);
return -1;
}
if (pNewSocket->CreateRecvBuf(m_nBufSize) < 0)
{
delete pNewSocket;
closesocket(newsock);
return -1;
}
if (m_pListenSockFunc != NULL)
{
m_pListenSockFunc(this, (char*)ip, port, 0, pNewSocket, m_pListenUserData);
}
// 变成客户端的连接类
int ret = pNewSocket->SetSocket(newsock, connId, ip, port, m_pListenSockFunc, m_pListenUserData, (void*)this);
if (ret < 0)
{
if (m_pListenSockFunc != NULL)
{
m_pListenSockFunc(this, (char*)ip, port, -1, pNewSocket, m_pListenUserData);
}
}
return 1;
}
int CTcpSocket::SetSocket(SOCKET newsock, int connId, const char* ip, int port, OnListenSockFunc cbListen, void* listenuserdata, void* pListenSocket)
{
int nRet = -1;
TPTCPClient::m_bReconnEn = FALSE;
TPTCPClient::m_socket = newsock;
TPTCPClient::m_remoteIp = inet_addr(ip);
TPTCPClient::m_remotePort = htons(port);
TPTCPClient::m_bOnline = TRUE;
m_pListenSockFunc = cbListen;
m_pListenUserData = listenuserdata;
m_pListenSocket = pListenSocket;
int ret = TPTCPClient::CreateClientEnvironment();
if (ret >= 0)
{
#if (defined(WIN32) && !(defined(NETSDK_VERSION_SSL)))
// 将socket添加到完成端口中
ret = TPTCPClient::AddSocketToIOCP(TPTCPClient::m_socket, TPTCPClient::m_pPerHandleData);
if (ret >= 0)
{
TPTCPClient::m_pPerHandleData->AddRef();
TPTCPClient::m_pPerIoRecv->AddRef();
ret = TPTCPClient::PostRecvToIOCP(TPTCPClient::m_socket, TPTCPClient::m_pPerIoRecv);
if (ret < 0)
{
TPTCPClient::m_pPerIoRecv->DecRef();
TPTCPClient::m_pPerHandleData->DecRef();
TPTCPClient::ClearClientEnvironment();
}
else
{
nRet = 1;
}
}
else
{
TPTCPClient::ClearClientEnvironment();
}
#else
ret = TPTCPClient::AddSocketToThread(TPTCPClient::m_socket, TPTCPClient::m_pPerHandleData);
if (ret >= 0)
{
nRet = 1;
}
else
{
TPTCPClient::ClearClientEnvironment();
}
#endif
}
if (nRet < 0)
{
#if (defined(WIN32) && !(defined(NETSDK_VERSION_SSL)))
TPTCPClient::DelSocketFromIOCP(TPTCPClient::m_socket, TPTCPClient::m_pPerHandleData);
#else
TPTCPClient::DelSocketFromThread(TPTCPClient::m_socket, TPTCPClient::m_pPerHandleData);
#endif
}
return nRet;
}
int CTcpSocket::ResponseReg(bool bAccept)
{
// ack 现在无须回应
//
// BYTE ack[HEADER_SIZE] = {0};
// ack[0] = 0x82;
// ack[8] = 102;
// ack[12] = bAccept?0:1;
// WriteData((char*)ack, HEADER_SIZE);
return 1;
}
//////////////////////////////////////////////////////////////////////////
int CTcpSocket::SetIsReConn(int nEnable)
{
return TPTCPClient::SetIsReconnect(nEnable);
}
int CTcpSocket::SetIsDetectDisconn(int nEnable)
{
return TPTCPClient::SetIsDetectDisconn(nEnable);
}
int CTcpSocket::GetIsOnline()
{
int nIsOnline = 0;
CReadWriteMutexLock lock(TPTCPClient::m_csOnline, false, true, false);
if (TPTCPClient::m_bOnline)
{
nIsOnline = 1;
}
else
{
nIsOnline = 0;
}
lock.Unlock();
return nIsOnline;
}
void CTcpSocket::DealSpecialPacket(unsigned char *pbuf, int nlen)
{
if (0xB0 == (unsigned char)*pbuf && nlen < 64)
{
memcpy(m_registerAck, pbuf, nlen);
m_nRegisterLen = nlen;
SetEventEx(m_hRecEvent);
}
else if (0xF4 == (unsigned char)*pbuf && nlen > HEADER_SIZE)
{
pbuf[nlen-1] = '\0';
pbuf[nlen-2] = '\0';
char szCommand[64] = {0};
char szResultCode[64] = {0};
char *p = GetProtocolValue((char*)(pbuf+HEADER_SIZE), "ParameterName:", "\r\n", szCommand, 64);
if (p)
{
if (_stricmp(szCommand, "Dahua.Device.Network.ControlConnection.AckSubChannel") == 0)
{
p = GetProtocolValue((char*)(pbuf+HEADER_SIZE), "FaultCode:", "\r\n", szResultCode, 64);
if (p)
{
if (_stricmp(szResultCode, "OK") == 0)
{
m_registerAck[8] = 0;
}
else
{
m_registerAck[8] = 1;
}
SetEventEx(m_hRecEvent);
}
}
}
}
else if (m_pListenSockFunc != NULL && 0xB4 == (unsigned char)*pbuf && 0x07 == (unsigned char)*(pbuf + 8) && nlen < 1024)
{
// 主动注册包
DWORD extlen = *(DWORD*)(pbuf+4);
char *serial = new char[extlen+1];
memset(serial, 0, extlen+1);
memcpy(serial, pbuf+HEADER_SIZE, extlen);
if (m_pListenSockFunc != NULL)
{
in_addr ip = {0};
ip.s_addr = TPTCPClient::m_remoteIp;
m_pListenSockFunc(m_pListenSocket, inet_ntoa(ip), ntohs(TPTCPClient::m_remotePort), 1, (void*)serial, m_pListenUserData);
}
delete[] serial;
}
else if(0xf1 == (unsigned char)*pbuf && nlen < 64)
{
m_registerAck[0] = pbuf[14];
nlen = 1;
SetEventEx(m_hRecEvent);
}
else if(0x0b == (unsigned char)*pbuf && nlen == 32)
{
// 登出命令返回
SetEventEx(m_hRecEvent);
}
}
int CTcpSocket::GetData(unsigned char* buf, int len)
{
int nDataLen = 0;
CReadWriteMutexLock lock(m_csBuffer);
if ((int)(m_nWritePos - m_nReadPos) >= HEADER_SIZE)
{
unsigned int extlen = *(unsigned int*)(m_pPacketBuf + m_nReadPos + 4);
if ((extlen + HEADER_SIZE) >= len)
{
// 指示的扩展数据太长,不正常,清空缓存
#ifdef _DEBUG
OutputDebugString("指示的扩展数据太长,不正常,清空缓存\n");
#endif
m_nWritePos = m_nReadPos = 0;
return 0;
}
if (m_nWritePos - m_nReadPos >= extlen + HEADER_SIZE)
{
nDataLen = extlen + HEADER_SIZE;
memcpy(buf, m_pPacketBuf + m_nReadPos, nDataLen);
m_nReadPos += nDataLen;
}
}
lock.Unlock();
return nDataLen;
}
int CTcpSocket::CloseSubConn()
{
#if (defined(WIN32) && !(defined(NETSDK_VERSION_SSL)))
IOCPListener* listener = TPTCPClient::m_pPerHandleData->m_listener;
TPTCPClient::closeInside();
if (0 > TPTCPClient::Create(opMode_tcp))
{
return -1;
}
if (TPTCPClient::m_pPerHandleData != NULL)
{
CReadWriteMutexLock lock(TPTCPClient::m_pPerHandleData->m_pcsCallBack);
TPTCPClient::m_pPerHandleData->m_socket = TPTCPClient::m_socket;
TPTCPClient::m_pPerHandleData->m_connId = TPTCPClient::m_socket;
TPTCPClient::m_pPerHandleData->m_listener = listener;
}
#else
TPTCPClient::m_bOnline = FALSE;
TPTCPClient::m_bReconnEn = TRUE;
TPTCPClient::m_emSockStatus = TP_TCP_CLOSE;
#endif
return 1;
}
int CTcpSocket::ConnectSubConn()
{
#if (defined(WIN32) && !(defined(NETSDK_VERSION_SSL)))
int nOnline = TPTCPClient::IsConnected();
if (nOnline == 1)
{
m_nWritePos = m_nReadPos = 0;
int nRet = TPTCPClient::AddSocketToIOCP(TPTCPClient::m_socket, TPTCPClient::m_pPerHandleData);
if (nRet >= 0)
{
TPTCPClient::m_bOnline = TRUE;
TPTCPClient::m_pPerHandleData->AddRef();
TPTCPClient::m_pPerIoRecv->AddRef();
nRet = TPTCPClient::PostRecvToIOCP(TPTCPClient::m_socket, TPTCPClient::m_pPerIoRecv);
if (nRet < 0)
{
TPTCPClient::m_pPerIoRecv->DecRef();
TPTCPClient::m_pPerHandleData->DecRef();
}
}
}
else
{
if (GetTickCount() - TPTCPClient::m_dwLastConTime > 3000)
{
//connect
struct sockaddr_in my_addr;
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
my_addr.sin_addr.s_addr = TPTCPClient::m_remoteIp;
my_addr.sin_port = TPTCPClient::m_remotePort;
connect(TPTCPClient::m_socket, (struct sockaddr *)&my_addr, sizeof(struct sockaddr));
TPTCPClient::m_dwLastConTime = GetTickCount();
}
}
return nOnline;
#else
TPTCPClient::Heartbeat();
if (TPTCPClient::m_bOnline)
{
return 1;
}
return -1;
#endif
}
#ifdef NETSDK_VERSION_BOGUSSSL
int CTcpSocket::DealSSL()
{
CReadWriteMutexLock lock(m_csBuffer);
int nRevLen = (int)(m_nWritePos - m_nReadPos);
switch(m_nSSL)
{
case 0:
{
if (nRevLen >= 840)
{
m_nSSL++;
m_nWritePos = m_nReadPos = 0;
SetEventEx(m_hSpecialEvent);
}
}
break;
case 1:
{
if (nRevLen >= 130)
{
m_nSSL++;
m_nWritePos = m_nReadPos = 0;
SetEventEx(m_hSpecialEvent);
}
}
break;
case 2:
{
if (nRevLen >= 36)
{
m_nSSL++;
m_nWritePos = m_nReadPos = 0;
SetEventEx(m_hSpecialEvent);
}
}
break;
case 3:
{
if (nRevLen >= 35)
{
m_nSSL++;
m_nWritePos = m_nReadPos = 0;
SetEventEx(m_hSpecialEvent);
}
}
break;
case 4:
{
if (nRevLen >= 35)
{
m_nSSL++;
m_nWritePos = m_nReadPos = 0;
SetEventEx(m_hSpecialEvent);
}
}
break;
case 5:
{
if (nRevLen >= 30)
{
m_nSSL++;
m_nWritePos = m_nReadPos = 0;
SetEventEx(m_hSpecialEvent);
}
}
break;
case 6:
{
if (nRevLen >= 36)
{
m_nSSL++;
m_nWritePos = m_nReadPos = 0;
SetEventEx(m_hSpecialEvent);
}
}
break;
default:
break;
}
return 1;
}
#endif
#ifdef NETSDK_VERSION_SSL
int CTcpSocket::SetSSL(int nEnable)
{
TPTCPClient::m_bIsSSL = nEnable;
return 1;
}
#endif
| [
"guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd"
]
| [
[
[
1,
768
]
]
]
|
dc1e49c049c7fa21013665e7c504d9e044bd97e8 | 9ad9345e116ead00be7b3bd147a0f43144a2e402 | /SeedMinerIntegratedSolution/WAHArray/WAHStructure.h | 75aebffde01deb99890d94bd6e27809702e54b68 | []
| no_license | asankaf/scalable-data-mining-framework | e46999670a2317ee8d7814a4bd21f62d8f9f5c8f | 811fddd97f52a203fdacd14c5753c3923d3a6498 | refs/heads/master | 2020-04-02T08:14:39.589079 | 2010-07-18T16:44:56 | 2010-07-18T16:44:56 | 33,870,353 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,625 | h | #pragma once
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
#include "Math.h"
#include "BitStreamInfo.h"
#include <vector>
#include "Math.h"
#include <iostream>
using namespace std;
using namespace boost;
namespace CompressedStructure{
class WAHStructure:public BitStreamInfo
{
public:
WAHStructure(void);
~WAHStructure(void);
//Methods inherited from BitstreamInfo class
void CompressWords(boost::dynamic_bitset<>& _bit_map);
dynamic_bitset<> Decompress();
int GetSpaceUtilisation();
BitStreamInfo* operator~();
virtual BitStreamInfo* operator &(BitStreamInfo &);
BitStreamInfo* operator |(BitStreamInfo &);
unsigned long long Count();
// Overloaded operators
WAHStructure * operator & (WAHStructure&);
WAHStructure * operator |(WAHStructure & _structure);
//Methods not exposed to public interface but used among the structures
void SetCompressedStream(vector<unsigned long int> &_compressed_vector);
void printCompressedStream();
vector<unsigned long int>& GetCompressedVector();
unsigned long int GetOriginalStreamLength();
//Public Getters and setters
const int ActiveWordSize() const { return m_iActiveWordSize; }
void ActiveWordSize(int val) { m_iActiveWordSize = val; }
unsigned long int ActiveWord() const { return m_ulActiveWord; }
void ActiveWord(unsigned long int val) { m_ulActiveWord = val; }
int OriginalStreamSize() const { return m_iOriginalStreamSize; }
void OriginalStreamSize(unsigned long int val) { m_iOriginalStreamSize = val; }
enum operation_type {AND,OR};
//Constants
static const unsigned long int ZERO_LITERAL = 0;
static const unsigned long int ONE_LITERAL = 2147483647;
static const unsigned long int ONE_GAP_START_FLAG = 3221225472;
static const unsigned long int ZERO_GAP_START_FLAG = 2147483648;
static const int LITERAL_WORD = 0;
static const int ZERO_GAP_WORD = 1;
static const int ONE_GAP_WORD = 2;
private:
enum longer_operand{ONE_GAP,ZERO_GAP};
void BuildArray(boost::dynamic_bitset<>& _bitmap);
dynamic_bitset<> ConvertVectorToBitmap(vector<unsigned long int> &_decompressed_vector);
vector<unsigned long int> ExpandCompressedVector(vector<unsigned long int>& _compressed_vector);
vector<int> AlignRightWithLeft(int _left_op_end_pos,int _right_op_index,int _right_op_end_pos,vector<unsigned long int> &_right_operand,vector<unsigned long int> &_result_vector,longer_operand _longer,operation_type _type,bool _gap_state);
vector<int> AlignLeftWithRight(int _right_op_end_pos,int _left_op_index,int _left_op_end_pos,vector<unsigned long int> &_left_operand,vector<unsigned long int> &_result_vector, longer_operand _longer,operation_type _type ,bool _gap_extension_state);
void SetOneCount(unsigned long int _count,vector<unsigned long int> & _compressed);
void SetZeroCount(unsigned long int _count,vector<unsigned long int> & _compressed);
void SetLiteral(unsigned long int _literal_val,vector<unsigned long int> & _compressed);
void CopyIntegerToBitMap(dynamic_bitset<> &_bitmap,size_t _index);
int GetStartBitValue(size_t _word);
void SetValueOnCompressedWord(unsigned long int _word, vector<unsigned long int> &_compressed_result);
unsigned long int GetLiteralCount(unsigned long int &_bit_literal);
//Private Attributes
vector<unsigned long int> m_compressed_stream;
int * m_iMainArray;
unsigned long int m_iOriginalStreamSize;
unsigned long int m_ulActiveWord;
int m_iActiveWordSize;
static const int WORD_SIZE = 32;
};
} | [
"buddhi.1986@c7f6ba40-6498-11de-987a-95e5a5a5d5f1"
]
| [
[
[
1,
87
]
]
]
|
d201d2ff919069612a9722ae204e433fa5e33fa3 | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /tags/release-2006-04-24/eeschema/netlist.cpp | 29514e3f2d42b08792a07904498e901f911239e6 | []
| 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 | UTF-8 | C++ | false | false | 32,219 | cpp | /***********************************/
/* Module de calcul de la Netliste */
/***********************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "netlist.h" /* Definitions generales liees au calcul de netliste */
#include "protos.h"
/* Routines locales */
static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus );
static void SheetLabelConnection(ObjetNetListStruct *SheetLabel);
static int ListeObjetConnection(wxWindow * frame, SCH_SCREEN *Window, ObjetNetListStruct *ObjNet);
static int ConvertBusToMembers(ObjetNetListStruct *ObjNet);
static void PointToPointConnect(ObjetNetListStruct *RefObj, int IsBus,
int start);
static void SegmentToPointConnect(ObjetNetListStruct *Jonction, int IsBus,
int start);
static void LabelConnection(ObjetNetListStruct *Label);
static int TriNetCode(ObjetNetListStruct *Objet1, ObjetNetListStruct *Objet2);
static void ConnectBusLabels( ObjetNetListStruct *Label, int NbItems );
static void SetUnconnectedFlag( ObjetNetListStruct *ObjNet, int NbItems );
static int TriBySheet(ObjetNetListStruct *Objet1, ObjetNetListStruct *Objet2);
/* Variable locales */
static int FirstNumWireBus, LastNumWireBus, RootBusNameLength;
static int LastNetCode, LastBusNetCode;
static int s_PassNumber;
/********************************************************/
void FreeTabNetList(ObjetNetListStruct * TabNetItems, int NbrNetItems)
/********************************************************/
/*
Routine de liberation memoire des tableaux utilises pour le calcul
de la netliste
TabNetItems = pointeur sur le tableau principal (liste des items )
NbrNetItems = nombre d'elements
*/
{
int i;
/* Liberation memoire des strings du champ Label reserve par ConvertBusToMembers */
for (i = 0; i < NbrNetItems; i++)
{
switch( TabNetItems[i].m_Type )
{
case NET_PIN:
case NET_SHEETLABEL:
case NET_SEGMENT:
case NET_JONCTION:
case NET_BUS:
case NET_LABEL:
case NET_GLOBLABEL:
case NET_PINLABEL:
case NET_NOCONNECT:
break;
case NET_GLOBBUSLABELMEMBER:
case NET_SHEETBUSLABELMEMBER:
case NET_BUSLABELMEMBER:
delete TabNetItems[i].m_Label;
break;
}
}
MyFree(TabNetItems);
}
/*************************************************************/
void * BuildNetList(WinEDA_DrawFrame * frame, SCH_SCREEN * Window)
/*************************************************************/
/* Routine qui construit le tableau des elements connectes du projet
met a jour:
g_TabObjNet
g_NbrObjNet
*/
{
int NetNumber, SheetNumber;
int i, istart, NetCode;
SCH_SCREEN * CurrWindow;
ObjetNetListStruct * BaseTabObjNet;
wxString msg;
wxBusyCursor Busy;
NetNumber = 1;
s_PassNumber = 0;
frame->MsgPanel->EraseMsgBox();
Affiche_1_Parametre(frame, 1,_("List"), wxEmptyString, LIGHTRED);
/* 1ere passe : Comptage du nombre d'objet de Net */
g_TabObjNet = NULL; /* Init pour le 1er passage dans ListeObjetConnection */
CurrWindow = Window;
for ( g_NbrObjNet = 0; CurrWindow != NULL; CurrWindow = (SCH_SCREEN*)CurrWindow->Pnext )
{
g_NbrObjNet += ListeObjetConnection(frame, CurrWindow, NULL);
}
if( g_NbrObjNet == 0 )
{
DisplayError(frame, _("No component"), 20);
return(NULL);
}
i = sizeof(ObjetNetListStruct) * g_NbrObjNet;
BaseTabObjNet = g_TabObjNet = (ObjetNetListStruct *) MyZMalloc(i);
if( BaseTabObjNet == NULL ) return(NULL);
/* 2eme passe : Remplissage des champs des structures des objets de Net */
s_PassNumber ++;
Affiche_1_Parametre(frame, 1,_("List"), wxEmptyString,RED);
CurrWindow = Window;
for ( ; CurrWindow != NULL ; CurrWindow = (SCH_SCREEN*)CurrWindow->Pnext )
{
g_TabObjNet += ListeObjetConnection(frame, CurrWindow, g_TabObjNet );
}
Affiche_1_Parametre(frame, -1, wxEmptyString,_("Done"),RED);
msg.Printf( wxT("%d"), g_NbrObjNet);
Affiche_1_Parametre(frame, 8, _("NbItems"),msg,GREEN);
/* Recherche des connections pour les Segments et les Pins */
/* Tri du Tableau des objets de Net par Sheet */
qsort(BaseTabObjNet, g_NbrObjNet, sizeof(ObjetNetListStruct),
(int (*)(const void *, const void *)) TriBySheet);
Affiche_1_Parametre(frame, 18,_("Conn"), wxEmptyString,CYAN);
g_TabObjNet = BaseTabObjNet;
SheetNumber = g_TabObjNet[0].m_SheetNumber;
LastNetCode = LastBusNetCode = 1;
for (i = istart = 0; i < g_NbrObjNet; i++)
{
if(g_TabObjNet[i].m_SheetNumber != SheetNumber )
{
SheetNumber = g_TabObjNet[i].m_SheetNumber; istart = i;
}
switch( g_TabObjNet[i].m_Type )
{
case NET_PIN:
case NET_PINLABEL:
case NET_SHEETLABEL:
case NET_NOCONNECT:
if ( g_TabObjNet[i].m_NetCode != 0 ) break; /* Deja connecte */
case NET_SEGMENT:
/* Controle des connexions type point a point ( Sans BUS ) */
if( g_TabObjNet[i].m_NetCode == 0 )
{
g_TabObjNet[i].m_NetCode = LastNetCode;
LastNetCode++;
}
PointToPointConnect(g_TabObjNet+i, 0, istart);
break;
case NET_JONCTION:
/* Controle des jonction , hors BUS */
if( g_TabObjNet[i].m_NetCode == 0 )
{
g_TabObjNet[i].m_NetCode = LastNetCode;
LastNetCode++;
}
SegmentToPointConnect( g_TabObjNet+i, 0, istart);
/* Controle des jonction , sur BUS */
if( g_TabObjNet[i].m_BusNetCode == 0 )
{
g_TabObjNet[i].m_BusNetCode = LastBusNetCode;
LastBusNetCode++;
}
SegmentToPointConnect( g_TabObjNet+i, ISBUS, istart );
break;
case NET_LABEL:
case NET_GLOBLABEL:
/* Controle des connexions type jonction ( Sans BUS ) */
if( g_TabObjNet[i].m_NetCode == 0 )
{
g_TabObjNet[i].m_NetCode = LastNetCode;
LastNetCode++;
}
SegmentToPointConnect( g_TabObjNet+i, 0, istart );
break;
case NET_SHEETBUSLABELMEMBER:
if ( g_TabObjNet[i].m_BusNetCode != 0 ) break; /* Deja connecte */
case NET_BUS:
/* Controle des connexions type point a point mode BUS */
if( g_TabObjNet[i].m_BusNetCode == 0 )
{
g_TabObjNet[i].m_BusNetCode = LastBusNetCode;
LastBusNetCode++;
}
PointToPointConnect(g_TabObjNet+i, ISBUS, istart);
break;
case NET_BUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
/* Controle des connexions semblables a des sur BUS */
if( g_TabObjNet[i].m_NetCode == 0 )
{
g_TabObjNet[i].m_BusNetCode = LastBusNetCode;
LastBusNetCode++;
}
SegmentToPointConnect( g_TabObjNet+i, ISBUS, istart);
break;
}
}
Affiche_1_Parametre(frame, -1, wxEmptyString,_("Done"),CYAN);
/* Mise a jour des NetCodes des Bus Labels connectes par les Bus */
ConnectBusLabels( g_TabObjNet, g_NbrObjNet);
Affiche_1_Parametre(frame, 26,_("Labels"), wxEmptyString,CYAN);
/* Connections des groupes d'objets par labels identiques */
for (i = 0; i < g_NbrObjNet; i++)
{
switch( g_TabObjNet[i].m_Type )
{
case NET_PIN:
case NET_SHEETLABEL:
case NET_SEGMENT:
case NET_JONCTION:
case NET_BUS:
case NET_NOCONNECT:
break;
case NET_LABEL:
case NET_GLOBLABEL:
case NET_PINLABEL:
case NET_BUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
LabelConnection( g_TabObjNet+i );
break;
case NET_SHEETBUSLABELMEMBER:
break;
}
}
Affiche_1_Parametre(frame, -1, wxEmptyString,_("Done"),CYAN);
/* Connexion des hierarchies */
Affiche_1_Parametre(frame, 36,_("Hierar."), wxEmptyString,LIGHTRED);
for (i = 0; i < g_NbrObjNet; i++)
{
if( (g_TabObjNet[i].m_Type == NET_SHEETLABEL ) ||
( g_TabObjNet[i].m_Type == NET_SHEETBUSLABELMEMBER ) )
SheetLabelConnection(g_TabObjNet + i);
}
/* Tri du Tableau des objets de Net par NetCode */
qsort(g_TabObjNet, g_NbrObjNet, sizeof(ObjetNetListStruct),
(int (*)(const void *, const void *)) TriNetCode);
Affiche_1_Parametre(frame, -1, wxEmptyString,_("Done"),RED);
/* Compression des numeros de NetCode a des valeurs consecutives */
Affiche_1_Parametre(frame, 46,_("Sorting"), wxEmptyString,GREEN);
LastNetCode = NetCode = 0;
for (i = 0; i < g_NbrObjNet; i++)
{
if(g_TabObjNet[i].m_NetCode != LastNetCode)
{
NetCode++; LastNetCode = g_TabObjNet[i].m_NetCode;
}
g_TabObjNet[i].m_NetCode = NetCode;
}
Affiche_1_Parametre(frame, -1, wxEmptyString,_("Done"),GREEN);
/* Affectation du m_FlagOfConnection en fonction de connection ou non */
SetUnconnectedFlag( BaseTabObjNet, g_NbrObjNet);
return( (void*) BaseTabObjNet);
}
/*************************************************************
* Routine qui connecte les sous feuilles par les sheetLabels *
**************************************************************/
static void SheetLabelConnection(ObjetNetListStruct *SheetLabel)
{
int i;
ObjetNetListStruct *ObjetNet;
if( SheetLabel->m_NetCode == 0 ) return;
/* Calcul du numero de sous feuille correspondante au sheetlabel */
/* Comparaison du SheetLabel avec les GLABELS de la sous feuille
pour regroupement des NetCodes */
for (i = 0, ObjetNet = g_TabObjNet; i < g_NbrObjNet; i++)
{
if( ObjetNet[i].m_SheetNumber != SheetLabel->m_NumInclude ) continue;
if( (ObjetNet[i].m_Type != NET_GLOBLABEL ) &&
(ObjetNet[i].m_Type != NET_GLOBBUSLABELMEMBER ) )
continue;
if( ObjetNet[i].m_NetCode == SheetLabel->m_NetCode ) continue;
if( ObjetNet[i].m_Label->CmpNoCase(*SheetLabel->m_Label) != 0) continue;
/* Propagation du Netcode a tous les Objets de meme NetCode */
if( ObjetNet[i].m_NetCode )
PropageNetCode(ObjetNet[i].m_NetCode, SheetLabel->m_NetCode, 0);
else ObjetNet[i].m_NetCode = SheetLabel->m_NetCode;
}
}
/*****************************************************************************/
static int ListeObjetConnection(wxWindow * frame, SCH_SCREEN *Window, ObjetNetListStruct *ObjNet)
/*****************************************************************************/
/* Routine generant la liste des objets relatifs aux connection
entree:
Window: pointeur sur l'ecran a traiter
ObjNet:
si NULL: la routine compte seulement le nombre des objets
sinon: pointe le tableau a remplir
*/
{
int ii, NbrItem = 0, NumSheet;
EDA_BaseStruct *DrawList;
EDA_SchComponentStruct *DrawLibItem;
int TransMat[2][2], PartX, PartY, x2, y2;
EDA_LibComponentStruct *Entry;
LibEDA_BaseStruct *DEntry;
DrawSheetLabelStruct *SheetLabel;
SCH_SCREEN * ScreenInclude;
int NumInclude;
NumSheet = Window->m_SheetNumber;
DrawList = Window->EEDrawList;
while ( DrawList )
{
switch( DrawList->m_StructType )
{
case DRAW_SEGMENT_STRUCT_TYPE :
#undef STRUCT
#define STRUCT ((EDA_DrawLineStruct *) DrawList)
if( ObjNet)
{
if ( (STRUCT->m_Layer != LAYER_BUS) &&
(STRUCT->m_Layer != LAYER_WIRE) )
break;
ObjNet[NbrItem].m_Comp = STRUCT;
ObjNet[NbrItem].m_Window = Window;
ObjNet[NbrItem].m_SheetNumber = NumSheet;
ObjNet[NbrItem].m_Start = STRUCT->m_Start;
ObjNet[NbrItem].m_End = STRUCT->m_End;
if (STRUCT->m_Layer == LAYER_BUS)
{
ObjNet[NbrItem].m_Type = NET_BUS;
}
else /* Cas des WIRE */
{
ObjNet[NbrItem].m_Type = NET_SEGMENT;
}
}
NbrItem++;
break;
case DRAW_JUNCTION_STRUCT_TYPE :
#undef STRUCT
#define STRUCT ((DrawJunctionStruct *) DrawList)
if( ObjNet)
{
ObjNet[NbrItem].m_Comp = STRUCT;
ObjNet[NbrItem].m_Window = Window;
ObjNet[NbrItem].m_Type = NET_JONCTION;
ObjNet[NbrItem].m_SheetNumber = NumSheet;
ObjNet[NbrItem].m_Start = STRUCT->m_Pos;
ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start;
}
NbrItem++;
break;
case DRAW_NOCONNECT_STRUCT_TYPE :
#undef STRUCT
#define STRUCT ((DrawNoConnectStruct *) DrawList)
if( ObjNet)
{
ObjNet[NbrItem].m_Comp = STRUCT;
ObjNet[NbrItem].m_Window = Window;
ObjNet[NbrItem].m_Type = NET_NOCONNECT;
ObjNet[NbrItem].m_SheetNumber = NumSheet;
ObjNet[NbrItem].m_Start = STRUCT->m_Pos;
ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start;
}
NbrItem++;
break;
case DRAW_LABEL_STRUCT_TYPE :
#undef STRUCT
#define STRUCT ((DrawLabelStruct *) DrawList)
ii = IsBusLabel( STRUCT->m_Text);
if( ObjNet)
{
ObjNet[NbrItem].m_Comp = STRUCT;
ObjNet[NbrItem].m_Window = Window;
ObjNet[NbrItem].m_Type = NET_LABEL;
if (STRUCT->m_Layer == LAYER_GLOBLABEL)
ObjNet[NbrItem].m_Type = NET_GLOBLABEL;
ObjNet[NbrItem].m_Label = & STRUCT->m_Text;
ObjNet[NbrItem].m_SheetNumber = NumSheet;
ObjNet[NbrItem].m_Start = STRUCT->m_Pos;
ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start;
/* Si c'est un Bus, eclatement en Label */
if ( ii ) ConvertBusToMembers(ObjNet + NbrItem);
}
NbrItem += ii+1;
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE :
#undef STRUCT
#define STRUCT ((DrawGlobalLabelStruct *) DrawList)
ii = IsBusLabel( STRUCT->m_Text);
if( ObjNet)
{
ObjNet[NbrItem].m_Comp = STRUCT;
ObjNet[NbrItem].m_Window = Window;
ObjNet[NbrItem].m_Type = NET_LABEL;
if (STRUCT->m_Layer == LAYER_GLOBLABEL)
ObjNet[NbrItem].m_Type = NET_GLOBLABEL;
ObjNet[NbrItem].m_Label = & STRUCT->m_Text;
ObjNet[NbrItem].m_SheetNumber = NumSheet;
ObjNet[NbrItem].m_Start = STRUCT->m_Pos;
ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start;
/* Si c'est un Bus, eclatement en Label */
if ( ii ) ConvertBusToMembers(ObjNet + NbrItem);
}
NbrItem += ii+1;
break;
case DRAW_LIB_ITEM_STRUCT_TYPE :
DrawLibItem = (EDA_SchComponentStruct *) DrawList;
memcpy(TransMat, DrawLibItem->m_Transform, sizeof(TransMat));
PartX = DrawLibItem->m_Pos.x; PartY = DrawLibItem->m_Pos.y;
Entry = FindLibPart(DrawLibItem->m_ChipName, wxEmptyString, FIND_ROOT);
if( Entry == NULL) break;
if(Entry->m_Drawings == NULL) break ;
DEntry = Entry->m_Drawings;
for ( ;DEntry != NULL; DEntry = DEntry->Next())
{
LibDrawPin * Pin = (LibDrawPin *) DEntry;
if( DEntry->m_StructType != COMPONENT_PIN_DRAW_TYPE) continue;
if( DEntry->m_Unit &&
(DEntry->m_Unit != DrawLibItem->m_Multi) ) continue;
if( DEntry->m_Convert &&
(DEntry->m_Convert != DrawLibItem->m_Convert)) continue;
x2 = PartX + TransMat[0][0] * Pin->m_Pos.x
+ TransMat[0][1] * Pin->m_Pos.y;
y2 = PartY + TransMat[1][0] * Pin->m_Pos.x
+ TransMat[1][1] * Pin->m_Pos.y;
if( ObjNet)
{
ObjNet[NbrItem].m_Comp = DEntry;
ObjNet[NbrItem].m_Type = NET_PIN;
ObjNet[NbrItem].m_Link = DrawLibItem;
ObjNet[NbrItem].m_Window = Window;
ObjNet[NbrItem].m_ElectricalType = Pin->m_PinType;
ObjNet[NbrItem].m_PinNum = Pin->m_PinNum;
ObjNet[NbrItem].m_Label = & Pin->m_PinName;
ObjNet[NbrItem].m_SheetNumber = NumSheet;
ObjNet[NbrItem].m_Start.x = x2;
ObjNet[NbrItem].m_Start.y = y2;
ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start;
}
NbrItem++;
if( ( (int) Pin->m_PinType == (int) PIN_POWER_IN ) &&
( Pin->m_Attributs & PINNOTDRAW ) )
{ /* Il y a un PIN_LABEL Associe */
if( ObjNet)
{
ObjNet[NbrItem].m_Comp = NULL;
ObjNet[NbrItem].m_Type = NET_PINLABEL;
ObjNet[NbrItem].m_Window = Window;
ObjNet[NbrItem].m_SheetNumber = NumSheet;
ObjNet[NbrItem].m_Label = & Pin->m_PinName;
ObjNet[NbrItem].m_Start.x = x2;
ObjNet[NbrItem].m_Start.y = y2;
ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start;
}
NbrItem++;
}
}
break;
case DRAW_PICK_ITEM_STRUCT_TYPE :
case DRAW_POLYLINE_STRUCT_TYPE :
case DRAW_BUSENTRY_STRUCT_TYPE :
case DRAW_MARKER_STRUCT_TYPE :
case DRAW_TEXT_STRUCT_TYPE :
break;
case DRAW_SHEET_STRUCT_TYPE :
#undef STRUCT
#define STRUCT ((DrawSheetStruct *) DrawList)
ScreenInclude = (SCH_SCREEN*) STRUCT->m_Son;
if( ScreenInclude ) NumInclude = ScreenInclude->m_SheetNumber;
else NumInclude = 0;
SheetLabel = STRUCT->m_Label;
for ( ; SheetLabel != NULL;
SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext)
{
ii = IsBusLabel(SheetLabel->m_Text);
if( ObjNet)
{
ObjNet[NbrItem].m_Comp = SheetLabel;
ObjNet[NbrItem].m_Link = DrawList;
ObjNet[NbrItem].m_Type = NET_SHEETLABEL;
ObjNet[NbrItem].m_Window = Window;
ObjNet[NbrItem].m_ElectricalType = SheetLabel->m_Shape;
ObjNet[NbrItem].m_Label = & SheetLabel->m_Text;
ObjNet[NbrItem].m_SheetNumber = NumSheet;
ObjNet[NbrItem].m_NumInclude = NumInclude;
ObjNet[NbrItem].m_Start = SheetLabel->m_Pos;
ObjNet[NbrItem].m_End = ObjNet[NbrItem].m_Start;
/* Si c'est un Bus, eclatement en Label */
if ( ii ) ConvertBusToMembers(ObjNet + NbrItem);
}
NbrItem += ii+1;
}
break;
case DRAW_SHEETLABEL_STRUCT_TYPE :
DisplayError(frame, wxT("Netlist: Type DRAW_SHEETLABEL inattendu"));
break;
default:
{
wxString msg;
msg.Printf( wxT("Netlist: Type struct %d inattendu"),
DrawList->m_StructType);
DisplayError(frame, msg);
break;
}
}
DrawList = DrawList->Pnext;
}
return(NbrItem);
}
/*******************************************************************/
/* void ConnectBusLabels( ObjetNetListStruct *Label, int NbItems ) */
/*******************************************************************/
/* Routine qui analyse les labels type xxBUSLABELMEMBER
Propage les Netcodes entre labels correspondants ( c'est a dire lorsque
leur numero de membre est identique) lorsqu'ils sont connectes
globalement par leur BusNetCode
Utilise et met a jour la variable LastNetCode
*/
static void ConnectBusLabels( ObjetNetListStruct *Label, int NbItems )
{
ObjetNetListStruct *LabelInTst, *Lim;
Lim = Label + NbItems;
for ( ; Label < Lim; Label++)
{
if( (Label->m_Type == NET_SHEETBUSLABELMEMBER) ||
(Label->m_Type == NET_BUSLABELMEMBER) ||
(Label->m_Type == NET_GLOBBUSLABELMEMBER) )
{
if( Label->m_NetCode == 0 )
{
Label->m_NetCode = LastNetCode; LastNetCode++;
}
for ( LabelInTst = Label+1; LabelInTst < Lim; LabelInTst++)
{
if( (LabelInTst->m_Type == NET_SHEETBUSLABELMEMBER) ||
(LabelInTst->m_Type == NET_BUSLABELMEMBER) ||
(LabelInTst->m_Type == NET_GLOBBUSLABELMEMBER) )
{
if( LabelInTst->m_BusNetCode != Label->m_BusNetCode ) continue;
if( LabelInTst->m_Member != Label->m_Member ) continue;
if( LabelInTst->m_NetCode == 0 )
LabelInTst->m_NetCode = Label->m_NetCode;
else
PropageNetCode( LabelInTst->m_NetCode, Label->m_NetCode,0);
}
}
}
}
}
/**************************************************/
int IsBusLabel( const wxString & LabelDrawList )
/**************************************************/
/* Routine qui verifie si le Label a une notation de type Bus
Retourne 0 si non
nombre de membres si oui
met a jour FirstNumWireBus, LastNumWireBus et RootBusNameLength
*/
{
int Num;
wxString BufLine;
long tmp;
bool error = FALSE;
/* Search for '[' because a bus label is like "busname[nn..mm]" */
Num = LabelDrawList.Find('[');
if ( Num < 0 ) return(0);
FirstNumWireBus = LastNumWireBus = 9;
RootBusNameLength = Num;
Num++;
while ( LabelDrawList[Num] != '.' && Num < LabelDrawList.Len())
{
BufLine.Append(LabelDrawList[Num]);
Num++;
}
if ( ! BufLine.ToLong(&tmp) ) error = TRUE;;
FirstNumWireBus = tmp;
while ( LabelDrawList[Num] == '.' && Num < LabelDrawList.Len() )
Num++;
BufLine.Empty();
while ( LabelDrawList[Num] != ']' && Num < LabelDrawList.Len())
{
BufLine.Append(LabelDrawList[Num]);
Num++;
}
if ( ! BufLine.ToLong(&tmp) ) error = TRUE;;
LastNumWireBus = tmp;
if( FirstNumWireBus < 0 ) FirstNumWireBus = 0;
if( LastNumWireBus < 0 ) LastNumWireBus = 0;
if( FirstNumWireBus > LastNumWireBus )
{
EXCHG( FirstNumWireBus, LastNumWireBus);
}
if ( error && (s_PassNumber == 0) )
{
wxString msg = _("Bad Bus Label: ") + LabelDrawList;
DisplayError(NULL, msg);
}
return(LastNumWireBus - FirstNumWireBus + 1 );
}
/*************************************************/
static int ConvertBusToMembers(ObjetNetListStruct * BusLabel)
/*************************************************/
/* Routine qui eclate un label type Bus en autant de Label qu'il contient de membres,
et qui cree les structures avec le type NET_GLOBBUSLABELMEMBER, NET_BUSLABELMEMBER
ou NET_SHEETBUSLABELMEMBER
entree = pointeur sur l'ObjetNetListStruct initialise corresp au buslabel
suppose que FirstNumWireBus, LastNumWireBus et RootBusNameLength sont a jour
modifie l'ObjetNetListStruct de base et remplit les suivants
m_Label is a pointer to a new wxString
m_Label must be deallocated by the user (only for a NET_GLOBBUSLABELMEMBER,
NET_BUSLABELMEMBER or a NET_SHEETBUSLABELMEMBER object type)
*/
{
int NumItem, BusMember;
wxString BufLine;
if( BusLabel->m_Type == NET_GLOBLABEL )
BusLabel->m_Type = NET_GLOBBUSLABELMEMBER;
else if (BusLabel->m_Type == NET_SHEETLABEL)
BusLabel->m_Type = NET_SHEETBUSLABELMEMBER;
else BusLabel->m_Type = NET_BUSLABELMEMBER;
/* Convertion du BusLabel en la racine du Label + le numero du fil */
BufLine = BusLabel->m_Label->Left(RootBusNameLength);
BusMember = FirstNumWireBus;
BufLine << BusMember;
BusLabel->m_Label = new wxString(BufLine);
BusLabel->m_Member = BusMember;
NumItem = 1;
for ( BusMember++; BusMember <= LastNumWireBus; BusMember++)
{
*(BusLabel+1) = *BusLabel; BusLabel ++; NumItem++;
/* Convertion du BusLabel en la racine du Label + le numero du fil */
BufLine = BusLabel->m_Label->Left(RootBusNameLength);
BufLine << BusMember;
BusLabel->m_Label = new wxString(BufLine);
BusLabel->m_Member = BusMember;
}
return( NumItem);
}
/**********************************************************************/
static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus )
/**********************************************************************/
/* PropageNetCode propage le netcode NewNetCode sur tous les elements
appartenant a l'ancien netcode OldNetCode
Si IsBus == 0; c'est le membre NetCode qui est propage
Si IsBus != 0; c'est le membre BusNetCode qui est propage
*/
{
int jj;
ObjetNetListStruct * Objet = g_TabObjNet;
if( OldNetCode == NewNetCode ) return;
if( IsBus == 0 ) /* Propagation du NetCode */
{
for (jj = 0; jj < g_NbrObjNet; jj++, Objet++)
{
if ( Objet->m_NetCode == OldNetCode )
{
Objet->m_NetCode = NewNetCode;
}
}
}
else /* Propagation du BusNetCode */
{
for (jj = 0; jj < g_NbrObjNet; jj++, Objet++)
{
if ( Objet->m_BusNetCode == OldNetCode )
{
Objet->m_BusNetCode = NewNetCode;
}
}
}
}
/***************************************************************************/
static void PointToPointConnect(ObjetNetListStruct *Ref, int IsBus, int start)
/***************************************************************************/
/* Routine qui verifie si l'element *Ref est connecte a
d'autres elements de la liste des objets du schema, selon le mode Point
a point ( Extremites superposees )
si IsBus:
la connexion ne met en jeu que des elements type bus
( BUS ou BUSLABEL ou JONCTION )
sinon
la connexion ne met en jeu que des elements type non bus
( autres que BUS ou BUSLABEL )
L'objet Ref doit avoir un NetCode valide.
La liste des objets est supposee classe par NumSheet Croissants,
et la recherche se fait a partir de l'element start, 1er element
de la feuille de schema
( il ne peut y avoir connexion physique entre elements de differentes sheets)
*/
{
int i, NetCode;
ObjetNetListStruct *Point = g_TabObjNet;
if ( IsBus == 0 ) /* Objets autres que BUS et BUSLABELS */
{
NetCode = Ref->m_NetCode;
for (i = start; i < g_NbrObjNet; i++)
{
if( Point[i].m_SheetNumber > Ref->m_SheetNumber ) break;
switch( Point[i].m_Type )
{
case NET_SEGMENT:
case NET_PIN:
case NET_LABEL:
case NET_GLOBLABEL:
case NET_SHEETLABEL:
case NET_PINLABEL:
case NET_JONCTION:
case NET_NOCONNECT:
if( (((Ref->m_Start.x == Point[i].m_Start.x) && (Ref->m_Start.y == Point[i].m_Start.y))) ||
(((Ref->m_Start.x == Point[i].m_End.x) && (Ref->m_Start.y == Point[i].m_End.y))) ||
(((Ref->m_End.x == Point[i].m_Start.x) && (Ref->m_End.y == Point[i].m_Start.y))) ||
(((Ref->m_End.x == Point[i].m_End.x) && (Ref->m_End.y == Point[i].m_End.y))) )
{
if( Point[i].m_NetCode == 0 ) Point[i].m_NetCode = NetCode;
else PropageNetCode( Point[i].m_NetCode, NetCode , 0);
}
break;
case NET_BUS:
case NET_BUSLABELMEMBER:
case NET_SHEETBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
break;
}
}
}
else /* Objets type BUS et BUSLABELS ( et JONCTIONS )*/
{
NetCode = Ref->m_BusNetCode;
for (i = start; i < g_NbrObjNet; i++)
{
if( Point[i].m_SheetNumber > Ref->m_SheetNumber ) break;
switch( Point[i].m_Type )
{
case NET_SEGMENT:
case NET_PIN:
case NET_LABEL:
case NET_GLOBLABEL:
case NET_SHEETLABEL:
case NET_PINLABEL:
case NET_NOCONNECT:
break;
case NET_BUS:
case NET_BUSLABELMEMBER:
case NET_SHEETBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
case NET_JONCTION:
if( (((Ref->m_Start.x == Point[i].m_Start.x) && (Ref->m_Start.y == Point[i].m_Start.y))) ||
(((Ref->m_Start.x == Point[i].m_End.x) && (Ref->m_Start.y == Point[i].m_End.y))) ||
(((Ref->m_End.x == Point[i].m_Start.x) && (Ref->m_End.y == Point[i].m_Start.y))) ||
(((Ref->m_End.x == Point[i].m_End.x) && (Ref->m_End.y == Point[i].m_End.y))) )
{
if( Point[i].m_BusNetCode == 0 )
Point[i].m_BusNetCode = NetCode;
else PropageNetCode( Point[i].m_BusNetCode, NetCode,1 );
}
break;
}
}
}
}
/**************************************************************/
static void SegmentToPointConnect(ObjetNetListStruct *Jonction,
int IsBus, int start)
/***************************************************************/
/*
Routine qui recherche si un point (jonction) est connecte a des segments,
et regroupe les NetCodes des objets connectes a la jonction.
Le point de jonction doit avoir un netcode valide
La liste des objets est supposee classe par NumSheet Croissants,
et la recherche se fait a partir de l'element start, 1er element
de la feuille de schema
( il ne peut y avoir connexion physique entre elements de differentes sheets)
*/
{
int i;
ObjetNetListStruct *Segment = g_TabObjNet;
for (i = start; i < g_NbrObjNet; i++)
{
if( Segment[i].m_SheetNumber > Jonction->m_SheetNumber ) break;
if( IsBus == 0)
{
if ( Segment[i].m_Type != NET_SEGMENT ) continue;
}
else
{
if ( Segment[i].m_Type != NET_BUS ) continue;
}
if ( SegmentIntersect(Segment[i].m_Start.x, Segment[i].m_Start.y,
Segment[i].m_End.x, Segment[i].m_End.y,
Jonction->m_Start.x, Jonction->m_Start.y) )
{
/* Propagation du Netcode a tous les Objets de meme NetCode */
if( IsBus == 0 )
{
if( Segment[i].m_NetCode )
PropageNetCode(Segment[i].m_NetCode,
Jonction->m_NetCode, IsBus);
else Segment[i].m_NetCode = Jonction->m_NetCode;
}
else
{
if( Segment[i].m_BusNetCode )
PropageNetCode(Segment[i].m_BusNetCode,
Jonction->m_BusNetCode, IsBus);
else Segment[i].m_BusNetCode = Jonction->m_BusNetCode;
}
}
}
}
/*****************************************************************
* Routine qui connecte les groupes d'objets si labels identiques *
*******************************************************************/
static void LabelConnection(ObjetNetListStruct *LabelRef)
{
int i, NetCode;
ObjetNetListStruct *ObjetNet;
if( LabelRef->m_NetCode == 0 ) return;
ObjetNet = g_TabObjNet;
for (i = 0; i < g_NbrObjNet; i++)
{
NetCode = ObjetNet[i].m_NetCode;
if( NetCode == LabelRef->m_NetCode ) continue;
if( ObjetNet[i].m_SheetNumber != LabelRef->m_SheetNumber )
{
if (ObjetNet[i].m_Type != NET_PINLABEL ) continue;
}
if( (ObjetNet[i].m_Type == NET_LABEL ) ||
(ObjetNet[i].m_Type == NET_GLOBLABEL ) ||
(ObjetNet[i].m_Type == NET_BUSLABELMEMBER ) ||
(ObjetNet[i].m_Type == NET_GLOBBUSLABELMEMBER ) ||
(ObjetNet[i].m_Type == NET_PINLABEL ) )
{
if( ObjetNet[i].m_Label->CmpNoCase(*LabelRef->m_Label) != 0) continue;
/* Ici 2 labels identiques */
/* Propagation du Netcode a tous les Objets de meme NetCode */
if( ObjetNet[i].m_NetCode )
PropageNetCode(ObjetNet[i].m_NetCode, LabelRef->m_NetCode, 0);
else ObjetNet[i].m_NetCode = LabelRef->m_NetCode;
}
}
}
/****************************************************************************/
static int TriNetCode(ObjetNetListStruct *Objet1, ObjetNetListStruct *Objet2)
/****************************************************************************/
/* Routine de comparaison pour le tri par NetCode croissant
du tableau des elements connectes ( TabPinSort ) par qsort()
*/
{
return (Objet1->m_NetCode - Objet2->m_NetCode);
}
/*****************************************************************************/
static int TriBySheet(ObjetNetListStruct *Objet1, ObjetNetListStruct *Objet2)
/*****************************************************************************/
/* Routine de comparaison pour le tri par NumSheet
du tableau des elements connectes ( TabPinSort ) par qsort() */
{
return (Objet1->m_SheetNumber - Objet2->m_SheetNumber);
}
/**********************************************************************/
static void SetUnconnectedFlag( ObjetNetListStruct *ListObj, int NbItems )
/**********************************************************************/
/* Routine positionnant le membre .FlagNoConnect des elements de
la liste des objets netliste, tries par ordre de NetCode
*/
{
ObjetNetListStruct * NetItemRef, * NetItemTst, *ItemPtr;
ObjetNetListStruct * NetStart, * NetEnd, * Lim;
int Nb;
IsConnectType StateFlag;
NetStart = NetEnd = ListObj;
Lim = ListObj + NbItems;
NetItemRef = NetStart;
Nb = 0; StateFlag = UNCONNECT;
for ( ; NetItemRef < Lim; NetItemRef++ )
{
if( NetItemRef->m_Type == NET_NOCONNECT )
if( StateFlag != CONNECT ) StateFlag = NOCONNECT;
/* Analyse du net en cours */
NetItemTst = NetItemRef + 1;
if( (NetItemTst >= Lim) ||
(NetItemRef->m_NetCode != NetItemTst->m_NetCode) )
{ /* Net analyse: mise a jour de m_FlagOfConnection */
NetEnd = NetItemTst;
for( ItemPtr = NetStart; ItemPtr < NetEnd; ItemPtr++ )
{
ItemPtr->m_FlagOfConnection = StateFlag;
}
if(NetItemTst >= Lim) return;
/* Start Analyse Nouveau Net */
StateFlag = UNCONNECT;
NetStart = NetItemTst;
continue;
}
for ( ; ; NetItemTst ++)
{
if( (NetItemTst >= Lim) ||
(NetItemRef->m_NetCode != NetItemTst->m_NetCode) )
break;
switch( NetItemTst->m_Type )
{
case NET_SEGMENT:
case NET_LABEL:
case NET_GLOBLABEL:
case NET_SHEETLABEL:
case NET_PINLABEL:
case NET_BUS:
case NET_BUSLABELMEMBER:
case NET_SHEETBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
case NET_JONCTION:
break;
case NET_PIN:
if( NetItemRef->m_Type == NET_PIN )
StateFlag = CONNECT;
break;
case NET_NOCONNECT:
if( StateFlag != CONNECT ) StateFlag = NOCONNECT;
break;
}
}
}
}
| [
"fcoiffie@244deca0-f506-0410-ab94-f4f3571dea26"
]
| [
[
[
1,
1039
]
]
]
|
724b585ad4c5e950f101a73969e27c4f033d014a | 7c93f9e101f6bba916bc1a967eb8e787afe9be92 | /7z920/CPP/7zip/Archive/LibExports.cpp | ccf4a28e57921097649ee72b281dcfe08863320a | []
| no_license | ditupao/vx7zip | 95759f909368c14f5b8f9a3cbee18a54dc3eae78 | 13fa94305e8d3491f9d920351e5d1534957a1c06 | refs/heads/master | 2016-08-11T10:55:47.619762 | 2011-06-05T09:50:51 | 2011-06-05T09:50:51 | 47,533,061 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,355 | cpp | // DLLExports.cpp
#include "StdAfx.h"
//#include "../../Common/MyInitGuid.h"
#if defined(_MY_WIN32) && defined(_7ZIP_LARGE_PAGES)
#include "../../../C/Alloc.h"
#endif
#include "../../Common/ComTry.h"
#include "../../Windows/NtCheck.h"
#include "../../Windows/PropVariant.h"
#include "../ICoder.h"
#include "../IPassword.h"
#include "IArchive.h"
#define NT_CHECK_FAIL_ACTION return FALSE;
DEFINE_GUID(CLSID_CArchiveHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
static const UInt16 kDecodeId = 0x2790;
DEFINE_GUID(CLSID_CCodec,
0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
STDAPI CreateArchiver(const GUID *classID, const GUID *iid, void **outObject);
STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
{
// COM_TRY_BEGIN
*outObject = 0;
if (*iid == IID_ICompressCoder || *iid == IID_ICompressCoder2 || *iid == IID_ICompressFilter)
{
return CreateCoder(clsid, iid, outObject);
}
else
{
return CreateArchiver(clsid, iid, outObject);
}
// COM_TRY_END
}
STDAPI SetLargePageMode()
{
#if defined(_MY_WIN32) && defined(_7ZIP_LARGE_PAGES)
SetLargePageSize();
#endif
return S_OK;
}
| [
"[email protected]"
]
| [
[
[
1,
59
]
]
]
|
b9c6b9084835e3dbc213b17ee68fa8b043380f97 | eb8a27a2cc7307f0bc9596faa4aa4a716676c5c5 | /WinEdition/browser-lcc/jscc/src/v8/v8/src/arm/assembler-arm-inl.h | b3571a2fd005a0b493a6353247e2c42597803779 | [
"BSD-3-Clause",
"bzip2-1.0.6",
"LicenseRef-scancode-public-domain",
"Artistic-2.0",
"Artistic-1.0"
]
| permissive | baxtree/OKBuzzer | c46c7f271a26be13adcf874d77a7a6762a8dc6be | a16e2baad145f5c65052cdc7c767e78cdfee1181 | refs/heads/master | 2021-01-02T22:17:34.168564 | 2011-06-15T02:29:56 | 2011-06-15T02:29:56 | 1,790,181 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,539 | h | // Copyright (c) 1994-2006 Sun Microsystems 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:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// - Redistribution 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.
//
// - Neither the name of Sun Microsystems or the names of contributors may
// 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.
// The original source code covered by the above license above has been modified
// significantly by Google Inc.
// Copyright 2006-2008 the V8 project authors. All rights reserved.
#ifndef V8_ARM_ASSEMBLER_ARM_INL_H_
#define V8_ARM_ASSEMBLER_ARM_INL_H_
#include "arm/assembler-arm.h"
#include "cpu.h"
#include "debug.h"
namespace v8 {
namespace internal {
void RelocInfo::apply(intptr_t delta) {
if (RelocInfo::IsInternalReference(rmode_)) {
// absolute code pointer inside code object moves with the code object.
int32_t* p = reinterpret_cast<int32_t*>(pc_);
*p += delta; // relocate entry
}
// We do not use pc relative addressing on ARM, so there is
// nothing else to do.
}
Address RelocInfo::target_address() {
ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
return Assembler::target_address_at(pc_);
}
Address RelocInfo::target_address_address() {
ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
return reinterpret_cast<Address>(Assembler::target_address_address_at(pc_));
}
int RelocInfo::target_address_size() {
return Assembler::kExternalTargetSize;
}
void RelocInfo::set_target_address(Address target) {
ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
Assembler::set_target_address_at(pc_, target);
}
Object* RelocInfo::target_object() {
ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
return Memory::Object_at(Assembler::target_address_address_at(pc_));
}
Handle<Object> RelocInfo::target_object_handle(Assembler* origin) {
ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
return Memory::Object_Handle_at(Assembler::target_address_address_at(pc_));
}
Object** RelocInfo::target_object_address() {
ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
return reinterpret_cast<Object**>(Assembler::target_address_address_at(pc_));
}
void RelocInfo::set_target_object(Object* target) {
ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
Assembler::set_target_address_at(pc_, reinterpret_cast<Address>(target));
}
Address* RelocInfo::target_reference_address() {
ASSERT(rmode_ == EXTERNAL_REFERENCE);
return reinterpret_cast<Address*>(Assembler::target_address_address_at(pc_));
}
Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() {
ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
Address address = Memory::Address_at(pc_);
return Handle<JSGlobalPropertyCell>(
reinterpret_cast<JSGlobalPropertyCell**>(address));
}
JSGlobalPropertyCell* RelocInfo::target_cell() {
ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
Address address = Memory::Address_at(pc_);
Object* object = HeapObject::FromAddress(
address - JSGlobalPropertyCell::kValueOffset);
return reinterpret_cast<JSGlobalPropertyCell*>(object);
}
void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) {
ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
Address address = cell->address() + JSGlobalPropertyCell::kValueOffset;
Memory::Address_at(pc_) = address;
}
Address RelocInfo::call_address() {
// The 2 instructions offset assumes patched debug break slot or return
// sequence.
ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
return Memory::Address_at(pc_ + 2 * Assembler::kInstrSize);
}
void RelocInfo::set_call_address(Address target) {
ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
Memory::Address_at(pc_ + 2 * Assembler::kInstrSize) = target;
}
Object* RelocInfo::call_object() {
return *call_object_address();
}
void RelocInfo::set_call_object(Object* target) {
*call_object_address() = target;
}
Object** RelocInfo::call_object_address() {
ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize);
}
bool RelocInfo::IsPatchedReturnSequence() {
Instr current_instr = Assembler::instr_at(pc_);
Instr next_instr = Assembler::instr_at(pc_ + Assembler::kInstrSize);
#ifdef USE_BLX
// A patched return sequence is:
// ldr ip, [pc, #0]
// blx ip
return ((current_instr & kLdrPCMask) == kLdrPCPattern)
&& ((next_instr & kBlxRegMask) == kBlxRegPattern);
#else
// A patched return sequence is:
// mov lr, pc
// ldr pc, [pc, #-4]
return (current_instr == kMovLrPc)
&& ((next_instr & kLdrPCMask) == kLdrPCPattern);
#endif
}
bool RelocInfo::IsPatchedDebugBreakSlotSequence() {
Instr current_instr = Assembler::instr_at(pc_);
return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP);
}
void RelocInfo::Visit(ObjectVisitor* visitor) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
visitor->VisitPointer(target_object_address());
} else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
visitor->VisitGlobalPropertyCell(this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
visitor->VisitExternalReference(target_reference_address());
#ifdef ENABLE_DEBUGGER_SUPPORT
// TODO(isolates): Get a cached isolate below.
} else if (((RelocInfo::IsJSReturn(mode) &&
IsPatchedReturnSequence()) ||
(RelocInfo::IsDebugBreakSlot(mode) &&
IsPatchedDebugBreakSlotSequence())) &&
Isolate::Current()->debug()->has_break_points()) {
visitor->VisitDebugTarget(this);
#endif
} else if (mode == RelocInfo::RUNTIME_ENTRY) {
visitor->VisitRuntimeEntry(this);
}
}
template<typename StaticVisitor>
void RelocInfo::Visit(Heap* heap) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
StaticVisitor::VisitPointer(heap, target_object_address());
} else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(heap, this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
StaticVisitor::VisitGlobalPropertyCell(heap, this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
StaticVisitor::VisitExternalReference(target_reference_address());
#ifdef ENABLE_DEBUGGER_SUPPORT
} else if (heap->isolate()->debug()->has_break_points() &&
((RelocInfo::IsJSReturn(mode) &&
IsPatchedReturnSequence()) ||
(RelocInfo::IsDebugBreakSlot(mode) &&
IsPatchedDebugBreakSlotSequence()))) {
StaticVisitor::VisitDebugTarget(heap, this);
#endif
} else if (mode == RelocInfo::RUNTIME_ENTRY) {
StaticVisitor::VisitRuntimeEntry(this);
}
}
Operand::Operand(int32_t immediate, RelocInfo::Mode rmode) {
rm_ = no_reg;
imm32_ = immediate;
rmode_ = rmode;
}
Operand::Operand(const ExternalReference& f) {
rm_ = no_reg;
imm32_ = reinterpret_cast<int32_t>(f.address());
rmode_ = RelocInfo::EXTERNAL_REFERENCE;
}
Operand::Operand(Smi* value) {
rm_ = no_reg;
imm32_ = reinterpret_cast<intptr_t>(value);
rmode_ = RelocInfo::NONE;
}
Operand::Operand(Register rm) {
rm_ = rm;
rs_ = no_reg;
shift_op_ = LSL;
shift_imm_ = 0;
}
bool Operand::is_reg() const {
return rm_.is_valid() &&
rs_.is(no_reg) &&
shift_op_ == LSL &&
shift_imm_ == 0;
}
void Assembler::CheckBuffer() {
if (buffer_space() <= kGap) {
GrowBuffer();
}
if (pc_offset() >= next_buffer_check_) {
CheckConstPool(false, true);
}
}
void Assembler::emit(Instr x) {
CheckBuffer();
*reinterpret_cast<Instr*>(pc_) = x;
pc_ += kInstrSize;
}
Address Assembler::target_address_address_at(Address pc) {
Address target_pc = pc;
Instr instr = Memory::int32_at(target_pc);
// If we have a bx instruction, the instruction before the bx is
// what we need to patch.
static const int32_t kBxInstMask = 0x0ffffff0;
static const int32_t kBxInstPattern = 0x012fff10;
if ((instr & kBxInstMask) == kBxInstPattern) {
target_pc -= kInstrSize;
instr = Memory::int32_at(target_pc);
}
#ifdef USE_BLX
// If we have a blx instruction, the instruction before it is
// what needs to be patched.
if ((instr & kBlxRegMask) == kBlxRegPattern) {
target_pc -= kInstrSize;
instr = Memory::int32_at(target_pc);
}
#endif
ASSERT(IsLdrPcImmediateOffset(instr));
int offset = instr & 0xfff; // offset_12 is unsigned
if ((instr & (1 << 23)) == 0) offset = -offset; // U bit defines offset sign
// Verify that the constant pool comes after the instruction referencing it.
ASSERT(offset >= -4);
return target_pc + offset + 8;
}
Address Assembler::target_address_at(Address pc) {
return Memory::Address_at(target_address_address_at(pc));
}
void Assembler::set_target_at(Address constant_pool_entry,
Address target) {
Memory::Address_at(constant_pool_entry) = target;
}
void Assembler::set_target_address_at(Address pc, Address target) {
Memory::Address_at(target_address_address_at(pc)) = target;
// Intuitively, we would think it is necessary to flush the instruction cache
// after patching a target address in the code as follows:
// CPU::FlushICache(pc, sizeof(target));
// However, on ARM, no instruction was actually patched by the assignment
// above; the target address is not part of an instruction, it is patched in
// the constant pool and is read via a data access; the instruction accessing
// this address in the constant pool remains unchanged.
}
} } // namespace v8::internal
#endif // V8_ARM_ASSEMBLER_ARM_INL_H_
| [
"[email protected]"
]
| [
[
[
1,
353
]
]
]
|
107832d4810596750222091f268422837c2968bf | 463c3b62132d215e245a097a921859ecb498f723 | /lib/dlib/stack/stack_kernel_abstract.h | 44ea72d00d1f4dea967ec92e3a5bb025da11eedd | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
]
| permissive | athulan/cppagent | 58f078cee55b68c08297acdf04a5424c2308cfdc | 9027ec4e32647e10c38276e12bcfed526a7e27dd | refs/heads/master | 2021-01-18T23:34:34.691846 | 2009-05-05T00:19:54 | 2009-05-05T00:19:54 | 197,038 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,630 | h | // Copyright (C) 2003 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_STACK_KERNEl_ABSTRACT_
#ifdef DLIB_STACK_KERNEl_ABSTRACT_
#include "../interfaces/enumerable.h"
#include "../interfaces/remover.h"
#include "../serialize.h"
#include "../memory_manager/memory_manager_kernel_abstract.h"
namespace dlib
{
template <
typename T,
typename mem_manager = memory_manager<char>::kernel_1a
>
class stack : public enumerable<T>,
public remover<T>
{
/*!
REQUIREMENTS ON T
T must be swappable by a global swap() and
T must have a default constructor
REQUIREMENTS ON mem_manager
must be an implementation of memory_manager/memory_manager_kernel_abstract.h or
must be an implementation of memory_manager_global/memory_manager_global_kernel_abstract.h or
must be an implementation of memory_manager_stateless/memory_manager_stateless_kernel_abstract.h
mem_manager::type can be set to anything.
POINTERS AND REFERENCES TO INTERNAL DATA
swap() and current() functions do not invalidate pointers
or references to internal data.
All other functions have no such guarantee.
INITIAL VALUE
size() == 0
ENUMERATION ORDER
The enumerator will iterate over the elements in the stack in the
same order they would be removed in by repeated calls to pop().
(e.g. current() would be the first element enumerated)
WHAT THIS OBJECT REPRESENTS
This is a last in first out stack containing items of type T.
e.g. if the stack is {b,c,d,e} then a is put in
the stack becomes {a,b,c,d,e} and then pop takes a back out
returning the stack to {b,c,d,e}
Also note that unless specified otherwise, no member functions
of this object throw exceptions.
!*/
public:
typedef T type;
typedef mem_manager mem_manager_type;
stack (
);
/*!
ensures
- #*this is properly initialized
throws
- std::bad_alloc or any exception thrown by T's constructor
!*/
virtual ~stack (
);
/*!
ensures
- all memory associated with *this has been released
!*/
void clear(
);
/*!
ensures
- #*this has its initial value
throws
- std::bad_alloc or any exception thrown by T's constructor
if this exception is thrown then *this is unusable
until clear() is called and succeeds
!*/
void push (
T& item
);
/*!
ensures
- item has been swapped onto the top of the stack
- #current() == item
- #item has an initial value for its type
- #size() == size() + 1
- #at_start() == true
throws
- std::bad_alloc or any exception thrown by T's constructor
if push() throws then it has no effect
!*/
void pop (
T& item
);
/*!
requires
- size() != 0
ensures
- #size() == size() - 1
- #item == current()
i.e. the top element of *this has been removed and swapped
into #item
- #at_start() == true
!*/
T& current (
);
/*!
requires
- size() != 0
ensures
- returns a const reference to the element at the top of *this
!*/
const T& current (
) const;
/*!
requires
- size() != 0
ensures
- returns a non-const reference to the element at the top of *this
!*/
void swap (
stack& item
);
/*!
ensures
- swaps *this and item
!*/
private:
// restricted functions
stack(stack&); // copy constructor
stack& operator=(stack&); // assignment operator
};
template <
typename T,
typename mem_manager
>
inline void swap (
stack<T,mem_manager>& a,
stack<T,mem_manager>& b
) { a.swap(b); }
/*!
provides a global swap function
!*/
template <
typename T,
typename mem_manager
>
void deserialize (
stack<T,mem_manager>& item,
std::istream& in
);
/*!
provides deserialization support
!*/
}
#endif // DLIB_STACK_KERNEl_ABSTRACT_
| [
"jimmy@DGJ3X3B1.(none)"
]
| [
[
[
1,
180
]
]
]
|
5b25a8c99aabd5f4fd6f8849d2e4db4c432eb64f | ee065463a247fda9a1927e978143186204fefa23 | /Src/Depends/ClanLib/ClanLib2.0/Sources/API/Core/Zip/zip_archive.h | ff69136944ee3488e95568c2a7c1e466f510b7b4 | []
| no_license | ptrefall/hinsimviz | 32e9a679170eda9e552d69db6578369a3065f863 | 9caaacd39bf04bbe13ee1288d8578ece7949518f | refs/heads/master | 2021-01-22T09:03:52.503587 | 2010-09-26T17:29:20 | 2010-09-26T17:29:20 | 32,448,374 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,041 | h | /*
** ClanLib SDK
** Copyright (c) 1997-2010 The ClanLib Team
**
** 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, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
** Note: Some of the libraries ClanLib may link to may have additional
** requirements or restrictions.
**
** File Author(s):
**
** Magnus Norddahl
** Harry Storbacka
*/
/// \addtogroup clanCore_I_O_Data clanCore I/O Data
/// \{
#pragma once
#include "../api_core.h"
#include "../System/sharedptr.h"
#include "zip_file_entry.h"
#include <vector>
class CL_IODevice;
class CL_ZipArchive_Impl;
/// \brief Zip archive.
///
/// \xmlonly !group=Core/Zip! !header=core.h! \endxmlonly
class CL_API_CORE CL_ZipArchive
{
/// \name Construction
/// \{
public:
/// \brief Constructs or loads a ZIP archive.
///
/// \param filename .zip archive to load.
CL_ZipArchive();
/// \brief Constructs a ZipArchive
///
/// \param input = IODevice
CL_ZipArchive(CL_IODevice &input);
/// \brief Constructs a ZipArchive
///
/// \param filename = String Ref
CL_ZipArchive(const CL_StringRef &filename);
/// \brief Constructs a ZipArchive
///
/// \param copy = Zip Archive
CL_ZipArchive(const CL_ZipArchive ©);
~CL_ZipArchive();
/// \}
/// \name Attributes
/// \{
public:
/// \brief List of file entries in archive.
std::vector<CL_ZipFileEntry> get_file_list();
std::vector<CL_ZipFileEntry> get_file_list(const CL_StringRef &path);
/// \}
/// \name Operations
/// \{
public:
/// \brief Opens a file in the archive.
CL_IODevice open_file(const CL_StringRef &filename);
/// \brief Get full path to source:
CL_String get_pathname(const CL_StringRef &filename);
/// \brief Creates a new file entry
CL_IODevice create_file(const CL_StringRef &filename, bool compress = true);
/// \brief Adds a file to zip archive.
/** <p>File is not added to zip file until it save() is called.</p>
\param filename Filename of file.*/
void add_file(const CL_StringRef &input_filename, const CL_StringRef &filename_in_archive);
/// \brief Saves zip archive.
///
/// \param filename Filename of zip archive. Must not be used to save to the same as loaded from.
/// <p>If no filename parameter was passed, it will modify the zip
/// archive loaded at construction time. It does this by creating a
/// temporary file, saving the new archive, deletes the old one and
/// renames the temp file to the original archive filename.</p>
/// -
/// <p>If the archive was created instead of loaded, a filename must
/// be specify a filename. Likewise, if saving to same archive as
/// loaded from, a filename must not be specified. Doing so will
/// cause the save operation to fail.</p>
void save();
/// \brief Save
///
/// \param filename = the filename to save to
void save(const CL_StringRef &filename);
/// \brief Save
///
/// \param iodev = The file to save to
void save(CL_IODevice iodev);
/// \brief Loads the zip archive from a input device (done automatically at construction).
void load(CL_IODevice &input);
/// \}
/// \name Implementation
/// \{
private:
CL_SharedPtr<CL_ZipArchive_Impl> impl;
/// \}
};
/// \}
| [
"[email protected]@28a56cb3-1e7c-bc60-7718-65c159e1d2df"
]
| [
[
[
1,
139
]
]
]
|
23fa956108c871df9eb6475b1d401671047a9b65 | 80f5de5b636381f2e03989d9cd5b8a9c3d463f18 | /csps/lpc32xx/tools/LPC3250NORFlashLoader(GUI_Sources)/CLACOMST.INC | c315f7a20ece4c27973b536f663cef606d7e469b | []
| no_license | sobczyk/bsp | cfb4680dad75af6687984c0bc2920dd22b8952e3 | 9b65758939f66eac0c0630c162b06fa69cb7aaa8 | refs/heads/master | 2021-01-01T18:16:54.573909 | 2011-01-06T19:09:45 | 2011-01-06T19:09:45 | 1,225,158 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 7,240 | inc | ! COM Port Equates
COM1 EQUATE(0)
COM2 EQUATE(1)
COM3 EQUATE(2)
COM4 EQUATE(3)
COM5 EQUATE(4)
COM6 EQUATE(5)
COM7 EQUATE(6)
COM8 EQUATE(7)
NOPARITY EQUATE(0)
ODDPARITY EQUATE(1)
EVENPARITY EQUATE(2)
ONESTOPBIT EQUATE(1)
TWOSTOPBIT EQUATE(2)
USECTS EQUATE(1)
NOCTS EQUATE(0)
USEXON EQUATE(1)
NOXON EQUATE(0)
USEDSR EQUATE(1)
NODSR EQUATE(0)
DTRON EQUATE(1)
DTROFF EQUATE(0)
RTSON EQUATE(1)
RTSOFF EQUATE(0)
BLACK EQUATE(0)
BLUE EQUATE(1)
GREEN EQUATE(2)
CYAN EQUATE(3)
RED EQUATE(4)
MAGENTA EQUATE(5)
BROWN EQUATE(6)
LTGREY EQUATE(7)
DKGRAY EQUATE(8)
LTBLUE EQUATE(9)
LTGREEN EQUATE(10)
LTCYAN EQUATE(11)
LTRED EQUATE(12)
LTMAGENTA EQUATE(13)
YELLOW EQUATE(14)
WHITE EQUATE(15)
NULLWIN EQUATE(0)
ASCITRANS EQUATE(0)
XMODEM EQUATE(1)
XMODEM1K EQUATE(2)
XMODEM1KG EQUATE(3)
YMODEM EQUATE(4)
YMODEMG EQUATE(5)
ZMODEM EQUATE(6)
! Supported Terminal Types
ANSI EQUATE(0)
TTY EQUATE(1)
VT100 EQUATE(2)
IBM3161 EQUATE(3)
NUMTERMTYP EQUATE(4)
TTGROUP GROUP,PRE(TTGRP)
STRING('IBM ANSI')
STRING('TTY ')
STRING('VT100 ')
STRING('IBM3161 ')
End
TermTypeString STRING(8),DIM(4),OVER(TTGROUP)
! structure for returning Port Parameters
COMPARAM GROUP,TYPE,PRE(ComParam)
baud LONG ! current baudrate
baudindex USHORT ! index # in baudrate table
databits USHORT ! current data bits
stop USHORT ! current stop bits
parity USHORT ! current parity
End
! Queue Prototype for WaitForQueString
WaitQueStr QUEUE,TYPE
WaitStr CSTRING(100) ! A String to Wait For
End
AnswerThrd LONG(0) ! Thread # for Phone Monitor
AThrdParentWin &WINDOW ! Pointer to Parent Window Struct
AnswerThrdGrp GROUP,Pre(ATHRD)
ParentHandle UNSIGNED ! Parent Window Handle
ParentThread LONG ! Parent Thread (Normally 1)
PortNum SHORT ! Com Port to use (0 Based)
NumRings SHORT ! # of Rings to Wait For
ConnectWait SHORT ! Seconds to Wait for Carrier after Answering
ModemBaud LONG ! Caller Connect Rate
LockBaud SHORT ! True to Lock the Baud Rate
StartMinimized SHORT ! True to start Minimized
ModemStr CSTRING(256) ! Modem Connect String
End
EVENT:StopMonitoring EQUATE(507h) ! Sent to Answer routine to stop monitoring
EVENT:Connected EQUATE(508h) ! Sent by Answer routine to tell us we are Connected
EVENT:PhoneMonClosed EQUATE(509h) ! Sent by Answer routine if it was closed
EVENT:GenConfig EQUATE(600h) ! Tell App Window to start Gen Config Form
EVENT:PortConfig EQUATE(601h) ! Tell App Window to start Port Config Form
EVENT:StartSplash EQUATE(602h) ! Tell App Window to start Splash Screen
EVENT:WM_CHAR EQUATE(610h) ! Received a keyboard character for Terminal
EVENT:GOT_CAR EQUATE(611h) ! Sent if Carrier Detect Changed (have carrier)
EVENT:NO_CAR EQUATE(612h) ! Sent if Carrier Detect Changed (don't have carrier)
EVENT:DOORWAY_ON EQUATE(613h) ! Sent if going into Doorway Mode
EVENT:DOORWAY_OFF EQUATE(614h) ! Sent if going out of DoorWay Mode
EVENT:AUTO_ZMODEM EQUATE(615h) ! Sent if Auto Zmodem detected
EVENT:WM_COMM_CHAR EQUATE(616h) ! Tell Terminal we received a character
EVENT:FileUpdated EQUATE(617h) !
TermFrameWin UNSIGNED(0) ! User Defined Terminal Emulator
TermClientWin UNSIGNED(0) ! Window Handles
OldTermProc LONG(0) ! Address of original Terminal Proc
OldTermClientProc LONG(0) ! Address of original Terminal Client Proc
OldHookHandle LONG(0) ! Handle of our Message Loop Filter
DoorWayMode SHORT(0) ! True if in DoorWay Mode
CapturingTerm SHORT(0) ! True if Capturing Terminal Session
EchoChars SHORT(0) ! True if Echoing Characters
CLATermPort SHORT(0) ! Port # being used by built in Terminal Emulator
! Dialog Codes
WM_ERASEBKGND EQUATE(0014h) ! Sent when Background needs to be Repainted
WM_GETDLGCODE EQUATE(0087h) ! Find out what Dialog wants to do
WM_CHAR EQUATE(0102h) ! Keyboard Input message (blocked by Clarion)
WM_COMMNOTIFY EQUATE(0044h) ! Received character Event
DLGC_WANTARROWS EQUATE(0001h) ! Control wants arrow keys
DLGC_WANTTAB EQUATE(0002h) ! Control wants tab keys
DLGC_WANTALLKEYS EQUATE(0004h) ! Control wants all keys
DLGC_WANTMESSAGE EQUATE(0004h) ! Pass message to control
DLGC_HASSETSEL EQUATE(0008h) ! Understands EM_SETSEL message
DLGC_DEFPUSHBUTTON EQUATE(0010h) ! Default pushbutton
DLGC_UNDEFPUSHBUT EQUATE(0020h) ! Non-default pushbutton
DLGC_RADIOBUTTON EQUATE(0040h) ! Radio button
DLGC_WANTCHARS EQUATE(0080h) ! Want WM_CHAR messages
DLGC_STATIC EQUATE(0100h) ! Static item: don't include
DLGC_BUTTON EQUATE(2000h) ! Button item: can be checked
! Thread specific Variables and Equates
! Win 32 Equates
INFINITE EQUATE(-1)
INVALID_HANDLE_VALUE EQUATE(-1)
! Win 32 Data Types
BOOL EQUATE(SIGNED)
DWORD EQUATE(ULONG)
HANDLE EQUATE(UNSIGNED)
LPTSTR EQUATE(CSTRING)
! Thread Priorities
THREAD_PRIORITY_IDLE EQUATE(-15)
THREAD_PRIORITY_LOWEST EQUATE(-2)
THREAD_PRIORITY_BELOW_NORMAL EQUATE(-1)
THREAD_PRIORITY_NORMAL EQUATE(0)
THREAD_PRIORITY_ABOVE_NORMAL EQUATE(1)
THREAD_PRIORITY_HIGHEST EQUATE(2)
THREAD_PRIORITY_TIME_CRITICAL EQUATE(15)
! Directory Changes we can monitor
FILE_NOTIFY_CHANGE_FILE_NAME EQUATE(1)
FILE_NOTIFY_CHANGE_DIR_NAME EQUATE(2)
FILE_NOTIFY_CHANGE_ATTRIBUTES EQUATE(4)
FILE_NOTIFY_CHANGE_SIZE EQUATE(8)
FILE_NOTIFY_CHANGE_LAST_WRITE EQUATE(010h)
! Variables for a Single Thread
thdAppClosing SIGNED(0) ! Set to 1 to tell Thread to Exit
thdThreadHandle UNSIGNED(0) ! Thread Handle from Create Thread
thdThreadID ULONG(0) ! Unique Thread ID
thdEventHandle UNSIGNED(0) ! Handle of Event to Monitor
| [
"[email protected]"
]
| [
[
[
1,
193
]
]
]
|
8c087bbe6d2a876e52337d83d9f1907eaa4fba6e | eec9d789e04bc81999ac748ca2c70f0a612dadb7 | /testProject/testProject/TreeList/NewTreeListCtrl.cpp | f69b32ac51a03f1071fd53db1432fb708ffa9f63 | []
| no_license | scriptkitz/myfirstpro-test | 45d79d9a35fe5ee1e8f237719398d08d7d86b859 | a3400413e3a7900657774a278006faea7d682955 | refs/heads/master | 2021-01-22T07:13:27.100583 | 2010-11-16T15:02:50 | 2010-11-16T15:02:50 | 38,792,869 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 33,926 | cpp | // NewTreeListCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "TLView.h"
#include "NewTreeListCtrl.h"
#include "TLFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define ID_TREE_LIST_HEADER 370
/////////////////////////////////////////////////////////////////////////////
// CTLItem
CTLItem::CTLItem()
{
m_cEnding = '¶';
m_itemString = "";
m_Bold = FALSE;
m_Color = ::GetSysColor(COLOR_WINDOWTEXT);
m_HasChildren = FALSE;
m_nPriority = 1000;
m_Group = FALSE;
}
CTLItem::CTLItem(CTLItem ©Item)
{
m_cEnding = copyItem.m_cEnding;
m_itemString = copyItem.GetItemString();
m_Bold = copyItem.m_Bold;
m_Color = copyItem.m_Color;
itemData = copyItem.itemData;
m_HasChildren = copyItem.m_HasChildren;
m_nPriority = copyItem.m_nPriority;
m_Group = copyItem.m_Group;
}
CString CTLItem::GetSubstring(int m_nSub)
{
CString m_tmpStr("");
int i=0, nHits=0;
int length = m_itemString.GetLength();
while((i<length) && (nHits<=m_nSub))
{
if(m_itemString[i]==m_cEnding)
{
nHits++;
}
else
if(nHits==m_nSub)
m_tmpStr+=m_itemString[i];
i++;
}
if((i>=length) && (nHits<m_nSub))
return "";
else
return m_tmpStr;
}
void CTLItem::SetSubstring(int m_nSub, CString m_sText)
{
CString m_tmpStr("");
int i=0, nHits=0, first=0;
int length = m_itemString.GetLength();
while((i<length) && (nHits<=m_nSub))
{
if(m_itemString[i]==m_cEnding)
{
if(nHits!=m_nSub)
first = i;
nHits++;
}
i++;
}
CString m_newStr("");
if((nHits>m_nSub) || ((nHits==m_nSub) && (i>=length)))
{
// insert in the middle
if(first!=0)
{
m_newStr = m_itemString.Left(first);
m_newStr += m_cEnding;
}
m_newStr += m_sText;
if(i<length)
{
m_newStr += m_cEnding;
m_newStr += m_itemString.Right(m_itemString.GetLength()-i);
}
m_itemString=m_newStr;
}
else
{
// insert at the end
for(i=nHits;i<m_nSub;i++)
m_itemString+=m_cEnding;
m_itemString+=m_sText;
}
}
/////////////////////////////////////////////////////////////////////////////
// CNewTreeListCtrl
CNewTreeListCtrl::CNewTreeListCtrl()
{
m_nColumns = m_nColumnsWidth = 0;
m_nOffset = 0;
m_ParentsOnTop = TRUE;
m_bLDragging = FALSE;
m_htiOldDrop = m_htiDrop = m_htiDrag = NULL;
m_scrollTimer = m_idTimer = 0;
m_timerticks = 0;
m_toDrag = FALSE;
m_RTL = FALSE;
}
CNewTreeListCtrl::~CNewTreeListCtrl()
{
}
BEGIN_MESSAGE_MAP(CNewTreeListCtrl, CTreeCtrl)
//{{AFX_MSG_MAP(CNewTreeListCtrl)
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONDBLCLK()
ON_WM_KEYDOWN()
ON_WM_TIMER()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewTreeListCtrl message handlers
int CNewTreeListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTreeCtrl::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
HTREEITEM CNewTreeListCtrl::GetTreeItem(int nItem)
{
HTREEITEM m_ParentItem = GetRootItem();
int m_nCount = 0;
while((m_ParentItem!=NULL) && (m_nCount<nItem))
{
m_nCount ++ ;
GetNextSiblingItem(m_ParentItem);
}
return m_ParentItem;
}
int CNewTreeListCtrl::GetListItem(HTREEITEM hItem)
{
HTREEITEM m_ParentItem = GetRootItem();
int m_nCount = 0;
while((m_ParentItem!=NULL) && (m_ParentItem!=hItem))
{
m_nCount ++ ;
GetNextSiblingItem(m_ParentItem);
}
return m_nCount;
}
void CNewTreeListCtrl::RecalcHeaderPosition()
{
if(m_RTL)
{
CRect m_clientRect;
GetClientRect(&m_clientRect);
if(GetColumnsWidth() > m_clientRect.Width())
{
int m_nOffset = m_clientRect.Width() - GetColumnsWidth();
CTLFrame *pFrame = (CTLFrame *)GetParent();
CRect m_wndRect;
pFrame->GetClientRect(&m_wndRect);
CRect m_headerRect;
m_wndHeader.GetClientRect(&m_headerRect);
m_wndHeader.SetWindowPos(&wndTop, m_nOffset, 0, max(pFrame->StretchWidth(GetColumnsWidth(),m_clientRect.Width()),m_wndRect.Width()), m_headerRect.Height(), SWP_SHOWWINDOW);
}
}
}
int CNewTreeListCtrl::InsertColumn( int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
{
HD_ITEM hdi;
hdi.mask = HDI_TEXT | HDI_FORMAT;
if(nWidth!=-1)
{
hdi.mask |= HDI_WIDTH;
hdi.cxy = nWidth;
}
hdi.pszText = (LPTSTR)lpszColumnHeading;
hdi.fmt = HDF_OWNERDRAW;
if(nFormat == LVCFMT_RIGHT)
hdi.fmt |= HDF_RIGHT;
else
if(nFormat == LVCFMT_CENTER)
hdi.fmt |= HDF_CENTER;
else
hdi.fmt |= HDF_LEFT;
m_nColumns ++ ;
int m_nReturn = m_wndHeader.InsertItem(nCol, &hdi);
if(m_nColumns==1)
{
m_wndHeader.SetItemImage(m_nReturn, 0);
}
RecalcColumnsWidth();
if(m_RTL)
RecalcHeaderPosition();
UpdateWindow();
return m_nReturn;
}
int CNewTreeListCtrl::GetColumnWidth(int nCol)
{
if(m_RTL)
{
nCol = GetColumnsNum() - nCol - 1;
}
HD_ITEM hItem;
hItem.mask = HDI_WIDTH;
if(!m_wndHeader.GetItem(nCol, &hItem))
return 0;
return hItem.cxy;
}
int CNewTreeListCtrl::GetColumnAlign(int nCol)
{
HD_ITEM hItem;
hItem.mask = HDI_FORMAT;
if(!m_wndHeader.GetItem(nCol, &hItem))
return LVCFMT_LEFT;
if(hItem.fmt & HDF_RIGHT)
return LVCFMT_RIGHT;
else
if(hItem.fmt & HDF_CENTER)
return LVCFMT_CENTER;
else
return LVCFMT_LEFT;
}
void CNewTreeListCtrl::RecalcColumnsWidth()
{
m_nColumnsWidth = 0;
for(int i=0;i<m_nColumns;i++)
m_nColumnsWidth += GetColumnWidth(i);
}
void CNewTreeListCtrl::DrawItemText (CDC* pDC, CString text, CRect rect, int nWidth, int nFormat)
{
//
// Make sure the text will fit in the prescribed rectangle, and truncate
// it if it won't.
//
BOOL bNeedDots = FALSE;
int nMaxWidth = nWidth - 4;
while ((text.GetLength()>0) && (pDC->GetTextExtent((LPCTSTR) text).cx > (nMaxWidth - 4))) {
text = text.Left (text.GetLength () - 1);
bNeedDots = TRUE;
}
if (bNeedDots) {
if (text.GetLength () >= 1)
text = text.Left (text.GetLength () - 1);
if(!m_RTL)
text += "...";
else
text = "..." + text;
}
//
// Draw the text into the rectangle using MFC's handy CDC::DrawText
// function.
//
rect.right = rect.left + nMaxWidth;
if(m_RTL)
{
rect.right += 4;
rect.left += 4;
}
UINT nStyle = DT_VCENTER | DT_SINGLELINE;
if (nFormat == LVCFMT_LEFT)
nStyle |= DT_LEFT;
else if (nFormat == LVCFMT_CENTER)
nStyle |= DT_CENTER;
else // nFormat == LVCFMT_RIGHT
nStyle |= DT_RIGHT;
if((text.GetLength()>0) && (rect.right>rect.left))
pDC->DrawText (text, rect, nStyle);
}
CRect CNewTreeListCtrl::CRectGet(int left, int top, int right, int bottom)
{
if(m_RTL)
{
CRect m_clientRect;
GetClientRect(&m_clientRect);
return CRect(m_clientRect.Width() - right, top, m_clientRect.Width() - left, bottom);
}
else
return CRect(left, top, right, bottom);
}
void CNewTreeListCtrl::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rcClient;
GetClientRect(&rcClient);
//CMemDC dc(&paintdc, rcClient);
CRect rcClip;
dc.GetClipBox( &rcClip );
// Set clip region to be same as that in paint DC
CRgn rgn;
rgn.CreateRectRgnIndirect( &rcClip );
dc.SelectClipRgn(&rgn);
rgn.DeleteObject();
COLORREF m_wndColor = GetSysColor( COLOR_WINDOW );
dc.SetViewportOrg(m_nOffset, 0);
dc.SetTextColor(m_wndColor);
// First let the control do its default drawing.
CRect m_clientRect;
GetClientRect(&m_clientRect);
if(m_RTL)
{
dc.SetViewportOrg(m_clientRect.Width(), 0);
CSize ext = dc.GetViewportExt();
ext.cx = ext.cx > 0 ? -ext.cx : ext.cx;
dc.SetMapMode(MM_ANISOTROPIC);
dc.SetViewportExt(ext);
}
CTreeCtrl::DefWindowProc( WM_PAINT, (WPARAM)dc.m_hDC, 0 );
if(m_RTL)
{
dc.SetViewportOrg(0, 0);
dc.SetMapMode(MM_TEXT);
}
HTREEITEM hItem = GetFirstVisibleItem();
int n = GetVisibleCount(), m_nWidth;
CTLItem *pItem;
// create the font
CFont *pFontDC;
CFont fontDC, boldFontDC;
LOGFONT logfont;
CFont *pFont = GetFont();
pFont->GetLogFont( &logfont );
fontDC.CreateFontIndirect( &logfont );
pFontDC = dc.SelectObject( &fontDC );
logfont.lfWeight = 700;
boldFontDC.CreateFontIndirect( &logfont );
// and now let's get to the painting itself
hItem = GetFirstVisibleItem();
n = GetVisibleCount();
while(hItem!=NULL && n>=0)
{
CRect rect;
UINT selflag = /*TVIS_DROPHILITED |*/ TVIS_SELECTED;
pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
HTREEITEM hParent = GetParentItem(hItem);
if(hParent != NULL)
{
CTLItem *pParent = (CTLItem *)CTreeCtrl::GetItemData(hParent);
if(pParent->m_Group)
pItem->m_Group = TRUE;
}
if ( !(GetItemState( hItem, selflag ) & selflag ))
{
dc.SetBkMode(TRANSPARENT);
CString sItem = pItem->GetItemText();
CRect m_labelRect;
GetItemRect( hItem, &m_labelRect, TRUE );
GetItemRect( hItem, &rect, FALSE );
if(GetColumnsNum()>1)
rect.left = min(m_labelRect.left, GetColumnWidth(0));
else
rect.left = m_labelRect.left;
rect.right = m_nColumnsWidth;
if(pItem->m_Group)
{
if(hParent != NULL)
GetItemRect( hParent, &m_labelRect, TRUE );
rect.left = m_labelRect.left;
CBrush bkBrush(m_wndColor);
dc.FillRect(rect, &bkBrush);
}
dc.SetBkColor( m_wndColor );
dc.SetTextColor( pItem->m_Color );
if(pItem->m_Bold)
{
dc.SelectObject( &boldFontDC );
}
if(!pItem->m_Group)
DrawItemText(&dc, sItem, CRectGet(rect.left+2, rect.top, GetColumnWidth(0), rect.bottom), GetColumnWidth(0)-rect.left-2, GetColumnAlign(0));
else
{
DrawItemText(&dc, sItem, CRectGet(rect.left+2, rect.top, GetColumnWidth(0), rect.bottom), GetColumnWidth(0)-rect.left-2, LVCFMT_RIGHT);
}
m_nWidth = 0;
for(int i=1;i<m_nColumns;i++)
{
m_nWidth += GetColumnWidth(i-1);
DrawItemText(&dc, pItem->GetSubstring(i), CRectGet(m_nWidth, rect.top, m_nWidth+GetColumnWidth(i), rect.bottom), GetColumnWidth(i), GetColumnAlign(i));
}
dc.SetTextColor(::GetSysColor (COLOR_WINDOWTEXT ));
if(pItem->m_Bold)
{
dc.SelectObject( &fontDC );
}
}
else
{
CRect m_labelRect;
GetItemRect( hItem, &m_labelRect, TRUE );
GetItemRect( hItem, &rect, FALSE );
if(GetColumnsNum()>1)
rect.left = min(m_labelRect.left, GetColumnWidth(0));
else
rect.left = m_labelRect.left;
rect.right = m_nColumnsWidth;
if(pItem->m_Group)
{
if(hParent != NULL)
GetItemRect( hParent, &m_labelRect, TRUE );
rect.left = m_labelRect.left;
}
// If the item is selected, paint the rectangle with the system color
// COLOR_HIGHLIGHT
COLORREF m_highlightColor = ::GetSysColor (COLOR_HIGHLIGHT);
CBrush brush(m_highlightColor);
if(!m_RTL)
{
dc.FillRect (rect, &brush);
// draw a dotted focus rectangle
dc.DrawFocusRect (rect);
}
else
{
CRect m_Rrect = rect;
m_Rrect.right = m_clientRect.Width() - rect.left;
m_Rrect.left = m_clientRect.Width() - rect.right;
dc.FillRect (m_Rrect, &brush);
// draw a dotted focus rectangle
dc.DrawFocusRect (m_Rrect);
}
pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
CString sItem = pItem->GetItemText();
dc.SetBkColor(m_highlightColor);
dc.SetTextColor(::GetSysColor (COLOR_HIGHLIGHTTEXT));
if(pItem->m_Bold)
{
dc.SelectObject( &boldFontDC );
}
if(!pItem->m_Group)
DrawItemText(&dc, sItem, CRectGet(rect.left+2, rect.top, GetColumnWidth(0), rect.bottom), GetColumnWidth(0)-rect.left-2, GetColumnAlign(0));
else
DrawItemText(&dc, sItem, CRectGet(rect.left+2, rect.top, GetColumnWidth(0), rect.bottom), GetColumnWidth(0)-rect.left-2, LVCFMT_RIGHT);
m_nWidth = 0;
for(int i=1;i<m_nColumns;i++)
{
m_nWidth += GetColumnWidth(i-1);
DrawItemText(&dc, pItem->GetSubstring(i), CRectGet(m_nWidth, rect.top, m_nWidth+GetColumnWidth(i), rect.bottom), GetColumnWidth(i), GetColumnAlign(i));
}
if(pItem->m_Bold)
{
dc.SelectObject( &fontDC );
}
}
hItem = GetNextVisibleItem( hItem );
n--;
}
dc.SelectObject( pFontDC );
}
void CNewTreeListCtrl::ResetVertScrollBar()
{
CTLFrame *pFrame = (CTLFrame*)GetParent();
CRect m_treeRect;
GetClientRect(&m_treeRect);
CRect m_wndRect;
pFrame->GetClientRect(&m_wndRect);
CRect m_headerRect;
m_wndHeader.GetClientRect(&m_headerRect);
CRect m_barRect;
pFrame->m_horScrollBar.GetClientRect(&m_barRect);
if(!pFrame->HorizontalScrollVisible())
SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_wndRect.Height()-m_headerRect.Height(), SWP_NOMOVE);
else
SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_wndRect.Height()-m_barRect.Height()-m_headerRect.Height(), SWP_NOMOVE);
if(pFrame->HorizontalScrollVisible())
{
if(!pFrame->VerticalScrollVisible())
{
pFrame->m_horScrollBar.SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_barRect.Height(), SWP_NOMOVE);
int nMin, nMax;
pFrame->m_horScrollBar.GetScrollRange(&nMin, &nMax);
if((nMax-nMin) == (GetColumnsWidth()-m_treeRect.Width()+GetSystemMetrics(SM_CXVSCROLL)))
// i.e. it disappeared because of calling
// SetWindowPos
{
if(nMax - GetSystemMetrics(SM_CXVSCROLL) > 0)
pFrame->m_horScrollBar.SetScrollRange(nMin, nMax - GetSystemMetrics(SM_CXVSCROLL));
else
// hide the horz scroll bar and update the tree
{
pFrame->m_horScrollBar.EnableWindow(FALSE);
// we no longer need it, so hide it!
{
pFrame->m_horScrollBar.ShowWindow(SW_HIDE);
SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_wndRect.Height() - m_headerRect.Height(), SWP_NOMOVE);
// the tree takes scroll's place
}
pFrame->m_horScrollBar.SetScrollRange(0, 0);
// set scroll offset to zero
{
m_nOffset = 0;
Invalidate();
m_wndHeader.GetWindowRect(&m_headerRect);
m_wndHeader.SetWindowPos(&wndTop, m_nOffset, 0, max(pFrame->StretchWidth(GetColumnsWidth(),m_wndRect.Width()),m_wndRect.Width()), m_headerRect.Height(), SWP_SHOWWINDOW);
}
}
}
}
else
{
pFrame->m_horScrollBar.SetWindowPos(&wndTop, 0, 0, m_wndRect.Width() - GetSystemMetrics(SM_CXVSCROLL), m_barRect.Height(), SWP_NOMOVE);
int nMin, nMax;
pFrame->m_horScrollBar.GetScrollRange(&nMin, &nMax);
if((nMax-nMin) == (GetColumnsWidth()-m_treeRect.Width()-GetSystemMetrics(SM_CXVSCROLL)))
// i.e. it appeared because of calling
// SetWindowPos
{
pFrame->m_horScrollBar.SetScrollRange(nMin, nMax + GetSystemMetrics(SM_CXVSCROLL));
}
}
}
else
if(pFrame->VerticalScrollVisible())
{
if(GetColumnsWidth()>m_treeRect.Width())
// the vertical scroll bar takes some place
// and the columns are a bit bigger than the client
// area but smaller than (client area + vertical scroll width)
{
// show the horz scroll bar
{
pFrame->m_horScrollBar.EnableWindow(TRUE);
pFrame->m_horScrollBar.ShowWindow(SW_SHOW);
// the tree becomes smaller
SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_wndRect.Height()-m_barRect.Height()-m_headerRect.Height(), SWP_NOMOVE);
pFrame->m_horScrollBar.SetWindowPos(&wndTop, 0, 0, m_wndRect.Width() - GetSystemMetrics(SM_CXVSCROLL), m_barRect.Height(), SWP_NOMOVE);
}
pFrame->m_horScrollBar.SetScrollRange(0, GetColumnsWidth()-m_treeRect.Width());
}
}
}
void CNewTreeListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
UINT flags;
HTREEITEM m_selectedItem = HitTest(point, &flags);
if((flags & TVHT_ONITEMRIGHT) || (flags & TVHT_ONITEMINDENT) ||
(flags & TVHT_ONITEM))
{
SelectItem(m_selectedItem);
}
if(!m_RTL)
{
if((GetColumnsNum()==0) || (point.x<GetColumnWidth(0)))
{
point.x -= m_nOffset;
m_selectedItem = HitTest(point, &flags);
if(flags & TVHT_ONITEMBUTTON)
{
Expand(m_selectedItem, TVE_TOGGLE);
}
}
}
else
{
CRect m_clientRect;
GetClientRect(&m_clientRect);
if((GetColumnsNum()==0) || (point.x>(m_clientRect.Width() - GetColumnWidth(0))))
{
point.x = m_clientRect.Width() - point.x;
point.x -= m_nOffset;
m_selectedItem = HitTest(point, &flags);
if(flags & TVHT_ONITEMBUTTON)
{
Expand(m_selectedItem, TVE_TOGGLE);
}
}
}
SetFocus();
ResetVertScrollBar();
m_toDrag = FALSE;
m_idTimer = SetTimer( 1000, 70, NULL );
// CTreeCtrl::OnLButtonDown(nFlags, point);
}
void CNewTreeListCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
if((GetColumnsNum()==0) || (point.x<GetColumnWidth(0)))
{
CTreeCtrl::OnLButtonDblClk(nFlags, point);
ResetVertScrollBar();
}
SetFocus();
GetParent()->SendMessage(WM_LBUTTONDBLCLK);
}
void CNewTreeListCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CTreeCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
ResetVertScrollBar();
}
BOOL CNewTreeListCtrl::SetItemData(HTREEITEM hItem, DWORD dwData)
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
pItem->itemData = dwData;
return CTreeCtrl::SetItemData(hItem, (LPARAM)pItem);
}
DWORD CNewTreeListCtrl::GetItemData(HTREEITEM hItem) const
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return NULL;
return pItem->itemData;
}
HTREEITEM CNewTreeListCtrl::InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
{
CTLItem *pItem = new CTLItem;
pItem->InsertItem(lpszItem);
m_nItems++;
if((hParent!=NULL) && (hParent!=TVI_ROOT))
{
CTLItem *pParent = (CTLItem *)CTreeCtrl::GetItemData(hParent);
pParent->m_HasChildren = TRUE;
}
HTREEITEM hReturn = CTreeCtrl::InsertItem(TVIF_PARAM|TVIF_TEXT, "", 0, 0, 0, 0, (LPARAM)pItem, hParent, hInsertAfter);
((CTLFrame*)GetParent())->ResetScrollBar();
if(m_RTL)
RecalcHeaderPosition();
return hReturn;
}
HTREEITEM CNewTreeListCtrl::InsertItem( LPCTSTR lpszItem, int nImage, int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter)
{
CTLItem *pItem = new CTLItem;
pItem->InsertItem(lpszItem);
m_nItems++;
if((hParent!=NULL) && (hParent!=TVI_ROOT))
{
CTLItem *pParent = (CTLItem *)CTreeCtrl::GetItemData(hParent);
pParent->m_HasChildren = TRUE;
}
HTREEITEM hReturn = CTreeCtrl::InsertItem(TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE, "", nImage, nSelectedImage, 0, 0, (LPARAM)pItem, hParent, hInsertAfter);
((CTLFrame*)GetParent())->ResetScrollBar();
if(m_RTL)
RecalcHeaderPosition();
return hReturn;
}
HTREEITEM CNewTreeListCtrl::InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter )
{
CTLItem *pItem = new CTLItem;
pItem->InsertItem(lpszItem);
pItem->itemData = lParam;
m_nItems++;
if((hParent!=NULL) && (hParent!=TVI_ROOT))
{
CTLItem *pParent = (CTLItem *)CTreeCtrl::GetItemData(hParent);
pParent->m_HasChildren = TRUE;
}
HTREEITEM hReturn = CTreeCtrl::InsertItem(nMask, "", nImage, nSelectedImage, nState, nStateMask, (LPARAM)pItem, hParent, hInsertAfter);
((CTLFrame*)GetParent())->ResetScrollBar();
if(m_RTL)
RecalcHeaderPosition();
return hReturn;
}
HTREEITEM CNewTreeListCtrl::CopyItem(HTREEITEM hItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
{
if(ItemHasChildren(hItem))
return NULL;
TV_ITEM item;
item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_STATE | TVIF_TEXT;
item.hItem = hItem;
GetItem(&item);
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
CTLItem *pNewItem = new CTLItem(*pItem);
item.lParam = (LPARAM)pNewItem;
TV_INSERTSTRUCT insStruct;
insStruct.item = item;
insStruct.hParent = hParent;
insStruct.hInsertAfter = hInsertAfter;
if((hParent!=NULL) && (hParent!=TVI_ROOT))
{
CTLItem *pParent = (CTLItem *)CTreeCtrl::GetItemData(hParent);
pParent->m_HasChildren = TRUE;
}
return CTreeCtrl::InsertItem(&insStruct);
}
HTREEITEM CNewTreeListCtrl::MoveItem(HTREEITEM hItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
{
if(ItemHasChildren(hItem))
return NULL;
TV_ITEM item;
item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
item.hItem = hItem;
GetItem(&item);
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
CTLItem *pNewItem = new CTLItem(*pItem);
item.pszText = "";
item.lParam = (LPARAM)pNewItem;
item.hItem = NULL;
item.mask |= TVIF_TEXT | TVIF_PARAM;
TV_INSERTSTRUCT insStruct;
insStruct.item = item;
insStruct.hParent = hParent;
insStruct.hInsertAfter = hInsertAfter;
if((hParent!=NULL) && (hParent!=TVI_ROOT))
{
CTLItem *pParent = (CTLItem *)CTreeCtrl::GetItemData(hParent);
pParent->m_HasChildren = TRUE;
}
DeleteItem(hItem);
return CTreeCtrl::InsertItem(&insStruct);
}
BOOL CNewTreeListCtrl::SetItemText( HTREEITEM hItem, int nCol ,LPCTSTR lpszItem )
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
pItem->SetSubstring(nCol, lpszItem);
return CTreeCtrl::SetItemData(hItem, (LPARAM)pItem);
}
BOOL CNewTreeListCtrl::SetItemColor( HTREEITEM hItem, COLORREF m_newColor, BOOL m_bInvalidate )
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
pItem->m_Color = m_newColor;
if(!CTreeCtrl::SetItemData(hItem, (LPARAM)pItem))
return FALSE;
if(m_bInvalidate)
Invalidate();
return TRUE;
}
BOOL CNewTreeListCtrl::SetItemPriority( HTREEITEM hItem, int m_nPriority)
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
pItem->m_nPriority = m_nPriority;
if(!CTreeCtrl::SetItemData(hItem, (LPARAM)pItem))
return FALSE;
return TRUE;
}
int CNewTreeListCtrl::GetItemPriority( HTREEITEM hItem )
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return -1;
return pItem->m_nPriority;
}
BOOL CNewTreeListCtrl::SetItemGroup( HTREEITEM hItem, BOOL m_Group, BOOL m_bInvalidate )
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
pItem->m_Group = m_Group;
Expand(hItem, TVE_EXPAND);
if(m_bInvalidate)
Invalidate();
return TRUE;
}
BOOL CNewTreeListCtrl::SetItemBold( HTREEITEM hItem, BOOL m_Bold, BOOL m_bInvalidate )
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
pItem->m_Bold = m_Bold;
if(!CTreeCtrl::SetItemData(hItem, (LPARAM)pItem))
return FALSE;
if(m_bInvalidate)
Invalidate();
return TRUE;
}
BOOL CNewTreeListCtrl::IsBold( HTREEITEM hItem )
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
return pItem->m_Bold;
}
BOOL CNewTreeListCtrl::IsGroup( HTREEITEM hItem )
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
return pItem->m_Group;
}
CString CNewTreeListCtrl::GetItemText( HTREEITEM hItem, int nSubItem )
{
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return "";
return pItem->GetSubstring(nSubItem);
}
CString CNewTreeListCtrl::GetItemText( int nItem, int nSubItem )
{
return GetItemText(GetTreeItem(nItem), nSubItem);
}
BOOL CNewTreeListCtrl::DeleteItem( HTREEITEM hItem )
{
HTREEITEM hOldParent = GetParentItem(hItem);
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
delete pItem;
int m_bReturn = CTreeCtrl::DeleteItem(hItem);
if(m_bReturn)
{
if((hOldParent!=TVI_ROOT) && (hOldParent!=NULL))
{
CTLItem *pOldParent = (CTLItem *)CTreeCtrl::GetItemData(hOldParent);
pOldParent->m_HasChildren = ItemHasChildren(hOldParent);
}
}
return m_bReturn;
}
BOOL CNewTreeListCtrl::DeleteItem( int nItem )
{
return DeleteItem(GetTreeItem(nItem));
}
HTREEITEM CNewTreeListCtrl::FindParentItem(CString m_title, int nCol, HTREEITEM hItem, LPARAM itemData)
{
// finds an item which has m_title at the nCol column
// searches only parent items
if(hItem == NULL)
hItem = GetRootItem();
if(itemData==0)
{
while((hItem!=NULL) && (GetItemText(hItem, nCol)!=m_title))
hItem = GetNextSiblingItem(hItem);
}
else
{
while(hItem!=NULL)
{
if((GetItemText(hItem, nCol)==m_title) && ((LPARAM)GetItemData(hItem)==itemData))
break;
hItem = GetNextSiblingItem(hItem);
}
}
return hItem;
}
void CNewTreeListCtrl::MemDeleteAllItems(HTREEITEM hParent)
{
HTREEITEM hItem = hParent;
CTLItem *pItem;
while(hItem!=NULL)
{
pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
delete pItem;
if(ItemHasChildren(hItem))
MemDeleteAllItems(GetChildItem(hItem));
hItem = GetNextSiblingItem(hItem);
}
}
BOOL CNewTreeListCtrl::DeleteAllItems()
{
SetRedraw(FALSE);
BeginWaitCursor();
MemDeleteAllItems(GetRootItem());
BOOL m_bReturn = CTreeCtrl::DeleteAllItems();
EndWaitCursor();
SetRedraw(TRUE);
Invalidate();
((CTLFrame*)GetParent())->ResetScrollBar();
return m_bReturn;
}
int CALLBACK CNewTreeListCtrl::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
CTLItem *pItem1 = (CTLItem *)lParam1;
CTLItem *pItem2 = (CTLItem *)lParam2;
SSortType *pSortType = (SSortType *)lParamSort;
if(pSortType->m_ParentsOnTop)
{
if((pItem1->m_HasChildren) && (!pItem2->m_HasChildren))
return -1;
else
if((pItem2->m_HasChildren) && (!pItem1->m_HasChildren))
return 1;
}
if(pItem1->m_nPriority > pItem2->m_nPriority)
return -1;
else
if(pItem1->m_nPriority < pItem2->m_nPriority)
return 1;
CString str1 = pItem1->GetSubstring(pSortType->nCol);
CString str2 = pItem2->GetSubstring(pSortType->nCol);
int m_nComp;
// compare the two strings, but
// notice:
// in this case, "xxxx10" comes after "xxxx2"
{
CString tmpStr1, tmpStr2;
int index = str1.FindOneOf("0123456789");
if(index!=-1)
tmpStr1 = str1.Right(str1.GetLength()-index);
index = str2.FindOneOf("0123456789");
if(index!=-1)
tmpStr2 = str2.Right(str2.GetLength()-index);
tmpStr1 = tmpStr1.SpanIncluding("0123456789");
tmpStr2 = tmpStr2.SpanIncluding("0123456789");
if((tmpStr1=="") && (tmpStr2==""))
m_nComp = str1.CompareNoCase(str2);
else
{
int num1 = atoi(tmpStr1);
int num2 = atoi(tmpStr2);
tmpStr1 = str1.SpanExcluding("0123456789");
tmpStr2 = str2.SpanExcluding("0123456789");
if(tmpStr1 == tmpStr2)
{
if(num1 > num2)
m_nComp = 1;
else
if(num1 < num2)
m_nComp = -1;
else
m_nComp = str1.CompareNoCase(str2);
}
else
m_nComp = str1.CompareNoCase(str2);
}
}
if(!pSortType->bAscending)
{
if(m_nComp == 1)
m_nComp = -1;
else
if(m_nComp == -1)
m_nComp = 1;
}
return m_nComp;
}
BOOL CNewTreeListCtrl::SortItems( int nCol, BOOL bAscending, HTREEITEM low)
{
TV_SORTCB tSort;
tSort.hParent = low;
tSort.lpfnCompare = CompareFunc;
SSortType *pSortType = new SSortType;
pSortType->nCol = nCol;
pSortType->bAscending = bAscending;
pSortType->m_ParentsOnTop = m_ParentsOnTop;
tSort.lParam = (LPARAM)pSortType;
BOOL m_bReturn = SortChildrenCB(&tSort);
delete pSortType;
return m_bReturn;
}
HTREEITEM CNewTreeListCtrl::AlterDropTarget(HTREEITEM hSource, HTREEITEM hTarget)
{
// TODO: the following lines should be adjusted
// according to your project's needs
if(hTarget==TVI_ROOT)
return TVI_ROOT;
if(ItemHasChildren(hTarget))
return hTarget;
else
{
HTREEITEM hParent = GetParentItem(hTarget);
if(hParent!=NULL)
return hParent;
else
if((hTarget!=NULL) && (IsBold(hTarget)))
return hTarget;
else
return TVI_ROOT;
}
}
void CNewTreeListCtrl::OnTimer(UINT nIDEvent)
{
if(nIDEvent == m_idTimer)
{
m_toDrag = TRUE;
KillTimer(m_idTimer);
/* HTREEITEM htiFloat = GetDropHilightItem();
if(htiFloat && htiFloat == m_htiDrop )
{
if(ItemHasChildren(htiFloat))
Expand( htiFloat, TVE_EXPAND );
}*/
}
/* else
if(nIDEvent == m_scrollTimer)
{
m_timerticks++;
POINT pt;
GetCursorPos( &pt );
RECT rect;
GetClientRect( &rect );
ClientToScreen( &rect );
// NOTE: Screen coordinate is being used because the call
// to DragEnter had used the Desktop window.
CImageList::DragMove(pt);
HTREEITEM hitem = GetFirstVisibleItem();
if( pt.y < rect.top + 10 )
{
// We need to scroll up
// Scroll slowly if cursor near the treeview control
int slowscroll = 6 - (rect.top + 10 - pt.y) / 20;
if( 0 == ( m_timerticks % (slowscroll > 0? slowscroll : 1) ) )
{
CImageList::DragShowNolock(FALSE);
SendMessage( WM_VSCROLL, SB_LINEUP);
SelectDropTarget(hitem);
m_htiDrop = hitem;
CImageList::DragShowNolock(TRUE);
}
}
else if( pt.y > rect.bottom - 10 )
{
// We need to scroll down
// Scroll slowly if cursor near the treeview control
int slowscroll = 6 - (pt.y - rect.bottom + 10 ) / 20;
if( 0 == ( m_timerticks % (slowscroll > 0? slowscroll : 1) ) )
{
CImageList::DragShowNolock(FALSE);
SendMessage( WM_VSCROLL, SB_LINEDOWN);
int nCount = GetVisibleCount();
for ( int i=0; i<nCount-1; ++i )
hitem = GetNextVisibleItem(hitem);
if( hitem )
SelectDropTarget(hitem);
m_htiDrop = hitem;
CImageList::DragShowNolock(TRUE);
}
}
}
*/
CTreeCtrl::OnTimer(nIDEvent);
}
void CNewTreeListCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
CTreeCtrl::OnLButtonUp(nFlags, point);
if( m_bLDragging )
{
CImageList::DragLeave(this);
CImageList::EndDrag();
ReleaseCapture();
delete m_pDragImage;
SelectDropTarget(NULL);
m_htiOldDrop = NULL;
if( m_htiDrag == m_htiDrop )
{
m_bLDragging = FALSE;
return;
}
if(m_htiDrop==NULL)
{
Invalidate();
m_bLDragging = FALSE;
return;
}
if(m_htiDrop!=TVI_ROOT)
{
HTREEITEM htiParent = m_htiDrop;
while( (htiParent = GetParentItem(htiParent)) != NULL )
{
if( htiParent == m_htiDrag )
{
m_bLDragging = FALSE;
return;
}
}
}
// please remove this line if you need to be able
// to drop any item everywhere
m_htiDrop = AlterDropTarget(m_htiDrag, m_htiDrop);
HTREEITEM hDragParent = GetParentItem(m_htiDrag);
HTREEITEM htiNew = MoveItem(m_htiDrag, m_htiDrop, TVI_SORT);
SelectItem( htiNew );
// please remove the following block too if it's not
// relevant to your project
{
// remove the parent item, if there was one,
// and we dragged out of it its last child
{
if(hDragParent!=NULL)
{
HTREEITEM hSecParent;
do
{
hSecParent = GetParentItem(hDragParent);
if(GetChildItem(hDragParent)==NULL) // no more children left
{
DeleteItem(hDragParent);
}
hDragParent = hSecParent;
} while(hSecParent!=NULL);
}
}
}
Expand(m_htiDrop, TVE_EXPAND);
if( m_idTimer )
{
KillTimer( m_idTimer );
m_idTimer = 0;
}
if( m_scrollTimer )
{
KillTimer( m_scrollTimer );
m_scrollTimer = 0;
}
}
(GetParent()->GetParent())->SendMessage(WM_LBUTTONUP);
m_bLDragging = FALSE;
m_toDrag = FALSE;
}
void CNewTreeListCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
CTreeCtrl::OnMouseMove(nFlags, point);
HTREEITEM hti;
UINT flags;
if((!m_bLDragging) && (m_htiDrop!=NULL) && (m_toDrag))
{
if(nFlags & MK_LBUTTON)
Begindrag(point);
}
else
if((!m_bLDragging) && (m_htiDrop==NULL))
{
m_htiDrop = TVI_ROOT;
}
else
if(m_bLDragging)
{
POINT pt = point;
ClientToScreen( &pt );
CImageList::DragMove(pt);
hti = HitTest(point,&flags);
// if( hti != NULL )
{
CImageList::DragShowNolock(FALSE);
if( m_htiOldDrop == NULL )
m_htiOldDrop = GetDropHilightItem();
SelectDropTarget(hti);
if(hti != NULL)
{
m_htiDrop = hti;
}
else
{
m_htiDrop = TVI_ROOT;
}
/* if( m_idTimer && hti == m_htiOldDrop )
{
KillTimer( m_idTimer );
m_idTimer = 0;
}
if( !m_idTimer )
m_idTimer = SetTimer( 1000, 1500, NULL );*/
CImageList::DragShowNolock(TRUE);
}
}
}
void CNewTreeListCtrl::Begindrag(CPoint point)
{
// disabling drag for now...
return;
UINT flags;
m_htiDrag = HitTest(point, &flags);
if(!((flags & TVHT_ONITEMRIGHT) || (flags & TVHT_ONITEMINDENT) ||
(flags & TVHT_ONITEM)))
{
m_htiDrag = NULL;
return;
}
m_htiDrop = NULL;
m_pDragImage = CreateDragImage( m_htiDrag );
if( !m_pDragImage )
return;
m_bLDragging = TRUE;
CPoint pt(0,0);
IMAGEINFO ii;
m_pDragImage->GetImageInfo( 0, &ii );
pt.x = (ii.rcImage.right - ii.rcImage.left) / 2;
pt.y = (ii.rcImage.bottom - ii.rcImage.top) / 2;
m_pDragImage->BeginDrag( 0, pt );
ClientToScreen(&point);
m_pDragImage->DragEnter(NULL,point);
// m_scrollTimer = SetTimer(1001, 75, NULL);
SetCapture();
}
void CNewTreeListCtrl::OnDestroy()
{
MemDeleteAllItems(GetRootItem());
CTreeCtrl::OnDestroy();
}
BOOL CNewTreeListCtrl::Expand(HTREEITEM hItem, UINT nCode)
{
BOOL bReturn = CTreeCtrl::Expand(hItem, nCode);
((CTLFrame*)GetParent())->ResetScrollBar();
return bReturn;
}
| [
"scriptkitz@da890e6b-1f8b-8dbb-282d-e1a1f9b2274c"
]
| [
[
[
1,
1459
]
]
]
|
6b074f3c6639d823ad345d3628cb592b46e45702 | 709cd826da3ae55945fd7036ecf872ee7cdbd82a | /Term/Bowling/trunk/Source/LethalBowling/World.h | 29f61f215282d5b7aece337c529d35193a0eda31 | []
| no_license | argapratama/kucgbowling | 20dbaefe1596358156691e81ccceb9151b15efb0 | 65e40b6f33c5511bddf0fa350c1eefc647ace48a | refs/heads/master | 2018-01-08T15:27:44.784437 | 2011-06-19T15:23:39 | 2011-06-19T15:23:39 | 36,738,655 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 3,494 | h | #pragma once
#include "Sprite.h"
#include "Camera.h"
#include "Light.h"
#include "TimeSpan.h"
#include "Ball.h"
#include "Pin.h"
#include "Contact.h"
#include <glut.h>
using namespace std;
namespace Virgin
{
// 이 프로그램의 모든 3D 요소 - 스프라이트, 조명, 옵션 등등 - 가 들어가 있는 Singleton 클래스
class World
{
private:
World(); // Singleton
public:
static World& Instance();
Ball& GetBall();
Ball& GetBall2();
Pin& GetPin(int number);
void ResizePinCount(int count);
Camera& GetCamera();
Light& GetLight();
void Update(TimeSpan time, TimeSpan timeDelta);
vector<Sprite*>& Sprites();
vector<Collision>& Collisions();
void DrawString3(void *font, const char *str, float x_position, float y_position, float z_position);
// 물리 시뮬레이션
void DoPhysical(TimeSpan time, TimeSpan timeDelta);
// 충돌 감지
void DoCollisionDetection();
bool FarFromBoundary(int i);
bool FarApart(int iT0, int iT1);
bool TetraBoundaryIntersection(int iTetra, int iBoundary, float* afDistance, Contact& rkContact);
void BuildContactMoveTetra(int iTetra, int iBoundary, int iHitIndex, float fDepthMax, Contact& rkContact);
void Reposition(int iT0, int iT1, Contact& rkContact);
bool IsVertex(const Vector3* akVertex, const Vector3& rkRes);
void CalculateNormal(const Vector3* akVertex, const Vector3& rkRes, Contact& rkContact);
Vector3 ClosestEdge(const Vector3* akVertex, const Vector3& rkRes,Vector3& rkOtherVertex);
// 충돌 반응
void DoCollisionResponse();
void ComputePreimpulseVelocity(std::vector<float>& preRelVel);
void ComputeImpulseMagnitude(std::vector<float>& preRelVel, std::vector<float>& impulseMag);
void DoImpulse(std::vector<float>& impulseMag);
void DoMotion();
static float CalcKE(const RigidBody& rigidBody);
void ShowCollisionInfo();
void HideCollisionInfo();
//
// 시각화
//
void DoVisual();
void DrawScene();
void InitializeGL();
void DrawObject();
void DrawFloor();
void DrawShadows();
void DrawReflections();
void DrawSprites();
void DrawOrigin();
void DrawCollisionInfo();
static void DrawBox(Box& box);
static void DrawSphere(Sphere& sphere);
static void DrawVertex(Vector3& vertex);
static Vector3 Force (float fTime, float fMass, const Vector3& rkPos,
const Quaternion& rkQOrient, const Vector3& rkLinMom,
const Vector3& rkAngMom, const Matrix3& rkOrient,
const Vector3& rkLinVel, const Vector3& rkAngVel);
static Vector3 Torque (float fTime, float fMass, const Vector3& rkPos,
const Quaternion& rkQOrient, const Vector3& rkLinMom,
const Vector3& rkAngMom, const Matrix3& rkOrient,
const Vector3& rkLinVel, const Vector3& rkAngVel);
private:
vector<Sprite*> sprites_; // 여기에 모든 스프라이트들을 등록해두어야 함 (충돌 검사 등에 사용)
vector<Collision> collisions_;
vector<Contact> contacts_;
Ball ball_;
Ball ball2_;
vector<Pin> pins_;
float shadow_matrix[16];
Light light_;
RigidBody floor_;
float totalKE_;
Camera camera_;
Camera topCamera_;
Camera sideCamera_;
Camera frontCamera_;
GLuint texture[4];
bool doShowCollisionInfo_;
void LoadGLTextures();
};
}
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
10
],
[
12,
38
],
[
41,
95
],
[
97,
101
],
[
103,
111
],
[
113,
113
],
[
115,
117
]
],
[
[
11,
11
],
[
39,
40
],
[
96,
96
],
[
102,
102
],
[
112,
112
],
[
114,
114
]
]
]
|
1327d1f75aa1588697476c2332a0955c300aaf6d | 74c8da5b29163992a08a376c7819785998afb588 | /NetAnimal/addons/pa/dependencies/include/ParticleUniverse/ParticleAffectors/ParticleUniverseLinearForceAffectorFactory.h | 1ced45e68df09fc3b71e8276b1ee321f662e39a8 | []
| no_license | dbabox/aomi | dbfb46c1c9417a8078ec9a516cc9c90fe3773b78 | 4cffc8e59368e82aed997fe0f4dcbd7df626d1d0 | refs/heads/master | 2021-01-13T14:05:10.813348 | 2011-06-07T09:36:41 | 2011-06-07T09:36:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,228 | h | /*
-----------------------------------------------------------------------------------------------
This source file is part of the Particle Universe product.
Copyright (c) 2010 Henry van Merode
Usage of this program is licensed under the terms of the Particle Universe Commercial License.
You can find a copy of the Commercial License in the Particle Universe package.
-----------------------------------------------------------------------------------------------
*/
#ifndef __PU_LINEAR_FORCE_AFFECTOR_FACTORY_H__
#define __PU_LINEAR_FORCE_AFFECTOR_FACTORY_H__
#include "ParticleUniversePrerequisites.h"
#include "ParticleUniverseBaseForceAffectorTokens.h"
#include "ParticleUniverseLinearForceAffector.h"
#include "ParticleUniverseLinearForceAffectorTokens.h"
#include "ParticleUniverseAffectorFactory.h"
namespace ParticleUniverse
{
/** Factory class responsible for creating the LinearForceAffector.
*/
class _ParticleUniverseExport LinearForceAffectorFactory : public ParticleAffectorFactory
{
public:
LinearForceAffectorFactory(void) {};
virtual ~LinearForceAffectorFactory(void) {};
/** See ParticleAffectorFactory */
Ogre::String getAffectorType(void) const
{
return "LinearForce";
}
/** See ParticleAffectorFactory */
ParticleAffector* createAffector(void)
{
return _createAffector<LinearForceAffector>();
}
/** See ScriptReader */
virtual bool translateChildProperty(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node)
{
return mLinearForceAffectorTranslator.translateChildProperty(compiler, node);
};
/** See ScriptReader */
virtual bool translateChildObject(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node)
{
return mLinearForceAffectorTranslator.translateChildObject(compiler, node);
};
/* */
virtual void write(ParticleScriptSerializer* serializer , const IElement* element)
{
// Delegate
mLinearForceAffectorWriter.write(serializer, element);
}
protected:
LinearForceAffectorWriter mLinearForceAffectorWriter;
LinearForceAffectorTranslator mLinearForceAffectorTranslator;
};
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
68
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.