Esempio n. 1
0
void* regLoop(void* userData) {
  int l = 0;
  int status;
  int numParamsChanged;
  int numRecvdCmds;
  int recvdCmds[REG_MAX_NUM_STR_CMDS];
  char** changedParamLabels;
  char** recvdCmdParams;
  bool done;
  bool needRefresh = false;

  // params to be registered...
  int mVis;
  int bVis;
  double isoValue[PVS_MAX_ISOS];
  int isoVis[PVS_MAX_ISOS];
  int orthoslice;
  int cutplane;

  // thread data...
  threadData* td = (threadData*) ((ThreadInfoStruct*) userData)->UserData;

  // allocate memory...
  changedParamLabels = Alloc_string_array(REG_MAX_STRING_LENGTH,
					  REG_MAX_NUM_STR_PARAMS);
  recvdCmdParams = Alloc_string_array(REG_MAX_STRING_LENGTH,
				      REG_MAX_NUM_STR_CMDS);

  // initialise steering library...
  regInit();

  // register params...
  if(td->xyzPipeline) {
    ((PlatoXYZPipeline*) td->xyzPipeline)->isMoleculeVisible() ? mVis = 1 : mVis = 0;
    status = Register_param("Molecule visible?", REG_TRUE, (void*) &mVis,
			    REG_INT, "0", "1");
    ((PlatoXYZPipeline*) td->xyzPipeline)->isBondsVisible() ? bVis = 1 : bVis = 0;
    status = Register_param("Bonds visible?", REG_TRUE, (void*) &bVis,
			    REG_INT, "0", "1");
  }

  double* isoRange = ((PlatoDataReader*) td->dataReader)->getDataRange();
  char isoMin[10];
  char isoMax[10];
  char isoLabel[20];
  snprintf(isoMin, 10, "%f", isoRange[0]);
  snprintf(isoMax, 10, "%f", isoRange[1]);
  for(int i = 0; i < PVS_MAX_ISOS; i++) {
    snprintf(isoLabel, 20, "Iso %d visible?", i);
    ((PlatoIsoPipeline*) td->isoPipeline)->isIsoVisible(i) ? isoVis[i] = 1 : isoVis[i] = 0;
    status = Register_param(isoLabel, REG_TRUE, (void*) &isoVis[i],
			    REG_INT, "0", "1");
    snprintf(isoLabel, 20, "Iso %d value", i);
    isoValue[i] = ((PlatoIsoPipeline*) td->isoPipeline)->getIsoValue(i);
    status = Register_param(isoLabel, REG_TRUE, (void*) &isoValue[i],
			    REG_DBL, isoMin, isoMax);
  }

  ((PlatoOrthoPipeline*) td->orthoPipeline)->isOrthosliceOn() ? orthoslice = 1
    : orthoslice = 0;
  status = Register_param("Orthoslice?", REG_TRUE, (void*) &orthoslice,
			  REG_INT, "0", "1");

  ((PlatoIsoPipeline*) td->isoPipeline)->isIsoCutterOn() ? cutplane = 1 :
    cutplane = 0;
  status = Register_param("Cut-plane?", REG_TRUE, (void*) &cutplane,
			  REG_INT, "0", "1");

  loopLock->Lock();
  done = regLoopDone;
  loopLock->Unlock();

  // go into loop until told to finish...
  while(!done) {
    // sleep for 0.2 seconds...
    usleep(200000);

    status = Steering_control(l, &numParamsChanged, changedParamLabels,
			      &numRecvdCmds, recvdCmds, recvdCmdParams);

    if(status != REG_SUCCESS) {
      std::cerr << "Call to Steering_control failed...\n";
      continue;
    }

    // deal with commands from steering library...
    for(int i = 0; i < numRecvdCmds; i++) {
      switch(recvdCmds[i]) {
      case REG_STR_STOP:
	//td->window->getInteractor()->InvokeEvent(vtkCommand::ExitEvent);
	td->window->exit();
	break;
      }
    }

    // deal with changed parameters...
    for(int i = 0; i < numParamsChanged; i++) {
      if(strstr(changedParamLabels[i], "Molecule") || 
	 strstr(changedParamLabels[i], "Bonds")) {
	moleculeVisibility((PlatoXYZPipeline*) td->xyzPipeline, mVis, bVis);
	needRefresh = true;
	continue;
      }

      if(!strncmp(changedParamLabels[i], "Iso", 3)) {
	isoChanged((PlatoIsoPipeline*) td->isoPipeline,
		   changedParamLabels[i], isoValue, isoVis);
	needRefresh = true;
	continue;
      }

      if(!strcmp(changedParamLabels[i], "Orthoslice?")) {
	toggleOrthoslice((PlatoOrthoPipeline*) td->orthoPipeline, orthoslice);
	needRefresh = true;
	continue;
      }

      if(!strcmp(changedParamLabels[i], "Cut-plane?")) {
	toggleCutplane((PlatoIsoPipeline*) td->isoPipeline, cutplane);
	needRefresh = true;
	continue;
      }
    }

    // tell the interactor to render if needs be...
    if(needRefresh) {
      renderLock->Lock();
      reRender = true;
      renderLock->Unlock();
      needRefresh = false;
    }

    // see if we're done yet...
    loopLock->Lock();
    done = regLoopDone;
    loopLock->Unlock();

    // update loop count for steering library...
    l++;
  }

  // clean up steering library...
  regFinalise();

  // tell main thread that this one is done...
  sem_post(&regDone);
}
Esempio n. 2
0
void Camera::resetCapabilities() {
  QtCamDevice *dev = device();

  delete m_zoom;
  m_zoom = new Zoom(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()), m_zoom, SLOT(prepareForDeviceChange()));
  emit zoomChanged();

  delete m_flash;
  m_flash = new Flash(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_flash, SLOT(prepareForDeviceChange()));
  emit flashChanged();

  delete m_scene;
  m_scene = new Scene(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_scene, SLOT(prepareForDeviceChange()));
  emit sceneChanged();

  delete m_evComp;
  m_evComp = new EvComp(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_evComp, SLOT(prepareForDeviceChange()));
  emit evCompChanged();

  delete m_whiteBalance;
  m_whiteBalance = new WhiteBalance(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_whiteBalance, SLOT(prepareForDeviceChange()));
  emit whiteBalanceChanged();

  delete m_colorTone;
  m_colorTone = new ColorTone(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_colorTone, SLOT(prepareForDeviceChange()));
  emit colorToneChanged();

  delete m_iso;
  m_iso = new Iso(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()), m_iso, SLOT(prepareForDeviceChange()));
  emit isoChanged();

  delete m_exposure;
  m_exposure = new Exposure(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_exposure, SLOT(prepareForDeviceChange()));
  emit exposureChanged();

  delete m_aperture;
  m_aperture = new Aperture(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_aperture, SLOT(prepareForDeviceChange()));
  emit apertureChanged();

  delete m_noiseReduction;
  m_noiseReduction = new NoiseReduction(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_noiseReduction, SLOT(prepareForDeviceChange()));
  emit noiseReductionChanged();

  delete m_flickerReduction;
  m_flickerReduction = new FlickerReduction(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_flickerReduction, SLOT(prepareForDeviceChange()));
  emit flickerReductionChanged();

  delete m_focus;
  m_focus = new Focus(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_focus, SLOT(prepareForDeviceChange()));
  emit focusChanged();

  delete m_autoFocus;
  m_autoFocus = new AutoFocus(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_autoFocus, SLOT(prepareForDeviceChange()));
  emit autoFocusChanged();

  delete m_roi;
  m_roi = new Roi(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()), m_roi, SLOT(prepareForDeviceChange()));
  emit roiChanged();

  delete m_videoMute;
  m_videoMute = new VideoMute(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_videoMute, SLOT(prepareForDeviceChange()));
  emit videoMuteChanged();

  delete m_videoTorch;
  m_videoTorch = new VideoTorch(dev, this);
  QObject::connect(this, SIGNAL(prepareForDeviceChange()),
		   m_videoTorch, SLOT(prepareForDeviceChange()));
  emit videoTorchChanged();
}