void setLocalConstraint(TransInfo *t, int mode, const char text[]) { if (t->flag & T_EDIT) { float obmat[3][3]; copy_m3_m4(obmat, t->scene->obedit->obmat); normalize_m3(obmat); setConstraint(t, obmat, mode, text); } else { if (t->total == 1) { setConstraint(t, t->data->axismtx, mode, text); } else { strncpy(t->con.text + 1, text, 48); copy_m3_m3(t->con.mtx, t->data->axismtx); t->con.mode = mode; getConstraintMatrix(t); startConstraint(t); t->con.drawExtra = drawObjectConstraint; t->con.applyVec = applyObjectConstraintVec; t->con.applySize = applyObjectConstraintSize; t->con.applyRot = applyObjectConstraintRot; t->redraw = 1; } } }
Creature::Creature(int body_parts, int constraints, int hidden_layers, int neurons_per_layer) : _name(""), _number_of_body_parts(body_parts), _number_of_constraints(constraints), _body_parts(new BodyPart*[body_parts]), _constraints(new Constraint*[constraints]), _neural_network(NULL), _initial_position(btVector3(0.0, 0.0, 0.0)), _final_position(btVector3(0.0, 0.0, 0.0)), _fitness(0.0) { for (int i = 0; i < getNumberOfBodyParts(); ++i) { setBodyPart(i, new BodyPart()); getBodyPart(i).setId(i); getBodyPart(i).setName("Body Part #" + TO_STRING(i)); } for (int i = 0; i < getNumberOfConstraints(); ++i) { setConstraint(i, new Constraint()); getConstraint(i).setId(i); getConstraint(i).setName("Constraint #" + TO_STRING(i)); } _neural_network = new NeuralNetwork(4 * getNumberOfBodyParts(), hidden_layers, neurons_per_layer, 3 * (getNumberOfBodyParts() - 1)); getNeuralNetwork().getInputLayer().setActivationFunction(Neuron::AF_NONE); for (int i = 1; i < getNeuralNetwork().getNumberOfLayers(); ++i) { getNeuralNetwork().getLayer(i).setActivationFunction(Neuron::AF_TANH); } }
void Constraint::setConstraintWithVersion(const CString& p_str) { TCHAR pchar[1024] = {0} ; _tcscpy(pchar,p_str) ; nConstraintVersion = GetAndRemoveConstraintVersion(pchar) ; setConstraint(pchar,nConstraintVersion) ; }
void Constraint::readConstraintWithVersion(const char* _csStr,SAVE_TYPE _type ) { char szConstraint[1024] = ""; strcpy(szConstraint, _csStr); nConstraintVersion = GetAndRemoveConstraintVersion(szConstraint,_type); setConstraint(szConstraint, nConstraintVersion); }
/* applies individual td->axismtx constraints */ void setAxisMatrixConstraint(TransInfo *t, int mode, const char text[]) { if (t->total == 1) { float axismtx[3][3]; if (t->flag & T_EDIT) { mul_m3_m3m3(axismtx, t->obedit_mat, t->data->axismtx); } else { copy_m3_m3(axismtx, t->data->axismtx); } setConstraint(t, axismtx, mode, text); } else { BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1); copy_m3_m3(t->con.mtx, t->data->axismtx); t->con.mode = mode; getConstraintMatrix(t); startConstraint(t); t->con.drawExtra = drawObjectConstraint; t->con.applyVec = applyObjectConstraintVec; t->con.applySize = applyObjectConstraintSize; t->con.applyRot = applyObjectConstraintRot; t->redraw = TREDRAW_HARD; } }
void Constraint::readConstraint (ArctermFile& p_file,SAVE_TYPE _type ) { //char str[256] = ""; char str[1024] = ""; //changed by matt in 5,12,2004 p_file.getSubField (str, ';'); nConstraintVersion = GetAndRemoveConstraintVersion( str,_type ); setConstraint( str, nConstraintVersion ); }
/* * Set the constraint according to the user defined orientation * * ftext is a format string passed to BLI_snprintf. It will add the name of * the orientation where %s is (logically). */ void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[]) { char text[40]; switch (orientation) { case V3D_MANIP_GLOBAL: { float mtx[3][3]; BLI_snprintf(text, sizeof(text), ftext, IFACE_("global")); unit_m3(mtx); setConstraint(t, mtx, mode, text); break; } case V3D_MANIP_LOCAL: BLI_snprintf(text, sizeof(text), ftext, IFACE_("local")); setLocalConstraint(t, mode, text); break; case V3D_MANIP_NORMAL: BLI_snprintf(text, sizeof(text), ftext, IFACE_("normal")); if (checkUseAxisMatrix(t)) { setAxisMatrixConstraint(t, mode, text); } else { setConstraint(t, t->spacemtx, mode, text); } break; case V3D_MANIP_VIEW: BLI_snprintf(text, sizeof(text), ftext, IFACE_("view")); setConstraint(t, t->spacemtx, mode, text); break; case V3D_MANIP_GIMBAL: BLI_snprintf(text, sizeof(text), ftext, IFACE_("gimbal")); setConstraint(t, t->spacemtx, mode, text); break; default: /* V3D_MANIP_CUSTOM */ BLI_snprintf(text, sizeof(text), ftext, t->spacename); setConstraint(t, t->spacemtx, mode, text); break; } t->con.orientation = orientation; t->con.mode |= CON_USER; }
void setLocalConstraint(TransInfo *t, int mode, const char text[]) { /* edit-mode now allows local transforms too */ if (t->flag & T_EDIT) { setConstraint(t, t->obedit_mat, mode, text); } else { setAxisMatrixConstraint(t, mode, text); } }
/* * Set the constraint according to the user defined orientation * * ftext is a format string passed to BLI_snprintf. It will add the name of * the orientation where %s is (logically). */ void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[]) { char text[256]; switch (orientation) { case V3D_ORIENT_GLOBAL: { float mtx[3][3]; BLI_snprintf(text, sizeof(text), ftext, IFACE_("global")); unit_m3(mtx); setConstraint(t, mtx, mode, text); break; } case V3D_ORIENT_LOCAL: BLI_snprintf(text, sizeof(text), ftext, IFACE_("local")); setLocalConstraint(t, mode, text); break; case V3D_ORIENT_NORMAL: BLI_snprintf(text, sizeof(text), ftext, IFACE_("normal")); if (checkUseAxisMatrix(t)) { setAxisMatrixConstraint(t, mode, text); } else { setConstraint(t, t->spacemtx, mode, text); } break; case V3D_ORIENT_VIEW: BLI_snprintf(text, sizeof(text), ftext, IFACE_("view")); setConstraint(t, t->spacemtx, mode, text); break; case V3D_ORIENT_CURSOR: BLI_snprintf(text, sizeof(text), ftext, IFACE_("cursor")); setConstraint(t, t->spacemtx, mode, text); break; case V3D_ORIENT_GIMBAL: BLI_snprintf(text, sizeof(text), ftext, IFACE_("gimbal")); setConstraint(t, t->spacemtx, mode, text); break; case V3D_ORIENT_CUSTOM_MATRIX: BLI_snprintf(text, sizeof(text), ftext, IFACE_("custom matrix")); setConstraint(t, t->spacemtx, mode, text); break; case V3D_ORIENT_CUSTOM: { char orientation_str[128]; BLI_snprintf(orientation_str, sizeof(orientation_str), "%s \"%s\"", IFACE_("custom orientation"), t->orientation.custom->name); BLI_snprintf(text, sizeof(text), ftext, orientation_str); setConstraint(t, t->spacemtx, mode, text); break; } } t->con.orientation = orientation; t->con.mode |= CON_USER; }
void setLocalConstraint(TransInfo *t, int mode, const char text[]) { /* edit-mode now allows local transforms too */ if (t->flag & T_EDIT) { /* Use the active (first) edit object. */ TransDataContainer *tc = t->data_container; setConstraint(t, tc->mat3_unit, mode, text); } else { setAxisMatrixConstraint(t, mode, text); } }
/* * Set the constraint according to the user defined orientation * * ftext is a format string passed to BLI_snprintf. It will add the name of * the orientation where %s is (logically). */ void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[]) { char text[40]; switch (orientation) { case V3D_MANIP_GLOBAL: { float mtx[3][3] = MAT3_UNITY; BLI_snprintf(text, sizeof(text), ftext, "global"); setConstraint(t, mtx, mode, text); } break; case V3D_MANIP_LOCAL: BLI_snprintf(text, sizeof(text), ftext, "local"); setLocalConstraint(t, mode, text); break; case V3D_MANIP_NORMAL: BLI_snprintf(text, sizeof(text), ftext, "normal"); setConstraint(t, t->spacemtx, mode, text); break; case V3D_MANIP_VIEW: BLI_snprintf(text, sizeof(text), ftext, "view"); setConstraint(t, t->spacemtx, mode, text); break; case V3D_MANIP_GIMBAL: BLI_snprintf(text, sizeof(text), ftext, "gimbal"); setConstraint(t, t->spacemtx, mode, text); break; default: /* V3D_MANIP_CUSTOM */ BLI_snprintf(text, sizeof(text), ftext, t->spacename); setConstraint(t, t->spacemtx, mode, text); break; } t->con.orientation = orientation; t->con.mode |= CON_USER; }
Creature::Creature(int body_parts, int constraints) : _name(""), _number_of_body_parts(body_parts), _number_of_constraints(constraints), _body_parts(new BodyPart*[body_parts]), _constraints(new Constraint*[constraints]), _neural_network(NULL), _initial_position(btVector3(0.0, 0.0, 0.0)), _final_position(btVector3(0.0, 0.0, 0.0)), _fitness(-1.0) { for (int i = 0; i < getNumberOfBodyParts(); ++i) { setBodyPart(i, NULL); } for (int i = 0; i < getNumberOfConstraints(); ++i) { setConstraint(i, NULL); } }
Creature::Creature(int body_parts, int constraints, const NeuralNetwork & neural_network) : _name(""), _number_of_body_parts(body_parts), _number_of_constraints(constraints), _body_parts(new BodyPart*[body_parts]), _constraints(new Constraint*[constraints]), _neural_network(NULL), _initial_position(btVector3(0.0, 0.0, 0.0)), _final_position(btVector3(0.0, 0.0, 0.0)), _fitness(0.0) { for (int i = 0; i < getNumberOfBodyParts(); ++i) { setBodyPart(i, new BodyPart()); getBodyPart(i).setName("Body Part #" + TO_STRING(i)); } for (int i = 0; i < getNumberOfConstraints(); ++i) { setConstraint(i, new Constraint()); getConstraint(i).setName("Constraint #" + TO_STRING(i)); } setNeuralNetwork(neural_network.clone()); }
void StackmapValue::setConstrainedChild(unsigned index, const ConstrainedValue& constrainedValue) { child(index) = constrainedValue.value(); setConstraint(index, constrainedValue.rep()); }
void Tableau::setConstraint(size_t row, const TableauConstraint &constraint) { setConstraint(row,constraint.m_leftSide,constraint.m_relation,constraint.m_rightSide); }
// need to get version info first and then call set void Constraint::setConstraintWithVersion ( char *p_str ) { nConstraintVersion = GetAndRemoveConstraintVersion( p_str); setConstraint( p_str, nConstraintVersion ); }
void MainWindow::createMenus() { QAction* action; QString name; QMenu* menu; QMenu* subMenu; // ----- File Menu ----- menu = menuBar()->addMenu("File"); name = "About"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showAbout())); name = "New Molecule"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(newMoleculeMenu())); action->setShortcut(QKeySequence::New); name = "New Viewer"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(newViewer())); name = "Open"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(openFile())); action->setShortcut(QKeySequence::Open); name = "Open Recent"; m_recentFilesMenu = menu->addMenu(name); updateRecentFilesMenu(); menu->addSeparator(); /* name = "Parse Test File"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(parseFile())); menu->addSeparator(); */ name = "Close Viewer"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(close())); action->setShortcut(QKeySequence::Close); name = "Save"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAll())); action->setShortcut(QKeySequence::Save); name = "Save As"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAs())); action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_S); menu->addSeparator(); name = "Save Picture"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewer, SLOT(saveSnapshot())); action->setShortcut(Qt::CTRL + Qt::Key_P); name = "Record Animation"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), this, SLOT(toggleRecordingActive())); action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_P); m_recordAnimationAction = action; name = "Show Message Log"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showLogMessages())); action->setShortcut(Qt::CTRL + Qt::Key_L); name = "Quit"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(quit())); action->setShortcut(Qt::CTRL + Qt::Key_Q); // ----- Edit Menu ----- menu = menuBar()->addMenu("Edit"); name = "Undo"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(undo())); action->setShortcut(QKeySequence::Undo); connect(&m_undoStack, SIGNAL(canUndoChanged(bool)), action, SLOT(setEnabled(bool))); name = "Redo"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(redo())); action->setShortcut(QKeySequence::Redo); connect(&m_undoStack, SIGNAL(canRedoChanged(bool)), action, SLOT(setEnabled(bool))); menu->addSeparator(); name = "Cut"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(cutSelection())); action->setShortcut(Qt::CTRL + Qt::Key_X); name = "Copy"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(copySelectionToClipboard())); action->setShortcut(Qt::CTRL + Qt::Key_C); name = "Paste"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(pasteSelectionFromClipboard())); action->setShortcut(Qt::CTRL + Qt::Key_V); menu->addSeparator(); name = "Select All"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(selectAll())); action->setShortcut(Qt::CTRL + Qt::Key_A); name = "Select None"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SIGNAL(clearSelection())); action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_A); name = "Invert Selection"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(invertSelection())); action->setShortcut(Qt::CTRL + Qt::Key_I); menu->addSeparator(); name = "Reindex Atoms"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(reindexAtoms())); menu->addSeparator(); name = "Preferences"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showPreferences())); // ----- Display Menu ----- menu = menuBar()->addMenu("Display"); name = "Full Screen"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), this, SLOT(fullScreen())); action->setShortcut(Qt::CTRL + Qt::Key_0); m_fullScreenAction = action; name = "Reset View"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewer, SLOT(resetView())); action->setShortcut(Qt::CTRL + Qt::Key_R); name = "Show Axes"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAxes())); connect(&m_viewerModel, SIGNAL(axesOn(bool)), action, SLOT(setChecked(bool))); action->setShortcut(Qt::Key_A); menu->addSeparator(); name = "Atom Labels"; subMenu = menu->addMenu(name); name = "Element"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Element); action->setShortcut(Qt::Key_E); action->setCheckable(true); m_labelActions << action; name = "Index"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Index); action->setShortcut(Qt::Key_I); action->setCheckable(true); m_labelActions << action; name = "Mass"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Mass); action->setShortcut(Qt::Key_M); action->setCheckable(true); m_labelActions << action; /* name = "NMR Shifts"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::NmrShifts); action->setShortcut(Qt::Key_N); action->setCheckable(true); m_labelActions << action; */ name = "Partial Charge"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Charge); action->setShortcut(Qt::Key_Q); action->setCheckable(true); m_labelActions << action; name = "Spin Densities"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Spin); action->setShortcut(Qt::Key_S); action->setCheckable(true); m_labelActions << action; menu->addSeparator(); name = "Configure Appearance"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(configureAppearance())); // These are not working correctly at the moment. /* name = "Partial Charge Type"; QActionGroup* partialChargeGroup = new QActionGroup(this); subMenu = menu->addMenu(name); QString pc("Gasteiger"); action = subMenu->addAction(pc); action->setCheckable(true); action->setChecked(true); action->setData(pc); partialChargeGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType())); pc = "Sanderson"; action = subMenu->addAction(pc); action->setCheckable(true); action->setData(pc); partialChargeGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType())); pc = "Mulliken"; action = subMenu->addAction(pc); action->setCheckable(true); action->setData(pc); partialChargeGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType())); */ // ----- Build Menu ----- menu = menuBar()->addMenu("Build"); name = "Fill Valencies With Hydrogens"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(addHydrogens())); action->setShortcut(Qt::CTRL + Qt::Key_F); name = "Reperceive Bonds"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(reperceiveBonds())); menu->addSeparator(); name = "Set Constraint"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(setConstraint())); action->setShortcut(Qt::CTRL + Qt::Key_K); name = "Minimize Structure"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(minimizeEnergy())); action->setShortcut(Qt::CTRL + Qt::Key_M); name = "Select Force Field"; QActionGroup* forceFieldGroup = new QActionGroup(this); subMenu = menu->addMenu(name); QString ff("MMFF94"); action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "MMFF94s"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "UFF"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "Ghemical"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "Gaff"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); menu->addSeparator(); name = "Translate To Center"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(translateToCenter())); action->setShortcut(Qt::CTRL + Qt::Key_T ); name = "Symmetrize Molecule"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(symmetrize())); action->setShortcut(Qt::CTRL + Qt::Key_Y ); name = "Set Symmetry Tolerance"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(adjustSymmetryTolerance())); name = "Auto-detect Symmetry"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAutoDetectSymmetry())); // ----- Calculation Menu ----- menu = menuBar()->addMenu("Calculation"); name = "Q-Chem Setup"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(openQChemUI())); action->setShortcut(Qt::CTRL + Qt::Key_U ); m_qchemSetupAction = action; name = "Job Monitor"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showProcessMonitor())); action->setShortcut(Qt::CTRL + Qt::Key_J ); menu->addSeparator(); name = "Edit Servers"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(editServers())); name = "Remove All Processes"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &(ProcessMonitor::instance()), SLOT(clearProcessList())); name = "Reset Password Vault Key"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setVaultPassword())); // ----- Help Menu ----- menu = menuBar()->addMenu("Help"); name = "Show Help"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showHelp())); }