bool printSinglecopyDocument::sPrintOneDoc(XSqlQuery *docq)
{
  QString reportname = docq->value("reportname").toString();
  QString docnumber  = docq->value("docnumber").toString();
  bool    printedOk  = false;

  if (! isSetup())
  {
    bool userCanceled = false;
    if (orReport::beginMultiPrint(_data->_printer, userCanceled) == false)
    {
      if(!userCanceled)
        systemError(this, tr("Could not initialize printing system for multiple reports."));
      return false;
    }
  }

  orReport report(reportname);
  if (! report.isValid())
    QMessageBox::critical(this, tr("Cannot Find Form"),
                          tr("<p>Cannot find form '%1' for %2 %3. "
                             "It cannot be printed until the Form "
                             "Assignment is updated to remove references "
                             "to this Form or the Form is created.")
                           .arg(reportname, _data->_doctypefull, docnumber));
  else
  {
    report.setParamList(getParams(docq));
    if (! report.isValid())
    {
      ErrorReporter::error(QtCriticalMsg, this, tr("Invalid Parameters"),
                           tr("<p>Report '%1' cannot be run. Parameters "
                               "are missing.").arg(reportname),
                           __FILE__, __LINE__);
      printedOk = false;
    }
    else if (report.print(_data->_printer, ! isSetup()))
    {
      setSetup(true);
      printedOk = true;
    }
    else
    {
      report.reportError(this);
      printedOk = false;
    }
  }

  if (printedOk)
    emit finishedPrinting(docq->value("docid").toInt());

  return printedOk;
}
void ArduinoDriver::sendByte(uchar val) {
	if(isSetup()) {
		qDebug() << "Sending " << (int)val;
		thread_port->write((char*)&val, 1);
		thread_port->waitForBytesWritten(5);
	}
}
Example #3
0
void ompl::base::SpaceInformation::printProperties(std::ostream &out) const
{
    out << "Properties of the state space '" << stateSpace_->getName() << "'" << std::endl;
    out << "  - signature: ";
    std::vector<int> sig;
    stateSpace_->computeSignature(sig);
    for (std::size_t i = 0 ; i < sig.size() ; ++i)
        out << sig[i] << " ";
    out << std::endl;
    out << "  - dimension: " << stateSpace_->getDimension() << std::endl;
    out << "  - extent: " << stateSpace_->getMaximumExtent() << std::endl;
    if (isSetup())
    {
        bool result = true;
        try
        {
            stateSpace_->sanityChecks();
        }
        catch(Exception &e)
        {
            result = false;
            out << std::endl << "  - SANITY CHECKS FOR STATE SPACE ***DID NOT PASS*** (" << e.what() << ")" << std::endl << std::endl;
            OMPL_ERROR(e.what());
        }
        if (result)
            out << "  - sanity checks for state space passed" << std::endl;
        out << "  - probability of valid states: " << probabilityOfValidState(magic::TEST_STATE_COUNT) << std::endl;
        out << "  - average length of a valid motion: " << averageValidMotionLength(magic::TEST_STATE_COUNT) << std::endl;
        double uniform, near, gaussian;
        samplesPerSecond(uniform, near, gaussian, magic::TEST_STATE_COUNT);
        out << "  - average number of samples drawn per second: sampleUniform()=" << uniform << " sampleUniformNear()=" << near << " sampleGaussian()=" << gaussian << std::endl;
    }
    else
        out << "Call setup() before to get more information" << std::endl;
}
//----------------------------------------
void ofxBox2dRevoluteJoint::destroy() {
	if (!isSetup()) return;
	if (joint) {
		world->DestroyJoint(joint);
	}
	joint = NULL;
	alive = false;
}
void ompl::geometric::LazyPRM::setRange(double distance)
{
    maxDistance_ = distance;
    if (!userSetConnectionStrategy_)
        connectionStrategy_.clear();
    if (isSetup())
        setup();
}
/**
 * @brief Run the analysis.
 */
void CNAnalysisMethodNormalDiploid::run()
{
    Verbose::out(1, "CNAnalysisMethodNormalDiploid::run(...) start");
	isSetup();
    determineLocalProbeSets();
    m_vSegments.deleteAll();
    newSegments(getSegmentType(), getProbeSets());
    Verbose::out(1, "CNAnalysisMethodNormalDiploid::run(...) end");
}
void ompl::geometric::LazyPRM::setMaxNearestNeighbors(unsigned int k)
{
    if (starStrategy_)
        throw Exception("Cannot set the maximum nearest neighbors for " + getName());
    if (!nn_)
    {
        nn_.reset(tools::SelfConfig::getDefaultNearestNeighbors<Vertex>(this));
        nn_->setDistanceFunction(boost::bind(&LazyPRM::distanceFunction, this, _1, _2));
    }
    if (!userSetConnectionStrategy_)
        connectionStrategy_.clear();
    if (isSetup())
        setup();
}
Example #8
0
void PositionPotential::setup(double prec) {
    if (isSetup(prec)) return;
    setApplyPrec(prec);

    QMPotential &V = *this;
    if (V.hasReal()) MSG_ERROR("Potential not properly cleared");
    if (V.hasImag()) MSG_ERROR("Potential not properly cleared");

    Timer timer;
    qmfunction::project(V, this->func, NUMBER::Real, this->apply_prec);
    timer.stop();

    int n = V.getNNodes(NUMBER::Total);
    double t = timer.getWallTime();
    Printer::printTree(1, "PositionPotential", n, t);
}
enum SetResponse printSinglecopyDocument::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  _data->_captive = true;

  QVariant param;
  bool     valid;

  if (! reportKey().isEmpty())
  {
    param = pParams.value(reportKey(), &valid);
    if (valid)
      setId(param.toInt());
  }

  param = pParams.value("docid", &valid);
  if (valid)
    setId(param.toInt());

  if (pParams.inList("print"))
  {
    sPrint();
    return NoError_Print;
  }

  if (pParams.inList("persistentPrint"))
  {
    _data->_alert = FALSE;

    if (isSetup())
    {
      sPrint();
      return NoError_Print;
    }
    else
      return Error_NoSetup;
  }

  return NoError;
}
Example #10
0
/** @brief refresh
  *	draw objects on screen
  * @return true if successful
  */
bool Renderer::refresh()
{
	if (!isInit())
		return false;
	if (!isSetup())
		return false;

  glClear( GL_COLOR_BUFFER_BIT );

	/** @todo change this to the proper accessors */
	//get time (turn, frame)
	unsigned int turn = 0; // = timeManager::turn();
	unsigned int frame = 0; // = timeManager::frame();

	std::map<unsigned int, renderObj*>::iterator it = get()->m_objects.begin();
	for (it; it != get()->m_objects.end(); it++)
	{
		/** @todo fill this in */
		it->second->renderAt(turn,frame);
	}
	return true;
}
//----------------------------------------
void ofxBox2dWeldJoint::destroy() {
	if (!isSetup()) return;
	world->DestroyJoint(joint);
	joint = NULL;
	alive = false;
}
/**
 * @brief Run the analysis.
 */
void CNAnalysisMethodMosaicism::run()
{
    Verbose::out(1, "CNAnalysisMethodMosaicism::run(...) start");
    isSetup();
        determineLocalProbeSets();

    m_vSegments.deleteAll();
    vector<int> vChromosomes = getChromosomes(getProbeSets());
    int iLastChromosome = vChromosomes[vChromosomes.size() - 1];
    Verbose::progressBegin(1,"CNAnalysisMethodMosaicism::run(...) ", iLastChromosome, 1, iLastChromosome);

    for (int i = 0; (i < vChromosomes.size()); i++)
    {
        int iChromosome = vChromosomes[i];
        if (iChromosome == 255) {continue;}
        if (iChromosome == m_iYChromosome && !m_bRunYChromosome) {
          continue;
        }
        int iProbeSetCount = getProbeSetCount(iChromosome, getProbeSets());
        if (iProbeSetCount == 0) continue; // probably 23 or Y
        Verbose::progressStep(1);

        // debug: for later use
        m_current_experiment=getExperiment()->getExperimentName();
        m_current_chr=ToStr(vChromosomes[i]);

        std::vector<int> vPositions(iProbeSetCount);
        double* pLog2Ratios = new double[iProbeSetCount];
        int iStartChromosome = getChrBounds(iChromosome, getProbeSets()).first;
        m_iStartIndex = 0;
        m_iEndIndex = (iProbeSetCount - 1);
        CNProbeSetArray* psets = getProbeSets();
        for (int j = 0; (j < iProbeSetCount); j++)
        {
            vPositions[j] = psets->at(iStartChromosome + j)->getPosition();
            pLog2Ratios[j] = psets->at(iStartChromosome + j)->getLog2Ratio();
        }
        double* pRunMean = new double[iProbeSetCount];
        int iMarkerBandwidth = Min(iProbeSetCount, m_iMarkerBandwidth);
        runmean(pLog2Ratios, pRunMean, &iProbeSetCount, &iMarkerBandwidth);

        // debug - this has been ruled out.
#ifdef MOSAICISM_DEBUG_MEANS
        writeRunningMeans(m_current_experiment+".chr"+m_current_chr+".means.tsv",
                          iProbeSetCount,
                          pLog2Ratios,
                          pRunMean);
#endif

        CNSegmentArray vSegments;
        newSegments((unsigned char)iChromosome, pRunMean, iProbeSetCount, vPositions, vSegments);
        // dont need this anymore.
        delete[] pRunMean;

        // debug
#ifdef MOSAICISM_DEBUG
        vSegments.writeToTsv(m_current_experiment+"-chr"+m_current_chr+".newseg1.tsv");
#endif
        //
        cleanSegments(vSegments);

        // Set marker count and median marker distance.
        for (int iSegmentIndex = 0; (iSegmentIndex < vSegments.getCount()); iSegmentIndex++)
        {
            CNSegment* p = vSegments.getAt(iSegmentIndex);
            p->setStartPosition(vPositions[p->getStartIndex()]);
            p->setEndPosition(vPositions[p->getEndIndex()]);
            calculateSegmentConfidence(pLog2Ratios, p);
            int iMarkerCount = 0;
            for (unsigned int iProbeSetIndex = 0; (iProbeSetIndex < vPositions.size()); iProbeSetIndex++)
            {
                if ((vPositions[iProbeSetIndex] >= p->getStartPosition()) && (vPositions[iProbeSetIndex] <= p->getEndPosition()))
                {
                    iMarkerCount++;
                }
            }
            if (iMarkerCount < 2)
            {
                p->setMarkerCount(iMarkerCount);
                p->setMeanMarkerDistance(0);
            }
            else
            {
                AffxMultiDimensionalArray<int> vMarkerDistances(iMarkerCount - 1);
                int iIndex = 0;
                for (unsigned int iProbeSetIndex = 1; (iProbeSetIndex < vPositions.size()); iProbeSetIndex++)
                {
                    int iPrevPosition = vPositions[iProbeSetIndex - 1];
                    int iNextPosition = vPositions[iProbeSetIndex];
                    if ((iPrevPosition >= p->getStartPosition()) && (iNextPosition <= p->getEndPosition()))
                    {
                        getProbeSets()->getAt(iStartChromosome + iProbeSetIndex - 1)->setMosaicismMixture(p->getMixtureAsDouble());
                        getProbeSets()->getAt(iStartChromosome + iProbeSetIndex)->setMosaicismMixture(p->getMixtureAsDouble());
                        vMarkerDistances.set(iIndex, (iNextPosition - iPrevPosition));
                        iIndex++;
                    }
                }
                p->setMarkerCount(iMarkerCount);
                p->setMeanMarkerDistance(vMarkerDistances.mean());
            }
            // transfer of ownership from vSegments to m_vSegments
            m_vSegments.add(p);
        }

#ifdef MOSAICISM_DEBUG
        vSegments.writeToTsv(m_current_experiment+"-chr"+m_current_chr+".seg2.tsv");
#endif
        // why "nullAll()" instead of "deleteAll()"?
        // because the pointers were copied to m_vSegments above and
        // AffxArray will delete the pointers in vSegments when it goes out of scope.
        vSegments.nullAll();
        delete[] pLog2Ratios;
    }
    Verbose::progressEnd(1, "Done");
    Verbose::out(1, "CNAnalysisMethodMosaicism::run(...) end");
}
void printSinglecopyDocument::sPrint()
{
  if (! isOkToPrint())
    return;

  bool mpStartedInitialized = isSetup();

  sClearPrintedList();

  MetaSQLQuery  docinfom(_docinfoQueryString);
  ParameterList alldocsp = getParamsDocList();
  XSqlQuery     docinfoq = docinfom.toQuery(alldocsp);
  while (docinfoq.next())
  {
    message(tr("Processing %1 #%2")
              .arg(_data->_doctypefull, docinfoq.value("docnumber").toString()));

    // This indirection allows scripts to replace core behavior - 14285
    emit aboutToStart(&docinfoq);
    emit timeToPrintOneDoc(&docinfoq);
    emit timeToMarkOnePrinted(&docinfoq);

    message("");
  }

  if (! mpStartedInitialized)
  {
    orReport::endMultiPrint(_data->_printer);
    setSetup(false);
  }

  if (_data->_printed.size() == 0)
    QMessageBox::information(this, tr("No Documents to Print"),
                             tr("There aren't any documents to print."));
  else if (! _markAllPrintedQry.isEmpty() &&
           QMessageBox::question(this, tr("Mark Documents as Printed?"),
                                 tr("<p>Did all of the documents print correctly?"),
                                 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
  {
    ParameterList allp;
    allp.append("printedDocs", QVariant(_data->_printed));
    MetaSQLQuery markAllPrintedm(_markAllPrintedQry);
    XSqlQuery markPrintedq = markAllPrintedm.toQuery(allp);
    ErrorReporter::error(QtCriticalMsg, this, tr("Database Error"),
                         markPrintedq, __FILE__, __LINE__); // don't return

    if (_data->_alert)
      emit docUpdated(-1);
  }

  sClearPrintedList();
  emit finishedWithAll();

  if (_data->_captive)
    accept();
  else
    clear();

  if (ErrorReporter::error(QtCriticalMsg, this, tr("Cannot Print"),
                           docinfoq, __FILE__, __LINE__))
    return;
}
Example #14
0
void ompl::base::Planner::checkValidity()
{
    if (!isSetup())
        setup();
    pis_.checkValidity();
}
//----------------------------------------
void ofxBox2dLineJoint::destroy() {
    if (!isSetup()) return;
    world->DestroyJoint(ljoint);
    ljoint = NULL;
    alive = false;
}
/**
 * @brief run the analysis
 */
void CNAnalysisMethodLOHCytoScan::run()
{
    Verbose::out(1, "CNAnalysisMethodLOHCytoScan::run(...) start");
    isSetup();

    getEngine()->setOpt("minSegSeparation", ::getInt(m_iLohCNSeparation));

    determineLocalProbeSets();

    std::vector<char> vHomHet(getProbeSets()->size());
    int iMarkerCount = 0;
    int iHetCutoff = 0;
    if (!lohPreProcessing(vHomHet, iMarkerCount, iHetCutoff)) {throw(Except("LohPreProcessing failed."));}
    int iLastChromosome = getProbeSets()->at(getProbeSets()->size() - 1)->getChromosome();
//    Verbose::progressBegin(1, "CNAnalysisMethodLOH::run(...) ", iLastChromosome, 1, iLastChromosome);
    for (int iChromosome = 1; (iChromosome <= iLastChromosome); iChromosome++)
    {
        try
        {
//        Verbose::progressStep(1);
        int iChromosomeProbeSetCount = 0;
        for (int iIndex = 0; (iIndex < (int)getProbeSets()->size()); iIndex++)
        {
            CNProbeSet* pobjProbeSet = getProbeSets()->at(iIndex);
            if ((vHomHet[iIndex] >= 0) && (pobjProbeSet->getChromosome() == iChromosome))
            {
                iChromosomeProbeSetCount++;
            }
        }
        std::vector<char> vChromosomeGenotypeCalls(iChromosomeProbeSetCount);
        std::vector<int> vChromosomePositions(iChromosomeProbeSetCount);
        std::vector<int> vChromosomeProbeSetIndexes(iChromosomeProbeSetCount);
        int iProbeSetIndex = 0;
        for (int iIndex = 0; (iIndex < (int)getProbeSets()->size()); iIndex++)
        {
            CNProbeSet* pobjProbeSet = getProbeSets()->at(iIndex);
            if ((vHomHet[iIndex] >= 0) && (pobjProbeSet->getChromosome() == iChromosome))
            {
                vChromosomeGenotypeCalls[iProbeSetIndex] = vHomHet[iIndex];
                vChromosomePositions[iProbeSetIndex] = pobjProbeSet->getPosition();
                vChromosomeProbeSetIndexes[iProbeSetIndex] = iIndex;
                iProbeSetIndex++;
            }
        }
        int iStartIndex = 0;
        for (int iIndex = 1; (iIndex <= iChromosomeProbeSetCount); iIndex++)
        {
            if ((iIndex == iChromosomeProbeSetCount) || ((getProbeSets()->at(vChromosomeProbeSetIndexes[iIndex])->getPosition() - getProbeSets()->at(vChromosomeProbeSetIndexes[iIndex - 1])->getPosition()) > m_iLohCNSeparation))
            {
                int iSegmentProbeSetCount = ((iIndex - 1) - iStartIndex + 1);
                if (iSegmentProbeSetCount >= iMarkerCount)
                {
                    std::vector<char> vSegmentGenotypeCalls(iSegmentProbeSetCount);
                    std::vector<int> vSegmentPositions(iSegmentProbeSetCount);
                    std::vector<char> vLoh(iSegmentProbeSetCount);
                    for (int iSegmentIndex = 0; (iSegmentIndex < iSegmentProbeSetCount); iSegmentIndex++)
                    {
                        vSegmentGenotypeCalls[iSegmentIndex] = vChromosomeGenotypeCalls[iStartIndex + iSegmentIndex];
                        vSegmentPositions[iSegmentIndex] = vChromosomePositions[iStartIndex + iSegmentIndex];
                    }
                    lohFind(vSegmentGenotypeCalls, vSegmentPositions, iMarkerCount, iHetCutoff, m_iLohCNMinGenomicSpan, vLoh);
                    for (int iSegmentIndex = 0; (iSegmentIndex < iSegmentProbeSetCount); iSegmentIndex++)
                    {
                        getProbeSets()->at(vChromosomeProbeSetIndexes[iStartIndex + iSegmentIndex])->setLoh(vLoh[iSegmentIndex]);
                    }
                }
                iStartIndex = iIndex;
            }
        }
        }
        catch(...) {Verbose::out(1, "CNAnalysisMethodLOHCytoScan::run(...) Working on Chromosome " + ::getInt(iChromosome)); throw;}
    }
    imputeMissingLOHCalls();
   //    Verbose::progressEnd(1, "Done");
    Verbose::out(1, "CNAnalysisMethodLOHCytoScan::run(...) end");
}