Example #1
0
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QWidget window;
	window.resize(200,200);

	//label1
	QLabel *label1 = new QLabel(&window);
	QPixmap pm1(100,100);
	pm1.fill(QColor(255,0,0));
	label1->setPixmap(pm1);
	label1->setFixedSize(100,100);

	//label2
	QLabel *label2 = new QLabel(&window);
	QPixmap pm2(100,100);
	pm2.fill(QColor(0,0,255));
	label2->setPixmap(pm2);
	label2->setFixedSize(100,100);

	label2->move(0,0);
	label1->move(0,0);
	//这时候,label1被label2挡住了。

	label1->raise();//将label1从父窗口的栈中提升,这样label1就挡住label2了
	window.show();
	return app.exec();
}
Example #2
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void TestErrorMessage()
{
  PipelineMessage e0;

  QString a0("Some Class Name");
  QString a1("Description");
  int eCode = -10;
  PipelineMessage e1;


  PipelineMessage e2(a0, a1, eCode);

  AbstractFilter::Pointer f = AbstractFilter::New();
  f->notifyErrorMessage("Some Test", a1, eCode);
  f->notifyErrorMessage("Another Test", "A description", -10);

  PipelineMessage pm("Joey's Test", "Testing Warning Message...", -23, PipelineMessage::Warning);
  PipelineMessage pm1("Joey's Test", "Testing Error Message...", -23, PipelineMessage::Error);
  PipelineMessage pm2("Joey's Test", "Testing Status Message...", -23, PipelineMessage::StatusMessage);
  PipelineMessage pm3("Joey's Test", "Testing Status Message...", -23, PipelineMessage::ProgressValue, 23);
  f->broadcastPipelineMessage(pm);
  f->broadcastPipelineMessage(pm1);
  f->broadcastPipelineMessage(pm2);

  if (true)
  { return; }

}
Example #3
0
void TabGuides::restoreDefaults(struct GuidesPrefs *prefsData, struct TypoPrefs *prefsData2, int unitIndex)
{
	QString unit = unitGetSuffixFromIndex(unitIndex);
	double unitRatio = unitGetRatioFromIndex(unitIndex);
	int decimals = unitGetPrecisionFromIndex(unitIndex);

	QPixmap pm3(54, 14);
	pm3.fill(prefsData->guideColor);
	colorGuides = prefsData->guideColor;
	guideColor->setIcon(pm3);
	QPixmap pm6(54, 14);
	pm6.fill(prefsData->marginColor);
	colorMargin = prefsData->marginColor;
	marginColor->setIcon(pm6);
	QPixmap pm1(54, 14);
	pm1.fill(prefsData->majorGridColor);
	colorMajorGrid = prefsData->majorGridColor;
	majorGridColor->setIcon(pm1);
	QPixmap pm(54, 14);
	pm.fill(prefsData->minorGridColor);
	colorMinorGrid = prefsData->minorGridColor;
	minorGridColor->setIcon(pm);
	QPixmap pm4(54, 14);
	pm4.fill(prefsData->baselineGridColor);
	colorBaselineGrid = prefsData->baselineGridColor;
	baselineColor->setIcon(pm4);
	minorSpace->setDecimals( decimals );
	minorSpace->setValue(prefsData->minorGridSpacing  * unitRatio);
	minorSpace->setSuffix( unit );
	majorSpace->setDecimals( decimals );
	majorSpace->setValue(prefsData->majorGridSpacing * unitRatio);
	majorSpace->setSuffix( unit );
	snapDistance->setValue(qRound(prefsData->guideRad));
	snapDistance->setSuffix( " " + tr( "px" ) );
	grabDistance->setValue(prefsData->grabRadius);
	grabDistance->setSuffix( " " + tr( " px" ) );
	baseGrid->setValue(prefsData->valueBaselineGrid);
	baseOffset->setValue(prefsData->offsetBaselineGrid);
	inBackground->setChecked( prefsData->guidePlacement );
	inForeground->setChecked( !prefsData->guidePlacement );
	baselineBox->setChecked(prefsData->baselineGridShown);
	checkGrid->setChecked(prefsData->gridShown);
	marginBox->setChecked(prefsData->marginsShown);
	guideBox->setChecked(prefsData->guidesShown);
}
Example #4
0
Model2D createSoccerFieldModel()
{
    Model2D m;

    geo::Vec2 p1(-4, -2.67);
    geo::Vec2 p2( 4,  2.67);

    geo::Vec2 pm1(0, p1.y);
    geo::Vec2 pm2(0, p2.y);

    createBoxContour(p1, p2, m.addContour());
    createBoxContour(pm1, pm2, m.addContour());

    createBoxContour(geo::Vec2(p1.x, -1), geo::Vec2(p1.x + 0.5, 1), m.addContour());
    createBoxContour(geo::Vec2(p2.x, -1), geo::Vec2(p2.x - 0.5, 1), m.addContour());

    createCircleContour(0.7, m.addContour());

    return m;
}
Example #5
0
int main(int argc, const char **argv)
{
  fprintf(stderr, "%s %s\n", __DATE__, __TIME__);
  bool sane = 1;
#define LARGE_MAT
#ifdef LARGE_MAT
#ifdef BSIM
  int A = 64;
  int B = 256;
#else
  int A = 256;
  int B = 2048;
#endif
  if (argc > 1) {
    B = strtoul(argv[1], 0, 0);
    A = 2*B;
  }
  srand(A*B);
  cv::Mat m1(A,B,CV_32F);
  cv::Mat m2(B,A,CV_32F);
  for(int a = 0; a < A; a++){
    for(int b = 0; b < B; b++){
      float v = (float)(rand() % 10);
      m2.at<float>(b,a) = (A*B)+v;
      m1.at<float>(a,b) = v;
    }
  }
#else
  cv::Mat m1 = (cv::Mat_<float>(4,8) <<
		11,12,13,14,15,16,17,18,
		21,22,23,24,25,26,27,28,
		31,32,33,34,35,36,37,38,
		41,42,43,44,45,46,47,48
		);
  cv::Mat m2 = (cv::Mat_<float>(8,4) <<
		51,62,53,54,
		55,56,57,58,
		61,62,63,64,
		65,66,67,68,
		71,72,73,74,
		75,76,77,78,
		81,82,83,84,
		85,86,87,88
		);
#endif

#ifndef CUDA_PERF_TEST
#ifdef MATRIX_NT
  mmdevice = new MmRequestNTProxy(IfcNames_MmRequestNTS2H);
#else
#ifdef MATRIX_TN
  mmdevice = new MmRequestTNProxy(IfcNames_MmRequestTNS2H);
#endif
#endif
  MmIndication *mmdeviceIndication = new MmIndication(IfcNames_MmIndicationH2S);
  //TimerRequestProxy *timerdevice = new TimerRequestProxy(IfcNames_TimerRequestPortalS2H);
  TimerIndication timerdeviceIndication(IfcNames_TimerIndicationH2S);
    DmaManager *dma = platformInit();

  if(sem_init(&mul_sem, 1, 0)){
    fprintf(stderr, "failed to init mul_sem\n");
    return -1;
  }

  long req_freq = 100000000;
  long freq = 0;
  setClockFrequency(0, req_freq, &freq);
  fprintf(stderr, "Requested FCLK[0]=%ld actually %ld\n", req_freq, freq);

  matAllocator = new PortalMatAllocator(dma);
  FILE *octave_file = fopen("foo.m", "w");

  fprintf(stderr, "OpenCV matmul\n");
  portalTimerStart(0);
  cv::Mat  m3 = m1 * m2;
  //uint64_t opencv_hw_cycles = portalTimerLap(0);

  PortalMat tm3;
  fprintf(stderr, "Naive matmul\n");
  portalTimerStart(0);
  tm3.naive_mul(m1,m2, octave_file);
  //uint64_t naive_hw_cycles = portalTimerLap(0);

  if (1) {
    fprintf(stderr, "DumpMat\n");
    dumpMatOctave<float>("m1",  "%10.5f", m1,  octave_file);
    dumpMatOctave<float>("m2",  "%10.5f", m2,  octave_file);
    dumpMatOctave<float>("m3",  "%10.5f", m3,  octave_file);
    dumpMatOctave<float>("tm3", "%10.5f", tm3, octave_file);
    fclose(octave_file);
    sane = tm3.compare(m3, 0, 0, 0.0001, 0, false);
    fprintf(stderr, "sane=%d\n", sane);
    fflush(stdout);
  }

#ifdef MATRIX_TN
  fprintf(stderr, "pm1t\n");
  PortalMat pm1t(m1.t());
  fprintf(stderr, "pm2\n");
  PortalMat pm2(m2);
  pm1t.reference();
  pm2.reference();
#else
#ifdef MATRIX_NT
  fprintf(stderr, "pm1\n");
  PortalMat pm1(m1);
  fprintf(stderr, "pm2t\n");
  PortalMat pm2t(m2.t());
  pm1.reference();
  pm2t.reference();
#endif
#endif
  PortalMat pm3;
  pm3.create(m1.rows, m2.cols, CV_32F);
  pm3.reference();

  // we invoke .reference on the matrices in advance 
  // in order to avoid counting the elapsed time for
  // performance analysis.  This is not strictly necessary
  // as all the portalmat methods make sure a valid 
  // reference is available before invoking the hardware

  pthread_t dbgtid;
  fprintf(stderr, "creating debug thread\n");

  if(pthread_create(&dbgtid, NULL,  dbgThread, NULL)){
   fprintf(stderr, "error creating debug thread\n");
   exit(1);
  }

  fprintf(stderr, "HW matmul\n");
  portalTimerStart(0);
#ifdef MATRIX_TN
  pm3.multf(pm1t, pm2, mmdeviceIndication);
#else
#ifdef MATRIX_NT
  pm3.multf(pm1, pm2t, mmdeviceIndication);
#endif
#endif
#if 0
  //uint64_t hw_cycles = portalTimerLap(0); 
  uint64_t read_beats = hostMemServerIndication.getMemoryTraffic(ChannelType_Read);
  uint64_t write_beats = hostMemServerIndication.getMemoryTraffic(ChannelType_Write);
  float read_util = (float)read_beats/(float)mmdeviceIndication->ccnt;
  float write_util = (float)write_beats/(float)mmdeviceIndication->ccnt;
  float read_bw = read_util * N_VALUE * 4 * (float)freq / 1.0e9;
  float write_bw = write_util * N_VALUE * 4 * (float)freq / 1.0e9;
  float macs = m1.rows * m2.rows * m2.cols;
  fprintf(stderr, "Bus frequency %f MHz\n", (float)freq / 1.0e6);
  fprintf(stderr, "memory read  beats %f utilization %f (beats/cycle), bandwidth %f (GB/s)\n", (float)read_beats, read_util, read_bw);
  fprintf(stderr, "memory write beats %f utilization %f (beats/cycle), bandwidth %f (GB/s)\n", (float)write_beats, write_util, write_bw);
  fprintf(stderr, "Throughput %f macs/cycle %f GFLOP/s\n",
	  (float)macs / (float)mmdeviceIndication->ccnt,
	  2.0 * (float)macs / (float)mmdeviceIndication->ccnt * freq / 1.0e9);
  fprintf(stderr, "Time %f cycles, opencv matmul %f cycles (speedup %f), naive matmul %f cycles (speedup %f)\n",
	  (float)mmdeviceIndication->ccnt,
	  (float)opencv_hw_cycles, (float)opencv_hw_cycles/(float)mmdeviceIndication->ccnt,
	  (float)naive_hw_cycles, (float)naive_hw_cycles/(float)mmdeviceIndication->ccnt);
#endif

  if (0) {
    dumpMat<float>("pm3", "%5.1f", pm3);
    dumpMat<float>(" m3", "%5.1f", m3);
  }
  bool eq = pm3.compare(m3);
#else // CUDA_PERF_TEST
  cv::Mat cm3(m1.rows,m2.cols, CV_32F);
  cuda_mm(m1, m2, cm3);
  cv::Mat  m3 = m1 * m2;
  bool eq = compare(m3, cm3, 0.01);
#endif // CUDA_PERF_TEST
  fprintf(stderr, "XXXXXXXXXXXXXXXXXXXXXXXXXX eq=%d\n", eq);
  return(!(eq&&sane));
}