ResearchPeriod::ResearchPeriod(const string & document) :document(document) { string line; ifstream myfile(document); if (myfile.fail()) cerr << "File can not be read!" << endl; else if (myfile.is_open()) { getline(myfile, line); vector<int> timeLine = getTimeLine(line); reasearchStartTime = timeLine[0]; researchEndTime = timeLine[1]; getline(myfile, line); numOfProjects = atoi(line.c_str()); while (getline(myfile, line)) { projects.push_back(getProject(line)); } projects = sortProjectsFinishTime(projects); myfile.close(); } optimalProjects = findOptimal(); optimalProjects = sortProjectCost(optimalProjects); partitionProjects(); }
/* ============================================================================= =============================================================================== */ bool CWorld::setNewView(string strView, double &dStart, double &dFinish, bool bUpdateCamera) { if (strView == "") return true; int iView = -1; if (strView[0] >= '0' && strView[0] <= '9') iView = atoi(strView.c_str()); else iView = getViewSet().getView(strView); if (!getViewSet().isValid(iView)) { cout << ("Unable to find view: " + strView); return false; } if (iView != getViewSet().getCur()) gotoView(iView, 0, bUpdateCamera); dStart = getTimeLine().getStart(); dFinish = getTimeLine().getFinish(); if (dStart > 0.0) { getTimeLine().setStart(dStart); getTimeLine().setCurTime(dStart); if (dFinish > 0.0 || getTimeLine().getFinish() < dStart) { dFinish = max(dStart, dFinish); getTimeLine().setFinish(dFinish); } updateTime(); } return true; }
int HJ1ACorrect::imagingRay(const ossimDpt& image_point, ossimEcefRay& image_ray) { bool runtime_dbflag = 0; NEWMAT::Matrix satToOrbit,camToSat,pianzhi; ossimDpt iPt = image_point; // // 1. Establish time of line imaging : // double t_line = getTimeLine(iPt.line); // // 2. Interpolate ephemeris position and velocity (in ECF): // ossimEcefPoint tempEcefPoint,tempEciPoint,tempEciPoint1; ossimEcefPoint P_ecf,P_eci,P_eci1; getPositionEcf(t_line, P_ecf); getVelocityEcf(t_line, tempEcefPoint); double rot = 7.292115856e-05; // tempEcefPoint.x() -= rot*P_ecf.y(); // tempEcefPoint.y() += rot*P_ecf.x(); double V[3],VV[3]; V[0] = tempEcefPoint.x() - rot*P_ecf.y(); V[1] = tempEcefPoint.y() + rot*P_ecf.x(); V[2] = tempEcefPoint.z(); /* CivilTime utc(short(2004),short(1),short(1),short(0),short(0),0.0); CommonTime UTC(utc); UTC.addSeconds(t_line); // CivilTime utc1(UTC); UTC.setTimeSystem(7); Vector<double> ecefPosVel(6,0.0),j2kPosVel(6,0.0),j2kPos(3,0.0),ecefPos(3,0.0),j2kVel(3,0.0),ecefVel(3,0.0); ecefPosVel[0] = P_ecf.x(); ecefPosVel[1] = P_ecf.y(); ecefPosVel[2] = P_ecf.z(); ecefPosVel[3] = tempEcefPoint.x(); ecefPosVel[4] = tempEcefPoint.y(); ecefPosVel[5] = tempEcefPoint.z(); j2kPosVel = ECEFPosVelToJ2k(UTC,ecefPosVel); P_eci.x() = j2kPosVel[0]; P_eci.y() = j2kPosVel[1]; P_eci.z() = j2kPosVel[2]; VV[0] = j2kPosVel[3]; VV[1] = j2kPosVel[4]; VV[2] = j2kPosVel[5]; */ ossimEcefVector V_ecf(V[0], V[1], V[2]); /* ossimEcefVector V_ecf(tempEcefPoint.x(), tempEcefPoint.y(), tempEcefPoint.z()); */ // // 3. Establish the look direction in Vehicle LSR space (S_sat). // ANGLES IN RADIANS // ossim_float64 Psi_x; getPixelLookAngleX(iPt.samp, Psi_x); ossim_float64 Psi_y; getPixelLookAngleY(iPt.samp, Psi_y); // ossimColumnVector3d u_sat (-tan(Psi_y), tan(Psi_x), -(1.0 )); ossimColumnVector3d u_cam (-tan(Psi_y), tan(Psi_x), -(1.0 )); // ossimColumnVector3d u_cam (-(Psi_y), 0, -(CCD1_FOCAL_LENGTH )); // ossimColumnVector3d u_cam (0, -(Psi_y), -(CCD1_FOCAL_LENGTH )); // u_cam = u_cam.unit(); //°²×°¾ØÕó computeCamToSatRotation(camToSat); // computePianzhiRotation(pianzhi); ossimColumnVector3d u_sat = ((camToSat*u_cam)).unit(); // // 4. Transform vehicle LSR space look direction vector to orbital LSR space // (S_orb): // computeSatToOrbRotation(satToOrbit, t_line); // computeSatToOrbRotationQ(satToOrbit, t_line); ossimColumnVector3d u_orb = (satToOrbit*u_sat).unit(); // // 5. Transform orbital LSR space look direction vector to ECF. // // a. S_orb space Z-axis (Z_orb) is || to the ECF radial vector (P_ecf), // b. X_orb axis is computed as cross-product between velocity and radial, // c. Y_orb completes the orthogonal S_orb coordinate system. // /* ossimColumnVector3d Z_orb1 (P_ecf.x(), P_ecf.y(), P_ecf.z()); Z_orb1 = Z_orb1.unit(); */ /* ossimColumnVector3d Z_orb1 (P_ecf.x(), P_ecf.y(), P_ecf.z()); Z_orb1 = Z_orb1.unit(); ossimColumnVector3d X_orb1 = (ossimColumnVector3d(V_ecf.x(), V_ecf.y(), V_ecf.z()).cross(Z_orb1)).unit(); ossimColumnVector3d Y_orb1 = Z_orb1.cross(X_orb1); // Z_orb1 = Z_orb1.unit(); NEWMAT::Matrix orbToEcfRotation = NEWMAT::Matrix(3, 3); orbToEcfRotation << X_orb1[0] << Y_orb1[0] << Z_orb1[0] << X_orb1[1] << Y_orb1[1] << Z_orb1[1] << X_orb1[2] << Y_orb1[2] << Z_orb1[2]; ossimColumnVector3d u_ecf1 = (orbToEcfRotation*u_orb); // // Establish the imaging ray given direction and origin: // image_ray = ossimEcefRay(P_ecf, ossimEcefVector(u_ecf1[0], u_ecf1[1], u_ecf1[2])); */ ossimColumnVector3d Z_orb (P_ecf.x(), P_ecf.y(), P_ecf.z()); Z_orb = Z_orb.unit(); ossimColumnVector3d X_orb = ossimColumnVector3d(V_ecf.x(), V_ecf.y(), V_ecf.z()).cross(Z_orb).unit(); ossimColumnVector3d Y_orb = Z_orb.cross(X_orb); NEWMAT::Matrix orbToEcfRotation = NEWMAT::Matrix(3, 3); orbToEcfRotation << X_orb[0] << Y_orb[0] << Z_orb[0] << X_orb[1] << Y_orb[1] << Z_orb[1] << X_orb[2] << Y_orb[2] << Z_orb[2]; ossimColumnVector3d u_ecf = (orbToEcfRotation*u_orb); // // Establish the imaging ray given direction and origin: // image_ray = ossimEcefRay(P_ecf, ossimEcefVector(u_ecf[0], u_ecf[1], u_ecf[2])); return 0; }
void GuiAppInstance::createNodeGui(const NodePtr &node, const NodePtr& parentMultiInstance, const CreateNodeArgs& args) { boost::shared_ptr<NodeCollection> group = node->getGroup(); NodeGraph* graph; if (group) { NodeGraphI* graph_i = group->getNodeGraph(); assert(graph_i); graph = dynamic_cast<NodeGraph*>(graph_i); assert(graph); } else { graph = _imp->_gui->getNodeGraph(); } if (!graph) { throw std::logic_error(""); } NodesGuiList selectedNodes = graph->getSelectedNodes(); NodeGuiPtr nodegui = _imp->_gui->createNodeGUI(node, args); assert(nodegui); if (parentMultiInstance && nodegui) { nodegui->hideGui(); boost::shared_ptr<NodeGuiI> parentNodeGui_i = parentMultiInstance->getNodeGui(); assert(parentNodeGui_i); nodegui->setParentMultiInstance( boost::dynamic_pointer_cast<NodeGui>(parentNodeGui_i) ); } ///It needs to be here because we rely on the _nodeMapping member bool isViewer = node->isEffectViewer() != 0; if (isViewer) { _imp->_gui->createViewerGui(node); } ///must be done after the viewer gui has been created if ( node->isRotoPaintingNode() ) { _imp->_gui->createNewRotoInterface( nodegui.get() ); } if ( ( node->isTrackerNodePlugin() || node->getEffectInstance()->isBuiltinTrackerNode() ) && !parentMultiInstance ) { _imp->_gui->createNewTrackerInterface( nodegui.get() ); } NodeGroup* isGroup = node->isEffectGroup(); if ( isGroup && isGroup->isSubGraphUserVisible() ) { _imp->_gui->createGroupGui(node, args.reason); } ///Don't initialize inputs if it is a multi-instance child since it is not part of the graph if (!parentMultiInstance) { nodegui->initializeInputs(); } if ( (args.reason == eCreateNodeReasonUserCreate) && !isViewer ) { ///we make sure we can have a clean preview. node->computePreviewImage( getTimeLine()->currentFrame() ); triggerAutoSave(); } ///only move main instances if ( node->getParentMultiInstanceName().empty() ) { bool autoConnect = args.reason == eCreateNodeReasonUserCreate; if ( selectedNodes.empty() ) { autoConnect = false; } if ( (args.xPosHint != INT_MIN) && (args.yPosHint != INT_MIN) && (!autoConnect) ) { QPointF pos = nodegui->mapToParent( nodegui->mapFromScene( QPointF(args.xPosHint, args.yPosHint) ) ); nodegui->refreshPosition( pos.x(), pos.y(), true ); } else { BackdropGui* isBd = dynamic_cast<BackdropGui*>( nodegui.get() ); if (!isBd) { NodeGuiPtr selectedNode; if ( (args.reason == eCreateNodeReasonUserCreate) && (selectedNodes.size() == 1) ) { selectedNode = selectedNodes.front(); BackdropGui* isBackdropGui = dynamic_cast<BackdropGui*>( selectedNode.get() ); if (isBackdropGui) { selectedNode.reset(); } } nodegui->getDagGui()->moveNodesForIdealPosition(nodegui, selectedNode, autoConnect); } } } } // createNodeGui
void GuiAppInstance::createNodeGui(const NodePtr &node, const NodePtr& parentMultiInstance, const CreateNodeArgs& args) { NodeCollectionPtr group = node->getGroup(); NodeGraph* graph; if (group) { NodeGraphI* graph_i = group->getNodeGraph(); assert(graph_i); graph = dynamic_cast<NodeGraph*>(graph_i); assert(graph); } else { graph = _imp->_gui->getNodeGraph(); } if (!graph) { throw std::logic_error(""); } NodesGuiList selectedNodes = graph->getSelectedNodes(); NodeGuiPtr nodegui = _imp->_gui->createNodeGUI(node, args); assert(nodegui); if (parentMultiInstance && nodegui) { nodegui->hideGui(); NodeGuiIPtr parentNodeGui_i = parentMultiInstance->getNodeGui(); assert(parentNodeGui_i); nodegui->setParentMultiInstance( boost::dynamic_pointer_cast<NodeGui>(parentNodeGui_i) ); } bool isViewer = node->isEffectViewerInstance() != 0; if (isViewer) { _imp->_gui->createViewerGui(node); } // Must be done after the viewer gui has been created _imp->_gui->createNodeViewerInterface(nodegui); NodeGroupPtr isGroup = node->isEffectNodeGroup(); if ( isGroup && isGroup->isSubGraphUserVisible() ) { _imp->_gui->createGroupGui(node, args); } ///Don't initialize inputs if it is a multi-instance child since it is not part of the graph if (!parentMultiInstance) { nodegui->initializeInputs(); } NodeSerializationPtr serialization = args.getProperty<NodeSerializationPtr >(kCreateNodeArgsPropNodeSerialization); if ( !serialization && !isViewer ) { ///we make sure we can have a clean preview. node->computePreviewImage( getTimeLine()->currentFrame() ); triggerAutoSave(); } ///only move main instances if ( node->getParentMultiInstanceName().empty() && !serialization) { bool autoConnect = args.getProperty<bool>(kCreateNodeArgsPropAutoConnect); if ( selectedNodes.empty() || serialization) { autoConnect = false; } double xPosHint = serialization ? INT_MIN : args.getProperty<double>(kCreateNodeArgsPropNodeInitialPosition, 0); double yPosHint = serialization ? INT_MIN : args.getProperty<double>(kCreateNodeArgsPropNodeInitialPosition, 1); if ( (xPosHint != INT_MIN) && (yPosHint != INT_MIN) && (!autoConnect) ) { QPointF pos = nodegui->mapToParent( nodegui->mapFromScene( QPointF(xPosHint, yPosHint) ) ); nodegui->refreshPosition( pos.x(), pos.y(), true ); } else { BackdropGuiPtr isBd = toBackdropGui(nodegui); if (!isBd) { NodeGuiPtr selectedNode; if ( !serialization && (selectedNodes.size() == 1) ) { selectedNode = selectedNodes.front(); BackdropGuiPtr isBdGui = toBackdropGui(selectedNode); if (isBdGui) { selectedNode.reset(); } } nodegui->getDagGui()->moveNodesForIdealPosition(nodegui, selectedNode, autoConnect); } } } } // createNodeGui
/* ============================================================================= =============================================================================== */ void CWorld::gotoViewTime(CView &View) { double start = 0, finish = 0, curtime = 0; curtime = View.getTime(); start = View.getStart(); finish = View.getFinish(); if (finish == NO_TIME) finish = start; if (start == NO_TIME) getDataSet().getTimeBounds(start, finish); double selstart = View.getSelStart() != NO_TIME && View.getSelStart() >= start ? View.getSelStart() : start; double selfinish = View.getSelFinish() != NO_TIME && View.getSelFinish() <= finish ? View.getSelFinish() : finish; getTimeLine().setStart(start); getTimeLine().setFinish(finish); getTimeLine().setSelStart(selstart); getTimeLine().setSelFinish(selfinish); getTimeLine().setLead(View.getLead()); getTimeLine().setTrail(View.getTrail()); if (curtime == NO_TIME) curtime = start; getTimeLine().setCurTime(curtime); getDataSet().setCurTime(curtime); getDataSet().setSelStart(selstart); getDataSet().setSelFinish(selfinish); getDataSet().setLead(View.getLead()); getDataSet().setTrail(View.getTrail()); getTimeLine().resetSpeed(); //SLOW THE WORLD STARTING SPEED DOWN getTimeLine().setSlower(); getTimeLine().setSlower(); getTimeLine().setSlower(); getTimeLine().setSlower(); getTimeLine().setSlower(); getTimeLine().setSlower(); getTimeLine().setSlower(); getTimeLine().setSlower(); getTimeLine().setSlower(); }