コード例 #1
0
void SymbolDataEditor::mousePressEvent(QMouseEvent *event)
{
    //drag the scene by middle mouse button
    if (event->button() == Qt::MidButton)
    {
        QMouseEvent fake(event->type(), event->pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers());
        QGraphicsView::mousePressEvent(&fake);

        while (QApplication::overrideCursor() != nullptr)
            QApplication::restoreOverrideCursor();

        return;
    }

    //move current item by left mouse button
    if (event->button() == Qt::LeftButton)
    {
        moveItem(event->pos());
        QMouseEvent fake(event->type(), event->pos(), Qt::MidButton, Qt::MidButton, event->modifiers());
        QGraphicsView::mousePressEvent(&fake);
        return;
    }

    QGraphicsView::mousePressEvent(event);
}
コード例 #2
0
POINTER smalloc_malloc P1(size_t, size)
#endif
{
    /* int i; */
    u *temp;

    DEBUG_CHECK(size == 0, "Malloc size 0.\n");
    if (size > SMALL_BLOCK_MAX_BYTES)
	return large_malloc(size, 0);

#if SIZEOF_PTR > SIZEOF_INT
    if (size < SIZEOF_PTR)
	size = SIZEOF_PTR;
#endif

    size = (size + 7) & ~3;	/* block size in bytes */
#define SIZE_INDEX(u_array, size) 	(*(u*) ((char*)u_array-8+size))
#define SIZE_PNT_INDEX(u_array, size)	(*(u**)((char*)u_array-8+size))
    /* i = (size - 8) >> 2; */
    count_up(small_alloc_stat, size);

    SIZE_INDEX(small_count, size) += 1;	/* update statistics */
    SIZE_INDEX(small_total, size) += 1;
    if (SIZE_INDEX(small_count, size) > SIZE_INDEX(small_max, size))
	SIZE_INDEX(small_max, size) = SIZE_INDEX(small_count, size);

    if (temp = SIZE_PNT_INDEX(sfltable, size)) {	/* allocate from the
							 * free list */
	count_back(small_free_stat, size);
	temp++;
	SIZE_PNT_INDEX(sfltable, size) = *(u **) temp;
	fake("From free list.");
	return (char *) temp;
    }				/* else allocate from the chunk */
    if (unused_size < size) {	/* no room in chunk, get another */
	/*
	 * don't waste this smaller block
	 */
	if (unused_size) {
	    count_up(small_free_stat, unused_size);
	    *s_size_ptr(next_unused) = unused_size >> 2;
	    *s_next_ptr(next_unused) = SIZE_PNT_INDEX(sfltable, unused_size);
	    SIZE_PNT_INDEX(sfltable, unused_size) = next_unused;
	}

	fake("Allocating new small chunk.");
	next_unused = (u *) large_malloc(SMALL_CHUNK_SIZE + SIZEOF_PTR, 1);
	if (next_unused == 0)
	    return 0;
	
	*next_unused = (u) last_small_chunk;
	last_small_chunk = next_unused++;
	count_up(small_chunk_stat, SMALL_CHUNK_SIZE + SIZEOF_PTR);
	unused_size = SMALL_CHUNK_SIZE;
    } else
コード例 #3
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
/* in response to a TOPIC message from the server */
static void p_topic(char *from, char **ArgList)
{
    struct channel *tmp;

    if (!ArgList[1]) {
	fake();
	return;
    }
    tmp = lookup_channel(ArgList[0], from_server, CHAN_NOUNLINK);
    malloc_strcpy(&tmp->topic, ArgList[1]);
    if (check_ignore(from, FromUserHost, tmp->channel, IGNORE_TOPICS | IGNORE_CRAP, NULL) != IGNORED) {
	message_from(ArgList[0], LOG_CRAP);
	if (do_hook(TOPIC_LIST, "%s %s %s", from, ArgList[0], ArgList[1])) {
	    if (ArgList[1] && *ArgList[1]) {
		if (get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET))
		    put_it("%s",
			   convert_output_format(get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET), "%s %s %s %s", update_clock(GET_TIME),
						 from, ArgList[0], ArgList[1]));
		put_it("%s",
		       convert_output_format(get_format(FORMAT_TOPIC_CHANGE_FSET), "%s %s %s %s", update_clock(GET_TIME), from,
					     ArgList[0], ArgList[1]));
	    } else
		put_it("%s",
		       convert_output_format(get_format(FORMAT_TOPIC_UNSET_FSET), "%s %s %s", update_clock(GET_TIME), from,
					     ArgList[0]));
	}

	message_from(NULL, LOG_CRAP);
    }
    update_all_status(curr_scr_win, NULL, 0);
}
コード例 #4
0
ファイル: room.c プロジェクト: oitofelix/mininim
void
draw_confg_top (ALLEGRO_BITMAP *bitmap, struct pos *p,
                enum em em, enum vm vm)
{
  switch (fake (p)) {
  case NO_FLOOR: return;
  case FLOOR: return;
  case BROKEN_FLOOR: return;
  case SKELETON_FLOOR: return;
  case LOOSE_FLOOR: return;
  case SPIKES_FLOOR: return;
  case OPENER_FLOOR: return;
  case CLOSER_FLOOR: return;
  case STUCK_FLOOR: return;
  case HIDDEN_FLOOR: return;
  case PILLAR: draw_pillar_top (bitmap, p, em, vm); break;
  case BIG_PILLAR_BOTTOM: return;
  case BIG_PILLAR_TOP: draw_big_pillar_top_top (bitmap, p, em, vm); break;
  case WALL: draw_wall_top (bitmap, p, em, vm); break;
  case DOOR: draw_door_top (bitmap, p, em, vm); break;
  case LEVEL_DOOR: return;
  case CHOPPER: return;
  case ARCH_BOTTOM: return;
  case ARCH_TOP_MID: return;
  case ARCH_TOP_SMALL: return;
  case ARCH_TOP_LEFT: return;
  case ARCH_TOP_RIGHT: return;
  case CARPET: draw_carpet_top (bitmap, p, FULL_WIDTH, em, vm); break;
  case TCARPET: draw_carpet_top (bitmap, p, FULL_WIDTH, em, vm); break;
  case MIRROR: return;
  default: assert (false); break;
  }
}
コード例 #5
0
ファイル: room.c プロジェクト: oitofelix/mininim
void
draw_confg_right (ALLEGRO_BITMAP *bitmap, struct pos *p,
                  enum em em, enum vm vm)
{
  switch (fake (p)) {
  case NO_FLOOR: return;
  case FLOOR: draw_floor_right (bitmap, p, em, vm); break;
  case BROKEN_FLOOR: draw_broken_floor_right (bitmap, p, em, vm); break;
  case SKELETON_FLOOR: draw_skeleton_floor_right (bitmap, p, em, vm); break;
  case LOOSE_FLOOR: draw_loose_floor_right (bitmap, p, em, vm); break;
  case SPIKES_FLOOR: draw_spikes_floor_right (bitmap, p, em, vm); break;
  case OPENER_FLOOR: draw_opener_floor_right (bitmap, p, em, vm); break;
  case CLOSER_FLOOR: draw_closer_floor_right (bitmap, p, em, vm); break;
  case STUCK_FLOOR: draw_pressed_closer_floor_right (bitmap, p, em, vm); break;
  case HIDDEN_FLOOR: return;
  case PILLAR: draw_pillar_right (bitmap, p, em, vm); break;
  case BIG_PILLAR_BOTTOM:
    draw_big_pillar_bottom_right (bitmap, p, em, vm); break;
  case BIG_PILLAR_TOP:
    draw_big_pillar_top_right (bitmap, p, em, vm); break;
  case WALL: draw_wall_right (bitmap, p, em, vm); break;
  case DOOR: draw_door_right (bitmap, p, em, vm); break;
  case LEVEL_DOOR: draw_level_door_right (bitmap, p, em, vm); break;
  case CHOPPER: draw_floor_right (bitmap, p, em, vm); break;
  case ARCH_BOTTOM: draw_floor_right (bitmap, p, em, vm); break;
  case ARCH_TOP_MID: return;
  case ARCH_TOP_SMALL: return;
  case ARCH_TOP_LEFT: return;
  case ARCH_TOP_RIGHT: return;
  case CARPET: draw_carpet_right (bitmap, p, FULL_WIDTH, em, vm); break;
  case TCARPET: draw_carpet_right (bitmap, p, FULL_WIDTH, em, vm); break;
  case MIRROR: draw_floor_right (bitmap, p, em, vm); break;
  default: assert (false); break;
  }
}
コード例 #6
0
ファイル: EigenProblemsTest.cpp プロジェクト: xhub/siconos
void EigenProblemsTest::testGeev1()
{
  std::cout << "--> Test: geev1." <<std::endl;
  // Compute only right eigenvectors.
  complex_matrix fake(1,1), rightV(size,size);
  complex_vector eigenval(size);
  Siconos::eigenproblems::geev(*A, eigenval, fake, rightV);
  complex_vector error(size);
  for( unsigned int i = 0; i < size; ++i ) error(i) = 0.0;
  for( unsigned int i = 0; i < size; ++i )
  {
    error.plus_assign(ublas::prod(*A->dense(), column(rightV, i) ));
    error.minus_assign(eigenval(i)*column(rightV,i));
  }

  // Check ...
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testGeev1 1: ", norm_2(error) < 10 * std::numeric_limits< double >::epsilon() , true);
  // Check if A has not been modified
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testGeev1 2: ", (*A) == (*Aref) , true);
  // Now compute only eigenvalues 
  complex_vector RefEigenValues(size);
  RefEigenValues = eigenval;
  eigenval *= 0.0;
  Siconos::eigenproblems::geev(*A, eigenval, fake, fake, false, false);
  
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testGeev1 3: ", norm_2(eigenval - RefEigenValues) < 10 * std::numeric_limits< double >::epsilon() , true);
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testGeev1 4: ", (*A) == (*Aref) , true);

  std::cout << "--> geev1 test ended with success." <<std::endl;
}
コード例 #7
0
QScriptValue PHIBaseItem::trigger( const QString &name, const QScriptValue &args, PHIDomEvent *de )
{
    if ( !isClientItem() ) return self();
    if ( name==SL( "drop" ) && !de ) return self(); // drop can not be triggered manually
    PHIEventHash hash=data( DEventFunctions ).value<PHIEventHash>();
    QScriptValueList functions=hash.values( name );
    PHIDomEvent fake( name, this );
    QScriptValue event, fn, res ;
    if ( de ) event=de->self();
    else event=eventToScriptValue( scriptEngine(), &fake );
    foreach ( fn, functions ) {
        if ( fn.isFunction() ) {
            res=fn.call( self(), QScriptValueList() << event << args );
        } else if ( fn.isString() ) res=scriptEngine()->evaluate( fn.toString() );
        if ( res.isError() ) {
            emit javaScriptError( res );
            qDebug() << res.toString();
        } else if ( de && res.isBool() ) if ( res.toBool()==false ) de->preventDefault();
    }
    hash=data( DOneEventFunctions ).value<PHIEventHash>();
    functions=hash.values( name );
    foreach( fn, functions ) {
        if ( fn.isFunction() ) {
            res=fn.call( self(), QScriptValueList() << event << args );
        } else if ( fn.isString() ) res=scriptEngine()->evaluate( fn.toString() );
        if ( res.isError() ) {
            emit javaScriptError( res );
            qDebug() << res.toString();
        } else if ( de && res.isBool() ) if ( res.toBool()==false ) de->preventDefault();
    }
    hash.remove( name );
    setData( DOneEventFunctions, qVariantFromValue( hash ) );
    return self();
}
コード例 #8
0
ファイル: CheatSearchTab.cpp プロジェクト: OrN/dolphin
void CheatSearchTab::OnListViewItemActivated(wxListEvent&)
{
  if (!m_btn_create_code->IsEnabled())
    return;

  wxCommandEvent fake(wxEVT_BUTTON, m_btn_create_code->GetId());
  m_btn_create_code->GetEventHandler()->ProcessEvent(fake);
}
コード例 #9
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
static void p_error(char *from, char **ArgList)
{

    PasteArgs(ArgList, 0);
    if (!ArgList[0]) {
	fake();
	return;
    }
    say("%s", ArgList[0]);
}
コード例 #10
0
ファイル: umlview.cpp プロジェクト: Nephos/umbrello
/**
 * Override standard method.
 */
void UMLView::mousePressEvent(QMouseEvent* event)
{
    if (event->button() == Qt::MidButton) {
        setDragMode(QGraphicsView::ScrollHandDrag);
        setInteractive(false);
        QMouseEvent fake(event->type(), event->pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers());
        QGraphicsView::mousePressEvent(&fake);
    } else
        QGraphicsView::mousePressEvent(event);
}
コード例 #11
0
ファイル: umlview.cpp プロジェクト: Nephos/umbrello
/**
 * Override standard method.
 */
void UMLView::mouseReleaseEvent(QMouseEvent* event)
{
    if (event->button() == Qt::MidButton) {
        QMouseEvent fake(event->type(), event->pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers());
        QGraphicsView::mouseReleaseEvent(&fake);
        setInteractive(true);
        setDragMode(QGraphicsView::NoDrag);
    } else
        QGraphicsView::mouseReleaseEvent(event);
}
コード例 #12
0
ファイル: room.c プロジェクト: oitofelix/mininim
void
draw_confg_left (ALLEGRO_BITMAP *bitmap, struct pos *p,
                 enum em em, enum vm vm)
{
  enum carpet_design d;

  switch (fake (p)) {
  case NO_FLOOR: return;
  case FLOOR: draw_floor_left (bitmap, p, em, vm); break;
  case BROKEN_FLOOR: draw_broken_floor_left (bitmap, p, em, vm); break;
  case SKELETON_FLOOR: draw_skeleton_floor_left (bitmap, p, em, vm); break;
  case LOOSE_FLOOR: draw_loose_floor_left (bitmap, p, em, vm); break;
  case SPIKES_FLOOR: draw_spikes_floor_left (bitmap, p, em, vm); break;
  case OPENER_FLOOR: draw_opener_floor_left (bitmap, p, em, vm); break;
  case CLOSER_FLOOR: draw_closer_floor_left (bitmap, p, em, vm); break;
  case STUCK_FLOOR: draw_pressed_closer_floor_left (bitmap, p, em, vm); break;
  case HIDDEN_FLOOR: return;
  case PILLAR: draw_pillar_left (bitmap, p, em, vm); break;
  case BIG_PILLAR_BOTTOM:
    draw_big_pillar_bottom_left (bitmap, p, em, vm); break;
  case BIG_PILLAR_TOP:
    draw_big_pillar_top_left (bitmap, p, em, vm); break;
  case WALL:
    if (con_caching) draw_wall_left (bitmap, p, em, vm);
    else draw_wall_left_cache (bitmap, p);
    break;
  case DOOR: draw_door_left (bitmap, p, em, vm); break;
  case LEVEL_DOOR: draw_level_door_left (bitmap, p, em, vm); break;
  case CHOPPER: draw_chopper_left (bitmap, p, em, vm); break;
  case ARCH_BOTTOM:
    draw_floor_left (bitmap, p, em, vm);
    draw_arch_bottom (bitmap, p, em, vm); break;
  case ARCH_TOP_MID: draw_arch_top_mid (bitmap, p, em, vm); break;
  case ARCH_TOP_SMALL: draw_arch_top_small (bitmap, p, em, vm); break;
  case ARCH_TOP_LEFT: draw_arch_top_left (bitmap, p, em, vm); break;
  case ARCH_TOP_RIGHT: draw_arch_top_right (bitmap, p, em, vm); break;
  case CARPET:
    draw_floor_left (bitmap, p, em, vm);
    draw_door_pole (bitmap, p, em, vm);
    break;
  case TCARPET:
    d = ext (p);
    if (d == ARCH_CARPET_RIGHT_00 || d == ARCH_CARPET_RIGHT_01)
      draw_arch_top_right_end (bitmap, p, em, vm);
    else draw_door_pole (bitmap, p, em, vm);
    break;
  case MIRROR:
    draw_floor_left (bitmap, p, em, vm);
    draw_mirror (bitmap, p, em, vm);
    break;
  default: assert (false); break;
  }
}
コード例 #13
0
ファイル: fmu.cpp プロジェクト: tpetri/rgb_cube
int
fmu_main(int argc, char *argv[])
{
	PortMode new_mode = PORT_MODE_UNSET;

	if (!strcmp(argv[1], "test"))
		test();

	if (!strcmp(argv[1], "fake"))
		fake(argc - 1, argv + 1);

	/*
	 * Mode switches.
	 *
	 * XXX use getopt?
	 */
	if (!strcmp(argv[1], "mode_gpio")) {
		new_mode = PORT_FULL_GPIO;

	} else if (!strcmp(argv[1], "mode_serial")) {
		new_mode = PORT_FULL_SERIAL;

	} else if (!strcmp(argv[1], "mode_pwm")) {
		new_mode = PORT_FULL_PWM;

	} else if (!strcmp(argv[1], "mode_gpio_serial")) {
		new_mode = PORT_GPIO_AND_SERIAL;

	} else if (!strcmp(argv[1], "mode_pwm_serial")) {
		new_mode = PORT_PWM_AND_SERIAL;

	} else if (!strcmp(argv[1], "mode_pwm_gpio")) {
		new_mode = PORT_PWM_AND_GPIO;
	}

	/* was a new mode set? */
	if (new_mode != PORT_MODE_UNSET) {

		/* yes but it's the same mode */
		if (new_mode == g_port_mode)
			return OK;

		/* switch modes */
		return fmu_new_mode(new_mode);
	}

	/* test, etc. here */

	fprintf(stderr, "FMU: unrecognised command, try:\n");
	fprintf(stderr, "  mode_gpio, mode_serial, mode_pwm, mode_gpio_serial, mode_pwm_serial, mode_pwm_gpio\n");
	return -EINVAL;
}
コード例 #14
0
ファイル: main.cpp プロジェクト: da-eto-ya/crypto-exercises
int main() {
    std::string iv_str, message_str, fake_str;

    std::getline(std::cin, iv_str);
    std::getline(std::cin, message_str);
    std::getline(std::cin, fake_str);

    uint8_vec iv = hex_to_codes(iv_str);
    uint8_vec m(message_str.begin(), message_str.end());
    uint8_vec fake(fake_str.begin(), fake_str.end());

    std::cout << codes_to_hex(xor_vec(iv, xor_vec(m, fake))) << std::endl;

    return 0;
}
コード例 #15
0
void SymbolDataEditor::mouseReleaseEvent(QMouseEvent *event)
{
    rememberChanges();

    if (event->button() == Qt::MidButton)
    {
        QMouseEvent fake(event->type(), event->pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers());
        QGraphicsView::mouseReleaseEvent(&fake);

        if (QApplication::overrideCursor() == nullptr)
            changeCursor();
    }
    else
        QGraphicsView::mouseReleaseEvent(event);
}
コード例 #16
0
ファイル: pointer.c プロジェクト: oitofelix/mininim
struct pos *
get_mouse_pos (struct pos *p)
{
  struct mouse_coord m;
  get_mouse_coord (&m);

  if (! is_valid_coord (&m.c)) {
    invalid_pos (p);
    return p;
  }

  int ry = (m.c.y - 3) % PLACE_HEIGHT;

  pos_gen (&m.c, p, 0, 3);

  if (edit == EDIT_NONE) {
    invalid_pos (p);
    return p;
  }

  struct pos p0;

  switch (fake (p)) {
  case MIRROR: case CHOPPER:
  case WALL: case PILLAR: case BIG_PILLAR_TOP:
  case BIG_PILLAR_BOTTOM: case ARCH_BOTTOM:
  case ARCH_TOP_MID: case ARCH_TOP_SMALL:
  case ARCH_TOP_LEFT: case ARCH_TOP_RIGHT: break;
  default:
    if (is_arch_top (prel (p, &p0, +0, -1)))
      break;
    if (ry >= 60) pos_gen (&m.c, p, 0, 3);
    else if (ry >= 50) pos_gen (&m.c, p, 23 - 2.5 * (ry - 50), 3);
    else pos_gen (&m.c, p, 23, 3);
    break;
  }

  struct pos np; npos (p, &np);
  if (! np.room) {
    invalid_pos (p);
    return p;
  }

  return p;
}
コード例 #17
0
ファイル: multi-room.c プロジェクト: oitofelix/mininim
void
draw_animated_background (ALLEGRO_BITMAP *bitmap, int room)
{
  room_view = room;

  struct pos p; new_pos (&p, &global_level, room, -1, -1);

  for (p.floor = FLOORS; p.floor >= 0; p.floor--)
    for (p.place = -1; p.place < PLACES; p.place++)
      draw_no_floor_selection (bitmap, &p);

  for (p.floor = FLOORS; p.floor >= -1; p.floor--)
    for (p.place = -1; p.place < PLACES; p.place++) {
      if (fake (&p) == WALL) continue;
      draw_fire (bitmap, &p, vm);
      draw_balcony_stars (bitmap, &p, vm);
    }
}
コード例 #18
0
ファイル: coins.cpp プロジェクト: bankonme/zerocash
// Zerocoin changes
CCoinsImmuntable MakeFakeZerocoinCCoin(){
    CTransaction dummy;
    {
    CScript scriptPubKey;
    scriptPubKey.clear();
    scriptPubKey << FLAG_ZC_POUR;
    CTxOut out(0,scriptPubKey);
    dummy.vout.push_back(out);
    }
    {
     CScript scriptPubKey;
     scriptPubKey.clear();
     scriptPubKey << FLAG_ZC_MINT;
     CTxOut out(1,scriptPubKey);
     dummy.vout.push_back(out);
    }
    CCoinsImmuntable fake(dummy);
    return fake;
}
コード例 #19
0
void TestRTFAnnotation::TestWriteNoChrfmt()
{
	ComparisonContext cContext;
	RTFFileContext context;
	RTFAnnotation annot(&context);
	FakeRTFWriter2 fake(&context);

	annot.m_bChrfmtFound = true;
	annot.Write(&fake);
	//assertMessage(fake.m_iEndGroupCount==0, _T("Write does nothing now - annotations are not written"));

	annot.m_bChrfmtFound = false;
	fake.m_iEndGroupCount=0;
//	fake.StartAnnot();
	
	annot.Write(&fake);
	//assertTest(fake.m_iEndGroupCount==0);
	
}
コード例 #20
0
ファイル: EigenProblemsTest.cpp プロジェクト: xhub/siconos
void EigenProblemsTest::testGeev2()
{
  std::cout << "--> Test: geev2." <<std::endl;
  // Compute only left eigenvectors.
  complex_matrix fake(1,1), leftV(size,size);
  complex_vector eigenval(size);
  Siconos::eigenproblems::geev(*A, eigenval, leftV, fake, true, false);
  complex_vector error(size);
  for( unsigned int i = 0; i < size; ++i ) error(i) = 0.0;
  for( unsigned int i = 0; i < size; ++i )
  {
    error.plus_assign(ublas::prod(conj(column(leftV, i)), *A->dense() ));
    error.minus_assign(eigenval(i)*conj(column(leftV,i)));
  }
  // Check ...
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testGeev2 1: ", norm_2(error) < 10 * std::numeric_limits< double >::epsilon() , true);
  // Check if A has not been modified
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testGeev2 2: ", (*A) == (*Aref) , true);

  std::cout << "--> geev1 test ended with success." <<std::endl;
}
コード例 #21
0
ファイル: room.c プロジェクト: oitofelix/mininim
void
draw_conbg (ALLEGRO_BITMAP *bitmap, struct pos *p,
            enum em em, enum vm vm)
{
  switch (bg (p)) {
  case NO_BG:
    if (em == PALACE) draw_bricks_02 (bitmap, p, em, vm);
    break;
  case BRICKS_00: draw_bricks_00 (bitmap, p, em, vm); break;
  case BRICKS_01: draw_bricks_01 (bitmap, p, em, vm); break;
  case BRICKS_02: draw_bricks_02 (bitmap, p, em, vm); break;
  case BRICKS_03: draw_bricks_03 (bitmap, p, em, vm); break;
  case NO_BRICKS: break;
  case TORCH: draw_torch (bitmap, p, em, vm); break;
  case WINDOW: draw_window (bitmap, p, em, vm); break;
  case BALCONY: draw_balcony (bitmap, p, em, vm); break;
  default: assert (false); break;
  }

  if (fake (p) == LEVEL_DOOR)
    draw_level_door (bitmap, p, em, vm);
}
コード例 #22
0
ファイル: room.c プロジェクト: oitofelix/mininim
void
draw_confg_fg (ALLEGRO_BITMAP *bitmap, struct pos *p,
               enum em em, enum vm vm, struct frame *f)
{
  switch (fake (p)) {
  case NO_FLOOR: return;
  case FLOOR: return;
  case BROKEN_FLOOR: draw_broken_floor_fg (bitmap, p, em, vm); break;
  case SKELETON_FLOOR: return;
  case LOOSE_FLOOR: return;
  case SPIKES_FLOOR: draw_spikes_fg (bitmap, p, em, vm); break;
  case OPENER_FLOOR: draw_opener_floor_fg (bitmap, p, em, vm); break;
  case CLOSER_FLOOR: draw_closer_floor_fg (bitmap, p, em, vm); break;
  case STUCK_FLOOR: return;
  case HIDDEN_FLOOR: return;
  case PILLAR: draw_pillar_fg (bitmap, p, em, vm); break;
  case BIG_PILLAR_BOTTOM:
    draw_big_pillar_bottom_fg (bitmap, p, em, vm); break;
  case BIG_PILLAR_TOP:
    draw_big_pillar_top_left (bitmap, p, em, vm); break;
  case WALL: draw_wall_fg (bitmap, p, f, em, vm); break;
  case DOOR: draw_door_fg (bitmap, p, f, em, vm); break;
  case LEVEL_DOOR: break;
  case CHOPPER: draw_chopper_fg (bitmap, p, em, vm); break;
  case ARCH_BOTTOM: draw_arch_bottom_fg (bitmap, p, em, vm);
    break;
  case ARCH_TOP_MID: draw_arch_top_mid (bitmap, p, em, vm); break;
  case ARCH_TOP_SMALL: draw_arch_top_small (bitmap, p, em, vm); break;
  case ARCH_TOP_LEFT: draw_arch_top_left (bitmap, p, em, vm); break;
  case ARCH_TOP_RIGHT: draw_arch_top_right (bitmap, p, em, vm); break;
  case CARPET: draw_carpet_fg (bitmap, p, f, em, vm); break;
  case TCARPET:
    draw_door_pole_base (bitmap, p, em, vm);
    draw_carpet_fg (bitmap, p, f, em, vm); break;
  case MIRROR: draw_mirror_fg (bitmap, p, f, em, vm); break;
  default: assert (false); break;
  }
}
コード例 #23
0
ファイル: room.c プロジェクト: oitofelix/mininim
void
draw_confg_base (ALLEGRO_BITMAP *bitmap, struct pos *p,
                 enum em em, enum vm vm)
{
  switch (fake (p)) {
  case NO_FLOOR: return;
  case FLOOR: draw_floor_base (bitmap, p, em, vm); break;
  case BROKEN_FLOOR: draw_floor_base (bitmap, p, em, vm); break;
  case SKELETON_FLOOR: draw_floor_base (bitmap, p, em, vm); break;
  case LOOSE_FLOOR: draw_loose_floor_base (bitmap, p, em, vm); break;
  case SPIKES_FLOOR: draw_floor_base (bitmap, p, em, vm); break;
  case OPENER_FLOOR: draw_opener_floor_base (bitmap, p, em, vm); break;
  case CLOSER_FLOOR: draw_closer_floor_base (bitmap, p, em, vm); break;
  case STUCK_FLOOR: draw_pressed_closer_floor_base (bitmap, p, em, vm); break;
  case HIDDEN_FLOOR: return;
  case PILLAR: draw_floor_base (bitmap, p, em, vm); break;
  case BIG_PILLAR_BOTTOM: draw_floor_base (bitmap, p, em, vm); break;
  case BIG_PILLAR_TOP: return;
  case WALL:
    if (con_caching) draw_wall_base (bitmap, p, em, vm);
    else draw_wall_base_cache (bitmap, p);
    break;
  case DOOR: draw_floor_base (bitmap, p, em, vm); break;
  case LEVEL_DOOR: draw_floor_base (bitmap, p, em, vm); break;
  case CHOPPER: draw_floor_base (bitmap, p, em, vm); break;
  case ARCH_BOTTOM: draw_floor_base (bitmap, p, em, vm); break;
  case ARCH_TOP_MID: return;
  case ARCH_TOP_SMALL: return;
  case ARCH_TOP_LEFT: return;
  case ARCH_TOP_RIGHT: return;
  case CARPET: draw_floor_base (bitmap, p, em, vm); break;
  case TCARPET: draw_door_pole_base (bitmap, p, em, vm); break;
  case MIRROR: draw_floor_base (bitmap, p, em, vm); break;
  default: assert (false); break;
  }
}
コード例 #24
0
ファイル: parse.c プロジェクト: Nicholas-S/xaric
static void p_wallops(char *from, char **ArgList)
{
    char *line;
    int from_server = strchr(from, '.') ? 1 : 0;

    if (!(line = PasteArgs(ArgList, 0))) {
	fake();
	return;
    }

    if (from_server || check_flooding(from, WALLOP_FLOOD, line, NULL)) {
	/* The old server check, don't use the whois stuff for servers */
	int level;
	char *high;

	switch (check_ignore(from, FromUserHost, NULL, IGNORE_WALLOPS, NULL)) {
	case (IGNORED):
	    return;
	case (HIGHLIGHTED):
	    high = highlight_char;
	    break;
	default:
	    high = empty_str;
	    break;
	}
	message_from(from, LOG_WALLOP);
	level = set_lastlog_msg_level(LOG_WALLOP);
	if (do_hook(WALLOP_LIST, "%s %c %s", from, from_server ? 'S' : '*', line))
	    put_it("%s", convert_output_format(get_format(from_server ? FORMAT_WALLOP_FSET : FORMAT_WALL_FSET),
					       "%s %s %s %s", update_clock(GET_TIME), from, from_server ? "!" : "*", line));
	if (beep_on_level & LOG_WALLOP)
	    beep_em(1);
	set_lastlog_msg_level(level);
	message_from(NULL, LOG_CRAP);
    }
}
コード例 #25
0
ファイル: qdockwidget.cpp プロジェクト: phen89/rtqt
/*! \reimp */
bool QDockWidget::event(QEvent *event)
{
    Q_D(QDockWidget);

    QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
    QMainWindowLayout *layout = qt_mainwindow_layout(win);

    switch (event->type()) {
#ifndef QT_NO_ACTION
    case QEvent::Hide:
        if (layout != 0)
            layout->keepSize(this);
        d->toggleViewAction->setChecked(false);
        emit visibilityChanged(false);
        break;
    case QEvent::Show:
        d->toggleViewAction->setChecked(true);
        emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
        break;
#endif
    case QEvent::ApplicationLayoutDirectionChange:
    case QEvent::LayoutDirectionChange:
    case QEvent::StyleChange:
    case QEvent::ParentChange:
        d->updateButtons();
        break;
    case QEvent::ZOrderChange: {
        bool onTop = false;
        if (win != 0) {
            const QObjectList &siblings = win->children();
            onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
        }
        if (!isFloating() && layout != 0 && onTop)
            layout->raise(this);
        break;
    }
    case QEvent::WindowActivate:
    case QEvent::WindowDeactivate:
        update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea());
        break;
    case QEvent::ContextMenu:
        if (d->state) {
            event->accept();
            return true;
        }
        break;
        // return true after calling the handler since we don't want
        // them to be passed onto the default handlers
    case QEvent::MouseButtonPress:
        if (d->mousePressEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::MouseButtonDblClick:
        if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::MouseMove:
        if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
#ifdef Q_OS_WIN
    case QEvent::Leave:
        if (d->state != 0 && d->state->dragging && !d->state->nca) {
            // This is a workaround for loosing the mouse on Vista.
            QPoint pos = QCursor::pos();
            QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton,
                             QApplication::mouseButtons(), QApplication::keyboardModifiers());
            d->mouseMoveEvent(&fake);
        }
        break;
#endif
    case QEvent::MouseButtonRelease:
        if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
            return true;
        break;
    case QEvent::NonClientAreaMouseMove:
    case QEvent::NonClientAreaMouseButtonPress:
    case QEvent::NonClientAreaMouseButtonRelease:
    case QEvent::NonClientAreaMouseButtonDblClick:
        d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
        return true;
    case QEvent::Move:
        d->moveEvent(static_cast<QMoveEvent*>(event));
        break;
    case QEvent::Resize:
        // if the mainwindow is plugging us, we don't want to update undocked geometry
        if (isFloating() && layout != 0 && layout->pluggingWidget != this)
            d->undockedGeometry = geometry();
        break;
    default:
        break;
    }
    return QWidget::event(event);
}
コード例 #26
0
ファイル: listspawn.cpp プロジェクト: brainiac/showeq
int main (int argc, char *argv[])
{
	FILE *sdb;
	struct dbSpawnStruct dbSpawn;
	int counter=0;

	// CGI Convenience class
	CGI cgiconv;

	// search variables
	QString searchName = "";
	QString searchZone = "";
	int searchLevel = 0;
	QString searchRace = "";
	int searchClass = 0;

	// are we performing a serch (default = false)
	bool doSearch = false;

	// process any CGI data
	cgiconv.processCGIData();

	// If there are form parameters use them for searching
	if (cgiconv.getParamCount() != 0)
	{
		searchName = cgiconv.getParamValue("name");
		searchZone = cgiconv.getParamValue("zone");
		searchLevel = cgiconv.getParamValue("level").toInt();
		searchRace = cgiconv.getParamValue("race");
		searchClass = cgiconv.getParamValue("class").toInt();

		if (!searchName.isEmpty() || !searchZone.isEmpty() ||
			!searchRace.isEmpty() ||
			(searchLevel != 0) || (searchClass != 0))
			doSearch = true;
	}
	else if (argc == 2)
	{
		// use the argument for the name search
		searchName = argv[1];

		// note that a search is being done.
		doSearch = true;
	}

	// open the output data stream
	Q3TextStream out(stdout, QIODevice::WriteOnly);
	out.setEncoding(Q3TextStream::Latin1);
	out.flags(Q3TextStream::showbase | Q3TextStream::dec);

	const char* header =
		"Content-type: text/html; charset=iso-8859-1\n\n"
		"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n"
		"<HTML>\n"
		"  <HEAD>\n"
		"    <TITLE>ShowEQ Spawn List</TITLE>\n"
		"    <style type=\"text/css\">\n"
		"      <!--\n"
		"          table { border: black 2px solid }\n"
		"          td { border: black 1px solid }\n"
		"          th { border: black 1px solid }\n"
		"      -->\n"
		"    </style>\n"
		"  </HEAD>\n"
		"  <BODY>\n";

	/* Print HTML header */
	out << header;

	const char* footer =
		"  </BODY>\n"
		"</HTML>\n";

	// check for browser type
	QString userAgent = cgiconv.getHTTPUserAgent();
	out << "    <!-- Output for UserAgent: " << userAgent << "-->\n";


	out << "<FORM method=\"POST\" action=\"" << cgiconv.getScriptName()
		<< "\">\n";

	// beware Netscape 4.x style sheet brain death
	if ((userAgent.contains("Mozilla/4.") == 1) &&
		(userAgent.contains("MSIE") == 0))
		out << "<TABLE border=2 cellspacing=0 cellpadding=2>\n";
	else
		out << "<TABLE cellspacing=0 cellpadding=2>\n";

	out <<
		"<TR>"
		"<TH>Name</TH><TH>Zone</TH><TH>Level</TH><TH>Race</TH><TH>Class</TH>\n"
		"<TD><INPUT type=\"reset\" value=\"Reset\"/></TD>\n"
		"</TR>\n";

	out << "<TR>";

	// name field
	out << "<TD><INPUT type=\"text\" name=\"name\" value=\""
		<< searchName << "\"/></TD>\n";

	// zone field
	out << "<TD><INPUT type=\"text\" name=\"zone\" value=\""
		<< searchZone << "\"/></TD>\n";

	// level field
	out <<
		"<TD><INPUT type=\"text\" name=\"level\" size=\"2\" maxlength=\"2\""
		" value=\"";
	if (searchLevel)
		out << searchLevel;
	out << "\"/></TD>\n";

	// race field
	out << "<TD><INPUT type=\"text\" name=\"race\" value=\""
		<< searchRace << "\"/></TD>\n";

	// Class field
	out << "<TD><SELECT name=\"class\" size=\"1\">\n";
	out << "<OPTION value=\"0\"";
	if (searchClass == 0)
		out << " selected";
	out << ">Any</OPTION>\n";

	Spawn fake(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	// start at class value 1, and go until maximum known class value
	for (int i = 1; i <= 32; ++i)
	{
		fake.setClassVal(i);
		out << "<OPTION value=\"" << i << "\"";
		if (searchClass == i)
			out << " selected";
		out << ">" << fake.classString() << "</OPTION>\n";
	}
	out << "</SELECT></TD>\n";

	// Submission button
	out << "<TD><INPUT type=\"submit\" value=\"Search\"/></TD>\n";

	// close the form
	out <<
		"</TR>\n"
		"</TABLE>\n"
		"</FORM>\n";

	/////////////////////
	// on with the search
	sdb = fopen (SPAWNFILE, "r");
	if (sdb == NULL)
	{
		// display the error
		out << "<H1>Unable to open file '" SPAWNFILE "' (errno = "
			<< errno << ")</H1>\n";

		// close the document
		out << footer;

		// nothing more can be done
		exit(1);
	}


	// start the result table
	// beware Netscape 4.x style sheet brain death
	if ((userAgent.contains("Mozilla/4.") == 1) &&
		(userAgent.contains("MSIE") == 0))
		out << "<TABLE border=2 cellspacing=0 cellpadding=2>\n";
	else
		out << "<TABLE cellspacing=0 cellpadding=2>\n";
	out <<
		"<TR>\n"
		"<TD align=center><STRONG>Short Name</STRONG></TD>\n"
		"<TD align=center><STRONG>Long Name</STRONG></TD>\n"
		"<TD align=center><STRONG>Zone Name</STRONG></TD>\n"
		"<TD align=center><STRONG>Level</STRONG></TD>\n"
		"<TD align=center><STRONG>HP</STRONG></TD>\n"
		"<TD align=center><STRONG>Race</STRONG></TD>\n"
		"<TD align=center><STRONG>Class</STRONG></TD>\n"
		"</TR>\n";

	QString spawnName;
	QRegExp stripExp("[0-9]");

	// iterate over the contents of the spawn database
	while (fread (&dbSpawn, sizeof(dbSpawnStruct), 1, sdb))
	{
		Spawn spawn(&dbSpawn.spawn);

		// stash the name for later use and cooking
		spawnName = spawn.name();

		// is a search being performed, then do it already...
		if (doSearch)
		{
			// is it a name search, if so do we have a match
			if ((!searchName.isEmpty()) &&
				(spawnName.find(searchName, 0, false) == -1))
				continue;  // nope, you are the weakest link, good bye...

			// is it a zone search, if so check
			if ((!searchZone.isEmpty()) &&
				(QString(dbSpawn.zoneName).find(searchZone, 0, false) == -1))
				continue;

			// is it a level search, if so check
			if ((searchLevel != 0) &&
				(searchLevel != spawn.level()))
				continue;

			// is it a race search, if so check
			if ((!searchRace.isEmpty()) &&
				(spawn.raceString().find(searchRace, 0, false) == -1))
				continue;

			// is it a class search, if so check
			if ((searchClass != 0) &&
				(searchClass != spawn.classVal()))
				continue;
		}

		// strip the numbers off the spawn name
		spawnName.replace(stripExp, "");

		// display the spawn's data
		out << "<TR>\n";
		out << "<TD><A HREF=\"showspawn.cgi?name=" << spawnName
			<< "\">" << spawnName << "</A></TD>\n";
		out << "<TD>" << spawn.realName() << "</TD>\n";
		out << "<TD>" << dbSpawn.zoneName << "</TD>\n";
		out << "<TD align=right>" << spawn.level() << "</TD>\n";
		out << "<TD align=right>" << spawn.HP() << "/"
			<< spawn.maxHP() << "</TD>\n";
		out << "<TD>" << spawn.raceString() << "</TD>\n";
		out << "<TD>" << spawn.classString() << "</TD>\n";
		out << "</TR>\n";

		// increment the count
		counter++;
	}

	// close the table
	out << "</TABLE>\n";

	// display the number of matches
	out << "<P>"  << counter << " matches found</P>\n";

	// close the document
	out << footer;

	// close the spawn database
	fclose (sdb);
}
コード例 #27
0
/*! \reimp */
bool QToolBar::event(QEvent *event)
{
    Q_D(QToolBar);

    switch (event->type()) {
    case QEvent::Timer:
        if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()) {
            QWidget *w = QApplication::activePopupWidget();
            if (!waitForPopup(this, w)) {
                d->waitForPopupTimer.stop();
                if (!this->underMouse())
                    d->layout->setExpanded(false);
            }
        }
        break;
    case QEvent::Hide:
        if (!isHidden())
            break;
    // fallthrough intended
    case QEvent::Show:
        d->toggleViewAction->setChecked(event->type() == QEvent::Show);
        emit visibilityChanged(event->type() == QEvent::Show);
#if defined(Q_WS_MAC)
        if (toolbarInUnifiedToolBar(this)) {
            // I can static_cast because I did the qobject_cast in the if above, therefore
            // we must have a QMainWindowLayout here.
            QMainWindowLayout *mwLayout = static_cast<QMainWindowLayout *>(parentWidget()->layout());
            mwLayout->fixSizeInUnifiedToolbar(this);
            mwLayout->syncUnifiedToolbarVisibility();
        }
#  if !defined(QT_MAC_USE_COCOA)
    // Fall through
    case QEvent::LayoutRequest: {
        // There's currently no way to invalidate the size and let
        // HIToolbar know about it. This forces a re-check.
        int earlyResult = -1;
        if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget())) {
            bool needUpdate = true;
            if (event->type() == QEvent::LayoutRequest) {
                QSize oldSizeHint = sizeHint();
                earlyResult = QWidget::event(event) ? 1 : 0;
                needUpdate = oldSizeHint != sizeHint();
            }

            if (needUpdate) {
                OSWindowRef windowRef = qt_mac_window_for(mainWindow);
                if (toolbarInUnifiedToolBar(this)
                        && macWindowToolbarIsVisible(windowRef))   {
                    DisableScreenUpdates();
                    macWindowToolbarShow(this, false);
                    macWindowToolbarShow(this, true);
                    EnableScreenUpdates();
                }
            }

            if (earlyResult != -1)
                return earlyResult;
        }
    }
#  endif // !QT_MAC_USE_COCOA
#endif // Q_WS_MAC
    break;
    case QEvent::ParentChange:
        d->layout->checkUsePopupMenu();
#if defined(Q_WS_MAC)
        if (parentWidget() && parentWidget()->isWindow())
            qt_mac_updateToolBarButtonHint(parentWidget());
#endif
        break;

    case QEvent::MouseButtonPress: {
        if (d->mousePressEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    }
    case QEvent::MouseButtonRelease:
        if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    case QEvent::HoverEnter:
    case QEvent::HoverLeave:
        // there's nothing special to do here and we don't want to update the whole widget
        return true;
    case QEvent::HoverMove: {
#ifndef QT_NO_CURSOR
        QHoverEvent *e = static_cast<QHoverEvent*>(event);
        QStyleOptionToolBar opt;
        initStyleOption(&opt);
        if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos()))
            setCursor(Qt::SizeAllCursor);
        else
            unsetCursor();
#endif
        break;
    }
    case QEvent::MouseMove:
        if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
#ifdef Q_WS_WINCE
    case QEvent::ContextMenu:
    {
        QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);
        QWidget* child = childAt(contextMenuEvent->pos());
        QAbstractButton* button = qobject_cast<QAbstractButton*>(child);
        if (button)
            button->setDown(false);
    }
    break;
#endif
    case QEvent::Leave:
        if (d->state != 0 && d->state->dragging) {
#ifdef Q_OS_WIN
            // This is a workaround for loosing the mouse on Vista.
            QPoint pos = QCursor::pos();
            QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton,
                             QApplication::mouseButtons(), QApplication::keyboardModifiers());
            d->mouseMoveEvent(&fake);
#endif
        } else {
            if (!d->layout->expanded)
                break;

            QWidget *w = QApplication::activePopupWidget();
            if (waitForPopup(this, w)) {
                d->waitForPopupTimer.start(POPUP_TIMER_INTERVAL, this);
                break;
            }

            d->waitForPopupTimer.stop();
            d->layout->setExpanded(false);
            break;
        }
    default:
        break;
    }
    return QWidget::event(event);
}
コード例 #28
0
ファイル: bspmerge.cpp プロジェクト: HaiJiaoXinHeng/sandbox
void BSPPartition(std::unique_ptr<BSPNode> n, const float4 &p, std::unique_ptr<BSPNode> & nodeunder, std::unique_ptr<BSPNode> & nodeover) {
	nodeunder=NULL;
	nodeover =NULL;
	if(!n) {
		return;
	}
//	assert(n->cell);
	int flag;
	//flag = SplitTest(n->cell,p);
	//assert(flag==SplitTest(*n->convex,p));
	flag = n->convex.SplitTest(p);
	if(flag == UNDER) {
		nodeunder = move(n);
		return;
	}
	if(flag==OVER) {
		nodeover = move(n);
		return;
	}
	assert(flag==SPLIT);
//	Polyhedron *cellover  = PolyhedronDup(n->cell);
//	Polyhedron *cellunder = PolyhedronDup(n->cell);
//	cellunder->Crop(p);
//	cellover->Crop(Plane(-p.normal,-p.dist));
	nodeunder.reset(new BSPNode(n->xyz(), n->w));
	nodeover.reset(new BSPNode(n->xyz(),n->w));
	nodeunder->isleaf = n->isleaf;
	nodeover->isleaf = n->isleaf;
//	nodeunder->cell= cellunder;
//	nodeover->cell = cellover;
	nodeunder->convex = WingMeshCrop(n->convex,p);
	nodeover->convex = WingMeshCrop(n->convex, float4(-p.xyz(), -p.w));
	if(n->isleaf==UNDER) { 
		int i;
		BSPNode fake(p.xyz(), p.w);
		fake.under=move(nodeunder);
		fake.over=move(nodeover);
		i=n->brep.size();
		while(i--){
			FaceEmbed(&fake, std::move(n->brep[i]));
		}
		n->brep.clear();
        nodeunder = move(fake.under);
        nodeover = move(fake.over);

	}
	BSPPartition(move(n->under), p, nodeunder->under, nodeover->under);
	BSPPartition(move(n->over), p, nodeunder->over, nodeover->over );
	if(n->isleaf) { 
		assert(nodeunder->isleaf);
		assert(nodeover->isleaf);
		return;
	} 
	assert(nodeunder->over || nodeunder->under);
	assert(nodeover->over || nodeover->under);
    n.reset();
	if(!nodeunder->under) {
//		assert(SplitTest(nodeunder->cell,*nodeunder)==OVER);
        nodeunder = move(nodeunder->over);
	}
	else if(!nodeunder->over) {
//		assert(SplitTest(nodeunder->cell,*nodeunder)==UNDER);
        nodeunder = move(nodeunder->under);
	}
	assert(nodeunder);
	assert(nodeunder->isleaf || (nodeunder->under && nodeunder->over));
	if(!nodeover->under) {
//		assert(SplitTest(nodeover->cell,*nodeover)==OVER);
        nodeover = move(nodeover->over);
	}
	else if(!nodeover->over) {
//		assert(SplitTest(nodeover->cell,*nodeover)==UNDER);
        nodeover = move(nodeover->under);
	}
	assert(nodeover);
	assert(nodeover->isleaf || (nodeover->under && nodeover->over));
	if(!nodeunder->isleaf && nodeunder->over->isleaf && nodeunder->over->isleaf==nodeunder->under->isleaf) {
		nodeunder->isleaf = nodeunder->over->isleaf; // pick one of the children
		int i;
		i=nodeunder->under->brep.size();
		while(i--){
			nodeunder->brep.push_back(nodeunder->under->brep[i]);
		}
		nodeunder->under->brep.clear();
		i=nodeunder->over->brep.size();
		while(i--){
			nodeunder->brep.push_back(nodeunder->over->brep[i]);
		}
		nodeunder->over->brep.clear();
        nodeunder->under.reset();
        nodeunder->over.reset();
	}
	// wtf:	if(!nodeover->isleaf && nodeover->over->isleaf==nodeover->under->isleaf) {
	if(!nodeover->isleaf && nodeover->over->isleaf && nodeover->over->isleaf==nodeover->under->isleaf) {
		nodeover->isleaf = nodeover->over->isleaf; // pick one of the children
		int i;
		i=nodeover->under->brep.size();
		while(i--){
			nodeover->brep.push_back(nodeover->under->brep[i]);
		}
		nodeover->under->brep.clear();
		i=nodeover->over->brep.size();
		while(i--){
			nodeover->brep.push_back(nodeover->over->brep[i]);
		}
		nodeover->over->brep.clear();
        nodeover->under.reset();
        nodeover->over.reset();
	}
/*	if(fusenodes) {
		if(0==nodeunder->isleaf) {
			if(nodeunder->over->isleaf==UNDER) {
				DeriveCells(nodeunder->under,nodeunder->cell);
				nodeunder = nodeunder->under; // memleak
			}
			else if(nodeunder->under->isleaf==OVER) {
				DeriveCells(nodeunder->over,nodeunder->cell);
				nodeunder = nodeunder->over; // memleak
			}
		}
		assert(nodeunder);
		if(0==nodeover->isleaf) {
			if(nodeover->over->isleaf==UNDER) {
				DeriveCells(nodeover->under,nodeover->cell);
				nodeover = nodeover->under; // memleak
			}
			else if(nodeover->under->isleaf==OVER) {
				DeriveCells(nodeover->over,nodeover->cell);
				nodeover = nodeover->over;  // memleak
			}
		}
		assert(nodeover);
	}
*/
}
コード例 #29
0
   void AppearanceTest()
   {
      instantiateAllTestFixtures( "appearance-groups1.xml",
                                  "subscription1",
                                  "credential1",
                                  "177.0.0.1:54140");

      UtlString sharedUri = "sip:[email protected]:54140";
      UtlString app1uri = "sip:127.0.0.1:45141";
      UtlString dialogHandle;

      // receive the reg-info subscribe
      SipMessage request;
      UtlString b;
      ssize_t l;
      while(getNextMessageFromAppearanceAgentUnderTest( request, 5 ))
      {
         request.getBytes(&b, &l);
         OsSysLog::add(FAC_RLS, PRI_DEBUG, "got message %s", b.data());
         UtlString method;
         request.getRequestMethod(&method);
         if(!request.isResponse() &&
            0 == method.compareTo(SIP_SUBSCRIBE_METHOD) )
         {
            // Accept the Subscription, regardless of whether it for a 'dialog' or 'reg' event
            // in order to stop retransmissions
            SipMessage regResponse;
            regResponse.setResponseData(&request, 202, "Accepted", app1uri);
            SipMessage * dispatchedMessage = new SipMessage(regResponse);
            dispatchedMessage->getBytes(&b, &l);
            OsSysLog::add(FAC_RLS, PRI_DEBUG, "sent message %s", b.data());
            pAppearanceAgentUnderTest->mServerUserAgent.dispatch(dispatchedMessage);

            // Deal with the two events separately
            UtlString eventField;
            request.getEventField(eventField);
            if(0 == eventField.compareTo("reg"))
            {
               UtlString contactInfo;
               request.getContactUri(0, &contactInfo);
               UtlString callid;
               request.getCallIdField(&callid);
               int cseq;
               request.getCSeqField(&cseq, NULL);

               Url toField;
               regResponse.getToUrl(toField);

               SipMessage regNotify;
               regNotify.setNotifyData(&request, 1, "", "", "reg");
               UtlString regInfo ("<?xml version=\"1.0\"?>\r\n"
                                 "<reginfo xmlns=\"urn:ietf:params:xml:ns:reginfo\" "
                                 "xmlns:gr=\"urn:ietf:params:xml:ns:gruuinfo\" version=\"911\" state=\"full\">\r\n"
                                 "   <registration aor=\"sip:[email protected]:54140\" id=\"sip:[email protected]:54140\" state=\"active\">\r\n "
                                 "      <contact id=\"sip:[email protected]:54140@@&lt;");
               regInfo.append(contactInfo);
               regInfo.append("&gt;\" state=\"active\" event=\"registered\" q=\"1\" callid=\"");
               regInfo.append(callid);
               regInfo.append("\" cseq=\"");
               regInfo.appendNumber(cseq);
               regInfo.append("\">\r\n");
               regInfo.append("<uri>");
               regInfo.append(app1uri);
               regInfo.append("</uri>");
               regInfo.append("      </contact>\r\n"
                              "   </registration>\r\n"
                              "</reginfo>");
               HttpBody * newBody = new HttpBody (regInfo, strlen(regInfo), "application/reginfo+xml");
               regNotify.setContentType("application/reginfo+xml");
               regNotify.setBody(newBody);

               // Set the From field the same as the to field from the 202 response, as it
               // contains the dialog identifying to tags
               regNotify.setRawFromField(toField.toString().data());
               sendToAppearanceAgentUnderTest( regNotify );
               regNotify.getBytes(&b, &l);
               OsSysLog::add(FAC_RLS, PRI_DEBUG, "sent reg NOTIFY to AppAgent");
               OsSysLog::add(FAC_RLS, PRI_DEBUG, "sent message %s", b.data());
            }
            else if (0 == eventField.compareTo(SLA_EVENT_TYPE))
             {
                // should send empty NOTIFY, but no one will care
                // save dialogHandle for this subscription/Appearance (ignore retransmissions)
                if (dialogHandle.isNull())
                {
                   SipMessage fake(b);
                   fake.getDialogHandle(dialogHandle);
                   OsSysLog::add(FAC_RLS, PRI_DEBUG, "got SUBSCRIBE(sla) request: dialogHandle %s", dialogHandle.data());
                }
             }
         }
      }

      CPPUNIT_ASSERT( !dialogHandle.isNull() );
      OsSysLog::add(FAC_RLS, PRI_DEBUG, "we now have an Appearance - test it");
      AppearanceGroup* pAppGroup = pAppearanceAgentUnderTest->getAppearanceGroupSet().
         findAppearanceGroup(sharedUri);
      CPPUNIT_ASSERT( pAppGroup );

      Appearance* pApp = pAppGroup->findAppearance(dialogHandle);
      CPPUNIT_ASSERT( pApp );
      ASSERT_STR_EQUAL( app1uri.data(), pApp->getUri()->data() );

      // test adding a new dialog
      const char* dialogEventString =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"0\" state=\"partial\" entity=\"sip:[email protected]:54140\">\n"
            "<dialog id=\"1\" call-id=\"[email protected]\" local-tag=\"264460498\" remote-tag=\"1c10982\" direction=\"recipient\">\n"
            "<state>confirmed</state>\n"
            "<local>\n"
            "<identity>[email protected]:5120</identity>\n"
            "<target uri=\"sip:[email protected]:5120\">\n"
            "<param pname=\"x-line-id\" pval=\"0\"/>\n"
            "<param pname=\"+sip.rendering\" pval=\"yes\"/>\n"
            "</target>\n"
            "</local>\n"
            "<remote>\n"
            "<identity>[email protected]</identity>\n"
            "</remote>\n"
            "</dialog>\n"
            "</dialog-info>\n"
            ;
      SipDialogEvent dialogEvent(dialogEventString);
      bool bFullContentChanged = false;
      bool bPartialContentChanged = pApp->updateState(&dialogEvent, bFullContentChanged);
      CPPUNIT_ASSERT(bPartialContentChanged);
      CPPUNIT_ASSERT(bFullContentChanged);
      pApp->dumpState();
      CPPUNIT_ASSERT(pApp->appearanceIsBusy());
      CPPUNIT_ASSERT(pApp->appearanceIdIsSeized("0"));
      CPPUNIT_ASSERT(!pApp->appearanceIdIsSeized("1"));

      // simulate user putting the call on hold
      const char* dialogEventString2 =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"0\" state=\"partial\" entity=\"sip:[email protected]:54140\">\n"
            "<dialog id=\"1\" call-id=\"[email protected]\" local-tag=\"264460498\" remote-tag=\"1c10982\" direction=\"recipient\">\n"
            "<state>confirmed</state>\n"
            "<local>\n"
            "<identity>[email protected]:5120</identity>\n"
            "<target uri=\"sip:[email protected]:5120\">\n"
            "<param pname=\"x-line-id\" pval=\"0\"/>\n"
            "<param pname=\"+sip.rendering\" pval=\"no\"/>\n"
            "</target>\n"
            "</local>\n"
            "<remote>\n"
            "<identity>[email protected]</identity>\n"
            "</remote>\n"
            "</dialog>\n"
            "</dialog-info>\n"
            ;
      SipDialogEvent dialogEvent2(dialogEventString2);
      bPartialContentChanged = pApp->updateState(&dialogEvent2, bFullContentChanged);
      CPPUNIT_ASSERT(bPartialContentChanged);
      CPPUNIT_ASSERT(bFullContentChanged);
      pApp->dumpState();
      CPPUNIT_ASSERT(!pApp->appearanceIsBusy());
      CPPUNIT_ASSERT(pApp->appearanceIdIsSeized("0"));
      CPPUNIT_ASSERT(!pApp->appearanceIdIsSeized("1"));

      // test MESSAGE debug handling
      const char* message =
         "MESSAGE sip:[email protected]:54140 SIP/2.0\r\n"
         "From: <sip:[email protected]>;tag=17211757-9E4FBD78\r\n"
         "To: <sip:[email protected]:54140>\r\n"
         "CSeq: 1 MESSAGE\r\n"
         "Call-ID: 51405734-b9be4835-dcd9d196\r\n"
         "Contact: <sip:[email protected]>\r\n"
         "Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, MESSAGE, SUBSCRIBE, NOTIFY, PRACK, UPDATE, REFER\r\n"
         "Event: dialog\r\n"
         "User-Agent: UnitTest\r\n"
         "Accept-Language: en\r\n"
         "Accept: application/dialog-info+xml\r\n"
         "Max-Forwards: 70\r\n"
         "Expires: 3600\r\n"
         "Content-Length: 0\r\n"
         "\r\n";

      // send the MESSAGE
      SipMessage messageRequest( message, strlen( message ) );
      CPPUNIT_ASSERT( sendToAppearanceAgentUnderTest( messageRequest ) );

      // receive the 200 OK response
      SipMessage response;
      CPPUNIT_ASSERT( getNextMessageFromAppearanceAgentUnderTest( response, 5 ) );
      CPPUNIT_ASSERT( response.isResponse() );
      CPPUNIT_ASSERT( response.getResponseStatusCode() == SIP_OK_CODE );
   }
コード例 #30
0
ファイル: fmu.cpp プロジェクト: Bjarne-Madsen/Firmware
int
fmu_main(int argc, char *argv[])
{
	PortMode new_mode = PORT_MODE_UNSET;
	const char *verb = argv[1];

	if (!strcmp(verb, "stop")) {
		fmu_stop();
		errx(0, "FMU driver stopped");
	}

	if (!strcmp(verb, "id")) {
		uint8_t id[12];
		(void)get_board_serial(id);

		errx(0, "Board serial:\n %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X",
		     (unsigned)id[0], (unsigned)id[1], (unsigned)id[2], (unsigned)id[3], (unsigned)id[4], (unsigned)id[5],
		     (unsigned)id[6], (unsigned)id[7], (unsigned)id[8], (unsigned)id[9], (unsigned)id[10], (unsigned)id[11]);
	}


	if (fmu_start() != OK)
		errx(1, "failed to start the FMU driver");

	/*
	 * Mode switches.
	 */
	if (!strcmp(verb, "mode_gpio")) {
		new_mode = PORT_FULL_GPIO;

	} else if (!strcmp(verb, "mode_pwm")) {
		new_mode = PORT_FULL_PWM;

#if defined(CONFIG_ARCH_BOARD_PX4FMU_V2)
	} else if (!strcmp(verb, "mode_pwm4")) {
		new_mode = PORT_PWM4;
#endif
#if defined(CONFIG_ARCH_BOARD_PX4FMU_V1)

	} else if (!strcmp(verb, "mode_serial")) {
		new_mode = PORT_FULL_SERIAL;

	} else if (!strcmp(verb, "mode_gpio_serial")) {
		new_mode = PORT_GPIO_AND_SERIAL;

	} else if (!strcmp(verb, "mode_pwm_serial")) {
		new_mode = PORT_PWM_AND_SERIAL;

	} else if (!strcmp(verb, "mode_pwm_gpio")) {
		new_mode = PORT_PWM_AND_GPIO;
#endif
	}

	/* was a new mode set? */
	if (new_mode != PORT_MODE_UNSET) {

		/* yes but it's the same mode */
		if (new_mode == g_port_mode)
			return OK;

		/* switch modes */
		int ret = fmu_new_mode(new_mode);
		exit(ret == OK ? 0 : 1);
	}

	if (!strcmp(verb, "test"))
		test();

	if (!strcmp(verb, "fake"))
		fake(argc - 1, argv + 1);

	if (!strcmp(verb, "sensor_reset")) {
		if (argc > 2) {
			int reset_time = strtol(argv[2], 0, 0);
			sensor_reset(reset_time);

		} else {
			sensor_reset(0);
			warnx("resettet default time");
		}

		exit(0);
	}

	if (!strcmp(verb, "peripheral_reset")) {
		if (argc > 2) {
			int reset_time = strtol(argv[2], 0, 0);
			peripheral_reset(reset_time);

		} else {
			peripheral_reset(0);
			warnx("resettet default time");
		}

		exit(0);
	}

	if (!strcmp(verb, "i2c")) {
		if (argc > 3) {
			int bus = strtol(argv[2], 0, 0);
			int clock_hz = strtol(argv[3], 0, 0);
			int ret = fmu_new_i2c_speed(bus, clock_hz);

			if (ret) {
				errx(ret, "setting I2C clock failed");
			}

			exit(0);
		} else {
			warnx("i2c cmd args: <bus id> <clock Hz>");
		}
	}

	fprintf(stderr, "FMU: unrecognised command %s, try:\n", verb);
#if defined(CONFIG_ARCH_BOARD_PX4FMU_V1)
	fprintf(stderr, "  mode_gpio, mode_serial, mode_pwm, mode_gpio_serial, mode_pwm_serial, mode_pwm_gpio, test, fake, sensor_reset, id\n");
#elif defined(CONFIG_ARCH_BOARD_PX4FMU_V2) || defined(CONFIG_ARCH_BOARD_AEROCORE)
	fprintf(stderr, "  mode_gpio, mode_pwm, test, sensor_reset [milliseconds], i2c <bus> <hz>\n");
#endif
	exit(1);
}