/*! * // Tab "General" */ void XYFitCurveDock::setupGeneral() { QWidget* generalTab = new QWidget(ui.tabGeneral); uiGeneralTab.setupUi(generalTab); QGridLayout* gridLayout = dynamic_cast<QGridLayout*>(generalTab->layout()); if (gridLayout) { gridLayout->setContentsMargins(2,2,2,2); gridLayout->setHorizontalSpacing(2); gridLayout->setVerticalSpacing(2); } cbXDataColumn = new TreeViewComboBox(generalTab); gridLayout->addWidget(cbXDataColumn, 4, 4, 1, 2); cbYDataColumn = new TreeViewComboBox(generalTab); gridLayout->addWidget(cbYDataColumn, 5, 4, 1, 2); cbWeightsColumn = new TreeViewComboBox(generalTab); gridLayout->addWidget(cbWeightsColumn, 6, 4, 1, 2); uiGeneralTab.cbModel->addItem(i18n("Polynomial")); uiGeneralTab.cbModel->addItem(i18n("Power")); uiGeneralTab.cbModel->addItem(i18n("Exponential")); uiGeneralTab.cbModel->addItem(i18n("Inverse Exponential")); uiGeneralTab.cbModel->addItem(i18n("Fourier")); uiGeneralTab.cbModel->addItem(i18n("Gaussian")); uiGeneralTab.cbModel->addItem(i18n("Lorentz (Cauchy)")); uiGeneralTab.cbModel->addItem(i18n("Maxwell-Boltzmann")); uiGeneralTab.cbModel->addItem(i18n("Sigmoid")); uiGeneralTab.cbModel->addItem(i18n("Custom")); uiGeneralTab.teEquation->setMaximumHeight(uiGeneralTab.leName->sizeHint().height()*2); uiGeneralTab.tbConstants->setIcon( KIcon("labplot-format-text-symbol") ); uiGeneralTab.tbFunctions->setIcon( KIcon("preferences-desktop-font") ); uiGeneralTab.pbRecalculate->setIcon(KIcon("run-build")); QHBoxLayout* layout = new QHBoxLayout(ui.tabGeneral); layout->setMargin(0); layout->addWidget(generalTab); //Slots connect( uiGeneralTab.leName, SIGNAL(returnPressed()), this, SLOT(nameChanged()) ); connect( uiGeneralTab.leComment, SIGNAL(returnPressed()), this, SLOT(commentChanged()) ); connect( uiGeneralTab.chkVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) ); connect( uiGeneralTab.cbModel, SIGNAL(currentIndexChanged(int)), this, SLOT(modelChanged(int)) ); connect( uiGeneralTab.sbDegree, SIGNAL(valueChanged(int)), this, SLOT(updateModelEquation()) ); connect( uiGeneralTab.teEquation, SIGNAL(expressionChanged()), this, SLOT(enableRecalculate()) ); connect( uiGeneralTab.tbConstants, SIGNAL(clicked()), this, SLOT(showConstants()) ); connect( uiGeneralTab.tbFunctions, SIGNAL(clicked()), this, SLOT(showFunctions()) ); connect( uiGeneralTab.pbParameters, SIGNAL(clicked()), this, SLOT(showParameters()) ); connect( uiGeneralTab.pbOptions, SIGNAL(clicked()), this, SLOT(showOptions()) ); connect( uiGeneralTab.pbRecalculate, SIGNAL(clicked()), this, SLOT(recalculateClicked()) ); }
VideoExtractor::VideoExtractor(bool dual, VideoReader * source1, VideoReader * source2 ) : m_stopped(true), m_dual(dual), m_videoStream{ source1 , source2 }, m_currentParent(nullptr) { auto lambda = [this]( QVariant Value, HandleParameters * hp ) { hideParameters(); hp->acceptChanges(Value); if( m_currentParent ) showParameters(m_currentParent); }; m_paramHandle.setActionOnChangeValue( lambda ); threadLanced = false; }
VideoExtractor::VideoExtractor(bool dual, VideoReader * source1, VideoReader * source2 ) : m_autoPlay(false), m_currentParent(nullptr), m_dual(dual), m_isHandleActived(true), m_stopped(true), m_videoStream{ source1 , source2 } { m_paramHandle.setActionOnChangeValue( [this]( QVariant Value, HandleParameters * hp ) { hideParameters(); hp->acceptChanges(Value); if( m_currentParent ) showParameters(m_currentParent); } ); }
//-----------------------------------------------------------------------// void CDelphiDataMarshal::updateParameters() { // ++++++ update parameters after reading the parameter file ++++++// //*****************************************************************// // // // perform updates after reading the parameter file // // // //*****************************************************************// if (-1 == vctfProbeRadius[1]) vctfProbeRadius[1] = vctfProbeRadius[0]; /* * parameters set at the end of subroutine rdprm */ if (0 > fExDielec || 0 > fInDielec) { CMinusDielec warning(fExDielec, fInDielec); fExDielec = abs(fExDielec); fInDielec = abs(fInDielec); } delphi_real fZ1Plus = vctiValence1[0]; // valence 1 delphi_real fZ1Minus = vctiValence1[1]; delphi_real fZ2Plus = vctiValence2[0]; // valence 2 delphi_real fZ2Minus = vctiValence2[1]; /* * concentration of positive ion */ delphi_real fZ1PlusConcentrate = vctfSalt[0]*fZ1Minus; delphi_real fZ2PlusConcentrate = vctfSalt[1]*fZ2Minus; fIonStrength = (fZ1PlusConcentrate*fZ1Plus*(fZ1Plus+fZ1Minus) + fZ2PlusConcentrate*fZ2Plus*(fZ2Plus+fZ2Minus))/2.0; /* * coefficients in Taylor series of the charge concentration apart from n! (order >=1) * (chuan 2012Apr24) Correct coefficients in Taylor series. NOT in compact form just for clean math formula */ fTaylorCoeff1 = -2.0*fIonStrength; fTaylorCoeff2 = ( fZ1PlusConcentrate*fZ1Plus *pow(fZ1Plus, 2) - fZ1PlusConcentrate*fZ1Minus*pow(fZ1Minus,2) + fZ2PlusConcentrate*fZ2Plus *pow(fZ2Plus, 2) - fZ2PlusConcentrate*fZ2Minus*pow(fZ2Minus,2) )/2.0; fTaylorCoeff3 = -( fZ1PlusConcentrate*fZ1Plus *pow(fZ1Plus, 3) + fZ1PlusConcentrate*fZ1Minus*pow(fZ1Minus,3) + fZ2PlusConcentrate*fZ2Plus *pow(fZ2Plus, 3) + fZ2PlusConcentrate*fZ2Minus*pow(fZ2Minus,3) )/6.0; fTaylorCoeff4 = ( fZ1PlusConcentrate*fZ1Plus *pow(fZ1Plus, 4) - fZ1PlusConcentrate*fZ1Minus*pow(fZ1Minus,4) + fZ2PlusConcentrate*fZ2Plus *pow(fZ2Plus, 4) - fZ2PlusConcentrate*fZ2Minus*pow(fZ2Minus,4) )/24.0; fTaylorCoeff5 = -( fZ1PlusConcentrate*fZ1Plus *pow(fZ1Plus, 5) + fZ1PlusConcentrate*fZ1Minus*pow(fZ1Minus,5) + fZ2PlusConcentrate*fZ2Plus *pow(fZ2Plus, 5) + fZ2PlusConcentrate*fZ2Minus*pow(fZ2Minus,5) )/120.0; /* * convert ionic strength to debye length */ if (fZero < fIonStrength) { delphi_real fDebyeFactor = 0.01990076478*sqrt(fTemper*fExDielec); fDebyeLength = fDebyeFactor/sqrt(fIonStrength); if (0 < iNonIterateNum) bNonlinearEng = true; } else { bIonsEng = false; fDebyeLength = 1.0e6; } /* * epkt assignment as a function of temperature */ fEPKT = dEPK/fTemper; /* * set epsin and epsout (= epkt adjusted dielectrics such that all distances are in angstroms, charges in e) */ fEpsIn = fInDielec/fEPKT; fEpsOut = fExDielec/fEPKT; /* * test for unformatted pdb and frc files * the same tests have been implemented in class CIO. However, here users may make mistakes in parameter file to * require wrong format of the files. So check again to reset format flags. */ string strASCI = "1234567890 .-+#,$asdfghjklzxcvbnmqwertyuiopASDFGHJKLZXCVBNMQWERTYUIOP)(}{][/"; ifstream ifFileHandle; char cTestChar[80]; if (!bPdbUnformatIn) // PDB file { ifFileHandle.open(strPdbFile.c_str()); if (!ifFileHandle.is_open()) throw CUnknownFile(strPdbFile); ifFileHandle.read(cTestChar,80); int iCount = 0; for (int i = 0; i < 80; i++) { if (string::npos == strASCI.find(cTestChar[i]) ) iCount += 1; } if (10 < iCount) // unformatted PDB { bPdbUnformatIn = true; CToUnformattedFile warning(strPdbFile,strASCI); } ifFileHandle.close(); } if (bUnformatFrcOut) // FRC file { ifFileHandle.open(strFrcFile.c_str()); if (!ifFileHandle.is_open()) throw CUnknownFile(strFrcFile); ifFileHandle.read(cTestChar,80); int iCount = 0; for (int i = 0; i < 80; i++) { if (string::npos == strASCI.find(cTestChar[i]) ) iCount += 1; } if (10 < iCount) // unformatted FRC { CToUnformattedFile warning(strFrcFile,strASCI); bFrcUnformatIn = true; } ifFileHandle.close(); } //*****************************************************************// // // // read size, charge, PDB files // // // //*****************************************************************// unique_ptr<CIO> pIO(new CIO(fInDielec,fEPKT)); // smart unique_ptr pIO->setDelphiAtom(bSolvePB,bSurfCrgInSite,strSizeFile,strCrgFile,strPdbFile,iPdbFormatIn,bPdbUnformatIn,strCommPDB); iMediaNum = pIO->iMediaNum; // nmedia iObjectNum = pIO->iObjectNum; // nobject iAtomNum = pIO->iAtomNum; // natom iResidueNum = pIO->iResidueNum; // resnummax bOnlyMolecule = pIO->bOnlyMolecule; // ionlymol vctapAtomPdb = pIO->vctapAtomPdb; // delphipdb(natom) vctfMediaEps = pIO->vctfMediaEps; // medeps(0:nmediamax) vctstrObject = pIO->vctstrObject; // dataobject(nobjectmax,2) vctiAtomMediaNum = pIO->vctiAtomMediaNum; // iatmmed(Natom+Nobjectmax) /* * write unformatted PDB file */ if (bUnformatPdbOut) pIO->writeUnformatPdb(strUnformatPdbFile); /* * write mod/pqr/mod4/pqr4-type PDB file */ if (bModPdbOut) pIO->writeModifiedPdb(strModifiedPdbFile,iModPdbFormatOut); fEpsIn = pIO->vctfMediaEps[1]; if (1 < iMediaNum) iDirectEpsMap = 1; //--------------------------- extrmobjects ------------------------// /* * extrmobjects: find extrema of each object and according to them limobject contains extreme * values of each object for a molecule it has extreme but without radii */ iMoleculeNum = 0; // numbmol fMaxRadius = 0.01; // rdmx SExtrema<delphi_real> tmpExtrema; for (unsigned int i = 0; i < vctstrObject.size(); i=i+2) { string strLine = vctstrObject[2*i]; // vctstrObject[0][nobject] if (0 != strLine.compare(0,4,"is a")) throw CIsAnObjectType(strLine); iMoleculeNum += 1; #ifdef VERBOSE cout << "Object number " << i << " is a molecule\n"; #endif //cout << "## iAtomNum: " << iAtomNum << endl; if (0 == iAtomNum) throw CNoAtomsInMolecule(i); SGrid<delphi_real> gMinCoord = vctapAtomPdb[0].getPose(); SGrid<delphi_real> gMaxCoord = vctapAtomPdb[0].getPose(); fMaxRadius = vctapAtomPdb[0].getRadius(); for (delphi_integer j = 1; j < iAtomNum; j++) { gMinCoord = optMin<delphi_real>(gMinCoord,vctapAtomPdb[j].getPose()); gMaxCoord = optMax<delphi_real>(gMaxCoord,vctapAtomPdb[j].getPose()); fMaxRadius = max(fMaxRadius,vctapAtomPdb[j].getRadius()); } tmpExtrema.nMin = gMinCoord; tmpExtrema.nMax = gMaxCoord; vctefExtrema.push_back(tmpExtrema); } //------------------------------ extrm ---------------------------// /* * find extrema and calculate scale according to them and to the percent box fill */ gfMinCoordinate.nX = 6000.0; gfMinCoordinate.nY = 6000.0; gfMinCoordinate.nZ = 6000.0; gfMaxCoordinate.nX =-6000.0; gfMaxCoordinate.nY =-6000.0; gfMaxCoordinate.nZ =-6000.0; for (delphi_integer i = 0; i < iAtomNum; i++) { gfMinCoordinate = optMin<delphi_real>(gfMinCoordinate,vctapAtomPdb[i].getPose()-vctapAtomPdb[i].getRadius()); gfMaxCoordinate = optMax<delphi_real>(gfMaxCoordinate,vctapAtomPdb[i].getPose()+vctapAtomPdb[i].getRadius()); } gfGeometricCenter = (gfMinCoordinate + gfMaxCoordinate)/2.0; //------------------------------- off ----------------------------// if (bIsAcent) gfBoxCenter = gfAcent; else { gfBoxCenter = gfGeometricCenter - gfOffCenter/fScale; if (fZero > abs(gfOffCenter.nX-999.0) || fZero > abs(gfOffCenter.nX-777.0)) { if (fZero > abs(gfOffCenter.nX-999.0)) { cout << "modifying midpoints using frc input file \n"; gfBoxCenter = pIO->readFrcFile(strFrciFile,gfOffCenter,fScale); } else { cout << "modifying midpoints using fort.27 \n"; gfBoxCenter = pIO->readFrcFile(strCentFile,gfOffCenter,fScale); } } // ---------- end of if (fZero > abs(gfOffCenter-999.0) || fZero > abs(gfOffCenter-777.0)) } // ---------- end of if (bIsAcent) gfCoordinateRange = gfMaxCoordinate - gfMinCoordinate; { SGrid<delphi_real> gVec1 = 2.0*optABS<delphi_real>(gfMaxCoordinate-gfBoxCenter); delphi_real fMaxVal1 = optMax<delphi_real>(gVec1); SGrid<delphi_real> gVec2 = 2.0*optABS<delphi_real>(gfMinCoordinate-gfBoxCenter); delphi_real fMaxVal2 = optMax<delphi_real>(gVec2); fMaxDimension = (fMaxVal1 > fMaxVal2) ? fMaxVal1 : fMaxVal2; } if (0 == iGrid) { if (fZero > abs(fScale-10000.0) ) fScale = 2.0; if (fZero > abs(fPercentageFill-10000.0) ) fPercentageFill = 80.0; iGrid = fScale*100.0/fPercentageFill*fMaxDimension; } else if (fZero > abs(fScale-10000.0) ) { if (fZero > abs(fPercentageFill-10000.0) ) { fScale = 2.0; fPercentageFill = 100.0*fMaxDimension*fScale/(iGrid-1); } else fScale = (iGrid-1)*fPercentageFill/(100.0*fMaxDimension); } else fPercentageFill = 100.0*fMaxDimension*fScale/(iGrid-1); if (0 == iGrid%2) iGrid += 1; vctfMediaEps[0] = fEpsOut; if (bPdbUnformatIn && bUnformatPdbOut) CReadWriteUnformatPdb warning(bUnformatPdbOut); if (bFrcUnformatIn && bUnformatFrcOut) CReadWriteUnformatFrc warning(bUnformatPdbOut); SGrid<delphi_real> gLeftBndy = gfBoxCenter - (1.0/fScale)*(iGrid+1)*0.5; SGrid<delphi_real> gRightBndy = gfBoxCenter + (1.0/fScale)*(iGrid+1)*0.5; if (optORLT(gfMinCoordinate,gLeftBndy) || optORGT(gfMaxCoordinate,gRightBndy)) CSystemOutsideBox warning; /* * convert atom coordinates from angstroms to grid units * Added allocation of xn1 array in order to deal with different names in real (atpos) and dummy (xn1) * arguments in following subroutines */ for (delphi_integer i = 0; i < iAtomNum; i++) { vctgfAtomCoordA.push_back( vctapAtomPdb[i].getPose() ); vctgfAtomCoordG.push_back( (vctapAtomPdb[i].getPose()-gfBoxCenter)*fScale+(delphi_real)((iGrid+1)/2) ); } /* * verify if dielectric is uniform */ bUniformDielec = true; for (delphi_integer i = 0; i < iMediaNum; i++) { if (vctfMediaEps[i] != vctfMediaEps[i+1]) bUniformDielec = false; } /* * now pass uniformdiel to epsmak make the epsmap, and also a listing of boundary elements, and the * second epsmap used for the molecular surface scaling */ //prgiEpsMap.assign(iGrid*iGrid*iGrid,0); //vctbDielecMap.assign(iGrid*iGrid*iGrid,false); /* * new updates in c++ for more rigid check of input parameter values */ if (false == bAutoConverge && 0 == iLinIterateNum && 0 == iNonIterateNum) throw CBadAutoConvergence(bAutoConverge); showParameters(); pIO.reset(); }
void ZI::showParameters(void) { showParameters(m_parent); }
int main(int argc,char **argv) { std::string ifile = ""; OpenBabel::OBSpectrophore::AccuracyOption accuracy = OpenBabel::OBSpectrophore::AngStepSize20; OpenBabel::OBSpectrophore::StereoOption stereo = OpenBabel::OBSpectrophore::NoStereoSpecificProbes; OpenBabel::OBSpectrophore::NormalizationOption normalization = OpenBabel::OBSpectrophore::NoNormalization; double resolution = 3.0; int c; opterr = 0; std::string msg; while ((c = getopt(argc, argv, "ui:n:a:s:r:h")) != -1) { switch (c) { case 'u': showImplementationDetails(argv[0]); exit(1); break; case 'i': if (!isValidValue('i', optarg)) { msg = "Option -i is followed by an invalid argument: "; msg += optarg; showError(msg); exit(1); } else { ifile = optarg; } break; case 'n': if (!isValidValue('n', optarg)) { msg = "Option -n is followed by an invalid argument: "; msg += optarg; showError(msg); exit(1); } else normalization = stringToNormalizationOption(optarg); break; case 'a': if (!isValidValue('a', optarg)) { msg = "Option -a is followed by an invalid argument: "; msg += optarg; showError(msg); exit(1); } else accuracy = stringToAccuracyOption(optarg); break; case 's': if (!isValidValue('s', optarg)) { msg = "Option -s is followed by an invalid argument: "; msg += optarg; showError(msg); exit(1); } else stereo = stringToStereoOption(optarg); break; case 'r': if (!isValidValue('r', optarg)) { msg = "Option -r is followed by an invalid argument: "; msg += optarg; showError(msg); exit(1); } else { resolution = atof(optarg); if (resolution <= 0) { msg = "Resolution -r should be larger than 0.0: "; msg += optarg; showError(msg); exit(1); } } break; case 'h': showHelp(argv[0]); exit(0); break; case '?': if ((optopt == 'i') || (optopt == 'n') || (optopt == 'a') || (optopt == 's') || (optopt == 'r')) { msg = "Option -"; msg += optopt; msg += " requires an argument."; showError(msg); exit(1); } else { msg = "Unknown option -"; msg += optopt; msg += "."; showError(msg); exit(1); } break; default: showError("Unknown option"); exit(1); break; } } // The input file (-i) is the only required option if (ifile.empty()) { msg = "Input file specification is required (option -i)."; showError(msg); exit(1); } OpenBabel::OBConversion obconversion; OpenBabel::OBFormat *format = obconversion.FormatFromExt(ifile.c_str()); if (!format) { msg = "Could not find file format for "; msg += ifile; showError(msg); exit(1); } obconversion.SetInFormat(format); std::ifstream ifs; ifs.open(ifile.c_str()); obconversion.SetInStream(&ifs); // Start calculations OpenBabel::OBMol mol; OpenBabel::OBSpectrophore spec; spec.SetAccuracy(accuracy); spec.SetNormalization(normalization); spec.SetStereo(stereo); spec.SetResolution(resolution); showParameters(spec, ifile); unsigned int count(0); while (obconversion.Read(&mol)) { std::vector<double> result = spec.GetSpectrophore(&mol); if (result.empty()) { std::cerr << "Error calculating Spectrophore from molecule number "; std::cerr << count; std::cerr << " (counting starts at 0)!"; std::cerr << std::endl; } else { std::cout << mol.GetTitle() << "\t"; for (unsigned int i(0); i < result.size(); ++i) { std::cout << result[i] << "\t"; } std::cout << std::endl; } mol.Clear(); ++count; } return 0; }
bool MRFRegistrationDisplay::setMITKImageSeries(mitk::DataNode::Pointer imageSeries) { // try and cast the image mitk::Image::Pointer mitkImage = dynamic_cast<mitk::Image*>(imageSeries->GetData()); if(mitkImage.IsNull()) { std::cout << "Problem with the data you are tying to register" << std::endl; return false; } this->mitkImageSeries = imageSeries; // convert this image series into a stack of itk images int numImages = mitkImage->GetTimeSteps(); // get each image from the series and create a itk image for each one for(int i = 0; i < numImages; i++) { mitk::Image::Pointer timeStep = mitk::Image::New(); mitk::ImageSliceSelector::Pointer timeImageSelector = mitk::ImageSliceSelector::New(); timeImageSelector->SetInput(mitkImage); timeImageSelector->SetTimeNr(i); timeImageSelector->SetSliceNr(0); try { timeImageSelector->Update(); } catch( mitk::Exception &e ) { std::cerr << "Problem extracting the time slice from the series" << std::endl; std::cerr << e << std::endl; return false; } timeStep = timeImageSelector->GetOutput(); typedef mitk::ImageToItk<ImageType> ImageToItkFilterType; ImageToItkFilterType::Pointer itkFilter = ImageToItkFilterType::New(); itkFilter->SetInput(timeStep); try { itkFilter->Update(); } catch( mitk::Exception &e) { std::cerr << "Problem in converting to ITK image" << std::endl; std::cerr << e << std::endl; return false; } if(i == 0) { this->itkFixedImage = itkFilter->GetOutput(); } else { this->itkMovingImages.push_back(itkFilter->GetOutput()); } } showParameters(); return true; }