void Label::render() { Renderer* r; if (m_rectBgType == COLORED) { r = &Control::r_coloredRect; r->enableShader(); r->setData(R_COLORED_RECT::u_color, m_rectColor); updatePipeline(r); m_quadModel.render(); r->disableShader(); } else { r = &Control::r_texturedRect; r->enableShader(); r->setData(R_TEXTURED_RECT::u_texture, 0, GL_TEXTURE_2D, m_rectTexture); updatePipeline(r); m_quadModel.render(); r->disableShader(); } if (hasText()) { Control::m_textEngine.render(m_text, m_textStartingXs[0], m_textStartingYs[0], m_font.size, m_font.color, m_lineBreakInfos[0].lineBreaks); } }
void ListBox::customRender() { Renderer* r = &Control::r_texturedRectRenderer; Renderer* hlr = &Control::r_listBoxHighlightRenderer; for(int y = 0; y < m_curRowNum; y++) { for(int x = 0; x < m_colNum; x++) { int i = y * m_colNum + x; if( i == m_items.size()) break; /* // render texture int offset_x = m_rect.x + x * m_itemWidth; int offset_y = m_rect.y + y * m_itemHeight; Rect itemRect(offset_x, offset_y, m_itemWidth, m_itemHeight); */ Rect itemRect = m_items[i].rect; if (i == m_curIndex && m_curIndex >= 0) { float gap = 2; hlr->enableShader(); hlr->setData(RENDER_PASS1, "u_x1", itemRect.x + gap); hlr->setData(RENDER_PASS1, "u_x2", itemRect.x + itemRect.w - gap); hlr->setData(RENDER_PASS1, "u_y1", Control::toGUICoord(itemRect.y + itemRect.h - gap) ); hlr->setData(RENDER_PASS1, "u_y2", Control::toGUICoord(itemRect.y + gap) ); updatePipeline(hlr, itemRect); m_quadModel.render(); hlr->disableShader(); } r->enableShader(); Rect tempRect = m_items[i].modelRect; r->setData(RENDER_PASS1, "u_texture", 0, GL_TEXTURE0, m_items[i].textureID); updatePipeline(r, tempRect); m_quadModel.render(); r->disableShader(); // render text Control::m_textEngine.render(m_items[i].text, m_items[i].textStartingX, m_items[i].textStartingY, m_itemFont.size, m_itemFont.color, m_items[i].lineBreakInfo.lineBreaks); } } }
void CpuRiscV_Functional::busyLoop() { RISCV_event_wait(&config_done_); while (isEnabled()) { updatePipeline(); } }
void Label::render() { Control::r_coloredRectRenderer.enableShader(); Control::r_coloredRectRenderer.setData(RENDER_PASS1, "u_color", m_rectColor); updatePipeline(&Control::r_coloredRectRenderer); m_quadModel.render(); Control::m_textEngine.render(m_text, m_textStartingXs[0], m_textStartingYs[0], m_font.size, m_font.color, m_lineBreakInfos[0].lineBreaks); Control::r_coloredRectRenderer.disableShader(); }
void GLBackend::do_draw(Batch& batch, uint32 paramOffset) { updateInput(); updateTransform(); updatePipeline(); Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint; GLenum mode = _primitiveToGLmode[primitiveType]; uint32 numVertices = batch._params[paramOffset + 1]._uint; uint32 startVertex = batch._params[paramOffset + 0]._uint; glDrawArrays(mode, startVertex, numVertices); (void) CHECK_GL_ERROR(); }
void GLBackend::do_drawIndexed(Batch& batch, uint32 paramOffset) { updateInput(); updateTransform(); updatePipeline(); Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint; GLenum mode = _primitiveToGLmode[primitiveType]; uint32 numIndices = batch._params[paramOffset + 1]._uint; uint32 startIndex = batch._params[paramOffset + 0]._uint; GLenum glType = _elementTypeToGLType[_input._indexBufferType]; glDrawElements(mode, numIndices, glType, reinterpret_cast<GLvoid*>(startIndex + _input._indexBufferOffset)); (void) CHECK_GL_ERROR(); }
void vtkDataMeshInteractor::setData(medAbstractData *data) { medAbstractInteractor::setData(data); if(data->identifier() == "vtkDataMesh4D" || data->identifier() == "vtkDataMesh") { vtkMetaDataSet * mesh = dynamic_cast<vtkMetaDataSet*>((vtkDataObject *)(data->data())); d->metaDataSet = mesh; d->lut = LutPair(NULL, "Default"); updatePipeline(); setupParameters(); } qDebug() << d->metaDataSet->GetType(); }
void Button::render() { #if 1 Control::r_coloredRect.enableShader(); /* if(m_isInside && !m_down) Control::r_coloredRectRenderer.setData(RENDER_PASS1, "u_color", m_highlightColor); else if (m_down) Control::r_coloredRectRenderer.setData(RENDER_PASS1, "u_color", m_pressedColor); else Control::r_coloredRectRenderer.setData(RENDER_PASS1, "u_color", m_rectColor); */ if(m_isInside && !m_down) Control::r_coloredRect.setData(R_COLORED_RECT::u_color, m_highlightColor); else if (m_down) Control::r_coloredRect.setData(R_COLORED_RECT::u_color, m_pressedColor); else Control::r_coloredRect.setData(R_COLORED_RECT::u_color, m_rectColor); updatePipeline(&Control::r_coloredRect); m_quadModel.render(); // Control::m_textEngine.render(m_text, m_textStartingXs[0], m_textStartingYs[0], m_font.size, m_font.color); if (hasText()) { Control::m_textEngine.render(m_text, m_textStartingXs[0], m_textStartingYs[0], m_font.size, m_font.color, m_lineBreakInfos[0].lineBreaks); } Control::r_coloredRect.disableShader(); #endif // cout << "offset_x " << offset_x << endl; // cout << "offset_y " << offset_y << endl; // Control::m_textEngine.render(m_pipeline, offset_x, offset_y, m_text.c_str()); /* Renderer->enableShader(RenderPassID); if(m_isInside && !m_down) { p.pushMatrix(); p.scale(m_rect.w, m_rect.y, 0); p.translate(m_rect.x, m_rect.y, 0); Renderer->setUniLocs(p, RenderPassID); m_quadModel.render(); p.popMatrix(); float offset_x = 0.025 * m_rect.w; float offset_y = 0.05 * m_rect.h; m_pipeline.pushMatrix(); m_pipeline.translate( glm::vec3(m_rect.x + offset_x, m_rect.y + offset_y, 0) ); m_pipeline.scale(0.95,0.9,1.0); Control::customMatrixRender(m_pipeline, Renderer, RENDER_PASS1); m_pipeline.popMatrix(); } else if (m_down) { p_model = &m_pressed; Control::render(m_pipeline, Renderer, RENDER_PASS1, p_model); } else Control::render(m_pipeline, Renderer, RENDER_PASS1); int offset_x = computeTextStartingX(m_text); int offset_y = computeTextStartingY(); Renderer->disableShader(RenderPassID); // cout << "offset_x " << offset_x << endl; // cout << "offset_y " << offset_y << endl; // Control::m_textEngine.render(m_pipeline, offset_x, offset_y, m_text.c_str()); */ }
void ListBox::render() { #if 0 Renderer* r = &Control::r_texturedRectRenderer; Renderer* hlr = &Control::r_listBoxHighlightRenderer; for (int y = 0; y < m_curRowNum; y++) { for (int x = 0; x < m_colNum; x++) { int i = y * m_colNum + x; if (i == m_items.size()) break; /* // render texture int offset_x = m_rect.x + x * m_itemWidth; int offset_y = m_rect.y + y * m_itemHeight; Rect itemRect(offset_x, offset_y, m_itemWidth, m_itemHeight); */ Rect itemRect = m_items[i].rect; if (i == m_curIndex && m_curIndex >= 0) { float gap = 2; hlr->enableShader(); hlr->setData(RENDER_PASS1, "u_x1", itemRect.x + gap); hlr->setData(RENDER_PASS1, "u_x2", itemRect.x + itemRect.w - gap); hlr->setData(RENDER_PASS1, "u_y1", Control::toGUICoord(itemRect.y + itemRect.h - gap)); hlr->setData(RENDER_PASS1, "u_y2", Control::toGUICoord(itemRect.y + gap)); updatePipeline(hlr, itemRect); m_quadModel.render(); hlr->disableShader(); } r->enableShader(); Rect tempRect = m_items[i].modelRect; r->setData(RENDER_PASS1, "u_texture", 0, GL_TEXTURE_2D, m_items[i].textureID); updatePipeline(r, tempRect); m_quadModel.render(); r->disableShader(); // render text Control::m_textEngine.render(m_items[i].text, m_items[i].textStartingX, m_items[i].textStartingY, m_itemFont.size, m_itemFont.color, m_items[i].lineBreakInfo.lineBreaks); } } #endif /* Control::r_coloredRectRenderer.enableShader(); Control::r_coloredRectRenderer.setData(RENDER_PASS1, "u_color", m_rectColor); updatePipeline(&Control::r_coloredRectRenderer); m_quadModel.render(); // render the itemRectBox if( m_curIndex >= 0) { int offset_x = m_rect.x + m_curIndexX * m_itemWidth; int offset_y = m_rect.y + m_rect.h - ((m_curIndexY + 1) * m_itemHeight); Rect itemRect(offset_x, offset_y, m_itemWidth, m_itemHeight); Control::r_coloredRectRenderer.setData(RENDER_PASS1, "u_color", m_itemRectColor); updatePipeline(&Control::r_coloredRectRenderer, itemRect); m_quadModel.render(); } Control::r_coloredRectRenderer.disableShader(); for(int y = 0; y < m_curRowNum; y++) { for(int x = 0; x < m_colNum; x++) { int index = y * m_colNum + x; if( index == m_items.size()) { break; } else { int offset_x = m_rect.x + x * m_itemWidth; int offset_y = m_rect.y + m_rect.h - ((y + 1) * m_itemHeight) + 10; Control::m_textEngine.render(m_items[index].m_text, offset_x, offset_y, 0.4f, glm::vec3(0.5, 0.8f, 0.2f)); } } } */ }
void MinimalImpactTEDWriter::write(std::string filename) { updateInputs(); initPipeline(); int limitToISI = -1; if (optionLimitToISI) limitToISI = optionLimitToISI.as<int>() - SliceHashConfiguration::sectionOffset; if (optionWriteTedConditions) filename = "minimalImpactTEDconditions.txt"; // append ISI number to output filename if (limitToISI >= 0) filename = filename + "_" + optionLimitToISI.as<std::string>(); if (optionWriteTedConditions) { LOG_USER(minimalImpactTEDlog) << "writing ted conditions to " << filename << std::endl; } else { LOG_USER(minimalImpactTEDlog) << "writing ted coefficients to " << filename << std::endl; } // Remove the old file if( remove( filename.c_str() ) != 0 ) { LOG_DEBUG(minimalImpactTEDlog) << "Old file to output minimal impact TED approximation sucessfully deleted." << std::endl; } else { LOG_DEBUG(minimalImpactTEDlog) << "Could not delete old file to output minimal impact TED approximation." << std::endl; } // Open file for writing std::ofstream outfile; outfile.open(filename.c_str()); // Get a vector with all gold standard segments. const std::vector<boost::shared_ptr<Segment> > goldStandard = _goldStandard->getSegments(); int constant = 0; // Loop through variables std::set<unsigned int> variables = _problemConfiguration->getVariables(); LOG_USER(minimalImpactTEDlog) << "computing ted coefficients for " << variables.size() << " variables" << std::endl; if (optionWriteTedConditions) { outfile << "# hash: [hashes of flipped segments]" << std::endl; } else { outfile << "numVar " << variables.size() << std::endl; outfile << "# var_num costs # hash value_in_gs fs fm fp fn ( <- when flipped )" << std::endl; } std::set<unsigned int> goldStandardIds; foreach (boost::shared_ptr<Segment> s, goldStandard) goldStandardIds.insert(s->getId()); // create a map from segment ids to segment pointers std::map<unsigned int, boost::shared_ptr<Segment> > idToSegment; foreach (boost::shared_ptr<Segment> segment, _segments->getSegments()) idToSegment[segment->getId()] = segment; for ( unsigned int varNum = 0 ; varNum < variables.size() ; varNum++ ) { unsigned int segmentId = _problemConfiguration->getSegmentId(varNum); int interSectionInterval = _problemConfiguration->getInterSectionInterval(varNum); if (limitToISI >= 0) if (interSectionInterval != limitToISI) continue; std::string timerMessage = "\n\nMinimalImpactTEDWriter: variable " + boost::lexical_cast<std::string>(varNum) + ", %ws\n\n"; boost::timer::auto_cpu_timer timer(timerMessage); // re-create the pipeline for the current segment and its inter-section // interval if (!optionWriteTedConditions) updatePipeline(interSectionInterval, optionNumAdjacentSections.as<int>()); // Is the segment that corresponds to the variable part of the gold standard? bool isContained = (goldStandardIds.count(segmentId) > 0); // get the hash value of this segment SegmentHash segmentHash = idToSegment[segmentId]->hashValue(); // pin the value of the current variable to its opposite _linearSolver->pinVariable(varNum, (isContained ? 0 : 1)); if (!optionWriteTedConditions) { pipeline::Value<TolerantEditDistanceErrors> errors = _teDistance->getOutput("errors"); int sumErrors = errors->getNumSplits() + errors->getNumMerges() + errors->getNumFalsePositives() + errors->getNumFalseNegatives(); outfile << "c" << varNum << " "; outfile << (isContained ? -sumErrors : sumErrors) << " "; outfile << "# "; outfile << segmentHash << " "; outfile << (isContained ? 1 : 0) << " "; outfile << errors->getNumSplits() << " "; outfile << errors->getNumMerges() << " "; outfile << errors->getNumFalsePositives() << " "; outfile << errors->getNumFalseNegatives() << std::endl; if (isContained) { // Forced segment to not be part of the reconstruction. // This resulted in a number of errors that are going to be stored in the constant. // To make net 0 errors when the variable is on, minus the number of errors will be written to the file. constant += sumErrors; } } else { pipeline::Value<Solution> solution = _linearSolver->getOutput("solution"); outfile << segmentHash << ":"; for (unsigned int i = 0; i < variables.size(); i++) { unsigned int id = _problemConfiguration->getSegmentId(i); // was flipped? if ((*solution)[i] != goldStandardIds.count(id)) outfile << " " << idToSegment[id]->hashValue(); } outfile << std::endl; } // Remove constraint _linearSolver->unpinVariable(varNum); } if (!optionWriteTedConditions) { // Write constant to file outfile << "constant " << constant << std::endl; } outfile.close(); }