/* * The class constructor */ PixelView::PixelView(QWidget *parent, const char *name, Qt::WindowFlags fl) : QWidget(parent, fl) { int i, j, iz = B3DNINT(App->cvi->zmouse); setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_AlwaysShowToolTips); QVBoxLayout *vBox = new QVBoxLayout(this); vBox->setSpacing(3); // Make the mouse report box QHBoxLayout *hBox = diaHBoxLayout(vBox); mMouseLabel = diaLabel(" ", this, hBox); hBox->addStretch(); hBox->setSpacing(5); mFileValBox = diaCheckBox("File value", this, hBox); diaSetChecked(mFileValBox, fromFile); connect(mFileValBox, SIGNAL(toggled(bool)), this, SLOT(fromFileToggled(bool))); mFileValBox->setToolTip("Show value from file, not byte value from memory" ", at mouse position"); mFileValBox->setEnabled(fileReadable(App->cvi, iz)); QCheckBox *gbox = diaCheckBox("Grid", this, hBox); diaSetChecked(gbox, showButs); connect(gbox, SIGNAL(toggled(bool)), this, SLOT(showButsToggled(bool))); gbox->setToolTip("Show buttons with values from file or memory)"); hBox = diaHBoxLayout(vBox); mGridValBox = diaCheckBox("Grid value from file", this, hBox); diaSetChecked(mGridValBox, gridFromFile); connect(mGridValBox, SIGNAL(toggled(bool)), this, SLOT(gridFileToggled(bool))); mGridValBox->setToolTip("Show value from file, not byte value from memory" ", in each button"); mGridValBox->setEnabled(fileReadable(App->cvi, iz)); mConvertBox = NULL; if (App->cvi->rgbStore) { mConvertBox = diaCheckBox("Convert RGB to gray scale", this, hBox); diaSetChecked(mConvertBox, convertRGB); connect(mConvertBox, SIGNAL(toggled(bool)), this, SLOT(convertToggled(bool))); mConvertBox->setToolTip("Show luminance values instead of RGB triplets" ); }
bool Utils::fileToString(const std::string& path,std::string& out){ if(!fileReadable(path)) return false; std::ifstream ifs(path); out.assign((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); return true; }
bool LogType::validate() { writeInfo ( "config FILE = %s", getConfigFile().c_str()); // check if config file exists if( !fileExists(getConfigFile()) ) { writeError ("Can't find config FILE = %s", getConfigFile().c_str()); return false; } // check if config file can read if( !fileReadable(getConfigFile()) ) { writeError ("Can't read from config FILE = %s", getConfigFile().c_str()); return false; } // check if config file exists if( !iniParse(getConfigFile()) ) { writeError ("Can't parse config FILE = %s", getConfigFile().c_str()); return false; } bool result = parseStorageType() && parseIpAddress() && parseRemotePort() && parseSourcePort() && parseUdpBufferSize(); if (result) { __udp_socket = new boost::asio::ip::udp::socket( __io_service, boost::asio::ip::udp::endpoint( boost::asio::ip::address::from_string(getIpAddress()), getSourcePort())); __udp_remote_endpoint = new boost::asio::ip::udp::endpoint( boost::asio::ip::udp::endpoint( boost::asio::ip::address::from_string(getIpAddress()), getRemotePort())); } return result; }
/* * Display a new mouse position from whoever has one */ void pvNewMousePosition(ImodView *vi, float x, float y, int iz) { int ix = (int)x; int iy = (int)y; int isFloat = 0; float value; int red, green, blue; bool readable; unsigned char **data; QString str; lastMouseX = x; lastMouseY = y; if (!PixelViewDialog) return; if (ix < 0 || iy < 0 || ix >= vi->xsize || iy >= vi->ysize || iz < 0 || iz >= vi->zsize) return; readable = fileReadable(vi, iz); if (readable != lastReadable) { PixelViewDialog->mFileValBox->setEnabled(readable); lastReadable = readable; } if (fromFile && readable) { value = ivwGetFileValue(vi, ix, iy, iz); if (!(vi->image->mode == MRC_MODE_BYTE || vi->image->mode == MRC_MODE_SHORT || vi->image->mode == MRC_MODE_USHORT)) isFloat = 1; } else if (vi->rgbStore) { ivwGetTime(vi, &red); data = ivwGetZSectionTime(vi, iz, red); value = getAndConvertRGB(data, ix, iy, red, green, blue); } else value = ivwGetValue(vi, ix, iy, iz); if (isFloat) str.sprintf("Mouse: %5d, %5d, %4d Value: %9g", ix + 1, iy + 1, iz + 1, value); else str.sprintf("Mouse: %5d, %5d, %4d Value: %3d", ix + 1, iy + 1, iz + 1, (int)value); PixelViewDialog->mMouseLabel->setText(str); }
static FILE *_openIncludeFile(char *fname, char **newAllocName) { FILE *file = NULL; char fullName[_MAX_PATH]; pFDReadInd dir = NULL; char *fullNameCopy; strcpy(fullName, fname); rewindCurrSLListPos(g_opt.incPathList); do { setDefaultExt(fullName, "h"); if (fileReadable(fullName)) { file = wicFopen(fullName, "r"); if (file != NULL) { pFDReadInd newElem; fullNameCopy = wicStrdup(fullName); newElem = createFDReadInd(fullNameCopy, dir == NULL ? 0 : dir->readOnly); if (!addHTableElem(g_fileTable, newElem)) { reportError(ERR_FILE_WAS_INCLUDED, fullNameCopy); wicFclose(file); zapFDReadInd(newElem); file = NULL; } break; } } if (!getCurrSLListPosElem(g_opt.incPathList, &dir)) { strcpy(fullName, fname); setDefaultExt(fullName, "h"); reportError(ERR_INC_FILE_NOT_FOUND, fullName); break; } sprintf(fullName, "%s\\%s", dir->name, fname); incCurrSLListPos(g_opt.incPathList); } while (1); if (file == NULL) { *newAllocName = NULL; } else { *newAllocName = fullNameCopy; } return file; }
int main(int argc, char *argv[]) { int index; bool print = false; for (index = 1; index < argc; index++) { std::string str(argv[index]); if (str == "-S") { print = true; } else if (str == "-h" || str == "--help") { usage(); } else if (str == "-v" || str == "--version") { version(); } else { if (str[0] == '-') { llvm::outs() << "hoare: error: unrecognized command line option '" << str << "'\n"; } else { break; } } } bool compiled = false; for (; index < argc; index++) { if (!fileReadable(argv[index])) { continue; } if (!hoare::compile(argv[index], print)) { return 1; } compiled = true; } if (!compiled) { llvm::outs() << "hoare: error: no input files\n"; exit(1); } return 0; }