// Convert the OsDateTimeBase value to an OsTime value. // The OsTime value is relative to midnight (0 hour) 01/01/70. OsStatus OsDateTimeBase::cvtToTimeSinceEpoch(OsTime& rTime) const { struct tm thisTime; time_t thisTimeAsTimeT; // convert "this" OsDateTime to a time_t representation thisTime.tm_year = mYear - 1900; thisTime.tm_mon = mMonth; thisTime.tm_mday = mDay; thisTime.tm_hour = mHour; thisTime.tm_min = mMinute; thisTime.tm_sec = mSecond; thisTime.tm_isdst = 0; thisTimeAsTimeT = tm2Epoch(&thisTime); assert(thisTimeAsTimeT >= 0); OsTime timeSinceEpoch(thisTimeAsTimeT, mMicrosecond); rTime = timeSinceEpoch; return OS_SUCCESS; }
std::vector<Primitive*> DuplicateTool::Modify(const wxRealPoint& origin) { wxRegion region; for (const PrimitiveSelection& ps : selection) region.Union(ps.primitive->GetBounds()); wxRect rect = region.GetBox(); wxPoint start = rect.GetPosition(); float offx = -start.x + origin.x; float offy = -start.y + origin.y; std::vector<Primitive*> new_guys; for (const PrimitiveSelection& ps : selection) { Primitive* new_guy = ps.primitive->Copy(); new_guy->SetId(timeSinceEpoch()); new_guy->Move(offx, offy); new_guys.push_back(new_guy); } return new_guys; }
void MorphanView::OnClick(wxMouseEvent& event) { mouse = GetRealPosition(event.GetPosition()); if (tool) { tool->Add(mouse); if ((tool->CanCreate() && tool->IsInfinitePoint() && event.ShiftDown()) || (tool->CanCreate() && !tool->IsInfinitePoint())) { Primitive* p = tool->Create(); p->SetFill(fillColor); p->SetOutline(outlineColor); p->SetWidth(outlineWidth); p->SetFilled(filled); p->SetId(timeSinceEpoch()); GetDocument()->Add(current_frame, p); GetDocument()->Modify(true); tool->Clear(); panel->Refresh(); } } else { const std::set<PrimitiveSelection>& selection = modifyTool->GetSelection(); std::vector<Primitive*> primitives = GetPrimitivesAt(mouse); // No selection but we got primitives, set our selection. if (selection.empty() && !primitives.empty()) { modifyTool->SetSelection(primitives, mouse, true); } // We have a selection, and no primitives gotten perform action else if (!selection.empty() && primitives.empty()) { std::vector<Primitive*> added = modifyTool->Modify(mouse); modifyTool->Clear(); for (Primitive* p : added) { p->SetId(timeSinceEpoch()); GetDocument()->Add(current_frame, p); } GetDocument()->Modify(true); panel->Refresh(); } // We have a selection, and a primitive was selected (we perform action) else if (!selection.empty() && !primitives.empty() && !event.ControlDown()) { std::vector<Primitive*> added = modifyTool->Modify(mouse); modifyTool->Clear(); for (Primitive* p : added) { p->SetId(timeSinceEpoch()); GetDocument()->Add(current_frame, p); } GetDocument()->Modify(true); panel->Refresh(); } else if (!selection.empty() && !primitives.empty() && event.ControlDown()) { modifyTool->SetSelection(primitives, mouse, false); } } }