int CalcCSGeometry(struct tube *tu, int csi, float n[3]) { struct cs *cs; int j, ind; static float sx[] = {1, -1, -1, 1}; static float sy[] = {1, 1, -1, -1}; float dx, dy, a, b; cs = tu->cs[csi]; // when we come the second time ... FreePointStruct(cs->p); cs->p = AllocPointStruct(); // first we get Trafo from the relativ(crossection) to the absolute system CalcTrafo(tu, csi, n); // all corners, starting with the right top, next is left top, ... for (j = 0; j < 4; j += 2) { ////////////////////////////////////////////// // the right top || the left bottom corner ... ind = j; a = cs->c_a[ind]; b = cs->c_b[ind]; dx = cs->c_width/2 - a; dy = cs->c_height/2 - b; // First point of corner AddPoint(cs->p, sx[ind]*(dx+a), sy[ind]*dy, 0.0); cs->cov_ind[ind*2] = cs->p->nump-1; // second point of corner and the ellipse points ... if (!IS_0(a)) { CalcEllipsePoints(cs, a, b, sx[ind]*dx, sy[ind]*dy, (M_PI/2)*(ind), (M_PI/2)*(ind)+M_PI/2); AddPoint(cs->p, sx[ind]*dx, sy[ind]*(dy+b), 0.0); } cs->cov_ind[ind*2+1] = cs->p->nump-1; ////////////////////////////////////////////// // the left top || the right bottom corner ... ind = j+1; a = cs->c_a[ind]; b = cs->c_b[ind]; dx = cs->c_width/2 - a; dy = cs->c_height/2 - b; AddPoint(cs->p, sx[ind] * dx, sy[ind]*(dy+b), 0.0); cs->cov_ind[ind*2] = cs->p->nump-1; if (!IS_0(b)) { CalcEllipsePoints(cs, a, b, sx[ind]*dx, sy[ind]*dy, (M_PI/2)*(ind), (M_PI/2)*(ind)+M_PI/2); AddPoint(cs->p, sx[ind]*(dx+a), sy[ind]*dy, 0.0); } cs->cov_ind[ind*2+1] = cs->p->nump-1; } return 1; }
void SgListDlg::SGSelected(QListWidgetItem *pItem, QListWidgetItem*) { listSymOps->clear(); listTrafo->clear(); for(QLineEdit *pEdit : {editHM, /*editHall,*/ editLaue, editNr/*, editAxisSym*/}) pEdit->setText(""); if(!pItem) return; std::shared_ptr<const SpaceGroups<t_real>> sgs = SpaceGroups<t_real>::GetInstance(); const SpaceGroups<t_real>::t_vecSpaceGroups* pvecSG = sgs->get_space_groups_vec(); // header selected? unsigned int iSG = pItem->data(Qt::UserRole).toUInt(); if(iSG >= pvecSG->size()) return; const SpaceGroup<t_real>* psg = pvecSG->at(iSG); unsigned int iSgNr = psg->GetNr(); const std::string& strHM = psg->GetName(); const std::string& strPointGroup = psg->GetPointGroup(); const std::string& strLaue = psg->GetLaueGroup(); const std::string& strCrysSys = psg->GetCrystalSystemName(); editNr->setText(tl::var_to_str(iSgNr).c_str()); editHM->setText(strHM.c_str()); //editHall->setText(psg.symbol_hall().c_str()); editLaue->setText(("PG: " + strPointGroup + ", LG: " + strLaue + " (" + strCrysSys + ")").c_str()); bool bShowMatrices = checkMatrices->isChecked(); // all trafos const std::vector<SpaceGroup<t_real>::t_mat>& vecTrafos = psg->GetTrafos(); { std::ostringstream ostr; ostr << "All Symmetry Operations (" << vecTrafos.size() << ")"; listSymOps->addItem(create_header_item(ostr.str().c_str())); for(unsigned int iSymOp=0; iSymOp<vecTrafos.size(); ++iSymOp) { if(bShowMatrices) listSymOps->addItem(print_matrix(vecTrafos[iSymOp]).c_str()); else listSymOps->addItem(get_trafo_desc(vecTrafos[iSymOp]).c_str()); } } // primitive trafos const std::vector<unsigned int>& vecPrim = psg->GetPrimTrafos(); if(vecPrim.size()) { std::ostringstream ostr; ostr << "Primitive Symmetry Operations (" << (vecPrim.size()) << ")"; listSymOps->addItem(create_header_item(ostr.str().c_str())); for(unsigned int iSymOp=0; iSymOp<vecPrim.size(); ++iSymOp) { if(bShowMatrices) listSymOps->addItem(print_matrix(vecTrafos[vecPrim[iSymOp]]).c_str()); else listSymOps->addItem(get_trafo_desc(vecTrafos[vecPrim[iSymOp]]).c_str()); } } // inverting trafos const std::vector<unsigned int>& vecInv = psg->GetInvTrafos(); if(vecInv.size()) { std::ostringstream ostr; ostr << "Inverting Symmetry Operations (" << (vecInv.size()) << ")"; listSymOps->addItem(create_header_item(ostr.str().c_str())); for(unsigned int iSymOp=0; iSymOp<vecInv.size(); ++iSymOp) { if(bShowMatrices) listSymOps->addItem(print_matrix(vecTrafos[vecInv[iSymOp]]).c_str()); else listSymOps->addItem(get_trafo_desc(vecTrafos[vecInv[iSymOp]]).c_str()); } } // centering trafos const std::vector<unsigned int>& vecCenter = psg->GetCenterTrafos(); if(vecCenter.size()) { std::ostringstream ostr; ostr << "Centering Symmetry Operations (" << (vecCenter.size()) << ")"; listSymOps->addItem(create_header_item(ostr.str().c_str())); for(unsigned int iSymOp=0; iSymOp<vecCenter.size(); ++iSymOp) { if(bShowMatrices) listSymOps->addItem(print_matrix(vecTrafos[vecCenter[iSymOp]]).c_str()); else listSymOps->addItem(get_trafo_desc(vecTrafos[vecCenter[iSymOp]]).c_str()); } } RecalcBragg(); CalcTrafo(); }