本文整理汇总了C++中setFlag函数的典型用法代码示例。如果您正苦于以下问题:C++ setFlag函数的具体用法?C++ setFlag怎么用?C++ setFlag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setFlag函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: _edge
QGVEdge::QGVEdge(QGVEdgePrivate *edge, QGVScene *scene) : _edge(edge), _scene(scene)
{
setFlag(QGraphicsItem::ItemIsSelectable, true);
}
开发者ID:gavaza,项目名称:pacca,代码行数:4,代码来源:QGVEdge.cpp
示例2: RobotPart
//! [10]
Robot::Robot(QGraphicsItem *parent)
: RobotPart(parent)
{
setFlag(ItemHasNoContents);
QGraphicsObject *torsoItem = new RobotTorso(this);
QGraphicsObject *headItem = new RobotHead(torsoItem);
QGraphicsObject *upperLeftArmItem = new RobotLimb(torsoItem);
QGraphicsObject *lowerLeftArmItem = new RobotLimb(upperLeftArmItem);
QGraphicsObject *upperRightArmItem = new RobotLimb(torsoItem);
QGraphicsObject *lowerRightArmItem = new RobotLimb(upperRightArmItem);
QGraphicsObject *upperRightLegItem = new RobotLimb(torsoItem);
QGraphicsObject *lowerRightLegItem = new RobotLimb(upperRightLegItem);
QGraphicsObject *upperLeftLegItem = new RobotLimb(torsoItem);
QGraphicsObject *lowerLeftLegItem = new RobotLimb(upperLeftLegItem);
//! [10]
//! [11]
headItem->setPos(0, -18);
upperLeftArmItem->setPos(-15, -10);
lowerLeftArmItem->setPos(30, 0);
upperRightArmItem->setPos(15, -10);
lowerRightArmItem->setPos(30, 0);
upperRightLegItem->setPos(10, 32);
lowerRightLegItem->setPos(30, 0);
upperLeftLegItem->setPos(-10, 32);
lowerLeftLegItem->setPos(30, 0);
//! [11]
//! [12]
QParallelAnimationGroup *animation = new QParallelAnimationGroup(this);
QPropertyAnimation *headAnimation = new QPropertyAnimation(headItem, "rotation");
headAnimation->setStartValue(20);
headAnimation->setEndValue(-20);
QPropertyAnimation *headScaleAnimation = new QPropertyAnimation(headItem, "scale");
headScaleAnimation->setEndValue(1.1);
animation->addAnimation(headAnimation);
animation->addAnimation(headScaleAnimation);
//! [12]
QPropertyAnimation *upperLeftArmAnimation = new QPropertyAnimation(upperLeftArmItem, "rotation");
upperLeftArmAnimation->setStartValue(190);
upperLeftArmAnimation->setEndValue(180);
animation->addAnimation(upperLeftArmAnimation);
QPropertyAnimation *lowerLeftArmAnimation = new QPropertyAnimation(lowerLeftArmItem, "rotation");
lowerLeftArmAnimation->setStartValue(50);
lowerLeftArmAnimation->setEndValue(10);
animation->addAnimation(lowerLeftArmAnimation);
QPropertyAnimation *upperRightArmAnimation = new QPropertyAnimation(upperRightArmItem, "rotation");
upperRightArmAnimation->setStartValue(300);
upperRightArmAnimation->setEndValue(310);
animation->addAnimation(upperRightArmAnimation);
QPropertyAnimation *lowerRightArmAnimation = new QPropertyAnimation(lowerRightArmItem, "rotation");
lowerRightArmAnimation->setStartValue(0);
lowerRightArmAnimation->setEndValue(-70);
animation->addAnimation(lowerRightArmAnimation);
QPropertyAnimation *upperLeftLegAnimation = new QPropertyAnimation(upperLeftLegItem, "rotation");
upperLeftLegAnimation->setStartValue(150);
upperLeftLegAnimation->setEndValue(80);
animation->addAnimation(upperLeftLegAnimation);
QPropertyAnimation *lowerLeftLegAnimation = new QPropertyAnimation(lowerLeftLegItem, "rotation");
lowerLeftLegAnimation->setStartValue(70);
lowerLeftLegAnimation->setEndValue(10);
animation->addAnimation(lowerLeftLegAnimation);
QPropertyAnimation *upperRightLegAnimation = new QPropertyAnimation(upperRightLegItem, "rotation");
upperRightLegAnimation->setStartValue(40);
upperRightLegAnimation->setEndValue(120);
animation->addAnimation(upperRightLegAnimation);
QPropertyAnimation *lowerRightLegAnimation = new QPropertyAnimation(lowerRightLegItem, "rotation");
lowerRightLegAnimation->setStartValue(10);
lowerRightLegAnimation->setEndValue(50);
animation->addAnimation(lowerRightLegAnimation);
QPropertyAnimation *torsoAnimation = new QPropertyAnimation(torsoItem, "rotation");
torsoAnimation->setStartValue(5);
torsoAnimation->setEndValue(-20);
animation->addAnimation(torsoAnimation);
//! [13]
for (int i = 0; i < animation->animationCount(); ++i) {
QPropertyAnimation *anim = qobject_cast<QPropertyAnimation *>(animation->animationAt(i));
anim->setEasingCurve(QEasingCurve::SineCurve);
anim->setDuration(2000);
}
animation->setLoopCount(-1);
animation->start();
//! [13]
}
开发者ID:ismaell,项目名称:android-qt5-qtbase,代码行数:98,代码来源:robot.cpp
示例3: QQuickItem
QQuickCanvasItem::QQuickCanvasItem(QQuickItem *parent)
: QQuickItem(*(new QQuickCanvasItemPrivate), parent)
{
setFlag(ItemHasContents);
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:5,代码来源:qquickcanvasitem.cpp
示例4: m_frame
///////////////////////////////////////////////////////////////////////////////
// QSGVlcVideoFrameMaterial
QSGVlcVideoFrameMaterial::QSGVlcVideoFrameMaterial()
: m_frame( 0 )
{
memset( m_planeTexIds, 0, sizeof( m_planeTexIds ) );
setFlag( Blending, false );
}
开发者ID:Dorrro,项目名称:QmlVlc,代码行数:8,代码来源:SGVlcVideoNode.cpp
示例5: m_shuttle
AndroidRotationControl::AndroidRotationControl(Shuttle *shuttle) : m_shuttle(shuttle), width(200), height(200)
{
setFlag(QGraphicsItem::ItemIsFocusable);
setAcceptTouchEvents(true);
}
开发者ID:haagflo,项目名称:Qt2D-Shooter,代码行数:5,代码来源:androidrotationcontrol.cpp
示例6: prect
//.........这里部分代码省略.........
subModelColor = _subModel;
submodelLevel = _submodelLevel;
parentRelativeType = _parentRelativeType;
BorderData borderData = _border.valuePixels();
BackgroundData backgroundData = _background.value();
int bt = borderData.thickness;
QColor penColor,brushColor;
QRectF prect(bt/2,bt/2,pixmap->width()-1-bt,pixmap->height()-1-bt);
pixmap->setAlphaChannel(*pixmap);
pixmap->fill(Qt::transparent);
QPainter painter(pixmap);
switch(backgroundData.type) {
case BackgroundData::BgImage:
{
QString image_name = backgroundData.string;
QFile file(image_name);
if ( ! file.exists()) {
return;
}
QImage image(image_name);
if (backgroundData.stretch) {
QSize psize = pixmap->size();
QSize isize = image.size();
qreal sx = psize.width();
qreal sy = psize.height();
sx /= isize.width();
sy /= isize.height();
painter.scale(sx,sy);
painter.drawImage(0,0,image);
} else {
for (int y = 0; y < pixmap->height(); y += image.height()) {
for (int x = 0; x < pixmap->width(); x += image.width()) {
painter.drawImage(x,y,image);
}
}
}
brushColor = Qt::transparent;
}
break;
case BackgroundData::BgTransparent:
break;
case BackgroundData::BgColor:
case BackgroundData::BgSubmodelColor:
if (backgroundData.type == BackgroundData::BgColor) {
brushColor = LDrawColor::color(backgroundData.string);
} else {
brushColor = LDrawColor::color(_subModel.value(submodelLevel));
}
break;
}
qreal rx = borderData.radius;
qreal ry = borderData.radius;
qreal dx = pixmap->width();
qreal dy = pixmap->height();
if (dx && dy) {
if (dx > dy) {
// the rx is going to appear larger that ry, so decrease rx based on ratio
rx *= dy;
rx /= dx;
} else {
ry *= dx;
ry /= dy;
}
}
if (borderData.type == BorderData::BdrNone) {
penColor = Qt::transparent;
} else {
penColor = LDrawColor::color(borderData.color);
}
QPen pen;
pen.setColor(penColor);
pen.setWidth(bt);
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
painter.setPen(pen);
painter.setBrush(brushColor);
painter.setRenderHints(QPainter::HighQualityAntialiasing,true);
painter.setRenderHints(QPainter::Antialiasing,true);
if (borderData.type == BorderData::BdrRound) {
painter.drawRoundRect(prect,rx,ry);
} else {
painter.drawRect(prect);
}
setToolTip(toolTip);
setFlag(QGraphicsItem::ItemIsSelectable,true);
setFlag(QGraphicsItem::ItemIsMovable,true);
}
开发者ID:nathaneltitane,项目名称:lpub,代码行数:101,代码来源:backgrounditem.cpp
示例7: receive_RR
int receive_RR(int fd, char *RR, int s) {
char flag_ST;
int option = START;
int r = s ? 0 : 1;
int c_rr = 1 | (r << 5);
while(!(STOP_RR)){
read(fd, &flag_ST, 1);
//fprintf(stderr, "option %d flag_ST 0x%x flag %d r %d c_rr %x\n", option, flag_ST, getFlag(), r, c_rr);
int flag = getFlag();
if(flag && flag != -1){
alarm(0);
setFlag(-1);
STOP_RR = TRUE;
return -1;
}
switch (option) {
case START:
if (flag_ST == F){
option = FLAG_RCV;
RR[0] = flag_ST;
}
else
option = START;
break;
case FLAG_RCV:
if (flag_ST == F){
option = FLAG_RCV;
RR[0] = flag_ST;
}
else if (flag_ST == A) {
option = A_RCV;
RR[1] = flag_ST;
}
else
option = START;
break;
case A_RCV:
if (flag_ST == F){
option = FLAG_RCV;
RR[0] = flag_ST;
}
else if (flag_ST == c_rr) {
option = C_RCV;
RR[2] = flag_ST;
}
else
option = START;
break;
case C_RCV:
if (flag_ST == F) {
option = FLAG_RCV;
RR[0] = flag_ST;
}
else if (flag_ST == (c_rr^A)){
option = BCC_OK;
RR[3] = flag_ST;
}
else
option = START;
break;
case BCC_OK:
if (flag_ST == F){
option = STOP_ST;
STOP_RR = TRUE;
RR[4] = flag_ST;
}
else
option = START;
break;
case STOP_ST:
STOP_RR = TRUE;
break;
default:
break;
}
}
return r;
}
开发者ID:tomislaaaav,项目名称:RCOM_Proj1,代码行数:84,代码来源:state.c
示例8: setFlagTo
inline static UINT8 setFlagTo(UINT8 ccr, UINT8 flag, bool set) {
return set ? setFlag(ccr, flag) : clearFlag(ccr, flag);
}
开发者ID:RalfVB,项目名称:mame,代码行数:3,代码来源:es5510.cpp
示例9: QQuickPaintedItem
MyImage::MyImage(QQuickItem *parent) :
QQuickPaintedItem(parent)
#else
MyImage::MyImage(QDeclarativeItem *parent) :
QDeclarativeItem(parent)
#endif
{
#if(QT_VERSION<0x050000)
setFlag(QGraphicsItem::ItemHasNoContents, false);
#endif
m_status = Null;
m_cache = true;
m_grayscale = false;
m_source = "";
m_sourceSize = QSize(0,0);
pixmap = NULL;
reply = NULL;
connect(&manager, SIGNAL(finished(QNetworkReply*)), SLOT(onDownImageFinished(QNetworkReply*)));
}
MyImage::~MyImage()
{
if(pixmap!=NULL)
delete pixmap;
}
QUrl MyImage::source() const
{
return m_source;
}
QUrl MyImage::maskSource() const
{
return m_maskSource;
}
bool MyImage::cache() const
{
return m_cache;
}
bool MyImage::grayscale() const
{
return m_grayscale;
}
void MyImage::chromaticToGrayscale(QImage &image)
{
if(image.isNull()||image.isGrayscale ())
return;
for(int i=0;i<image.width ();++i){
for(int j=0;j<image.height ();++j){
QRgb pixel = image.pixel(i,j);
int a = qAlpha(pixel);
pixel = qGray (pixel);
pixel = qRgba(pixel,pixel,pixel,a);
image.setPixel (i,j,pixel);
}
}
}
QString MyImage::imageFormatToString(const QByteArray &array)
{
QByteArray str = array.toHex ();
if(str.mid (2,6)=="504e47")
return "png";
if(str.mid (12,8)=="4a464946")
return "jpg";
if(str.left (6)=="474946")
return "gif";
if(str.left (4)=="424d")
return "bmp";
return "";
}
开发者ID:9smart,项目名称:9News,代码行数:75,代码来源:myimage.cpp
示例10: QgsLayerTreeModel
QgsLegendModelV2::QgsLegendModelV2( QgsLayerTreeGroup* rootNode, QObject* parent )
: QgsLayerTreeModel( rootNode, parent )
{
setFlag( QgsLayerTreeModel::AllowLegendChangeState, false );
setFlag( QgsLayerTreeModel::AllowNodeReorder, true );
}
开发者ID:RossGammon,项目名称:QGIS,代码行数:6,代码来源:qgscomposerlegend.cpp
示例11: DiagramCanvas
ArrowPointCanvas::ArrowPointCanvas(UmlCanvas * canvas, int x, int y)
: DiagramCanvas(0, canvas, x, y, ARROW_POINT_SIZE, ARROW_POINT_SIZE, -1)
{
browser_node = canvas->browser_diagram();
setFlag(QGraphicsItem::ItemIsSelectable, true);
}
开发者ID:gilbertoca,项目名称:douml,代码行数:6,代码来源:ArrowPointCanvas.cpp
示例12: setFlag
void Letter::setJoin() {
setFlag(QGraphicsItem::ItemIsMovable, false);
setBrush(QColor("#555555"));
setCursor(Qt::ArrowCursor);
m_movable = false;
}
开发者ID:VitalD,项目名称:connectagram,代码行数:6,代码来源:letter.cpp
示例13: setReadOnly
inline void setReadOnly(bool set = true)
{ setFlag(flags, flagIsReadOnly, set); }
开发者ID:BackupTheBerlios,项目名称:hypnos-svn,代码行数:2,代码来源:cbook.hpp
示例14: mMapKey
YigSynthGraphic::YigSynthGraphic(QString synthType, QString mapKey, const QPointF &point, float param1, float param2,
int outBus, QGraphicsScene *scene) :
mMapKey(mapKey),
audioOutBus(outBus),
selectingUser(" "),
QGraphicsEllipseItem(0, 0, ELLIPSE_SIZE, ELLIPSE_SIZE, 0)
{
mSynthType = synthType;
autoCableCounter = 0;
moveBy(point.x(), point.y());
setFlag( QGraphicsItem::ItemIsSelectable, true );
setFlag( QGraphicsItem::ItemIsMovable, true );
setFlag(QGraphicsItem::ItemSendsGeometryChanges);
setZValue(10);
//setCacheMode(QGraphicsItem::DeviceCoordinateCache);
//setAcceptsHoverEvents(true);
// MOD FIELD 1
modField1 = new YigModField(this, param1, 0, 0, MOD_FIELD_SIZE, MOD_FIELD_SIZE, this);
modField1->moveBy((-MOD_FIELD_SIZE/2) + (ELLIPSE_SIZE/2), (-MOD_FIELD_SIZE/2) + (ELLIPSE_SIZE/2));
modField1->setFlag( QGraphicsItem::ItemIsSelectable, true );
modField1->setFlag( QGraphicsItem::ItemIsMovable, false );
QColor outlineColor = YigColorKit::background2;
pen.setColor(QColor(0, 0, 0, 25));
pen.setColor( outlineColor );
modField1->setPen( pen );
//modField1->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
/*
QRadialGradient gradient(QPointF(MOD_FIELD_SIZE/2, MOD_FIELD_SIZE/2), MOD_FIELD_SIZE/2,
QPointF(MOD_FIELD_SIZE/2, MOD_FIELD_SIZE/2));
gradient.setColorAt(0, QColor(0, 0, 0, 0));
gradient.setColorAt(0.3, QColor(0, 0, 0, 100));
gradient.setColorAt(0.75, QColor(0, 0, 0, 170));
gradient.setColorAt(1, QColor(0, 0, 0, 50));
QBrush radialBrush(gradient);*/
//modField1->setBrush( QColor(0, 0, 0, 160) );
modField1->setBrush(Qt::NoBrush);
QColor modColor = YigColorKit::background2;
modColor.setAlpha(150);
//brush.setColor(modColor);
//modField1->setBrush(QBrush(modColor));
modField1->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
modField1->setZValue(0);
//modField1->setCacheMode( QGraphicsItem::DeviceCoordinateCache );
// MOD FIELD 2
modField2 = new YigModField2(this, param2, 0, 0, MOD_FIELD_2_SIZE, MOD_FIELD_2_SIZE, this);
modField2->moveBy(((-MOD_FIELD_2_SIZE/2) + (ELLIPSE_SIZE/2)), ((-MOD_FIELD_2_SIZE/2) + (ELLIPSE_SIZE/2)));
modField2->setFlag( QGraphicsItem::ItemIsSelectable, true );
modField2->setFlag( QGraphicsItem::ItemIsMovable, false );
//modField2->setPen( pen );
modField2->setPen(Qt::NoPen);
/*
QRadialGradient gradient2(QPointF(MOD_FIELD_2_SIZE/2, MOD_FIELD_2_SIZE/2), MOD_FIELD_2_SIZE/2,
QPointF(MOD_FIELD_2_SIZE/2, MOD_FIELD_2_SIZE/2));
gradient2.setColorAt(0, QColor(255, 255, 255, 0));
gradient2.setColorAt(0.5, QColor(0, 0, 0, 0));
gradient2.setColorAt(0.7, QColor(255, 255, 255, 160));
gradient2.setColorAt(0.8, QColor(255, 255, 255, 160));
gradient2.setColorAt(0.95, QColor(255, 255, 255, 100));
gradient2.setColorAt(1, QColor(0, 0, 0, 100));
QBrush radialBrush2(gradient2);
modField2->setBrush( radialBrush2 );*/
modField2->setBrush(Qt::NoBrush);
//modColor = YigColorKit::focus1Highlight;
//modColor.setAlpha(100);
//modField2->setBrush(modColor);
//modField2->setCacheMode(QGraphicsItem::DeviceCoordinateCache);;
modField2->setFlag(QGraphicsItem::ItemStacksBehindParent);
//modField2->setZValue(3);
//modField2->setCacheMode( QGraphicsItem::DeviceCoordinateCache );
// AUDIO OUTPUT
/*
audioOutput = new YigEllipseItem( this, 0, 0, SMALL_ELLIPSE_SIZE, SMALL_ELLIPSE_SIZE, this );
//audioOutput->moveBy((ELLIPSE_SIZE/2) - (SMALL_ELLIPSE_SIZE/2), ELLIPSE_SIZE - SMALL_ELLIPSE_SIZE);
audioOutput->moveBy(7.5 + TRI_OFFSET_X, 7.5*SQRT_THREE + TRI_OFFSET_Y);
audioOutput->setFlag( QGraphicsItem::ItemIsSelectable, false );
audioOutput->setFlag( QGraphicsItem::ItemIsMovable, false );
audioOutput->setCacheMode(QGraphicsItem::DeviceCoordinateCache);*/
// AUDIO INPUT
/*
audioInput = new YigEllipseItem( this, 0, 0, SMALL_ELLIPSE_SIZE, SMALL_ELLIPSE_SIZE, this );
//audioInput->moveBy((ELLIPSE_SIZE/2) - (SMALL_ELLIPSE_SIZE/2), 0);
audioInput->moveBy(0 + TRI_OFFSET_X, 0 + TRI_OFFSET_Y);*/
audioInput = new QGraphicsEllipseItem(0, 0, AUDIO_ELLIPSE_SIZE, AUDIO_ELLIPSE_SIZE, this);
audioInput->moveBy((ELLIPSE_SIZE/2) - (AUDIO_ELLIPSE_SIZE/2), (ELLIPSE_SIZE/2) - (AUDIO_ELLIPSE_SIZE/2));
audioInput->setFlag( QGraphicsItem::ItemIsSelectable, false );
//.........这里部分代码省略.........
开发者ID:ChadMcKinney,项目名称:Yig,代码行数:101,代码来源:yigsynthgraphic.cpp
示例15: SetupDebug
void SetupDebug(void)
{
char var[256];
_DBPRINTF("** TextEditor.mcp v" LIB_REV_STRING " startup **********************\n");
_DBPRINTF("Exec version: v%ld.%ld\n", ((struct Library *)SysBase)->lib_Version, ((struct Library *)SysBase)->lib_Revision);
_DBPRINTF("Initializing runtime debugging:\n");
if(GetVar("texteditor.mcp.debug", var, sizeof(var), 0) > 0)
{
char *s = var;
// static list of our debugging classes tokens.
// in the texteditor.mcp.debug variable these classes always start with a @
static const struct { const char *token; unsigned long flag; } dbclasses[] =
{
{ "ctrace", DBC_CTRACE },
{ "report", DBC_REPORT },
{ "assert", DBC_ASSERT },
{ "timeval", DBC_TIMEVAL },
{ "debug", DBC_DEBUG },
{ "error", DBC_ERROR },
{ "warning", DBC_WARNING },
{ "mtrack", DBC_MTRACK },
{ "all", DBC_ALL },
{ NULL, 0 }
};
static const struct { const char *token; unsigned long flag; } dbflags[] =
{
{ "always", DBF_ALWAYS },
{ "startup", DBF_STARTUP },
{ "all", DBF_ALL },
{ NULL, 0 }
};
// we parse the env variable token-wise
while(*s)
{
ULONG i;
char *e;
if((e = strpbrk(s, " ,;")) == NULL)
e = s+strlen(s);
// check if the token is class definition or
// just a flag definition
if(s[0] == '@')
{
// check if this call is a negation or not
if(s[1] == '!')
{
// search for the token and clear the flag
for(i=0; dbclasses[i].token; i++)
{
if(strnicmp(&s[2], dbclasses[i].token, strlen(dbclasses[i].token)) == 0)
{
_DBPRINTF("clear '%s' debug class flag.\n", dbclasses[i].token);
clearFlag(debug_classes, dbclasses[i].flag);
}
}
}
else
{
// search for the token and set the flag
for(i=0; dbclasses[i].token; i++)
{
if(strnicmp(&s[1], dbclasses[i].token, strlen(dbclasses[i].token)) == 0)
{
_DBPRINTF("set '%s' debug class flag\n", dbclasses[i].token);
setFlag(debug_classes, dbclasses[i].flag);
}
}
}
}
else
{
// check if this call is a negation or not
if(s[0] == '!')
{
for(i=0; dbflags[i].token; i++)
{
if(strnicmp(&s[1], dbflags[i].token, strlen(dbflags[i].token)) == 0)
{
_DBPRINTF("clear '%s' debug flag\n", dbflags[i].token);
clearFlag(debug_flags, dbflags[i].flag);
}
}
}
else
{
// check if the token was "ansi" and if so enable the ANSI color
// output
if(strnicmp(s, "ansi", 4) == 0)
{
_DBPRINTF("ansi output enabled\n");
ansi_output = TRUE;
}
else
{
//.........这里部分代码省略.........
开发者ID:amiga-mui,项目名称:texteditor,代码行数:101,代码来源:Debug.c
示例16: setFlag
void SCgTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
setFlag(QGraphicsItem::ItemIsMovable, false);
QGraphicsTextItem::mouseReleaseEvent(event);
}
开发者ID:BABANIA,项目名称:kbe,代码行数:5,代码来源:scgtextitem.cpp
示例17: realloc
void ChapterCWriter::calculateChapter ( )
{
_chapter = ( uint8 * ) realloc ( _chapter, 1 );
if ( _chapter == NULL ) {
cerr << "realloc failed !" << endl;
exit ( EXIT_FAILURE );
}
memset ( _chapter, 0, 1 );
setFlag ( & _chapter[0], 0, 1 );
uint8 * position = _chapter + 1;
unsigned short len = 0;
for ( list<TCtrlInfo>::iterator i = _history.begin ( ) ; i != _history.end ( ) ; i++ ) {
if ( ( * i ).payload >= checkpoint ( ) ) {
if ( _tool[( * i ).number] & TOGGLE_TOOL ) {
len++;
_chapterLength = position - _chapter;
_chapter = ( uint8 * ) realloc ( _chapter, _chapterLength + 2 );
if ( _chapter == NULL ) {
cerr << "realloc failed !" << endl;
exit ( EXIT_FAILURE );
}
position = _chapter + _chapterLength;
position[0] = 0x80;
// S
if ( ( * i ).payload == currentPayloadNumber ( ) - 1 ) {
setFlag ( & position[0], 0, 0 );
setFlag ( & _chapter[0], 0, 0 );
unsetParentSBit ( );
}
// NUMBER
position[0] |= ( * i ).number;
// A + T
position[1] = 0xC0;
// VALUE
position[1] |= ( * i ).toggle;
position += 2;
}
if ( _tool[( * i ).number] & VALUE_TOOL ) {
len++;
_chapterLength = position - _chapter;
_chapter = ( uint8 * ) realloc ( _chapter, _chapterLength + 2 );
if ( _chapter == NULL ) {
cerr << "realloc failed !" << endl;
exit ( EXIT_FAILURE );
}
position = _chapter + _chapterLength;
// S
setFlag ( & position[0], 0, 1 );
if ( ( * i ).payload == currentPayloadNumber ( ) - 1 ) {
setFlag ( & position[0], 0, 0 );
setFlag ( & _chapter[0], 0, 0 );
unsetParentSBit ( );
}
// NUMBER
position[0] |= ( * i ).number;
// A
position[1] = 0x00;
// VALUE
position[1] |= ( * i ).value;
position += 2;
}
if ( _tool[( * i ).number] & COUNT_TOOL ) {
len++;
_chapterLength = position - _chapter;
_chapter = ( uint8 * ) realloc ( _chapter, _chapterLength + 2 );
if ( _chapter == NULL ) {
cerr << "realloc failed !" << endl;
exit ( EXIT_FAILURE );
}
position = _chapter + _chapterLength;
// S
setFlag ( & position[0], 0, 1 );
if ( ( * i ).payload == currentPayloadNumber ( ) - 1 ) {
setFlag ( & position[0], 0, 0 );
setFlag ( & _chapter[0], 0, 0 );
unsetParentSBit ( );
}
// NUMBER
position[0] |= ( * i ).number;
// A
position[1] = 0x80;
// VALUE
position[1] |= ( * i ).count;
position += 2;
}
}
}
_chapter[0] |= len - 1;
if ( len != 0 ) {
_chapterLength = 1 + len * 2;
}
else {
_chapterLength = 0;
}
//.........这里部分代码省略.........
开发者ID:AntonLanghoff,项目名称:whitecatlib,代码行数:101,代码来源:ChapterCWriter.cpp
示例18: receive_DISC
void receive_DISC(int fd, char *DISC_rec) {
char flag_ST;
int option = START;
while(!(STOP_DISC)){
read(fd, &flag_ST, 1);
int flag = getFlag();
if(flag && flag != -1){
alarm(0);
setFlag(-1);
STOP_DISC = TRUE;
}
switch (option){
case START:
if (flag_ST == F){
option = FLAG_RCV;
DISC_rec[0] = flag_ST;
}
else
option = START;
break;
case FLAG_RCV:
if (flag_ST == F) {
option = FLAG_RCV;
DISC_rec[0] = flag_ST;
}
else if (flag_ST == A){
option = A_RCV;
DISC_rec[1] = flag_ST;
}
else
option = START;
break;
case A_RCV:
if (flag_ST == F){
option = FLAG_RCV;
DISC_rec[0] = flag_ST;
}
else if (flag_ST == C_DISC){
option = C_RCV;
DISC_rec[2] = flag_ST;
}
else
option = START;
break;
case C_RCV:
if (flag_ST == F){
option = FLAG_RCV;
DISC_rec[0] = flag_ST;
}
else if (flag_ST == BCC_DISC){
option = BCC_OK;
DISC_rec[3] = flag_ST;
}
else
option = START;
break;
case BCC_OK:
if (flag_ST == F){
option = STOP_ST;
STOP_DISC = TRUE;
DISC_rec[4] = flag_ST;
}
else
option = START;
break;
case STOP_ST:
STOP_DISC = TRUE;
break;
default:
break;
}
}
}
开发者ID:tomislaaaav,项目名称:RCOM_Proj1,代码行数:83,代码来源:state.c
示例19: ledptn
/*
Descrition: To display different LED patterns accroding to input
Inut: 1, 2, 3, 4
Outut: None
*/
void ledptn(unsigned char pattern)
{
if (pattern == 1)
{
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x01); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x02); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x04); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x08); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x10); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x20); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x40); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x80); delayms(DELAY_TIME);}
}
else if (pattern == 2)
{
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x80); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x40); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x20); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x10); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x08); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x04); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x02); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x01); delayms(DELAY_TIME);}
}
else if (pattern == 3)
{
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x81); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x42); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x24); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x18); delayms(DELAY_TIME);}
setFlag();
}
else if (pattern == 4)
{
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x18); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x24); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x42); delayms(DELAY_TIME);}
setFlag();
if (chkFlag() == 0) { PORT_LED=led(0x81); delayms(DELAY_TIME);}
setFlag();
}
} /* ledptn */
开发者ID:WowFunHouse,项目名称:Wow_TestBench,代码行数:71,代码来源:led_B003.c
示例20: receive_UA
void receive_UA(int fd, char *UA) {
int option = START;
char flag_ST;
while(!(STOP_UA)) {
//fprintf(stderr, "flag %d\n", getFlag());
read(fd, &flag_ST, 1);
int flag = getFlag();
//fprintf(stderr, "option %d, flag_ST %x flag %d\n",option, flag_ST,flag);
if(flag && flag != -1){
alarm(0);
setFlag(-1);
STOP_UA = TRUE;
}
switch (option){
case START:
if (flag_ST == F){
option = FLAG_RCV;
UA[0] = flag_ST;
}
else
option = START;
break;
case FLAG_RCV:
if (flag_ST == F){
option = FLAG_RCV;
UA[0] = flag_ST;
}
else if (flag_ST == A){
option = A_RCV;
UA[1] = flag_ST;
}
else
option = START;
break;
case A_RCV:
if (flag_ST == F){
option = FLAG_RCV;
UA[0] = flag_ST;
}
else if (flag_ST == C_UA){
option = C_RCV;
UA[2] = flag_ST;
}
else
option = START;
break;
case C_RCV:
if (flag_ST == F){
option = FLAG_RCV;
UA[0] = flag_ST;
}
else if (flag_ST == BCC_UA){
option = BCC_OK;
UA[3] = flag_ST;
}
else
option = START;
break;
case BCC_OK:
if (flag_ST == F){
option = STOP_ST;
STOP_UA = TRUE;
UA[4] = flag_ST;
}
else
option = START;
break;
case STOP_ST:
STOP_UA = TRUE;
break;
default:
break;
}
}
}
开发者ID:tomislaaaav,项目名称:RCOM_Proj1,代码行数:84,代码来源:state.c
注:本文中的setFlag函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论