MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { isuser = false; ismanager = false; sleep(2); mainmanager = new manager; mainmanager->loadfileprocess(); createAction(); createMenu(); createCenter(); createStatusBar(); }
void ModelNode::createBound() { const VertexAttrib &vpos = _vertexBuffer.getVertexDecl()[0]; assert(vpos.index == VPOSITION); assert(vpos.type == GL_FLOAT); uint32 stride = MAX<uint32>(vpos.size, vpos.stride / sizeof(float)); float *vX = (float *) vpos.pointer; float *vY = vX + 1; float *vZ = vY + 1; for (uint32 v = 0; v < _vertexBuffer.getCount(); v++) _boundBox.add(vX[v * stride], vY[v * stride], vZ[v * stride]); createCenter(); }
void ProgramWindow::setup(const QList<LinkedFile *> & linkedFiles, const QString & alternativePath) { resize(500,700); setAttribute(Qt::WA_DeleteOnClose, true); QFrame * mainFrame = new QFrame(this); QFrame * headerFrame = createHeader(); QFrame * centerFrame = createCenter(); layout()->setMargin(0); layout()->setSpacing(0); QGridLayout *layout = new QGridLayout(mainFrame); layout->setMargin(0); layout->setSpacing(0); layout->addWidget(headerFrame,0,0); layout->addWidget(centerFrame,1,0); setCentralWidget(mainFrame); setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); QSettings settings; if (!settings.value("programwindow/state").isNull()) { restoreState(settings.value("programwindow/state").toByteArray()); } if (!settings.value("programwindow/geometry").isNull()) { restoreGeometry(settings.value("programwindow/geometry").toByteArray()); } installEventFilter(this); // Setup new menu bar for the programming window QMenuBar *menubar = menuBar(); QMenu *currentMenu = menubar->addMenu(tr("&File")); QAction *currentAction = new QAction(tr("New"), this); currentAction->setShortcut(tr("Ctrl+N")); currentAction->setStatusTip(tr("Create a new program")); connect(currentAction, SIGNAL(triggered()), this, SLOT(addTab())); currentMenu->addAction(currentAction); currentAction = new QAction(tr("&Open..."), this); currentAction->setShortcut(tr("Ctrl+O")); currentAction->setStatusTip(tr("Open a program")); connect(currentAction, SIGNAL(triggered()), this, SLOT(loadProgramFile())); currentMenu->addAction(currentAction); currentMenu->addSeparator(); m_saveAction = new QAction(tr("&Save"), this); m_saveAction->setShortcut(tr("Ctrl+S")); m_saveAction->setStatusTip(tr("Save the current program")); connect(m_saveAction, SIGNAL(triggered()), this, SLOT(save())); currentMenu->addAction(m_saveAction); currentAction = new QAction(tr("Rename"), this); currentAction->setStatusTip(tr("Rename the current program")); connect(currentAction, SIGNAL(triggered()), this, SLOT(rename())); currentMenu->addAction(currentAction); currentAction = new QAction(tr("Duplicate tab"), this); currentAction->setStatusTip(tr("Copies the current program into a new tab")); connect(currentAction, SIGNAL(triggered()), this, SLOT(duplicateTab())); currentMenu->addAction(currentAction); currentMenu->addSeparator(); currentAction = new QAction(tr("Remove tab"), this); currentAction->setShortcut(tr("Ctrl+W")); currentAction->setStatusTip(tr("Remove the current program from the sketch")); connect(currentAction, SIGNAL(triggered()), this, SLOT(closeCurrentTab())); currentMenu->addAction(currentAction); currentMenu->addSeparator(); m_printAction = new QAction(tr("&Print..."), this); m_printAction->setShortcut(tr("Ctrl+P")); m_printAction->setStatusTip(tr("Print the current program")); connect(m_printAction, SIGNAL(triggered()), this, SLOT(print())); currentMenu->addAction(m_printAction); currentMenu->addSeparator(); currentAction = new QAction(tr("&Quit"), this); currentAction->setShortcut(tr("Ctrl+Q")); currentAction->setStatusTip(tr("Quit the application")); currentAction->setMenuRole(QAction::QuitRole); connect(currentAction, SIGNAL(triggered()), qApp, SLOT(closeAllWindows2())); currentMenu->addAction(currentAction); currentMenu = menubar->addMenu(tr("&Edit")); m_undoAction = new QAction(tr("Undo"), this); m_undoAction->setShortcuts(QKeySequence::Undo); m_undoAction->setEnabled(false); connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo())); currentMenu->addAction(m_undoAction); m_redoAction = new QAction(tr("Redo"), this); m_redoAction->setShortcuts(QKeySequence::Redo); m_redoAction->setEnabled(false); connect(m_redoAction, SIGNAL(triggered()), this, SLOT(redo())); currentMenu->addAction(m_redoAction); currentMenu->addSeparator(); m_cutAction = new QAction(tr("&Cut"), this); m_cutAction->setShortcut(tr("Ctrl+X")); m_cutAction->setStatusTip(tr("Cut selection")); m_cutAction->setEnabled(false); connect(m_cutAction, SIGNAL(triggered()), this, SLOT(cut())); currentMenu->addAction(m_cutAction); m_copyAction = new QAction(tr("&Copy"), this); m_copyAction->setShortcut(tr("Ctrl+C")); m_copyAction->setStatusTip(tr("Copy selection")); m_copyAction->setEnabled(false); connect(m_copyAction, SIGNAL(triggered()), this, SLOT(copy())); currentMenu->addAction(m_copyAction); currentAction = new QAction(tr("&Paste"), this); currentAction->setShortcut(tr("Ctrl+V")); currentAction->setStatusTip(tr("Paste clipboard contents")); // TODO: Check clipboard status and disable appropriately here connect(currentAction, SIGNAL(triggered()), this, SLOT(paste())); currentMenu->addAction(currentAction); currentMenu->addSeparator(); currentAction = new QAction(tr("&Select All"), this); currentAction->setShortcut(tr("Ctrl+A")); currentAction->setStatusTip(tr("Select all text")); connect(currentAction, SIGNAL(triggered()), this, SLOT(selectAll())); currentMenu->addAction(currentAction); currentMenu = menuBar()->addMenu(tr("&Program")); QMenu *languageMenu = new QMenu(tr("Select language"), this); currentMenu->addMenu(languageMenu); QString currentLanguage = settings.value("programwindow/language", "").toString(); QStringList languages = getAvailableLanguages(); QActionGroup *languageActionGroup = new QActionGroup(this); foreach (QString language, languages) { currentAction = new QAction(language, this); currentAction->setCheckable(true); m_languageActions.insert(language, currentAction); languageActionGroup->addAction(currentAction); languageMenu->addAction(currentAction); if (!currentLanguage.isEmpty()) { if (language.compare(currentLanguage) == 0) { currentAction->setChecked(true); } } }
bool ModelNode_NWN2::loadSkin(Model_NWN2::ParserContext &ctx) { if (ctx.mdb->readUint32BE() != kSkinID) throw Common::Exception("Packet signatures do not match"); uint32 packetSize = ctx.mdb->readUint32LE(); _name.readFixedASCII(*ctx.mdb, 32); // Skipping lower level of detail models if (_name.endsWith("_L01") || _name.endsWith("_L02")) return false; Common::UString skeletonName; skeletonName.readFixedASCII(*ctx.mdb, 32); Common::UString diffuseMap, normalMap, tintMap, glowMap; diffuseMap.readFixedASCII(*ctx.mdb, 32); normalMap.readFixedASCII(*ctx.mdb, 32); tintMap.readFixedASCII(*ctx.mdb, 32); glowMap.readFixedASCII(*ctx.mdb, 32); _diffuse [0] = ctx.mdb->readIEEEFloatLE(); _diffuse [1] = ctx.mdb->readIEEEFloatLE(); _diffuse [2] = ctx.mdb->readIEEEFloatLE(); _specular[0] = ctx.mdb->readIEEEFloatLE(); _specular[1] = ctx.mdb->readIEEEFloatLE(); _specular[2] = ctx.mdb->readIEEEFloatLE(); float specularPower = ctx.mdb->readIEEEFloatLE(); float specularValue = ctx.mdb->readIEEEFloatLE(); uint32 textureFlags = ctx.mdb->readUint32LE(); uint32 vertexCount = ctx.mdb->readUint32LE(); uint32 faceCount = ctx.mdb->readUint32LE(); if ((vertexCount == 0) || (faceCount == 0)) return false; std::vector<Common::UString> textures; textures.push_back(diffuseMap); uint32 textureCount = textures.size(); loadTextures(textures); if (!createFaces(faceCount)) return false; // Read vertex coordinates std::vector<float> vX, vY, vZ; vX.resize(vertexCount); vY.resize(vertexCount); vZ.resize(vertexCount); std::vector<float> tX, tY, tZ; tX.resize(vertexCount); tY.resize(vertexCount); tZ.resize(vertexCount); for (uint32 i = 0; i < vertexCount; i++) { vX[i] = ctx.mdb->readIEEEFloatLE(); vY[i] = ctx.mdb->readIEEEFloatLE(); vZ[i] = ctx.mdb->readIEEEFloatLE(); ctx.mdb->skip(3 * 4); // Normals ctx.mdb->skip(4 * 4); // Bone weights ctx.mdb->skip(4 * 1); // Bone indices ctx.mdb->skip(3 * 4); // Tangents ctx.mdb->skip(3 * 4); // Binormals tX[i] = ctx.mdb->readIEEEFloatLE(); tY[i] = ctx.mdb->readIEEEFloatLE(); tZ[i] = ctx.mdb->readIEEEFloatLE(); ctx.mdb->skip(4); // Bone count } // Read faces for (uint32 i = 0; i < faceCount; i++) { const uint16 v1 = ctx.mdb->readUint16LE(); const uint16 v2 = ctx.mdb->readUint16LE(); const uint16 v3 = ctx.mdb->readUint16LE(); // Vertex coordinates _vX[3 * i + 0] = v1 < vX.size() ? vX[v1] : 0.0; _vY[3 * i + 0] = v1 < vY.size() ? vY[v1] : 0.0; _vZ[3 * i + 0] = v1 < vZ.size() ? vZ[v1] : 0.0; _boundBox.add(_vX[3 * i + 0], _vY[3 * i + 0], _vZ[3 * i + 0]); _vX[3 * i + 1] = v2 < vX.size() ? vX[v2] : 0.0; _vY[3 * i + 1] = v2 < vY.size() ? vY[v2] : 0.0; _vZ[3 * i + 1] = v2 < vZ.size() ? vZ[v2] : 0.0; _boundBox.add(_vX[3 * i + 1], _vY[3 * i + 1], _vZ[3 * i + 1]); _vX[3 * i + 2] = v3 < vX.size() ? vX[v3] : 0.0; _vY[3 * i + 2] = v3 < vY.size() ? vY[v3] : 0.0; _vZ[3 * i + 2] = v3 < vZ.size() ? vZ[v3] : 0.0; _boundBox.add(_vX[3 * i + 2], _vY[3 * i + 2], _vZ[3 * i + 2]); // Texture coordinates for (uint32 t = 0; t < textureCount; t++) { _tX[3 * textureCount * i + 3 * t + 0] = v1 < tX.size() ? tX[v1] : 0.0; _tY[3 * textureCount * i + 3 * t + 0] = v1 < tY.size() ? tY[v1] : 0.0; _tX[3 * textureCount * i + 3 * t + 1] = v2 < tX.size() ? tX[v2] : 0.0; _tY[3 * textureCount * i + 3 * t + 1] = v2 < tY.size() ? tY[v2] : 0.0; _tX[3 * textureCount * i + 3 * t + 2] = v3 < tX.size() ? tX[v3] : 0.0; _tY[3 * textureCount * i + 3 * t + 2] = v3 < tY.size() ? tY[v3] : 0.0; } } createCenter(); _render = true; return true; }
void ModelNode_Witcher::readMesh(Model_Witcher::ParserContext &ctx) { ctx.mdb->skip(8); uint32 offMeshArrays = ctx.mdb->readUint32LE(); ctx.mdb->skip(76); _ambient [0] = ctx.mdb->readIEEEFloatLE(); _ambient [1] = ctx.mdb->readIEEEFloatLE(); _ambient [2] = ctx.mdb->readIEEEFloatLE(); _diffuse [0] = ctx.mdb->readIEEEFloatLE(); _diffuse [1] = ctx.mdb->readIEEEFloatLE(); _diffuse [2] = ctx.mdb->readIEEEFloatLE(); _specular[0] = ctx.mdb->readIEEEFloatLE(); _specular[1] = ctx.mdb->readIEEEFloatLE(); _specular[2] = ctx.mdb->readIEEEFloatLE(); _shininess = ctx.mdb->readIEEEFloatLE(); ctx.mdb->skip(20); Common::UString texture[4]; texture[0].readFixedASCII(*ctx.mdb, 64); texture[1].readFixedASCII(*ctx.mdb, 64); texture[2].readFixedASCII(*ctx.mdb, 64); texture[3].readFixedASCII(*ctx.mdb, 64); ctx.mdb->skip(20); uint32 fourCC = ctx.mdb->readUint32BE(); ctx.mdb->skip(8); float coronaCenterX = ctx.mdb->readIEEEFloatLE(); ctx.mdb->skip(8); float enlargeStartDistance = ctx.mdb->readIEEEFloatLE(); ctx.mdb->skip(308); ctx.offTextureInfo = ctx.mdb->readUint32LE(); ctx.mdb->skip(4); uint32 endPos = ctx.mdb->seekTo(ctx.offRawData + offMeshArrays); ctx.mdb->skip(4); uint32 verticesOffset, verticesCount; Model::readArrayDef(*ctx.mdb, verticesOffset, verticesCount); uint32 normalsOffset, normalsCount; Model::readArrayDef(*ctx.mdb, normalsOffset, normalsCount); uint32 tangentsOffset, tangentsCount; Model::readArrayDef(*ctx.mdb, tangentsOffset, tangentsCount); uint32 biNormalsOffset, biNormalsCount; Model::readArrayDef(*ctx.mdb, biNormalsOffset, biNormalsCount); uint32 tVerts0Offset, tVerts0Count; Model::readArrayDef(*ctx.mdb, tVerts0Offset, tVerts0Count); uint32 tVerts1Offset, tVerts1Count; Model::readArrayDef(*ctx.mdb, tVerts1Offset, tVerts1Count); uint32 tVerts2Offset, tVerts2Count; Model::readArrayDef(*ctx.mdb, tVerts2Offset, tVerts2Count); uint32 tVerts3Offset, tVerts3Count; Model::readArrayDef(*ctx.mdb, tVerts3Offset, tVerts3Count); uint32 unknownOffset, unknownCount; Model::readArrayDef(*ctx.mdb, unknownOffset, unknownCount); uint32 facesOffset, facesCount; Model::readArrayDef(*ctx.mdb, facesOffset, facesCount); if (ctx.fileVersion == 133) ctx.offTexData = ctx.mdb->readUint32LE(); if ((verticesCount == 0) || (facesCount == 0)) { ctx.mdb->seekTo(endPos); return; } _render = true; std::vector<Common::UString> textures; readTextures(ctx, texture[0], textures); loadTextures(textures); uint32 textureCount = textures.size(); if (!createFaces(facesCount)) { ctx.mdb->seekTo(endPos); return; } // Read vertex coordinates ctx.mdb->seekTo(ctx.offRawData + verticesOffset); std::vector<float> vX, vY, vZ; vX.resize(verticesCount); vY.resize(verticesCount); vZ.resize(verticesCount); for (uint32 i = 0; i < verticesCount; i++) { vX[i] = ctx.mdb->readIEEEFloatLE(); vY[i] = ctx.mdb->readIEEEFloatLE(); vZ[i] = ctx.mdb->readIEEEFloatLE(); } // Read texture coordinates ctx.mdb->seekTo(ctx.offRawData + tVerts0Offset); std::vector<float> tX, tY; tX.resize(tVerts0Count); tY.resize(tVerts0Count); for (uint32 i = 0; i < tVerts0Count; i++) { tX[i] = ctx.mdb->readIEEEFloatLE(); tY[i] = ctx.mdb->readIEEEFloatLE(); } // Read faces ctx.mdb->seekTo(ctx.offRawData + facesOffset); for (uint32 i = 0; i < facesCount; i++) { ctx.mdb->skip(4 * 4 + 4); if (ctx.fileVersion == 133) ctx.mdb->skip(3 * 4); // Vertex indices const uint32 v1 = ctx.mdb->readUint32LE(); const uint32 v2 = ctx.mdb->readUint32LE(); const uint32 v3 = ctx.mdb->readUint32LE(); // Vertex coordinates _vX[3 * i + 0] = v1 < vX.size() ? vX[v1] : 0.0; _vY[3 * i + 0] = v1 < vY.size() ? vY[v1] : 0.0; _vZ[3 * i + 0] = v1 < vZ.size() ? vZ[v1] : 0.0; _boundBox.add(_vX[3 * i + 0], _vY[3 * i + 0], _vZ[3 * i + 0]); _vX[3 * i + 1] = v2 < vX.size() ? vX[v2] : 0.0; _vY[3 * i + 1] = v2 < vY.size() ? vY[v2] : 0.0; _vZ[3 * i + 1] = v2 < vZ.size() ? vZ[v2] : 0.0; _boundBox.add(_vX[3 * i + 1], _vY[3 * i + 1], _vZ[3 * i + 1]); _vX[3 * i + 2] = v3 < vX.size() ? vX[v3] : 0.0; _vY[3 * i + 2] = v3 < vY.size() ? vY[v3] : 0.0; _vZ[3 * i + 2] = v3 < vZ.size() ? vZ[v3] : 0.0; _boundBox.add(_vX[3 * i + 2], _vY[3 * i + 2], _vZ[3 * i + 2]); const float tX1 = v1 < tX.size() ? tX[v1] : 0.0; const float tY1 = v1 < tY.size() ? tY[v1] : 0.0; const float tX2 = v2 < tX.size() ? tX[v2] : 0.0; const float tY2 = v2 < tY.size() ? tY[v2] : 0.0; const float tX3 = v3 < tX.size() ? tX[v3] : 0.0; const float tY3 = v3 < tY.size() ? tY[v3] : 0.0; for (uint32 t = 0; t < textureCount; t++) { _tX[3 * textureCount * i + 3 * t + 0] = tX1; _tY[3 * textureCount * i + 3 * t + 0] = tY1; _tX[3 * textureCount * i + 3 * t + 1] = tX2; _tY[3 * textureCount * i + 3 * t + 1] = tY2; _tX[3 * textureCount * i + 3 * t + 2] = tX3; _tY[3 * textureCount * i + 3 * t + 2] = tY3; } if (ctx.fileVersion == 133) ctx.mdb->skip(4); } createCenter(); ctx.mdb->seekTo(endPos); }