// Get the current particle data from main form, register // it using a local copy, and prepare a list of particle // types; this function is called each time the board is launched void PolymerBoard::setData() { // Get a list of particles that are currently rendered AggregateData *ad = mainForm->getAggregateData(); propertyBox->setPropertyInformation(ad->propertiesInformation); // Get the current settings and register // it using a local particle data structure thisPd = mainForm->getParticleData(); // Make entries in the combo box -- use only particle // types that are really needed; otherwise the list // gets too long if (atomCob) { atomCob->clear(); for (int i=0;i<(*thisPd).numberOfParticleTypes;i++) { // Check: is this particle type really needed? for (int j=0;j<(*ad).numberOfParticles;j++) { if (typeCmp( (char *)&(*ad).particles[j].type, (char *)&(*thisPd).type[i])) { // Add the item to the list atomCob->addItem( QString( (char *)&(*thisPd).type[i])); break; } } } atomCob->setMinimumSize( atomCob->sizeHint() ); } // Sort the entries alphabetically, at least approximately for (int i=0;i<(*thisPd).numberOfParticleTypes;i++) { for (int j=0;j<atomCob->count()-1;j++) { if (QString::compare(atomCob->itemText(j), atomCob->itemText(j+1)) > 0) { tag tmp; typeCopy( qPrintable(atomCob->itemText(j+1)), (char *)&tmp ); atomCob->insertItem(j, QString( (char *)&tmp)); atomCob->removeItem(j+2); } } } // Set the first particle type as the current type if ((*ad).numberOfParticles > 0) { thisPolymerAtomIndex = 0; this->setPolymerAtom(); } else { thisPolymerAtomIndex = -1; } }
// Set a default value void setColorAndDefaults( particleData * pd, char * buffer, int index ) { int i; char type[3]; float red, green, blue; char * ptr; // This is an ugly hack... extract the data out of // the string type[0] = buffer[0]; type[1] = buffer[1]; type[2] = 0; ptr = strstr( buffer, "." ); i=0; while (buffer+i<ptr-1) { buffer[i]=' '; i++; } red = (float)atof(buffer); *ptr = ' '; ptr = strstr( buffer, "." ); i=0; while (buffer+i<ptr-1) { buffer[i]=' '; i++; } green = (float)atof(buffer); *ptr = ' '; ptr = strstr( buffer, "." ); i=0; while (buffer+i<ptr-1) { buffer[i]=' '; i++; } blue = (float)atof(buffer); // Now add the entry if (index < ATOMS_MAX-1) { // Update the number of particle entries (*pd).numberOfParticleTypes = index+1; // Set type string typeCopy( type, (char *)&(*pd).type[index] ); // Set the default particle color (*pd).particleColors[index].red = red; (*pd).particleColors[index].green = green; (*pd).particleColors[index].blue = blue; // Use defaults for the color ramp: light blue for the minimum, // orange for the maximum (*pd).particleColors[index].redMin = 0.0; (*pd).particleColors[index].greenMin = 0.5; (*pd).particleColors[index].blueMin = 1.0; (*pd).particleColors[index].redMax = 1.0; (*pd).particleColors[index].greenMax = 0.3; (*pd).particleColors[index].blueMax = 0.0; // Use defaults for the second and third type color (*pd).particleColors[index].redTwo = 1.0; (*pd).particleColors[index].greenTwo = 1.0; (*pd).particleColors[index].blueTwo = 0.0; (*pd).particleColors[index].redThree = 0.0; (*pd).particleColors[index].greenThree = 1.0; (*pd).particleColors[index].blueThree = 0.0; // Use defaults for the remaining settings (*pd).showParticle[index] = TRUE; (*pd).showTrack[index] = TRUE; (*pd).colorCrit[index] = TYPE; (*pd).colorCritPos[index] = XPOS; (*pd).colorCritProp[index] = PROP1; (*pd).colorCritCodeRed[index] = PROP1; (*pd).colorCritCodeGreen[index] = PROP2; (*pd).colorCritCodeBlue[index] = PROP3; (*pd).relSize[index] = REGULAR; (*pd).line[index].fThickness = THIN; (*pd).line[index].fEmission = 0; (*pd).line[index].typeColorNumber = 1; (*pd).line[index].fAntiAlias = TRUE; // Assume zero bonding as default (*pd).particleBonds[index].numberOfNeighborBonds = 0; for (i=0;i<BONDS_MAX;i++) { (*pd).particleBonds[index].bShowBond[i] = FALSE; (*pd).particleBonds[index].bColor[i] = RED; (*pd).particleBonds[index].bThickness[i] = LINE; (*pd).particleBonds[index].bEmission[i] = 0.0; (*pd).particleBonds[index].bMinLength[i] = (float)BOND_MINLENGTH; (*pd).particleBonds[index].bMaxLength[i] = (float)BOND_MAXLENGTH; (*pd).particleBonds[index].bAntiAlias[i] = TRUE; (*pd).particleBonds[index].bSeqBond[i] = FALSE; } } else { printf("The maximum number of particle type entries (%d) is exceeded -- recompile\n", ATOMS_MAX); } return; }
// Set the pore under consideration: adjust the toggle switch void PoreBoard::setPore( void ) { tag thisPore; thisPoreIndex = -1; // Find out what combination of particles is set typeCopy( (const char *)poreCob->currentText(), (char *)&thisPore ); for (int i=0;i<(*thisPd).numberOfParticleTypes;i++) { if (typeCmp( (char *)&(*thisPd).type[i], (char *)&thisPore ) == TRUE) { // Found the correct entry thisPoreIndex = i; // Adjust the color board this->setColors(); // Adjust the toggles bool thisShowParticle = (*thisPd).showParticle[thisPoreIndex]; showPoreCb->setChecked( thisShowParticle); switch( thisShowParticle) { case TRUE: if (thisPoreIndex >= 0) { modeL->setDisabled( FALSE ); colorMode->setDisabled( FALSE ); } else { modeL->setDisabled( TRUE ); colorMode->setDisabled( TRUE ); } break; case FALSE: sizeBox->setDisabled( TRUE ); modeL->setDisabled( TRUE ); colorMode->setDisabled( TRUE ); break; } // Adjust the toggles if (poreRenderStyle != PDOT && poreRenderStyle != PLINE && thisShowParticle) { sizeBox->setDisabled( FALSE ); } else { sizeBox->setDisabled( TRUE ); } // Adjust size settings sizeBox->setParticle( thisPd, thisPoreIndex ); colorCriterion colorCrit = (*thisPd).colorCrit[thisPoreIndex]; switch (colorCrit) { case TYPE: this->buildLayout( TYPE ); colorMode0->setChecked( TRUE ); colorButton->setDisabled( FALSE ); break; case POSITION: this->buildLayout( POSITION ); colorMode1->setChecked( TRUE ); colorButton->setDisabled( FALSE ); break; case PROPERTY: this->buildLayout( PROPERTY ); colorMode2->setChecked( TRUE ); colorButton->setDisabled( FALSE ); break; case COLORCODE: this->buildLayout( COLORCODE ); colorMode3->setChecked( TRUE ); colorButton->setDisabled( TRUE ); colorLabel0->switchOff(); colorLabel1->switchOff(); colorLabel2->switchOff(); colorLabel3->switchOff(); colorLabel4->switchOff(); colorLabel5->switchOff(); break; } positionBox->setParticle( thisPd, thisPoreIndex ); propertyBox->setParticle( thisPd, thisPoreIndex ); codeBox->setParticle( thisPd, thisPoreIndex ); typeColorNumberBox->setParticle( thisPd, thisPoreIndex ); lineTypeBox->setParticle( thisPd, thisPoreIndex ); } } }
// Get the current particle data from main form, register // it using a local copy, and prepare a list of particle // types; this function is called each time the board is launched void PoreBoard::setData( void ) { aggregateData * ad = NULL; tag tmp; if (mainForm) { // Get the current switch settings and register // it using a local particle data structure thisPd = mainForm->getParticleData(); // Get a list of particles that are currently rendered ad = mainForm->getAggregateData(); // Make entries in the combo box -- use only particle // types that are really needed; otherwise the list // gets too long int item = 0; if (poreCob) { poreCob->clear(); for (int i=0;i<(*thisPd).numberOfParticleTypes;i++) { // Check: is this particle type really needed? bool needed = FALSE; for (int j=0;j<(*ad).numberOfParticles;j++) { if (typeCmp( (char *)&(*ad).particles[j].type, (char *)&(*thisPd).type[i]) == TRUE) { // Yes it is needed: set a flag needed = TRUE; break; } } // Add the item to the list if (needed) { poreCob->insertItem( QString( (char *)&(*thisPd).type[i]), item ); item++; } } poreCob->setMinimumSize( poreCob->sizeHint() ); } } // Sort the entries alphabetically, at least approximately for (int i=0;i<(*thisPd).numberOfParticleTypes;i++) { for (int j=0;j<poreCob->count()-1;j++) { if (QString::compare(poreCob->text(j), poreCob->text(j+1)) > 0) { typeCopy( (const char *)poreCob->text(j+1), (char *)&tmp ); poreCob->insertItem( QString( (char *)&tmp), j); poreCob->removeItem(j+2); } } } // Set the first pore as the current pore if ((*ad).numberOfParticles > 0) { thisPoreIndex = 0; this->setPore(); } else { thisPoreIndex = -1; } }
// Set the spin under consideration: adjust the toggle switch void SpinBoard::setSpin() { tag thisSpin; thisSpinIndex = -1; // Find out what combination of particles is set typeCopy( qPrintable(spinCob->currentText()), (char *)&thisSpin ); for (int i=0;i<(*thisPd).numberOfParticleTypes;i++) { if (typeCmp( (char *)&(*thisPd).type[i], (char *)&thisSpin )) { // Found the correct entry thisSpinIndex = i; // Adjust the color board this->setColors(); // Adjust the toggles bool thisShowParticle = (*thisPd).showParticle[thisSpinIndex]; showSpinCb->setChecked( thisShowParticle); if(thisShowParticle){ modeL->setDisabled(thisSpinIndex >= 0 ? false : true ); colorMode->setDisabled(thisSpinIndex >= 0 ? false : true ); } else { sizeBox->setDisabled(true); modeL->setDisabled(true); colorMode->setDisabled(true); } // Adjust the toggles if (spinRenderStyle != SDOT && spinRenderStyle != SLINE && thisShowParticle) { sizeBox->setDisabled(false); } else { sizeBox->setDisabled(true); } // Adjust size settings sizeBox->setParticle( thisPd, thisSpinIndex ); colorCriterion colorCrit = (*thisPd).colorCrit[thisSpinIndex]; switch (colorCrit) { case TYPE: this->buildLayout( TYPE ); colorMode0->setChecked(true); colorButton->setDisabled(false); break; case POSITION: this->buildLayout( POSITION ); colorMode1->setChecked(true); colorButton->setDisabled(false); break; case PROPERTY: this->buildLayout( PROPERTY ); colorMode2->setChecked(true); colorButton->setDisabled(false); break; case COLORCODE: this->buildLayout( COLORCODE ); colorMode3->setChecked(true); colorButton->setDisabled(true); colorLabel0->switchOff(); colorLabel1->switchOff(); colorLabel2->switchOff(); colorLabel3->switchOff(); colorLabel4->switchOff(); colorLabel5->switchOff(); break; } positionBox->setParticle( thisPd, thisSpinIndex ); propertyBox->setParticle( thisPd, thisSpinIndex ); codeBox->setParticle( thisPd, thisSpinIndex ); lineTypeBox->setParticle( thisPd, thisSpinIndex ); } } }