MainController::MainController() { width = 880; height = 520; // Init MainWindow and set the data mainWindow = new MainWindow(); mainWindow->setController(this); // Init the graph graph = std::make_shared<Graph>(mainWindow); initGraph(); // Init the units initUnits(); // Set the graph and the units mainWindow->setGraph(graph); mainWindow->setUnits(std::shared_ptr<Cow>(cow), std::shared_ptr<Chicken>(chicken)); mainWindow->resize(width, height); mainWindow->show(); gameLoop = std::unique_ptr<std::thread>(new std::thread(&MainController::run, this)); }
/* Parse cell attributes */ static vector<McObject*> aceAttrib(TiXmlElement* pElement) { /* Initialize XML attribute checker */ static const string required[4] = {"id","density","units","fraction"}; static XmlParser::XmlAttributes matAttrib(vector<string>(required, required + 4), vector<string>()); /* Check flags */ XmlParser::AttributeValue<string> units_flag("units","",initUnits()); XmlParser::AttributeValue<string> fraction_flag("fraction","",initFraction()); XmlParser::AttribMap mapAttrib = dump_attribs(pElement); /* Check user input */ matAttrib.checkAttributes(mapAttrib, "material"); /* Get attributes */ MaterialId id = fromString<MaterialId>(mapAttrib["id"]); double density = fromString<double>(mapAttrib["density"]); std::string units = units_flag.getValue(mapAttrib); std::string fraction = fraction_flag.getValue(mapAttrib); /* Push all the ACE objects (including the isotopes) */ vector<McObject*> ace_objects; /* Get isotopes */ TiXmlElement* pChild; map<string,double> isotopes; for (pChild = pElement->FirstChildElement(); pChild != 0; pChild = pChild->NextSiblingElement()) { string element_value(pChild->Value()); pair<string,double> pair_value = isoAttrib(pChild); string isotope = pair_value.first; /* Check if the user is not duplicating the isotope name */ map<string,double>::iterator it = isotopes.find(isotope); if(it == isotopes.end()) { /* Push isotope */ isotopes.insert(pair_value); ace_objects.push_back(new AceObject(pair_value.first)); } else { /* Duplicated name of isotope */ std::vector<std::string> keywords; XmlParser::AttribMap::const_iterator it_att = mapAttrib.begin(); for(; it_att != mapAttrib.end() ; ++it_att) { keywords.push_back((*it_att).first); keywords.push_back((*it_att).second); } throw Parser::KeywordParserError("Duplicated isotope with name " + isotope,keywords); } } /* Return surface definition */ ace_objects.push_back(new AceMaterialObject(id, density, units, fraction, isotopes)); return ace_objects; }
QPageSetupWidget::QPageSetupWidget(QWidget *parent) : QWidget(parent), m_pagePreview(0), m_printer(0), m_outputFormat(QPrinter::PdfFormat), m_units(QPageLayout::Point), m_blockSignals(false) { m_ui.setupUi(this); QVBoxLayout *lay = new QVBoxLayout(m_ui.preview); m_ui.preview->setLayout(lay); m_pagePreview = new QPagePreview(m_ui.preview); m_pagePreview->setPagePreviewLayout(1, 1); lay->addWidget(m_pagePreview); setAttribute(Qt::WA_WState_Polished, false); #ifdef PSD_ENABLE_PAPERSOURCE for (int i=0; paperSourceNames[i]; ++i) m_ui.paperSource->insertItem(paperSourceNames[i]); #else m_ui.paperSourceLabel->setVisible(false); m_ui.paperSource->setVisible(false); #endif m_ui.reverseLandscape->setVisible(false); m_ui.reversePortrait->setVisible(false); initUnits(); initPagesPerSheet(); connect(m_ui.unitCombo, SIGNAL(activated(int)), this, SLOT(unitChanged())); connect(m_ui.pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(pageSizeChanged())); connect(m_ui.pageWidth, SIGNAL(valueChanged(double)), this, SLOT(pageSizeChanged())); connect(m_ui.pageHeight, SIGNAL(valueChanged(double)), this, SLOT(pageSizeChanged())); connect(m_ui.leftMargin, SIGNAL(valueChanged(double)), this, SLOT(leftMarginChanged(double))); connect(m_ui.topMargin, SIGNAL(valueChanged(double)), this, SLOT(topMarginChanged(double))); connect(m_ui.rightMargin, SIGNAL(valueChanged(double)), this, SLOT(rightMarginChanged(double))); connect(m_ui.bottomMargin, SIGNAL(valueChanged(double)), this, SLOT(bottomMarginChanged(double))); connect(m_ui.portrait, SIGNAL(clicked()), this, SLOT(pageOrientationChanged())); connect(m_ui.landscape, SIGNAL(clicked()), this, SLOT(pageOrientationChanged())); connect(m_ui.pagesPerSheetCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(pagesPerSheetChanged())); }
bool ossimLasReader::parseVarRecords() { static const char M[] = "ossimLasReader::parseVarRecords"; if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n"; bool result = false; if ( isOpen() ) { std::streampos origPos = m_str.tellg(); std::streamoff pos = static_cast<std::streamoff>(m_hdr->getHeaderSize()); m_str.clear(); m_str.seekg(pos, std::ios_base::beg); ossim_uint32 vlrCount = m_hdr->getNumberOfVlrs(); ossim_uint16 reserved; char uid[17]; uid[16]='\n'; ossim_uint16 recordId; ossim_uint16 length; char des[33]; des[32] = '\n'; //--- // Things we need to save for printGeoKeys: //--- ossim_uint16* geoKeyBlock = 0; ossim_uint64 geoKeyLength = 0; ossim_float64* geoDoubleBlock = 0; ossim_uint64 geoDoubleLength = 0; ossim_int8* geoAsciiBlock = 0; ossim_uint64 geoAsciiLength = 0; ossimEndian* endian = 0; // LAS LITTLE ENDIAN: if ( ossim::byteOrder() == OSSIM_BIG_ENDIAN ) { endian = new ossimEndian; } for ( ossim_uint32 i = 0; i < vlrCount; ++i ) { m_str.read((char*)&reserved, 2); m_str.read(uid, 16); m_str.read((char*)&recordId, 2); m_str.read((char*)&length, 2); m_str.read(des, 32); // LAS LITTLE ENDIAN: if ( endian ) { endian->swap(recordId); endian->swap(length); } if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_DEBUG) << "uid: " << uid << "\nrecordId: " << recordId << "\nlength: " << length << "\ndes: " << des << std::endl; } if (recordId == 34735) // GeoTiff projection keys. { geoKeyLength = length/2; if ( geoKeyBlock ) { delete [] geoKeyBlock; } geoKeyBlock = new ossim_uint16[geoKeyLength]; m_str.read((char*)geoKeyBlock, length); if ( endian ) { endian->swap(geoKeyBlock, geoKeyLength); } } else if (recordId == 34736) // GeoTiff double parameters. { geoDoubleLength = length/8; if ( geoDoubleBlock ) { delete [] geoDoubleBlock; } geoDoubleBlock = new ossim_float64[geoDoubleLength]; m_str.read((char*)geoDoubleBlock, length); if ( endian ) { endian->swap(geoDoubleBlock, geoDoubleLength); } } else if (recordId == 34737) // GeoTiff ascii block. { geoAsciiLength = length; if (geoAsciiBlock) { delete [] geoAsciiBlock; } geoAsciiBlock = new ossim_int8[length]; m_str.read((char*)geoAsciiBlock, length); } else { m_str.seekg(length, ios_base::cur); } } //--- // Must have at mimimum the geoKeyBlock for a projection. // Note the geoDoubleBlock is needed for some. // Note the geoAsciiBlock is not needed, i.e. only informational. //--- if ( geoKeyBlock ) { //--- // Give the geokeys to ossimTiffInfo to get back a keyword list that can be fed to // ossimProjectionFactoryRegistry::createProjection //--- ossimTiffInfo info; ossimKeywordlist geomKwl; info.getImageGeometry(geoKeyLength, geoKeyBlock, geoDoubleLength,geoDoubleBlock, geoAsciiLength,geoAsciiBlock, geomKwl); // Create the projection. m_proj = ossimProjectionFactoryRegistry::instance()->createProjection(geomKwl); if (m_proj.valid()) { // Units must be set before initValues and initProjection. initUnits(geomKwl); // Must be called before initProjection. initValues(); result = initProjection(); // Sets the ties and scale... if (traceDebug()) { m_proj->print(ossimNotify(ossimNotifyLevel_DEBUG)); } } } if ( geoKeyBlock ) { delete [] geoKeyBlock; geoKeyBlock = 0; } if (geoDoubleBlock) { delete [] geoDoubleBlock; geoDoubleBlock = 0; } if (geoAsciiBlock) { delete [] geoAsciiBlock; geoAsciiBlock = 0; } m_str.seekg(origPos); if ( endian ) { delete endian; endian = 0; } } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " exit status = " << (result?"true\n":"false\n"); } return result; }